com.google.javascript.jscomp.deps
Class DepsFileParser

java.lang.Object
  extended by com.google.javascript.jscomp.deps.JsFileLineParser
      extended by com.google.javascript.jscomp.deps.DepsFileParser

public class DepsFileParser
extends JsFileLineParser

A parser that can extract dependency information from existing deps.js files.

See //javascript/closure/deps.js for an example file.


Constructor Summary
DepsFileParser(ErrorManager errorManager)
          Constructor
DepsFileParser(com.google.common.base.Function<String,String> pathTranslator, ErrorManager errorManager)
           
 
Method Summary
 List<DependencyInfo> parseFile(String filePath)
          Parses the given file and returns a list of dependency information that it contained.
 List<DependencyInfo> parseFile(String filePath, String fileContents)
          Parses the given file and returns a list of dependency information that it contained.
 List<DependencyInfo> parseFileReader(String filePath, Reader reader)
          Parses the file from the given reader and returns a list of dependency information that it contained.
protected  boolean parseLine(String line)
          Extracts dependency information from lines that look like goog.addDependency('pathRelativeToClosure', ['provides'], ['requires']); Adds the dependencies to depInfos.
 
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 Detail

DepsFileParser

public DepsFileParser(ErrorManager errorManager)
Constructor

Parameters:
errorManager - Handles parse errors.

DepsFileParser

public DepsFileParser(com.google.common.base.Function<String,String> pathTranslator,
                      ErrorManager errorManager)
Parameters:
pathTranslator - Translates paths in different build systems.
errorManager - Handles parse errors.
Method Detail

parseFile

public List<DependencyInfo> parseFile(String filePath)
                               throws IOException
Parses the given file and returns a list of dependency information that it contained.

Parameters:
filePath - Path to the file to parse.
Returns:
A list of DependencyInfo objects.
Throws:
IOException - Thrown if the file could not be read.

parseFile

public List<DependencyInfo> parseFile(String filePath,
                                      String fileContents)
Parses the given file and returns a list of dependency information that it contained. It uses the passed in fileContents instead of reading the file.

Parameters:
filePath - Path to the file to parse.
fileContents - The contents to parse.
Returns:
A list of DependencyInfo objects.

parseFileReader

public List<DependencyInfo> parseFileReader(String filePath,
                                            Reader reader)
Parses the file from the given reader and returns a list of dependency information that it contained.

Parameters:
filePath - Path to the file to parse.
reader - A reader for the file.
Returns:
A list of DependencyInfo objects.

parseLine

protected boolean parseLine(String line)
                     throws com.google.javascript.jscomp.deps.JsFileLineParser.ParseException
Extracts dependency information from lines that look like goog.addDependency('pathRelativeToClosure', ['provides'], ['requires']); Adds the dependencies to depInfos.

Parameters:
line - The line to parse.
Returns:
true to keep going, false otherwise.
Throws:
ParseException - Thrown if the given line has a malformed goog.addDependency().
com.google.javascript.jscomp.deps.JsFileLineParser.ParseException