Class DepsFileParser

java.lang.Object
com.google.javascript.jscomp.deps.JsFileLineParser
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 Details

    • 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 Details

    • 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.
      Throws:
      com.google.javascript.jscomp.deps.JsFileLineParser.ParseException - Thrown if the given line has a malformed goog.addDependency().