Class DepsFileRegexParser


  • @GwtIncompatible("java.util.regex")
    public final class DepsFileRegexParser
    extends JsFileLineParser
    A parser that can extract dependency information from existing deps.js files.

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

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DepsFileRegexParser

        public DepsFileRegexParser​(ErrorManager errorManager)
        Constructor
        Parameters:
        errorManager - Handles parse errors.
      • DepsFileRegexParser

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

      • parseFile

        public java.util.List<DependencyInfo> parseFile​(java.lang.String filePath)
                                                 throws java.io.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:
        java.io.IOException - Thrown if the file could not be read.
      • parseFile

        public 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. 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 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.
        Parameters:
        filePath - Path to the file to parse.
        reader - A reader for the file.
        Returns:
        A list of DependencyInfo objects.
      • parseLine

        protected boolean parseLine​(java.lang.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().