Package com.google.javascript.jscomp.deps

# Class JsFileParser

java.lang.Object
com.google.javascript.jscomp.deps.JsFileLineParser
com.google.javascript.jscomp.deps.JsFileParser

public class JsFileParser extends JsFileLineParser
A parser that can extract goog.require() and goog.provide() dependency information from a .js file.

## Constructor Summary

Constructors
Constructor
Description
`JsFileParser(ErrorManager errorManager)`
Constructor

## Method Summary

Modifier and Type
Method
Description
`DependencyInfo`
`parseFile(String filePath, String closureRelativePath)`
Parses the given file and returns the dependency information that it contained.
`DependencyInfo`
`parseFile(String filePath, String closureRelativePath, String fileContents)`
Parses the given file and returns the dependency information that it contained.
`protected boolean`
`parseLine(String line)`
Parses a line of JavaScript, extracting goog.provide and goog.require information.
`JsFileParser`
`setIncludeGoogBase(boolean include)`
Sets whether we should create implicit provides and requires of the root namespace.

### Methods inherited from class com.google.javascript.jscomp.deps.JsFileLineParser

`didParseSucceed, setShortcutMode`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### JsFileParser

public JsFileParser(ErrorManager errorManager)
Constructor

Parameters:
  `errorManager` - Handles parse errors.

## Method Details

### setIncludeGoogBase

public JsFileParser setIncludeGoogBase(boolean include)
Sets whether we should create implicit provides and requires of the root namespace. When generating deps files, you do not want this behavior. Deps files need base.js to run anyway, so they don't need information about it. When generating abstract build graphs, you probably do want this behavior. It will create an implicit dependency of all files with provides/requires on base.js.

Returns:
  this for easy chaining.

### parseFile

public DependencyInfo parseFile(String filePath, String closureRelativePath) throws IOException
Parses the given file and returns the dependency information that it contained.

Parameters:
  `filePath` - Path to the file to parse.
  `closureRelativePath` - Path of the file relative to closure.
Returns:
  A DependencyInfo containing all provides/requires found in the file.
Throws:
  `IOException` - Thrown if there was an problem reading the given file.

### parseFile

public DependencyInfo parseFile(String filePath, String closureRelativePath, String fileContents)
Parses the given file and returns the dependency information that it contained.

Parameters:
  `filePath` - Path to the file to parse.
  `closureRelativePath` - Path of the file relative to closure.
  `fileContents` - The contents to parse.
Returns:
  A DependencyInfo containing all provides/requires found in the file.

### parseLine

protected boolean parseLine(String line) throws com.google.javascript.jscomp.deps.JsFileLineParser.ParseException
Parses a line of JavaScript, extracting goog.provide and goog.require information.

Throws:
  `com.google.javascript.jscomp.deps.JsFileLineParser.ParseException`