Class JsFileRegexParser
- java.lang.Object
-
- com.google.javascript.jscomp.deps.JsFileLineParser
-
- com.google.javascript.jscomp.deps.JsFileRegexParser
-
@GwtIncompatible("java.util.regex") public final class JsFileRegexParser extends JsFileLineParser
A parser that can extract dependency information from a .js file, including goog.require, goog.provide, goog.module, import statements, and export statements.
-
-
Field Summary
-
Fields inherited from class com.google.javascript.jscomp.deps.JsFileLineParser
PARSE_ERROR
-
-
Constructor Summary
Constructors Constructor Description JsFileRegexParser(ErrorManager errorManager)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static boolean
isSupported()
DependencyInfo
parseFile(java.lang.String filePath, java.lang.String closureRelativePath, java.lang.String fileContents)
Parses the given file and returns the dependency information that it contained.protected boolean
parseJsDocCommentLine(java.lang.String line)
protected boolean
parseLine(java.lang.String line)
Parses a line of JavaScript, extracting goog.provide and goog.require information.JsFileRegexParser
setIncludeGoogBase(boolean include)
Sets whether we should create implicit provides and requires of the root namespace.JsFileRegexParser
setModuleLoader(ModuleLoader loader)
Sets a list of "module root" URIs, which allow relativizing filenames for modules.-
Methods inherited from class com.google.javascript.jscomp.deps.JsFileLineParser
didParseSucceed, setShortcutMode
-
-
-
-
Constructor Detail
-
JsFileRegexParser
public JsFileRegexParser(ErrorManager errorManager)
Constructor- Parameters:
errorManager
- Handles parse errors.
-
-
Method Detail
-
setIncludeGoogBase
@CanIgnoreReturnValue public JsFileRegexParser 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.
-
setModuleLoader
@CanIgnoreReturnValue public JsFileRegexParser setModuleLoader(ModuleLoader loader)
Sets a list of "module root" URIs, which allow relativizing filenames for modules.- Returns:
- this for easy chaining.
-
parseFile
public DependencyInfo parseFile(java.lang.String filePath, java.lang.String closureRelativePath, java.lang.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.
-
parseJsDocCommentLine
protected boolean parseJsDocCommentLine(java.lang.String line)
-
parseLine
protected boolean parseLine(java.lang.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
-
isSupported
public static boolean isSupported()
-
-