@GwtIncompatible(value="java.util.regex") public final class DepsFileParser extends JsFileLineParser
See //javascript/closure/deps.js for an example file.
JsFileLineParser.ParseException
Modifier and Type | Field and Description |
---|---|
private Matcher |
depArgsMatch
Pattern for matching the args of a goog.addDependency().
|
private java.util.List<DependencyInfo> |
depInfos
The dependency information extracted from the current file.
|
private Matcher |
depMatcher
Pattern for matching JavaScript string literals.
|
private static java.util.logging.Logger |
logger |
private com.google.common.base.Function<java.lang.String,java.lang.String> |
pathTranslator
Translates paths in different build systems.
|
errorManager, filePath, lineNum, PARSE_ERROR, PARSE_WARNING, parseSucceeded, shortcutMode
Constructor and Description |
---|
DepsFileParser(ErrorManager errorManager)
Constructor
|
DepsFileParser(com.google.common.base.Function<java.lang.String,java.lang.String> pathTranslator,
ErrorManager errorManager) |
Modifier and Type | Method and Description |
---|---|
java.util.List<DependencyInfo> |
parseFile(java.lang.String filePath)
Parses the given file and returns a list of dependency information that it
contained.
|
java.util.List<DependencyInfo> |
parseFile(java.lang.String filePath,
java.lang.String fileContents)
Parses the given file and returns a list of dependency information that it
contained.
|
java.util.List<DependencyInfo> |
parseFileReader(java.lang.String filePath,
java.io.Reader reader)
Parses the file from the given reader and returns a list of
dependency information that it contained.
|
protected boolean |
parseLine(java.lang.String line)
Extracts dependency information from lines that look like
goog.addDependency('pathRelativeToClosure', ['provides'], ['requires']);
Adds the dependencies to depInfos.
|
private java.util.Map<java.lang.String,java.lang.String> |
parseLoadFlags(java.lang.String loadFlags) |
didParseSucceed, doParse, parseJsString, parseJsStringArray, parseJsStringMap, setShortcutMode
private static java.util.logging.Logger logger
private final Matcher depMatcher
private final Matcher depArgsMatch
private java.util.List<DependencyInfo> depInfos
private final com.google.common.base.Function<java.lang.String,java.lang.String> pathTranslator
public DepsFileParser(ErrorManager errorManager)
errorManager
- Handles parse errors.public DepsFileParser(com.google.common.base.Function<java.lang.String,java.lang.String> pathTranslator, ErrorManager errorManager)
pathTranslator
- Translates paths in different build systems.errorManager
- Handles parse errors.public java.util.List<DependencyInfo> parseFile(java.lang.String filePath) throws java.io.IOException
filePath
- Path to the file to parse.java.io.IOException
- Thrown if the file could not be read.public java.util.List<DependencyInfo> parseFile(java.lang.String filePath, java.lang.String fileContents)
filePath
- Path to the file to parse.fileContents
- The contents to parse.public java.util.List<DependencyInfo> parseFileReader(java.lang.String filePath, java.io.Reader reader)
filePath
- Path to the file to parse.reader
- A reader for the file.protected boolean parseLine(java.lang.String line) throws JsFileLineParser.ParseException
parseLine
in class JsFileLineParser
line
- The line to parse.ParseException
- Thrown if the given line has a malformed
goog.addDependency().JsFileLineParser.ParseException
private java.util.Map<java.lang.String,java.lang.String> parseLoadFlags(java.lang.String loadFlags) throws JsFileLineParser.ParseException
JsFileLineParser.ParseException