public class DepsGenerator
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
DepsGenerator.InclusionStrategy |
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
closurePathAbs |
private java.util.Collection<SourceFile> |
deps |
(package private) static DiagnosticType |
DUPE_PROVIDES_WARNING |
(package private) static DiagnosticType |
DUPE_REQUIRE_WARNING |
(package private) ErrorManager |
errorManager |
private static java.util.logging.Logger |
logger |
private DepsGenerator.InclusionStrategy |
mergeStrategy |
(package private) static DiagnosticType |
MULTIPLE_PROVIDES_ERROR |
(package private) static DiagnosticType |
NEVER_PROVIDED_ERROR |
(package private) static DiagnosticType |
NO_DEPS_WARNING |
(package private) static DiagnosticType |
SAME_FILE_WARNING |
private java.util.Collection<SourceFile> |
srcs |
Constructor and Description |
---|
DepsGenerator(java.util.Collection<SourceFile> deps,
java.util.Collection<SourceFile> srcs,
DepsGenerator.InclusionStrategy mergeStrategy,
java.lang.String closurePathAbs,
ErrorManager errorManager)
Creates a new DepsGenerator.
|
Modifier and Type | Method and Description |
---|---|
private void |
addToProvideMap(java.lang.Iterable<DependencyInfo> depInfos,
java.util.Map<java.lang.String,DependencyInfo> providesMap)
Adds the given DependencyInfos to the given providesMap.
|
protected void |
cleanUpDuplicatedFiles(java.util.Map<java.lang.String,DependencyInfo> depsFiles,
java.util.Map<java.lang.String,DependencyInfo> jsFiles)
Removes duplicated depsInfo from jsFiles if this info already present in
some of the parsed deps.js
|
java.lang.String |
computeDependencyCalls()
Performs the parsing inputs and writing of outputs.
|
protected DepsFileParser |
createDepsFileParser() |
(package private) static java.util.List<SourceFile> |
createSourceFilesFromPaths(java.util.Collection<java.lang.String> paths) |
(package private) static java.util.List<SourceFile> |
createSourceFilesFromPaths(java.lang.String... paths) |
(package private) static java.util.List<SourceFile> |
createSourceFilesFromZipPaths(java.util.Collection<java.lang.String> paths) |
protected java.lang.String |
formatPathToDepsFile(java.lang.String path)
Format the deps file path so that it can be included in the output file.
|
private java.util.Map<java.lang.String,DependencyInfo> |
parseDepsFiles()
Parses all deps.js files in the deps list and creates a map of
closure-relative path -> DependencyInfo.
|
private java.util.Map<java.lang.String,DependencyInfo> |
parseSources(java.util.Set<java.lang.String> preparsedFiles)
Parses all source files for dependency information.
|
private void |
reportDuplicateProvide(java.lang.String namespace,
DependencyInfo firstDep,
DependencyInfo secondDep) |
private void |
reportDuplicateRequire(java.lang.String namespace,
DependencyInfo depInfo) |
private void |
reportNoDepsInDepsFile(java.lang.String filePath) |
private void |
reportSameFile(java.lang.String namespace,
DependencyInfo depInfo) |
private void |
reportUndefinedNamespace(java.lang.String namespace,
DependencyInfo depInfo) |
protected boolean |
shouldSkipDepsFile(SourceFile file)
Returns whether we should ignore dependency info in the given deps file.
|
private void |
validateDependencies(java.lang.Iterable<DependencyInfo> preparsedFileDepedencies,
java.lang.Iterable<DependencyInfo> parsedFileDependencies)
Reports if there are any dependency problems with the given dependency
information.
|
private void |
writeDepInfos(java.io.PrintStream out,
java.util.Collection<DependencyInfo> depInfos)
Writes goog.addDependency() lines for each DependencyInfo in depInfos.
|
private void |
writeDepsContent(java.util.Map<java.lang.String,DependencyInfo> depsFiles,
java.util.Map<java.lang.String,DependencyInfo> jsFiles,
java.io.PrintStream out)
Creates the content to put into the output deps.js file.
|
private static void |
writeJsArray(java.io.PrintStream out,
java.util.Collection<java.lang.String> values)
Prints a list of strings formatted as a JavaScript array of string
literals.
|
private void |
writeJsBoolean(java.io.PrintStream out,
boolean value) |
private static java.util.logging.Logger logger
private final java.util.Collection<SourceFile> srcs
private final java.util.Collection<SourceFile> deps
private final java.lang.String closurePathAbs
private final DepsGenerator.InclusionStrategy mergeStrategy
final ErrorManager errorManager
static final DiagnosticType SAME_FILE_WARNING
static final DiagnosticType NEVER_PROVIDED_ERROR
static final DiagnosticType DUPE_PROVIDES_WARNING
static final DiagnosticType MULTIPLE_PROVIDES_ERROR
static final DiagnosticType DUPE_REQUIRE_WARNING
static final DiagnosticType NO_DEPS_WARNING
public DepsGenerator(java.util.Collection<SourceFile> deps, java.util.Collection<SourceFile> srcs, DepsGenerator.InclusionStrategy mergeStrategy, java.lang.String closurePathAbs, ErrorManager errorManager)
public java.lang.String computeDependencyCalls() throws java.io.IOException
java.io.IOException
- Occurs upon an IO error.protected void cleanUpDuplicatedFiles(java.util.Map<java.lang.String,DependencyInfo> depsFiles, java.util.Map<java.lang.String,DependencyInfo> jsFiles)
depsFiles
- DepsInfo from deps.js dependenciesjsFiles
- DepsInfo from some of jsSourcesprivate void validateDependencies(java.lang.Iterable<DependencyInfo> preparsedFileDepedencies, java.lang.Iterable<DependencyInfo> parsedFileDependencies)
preparsedFileDepedencies
- Dependency information from existing
deps.js files.parsedFileDependencies
- Dependency information from parsed .js files.private void reportSameFile(java.lang.String namespace, DependencyInfo depInfo)
private void reportUndefinedNamespace(java.lang.String namespace, DependencyInfo depInfo)
private void reportDuplicateProvide(java.lang.String namespace, DependencyInfo firstDep, DependencyInfo secondDep)
private void reportDuplicateRequire(java.lang.String namespace, DependencyInfo depInfo)
private void reportNoDepsInDepsFile(java.lang.String filePath)
private void addToProvideMap(java.lang.Iterable<DependencyInfo> depInfos, java.util.Map<java.lang.String,DependencyInfo> providesMap)
protected DepsFileParser createDepsFileParser()
protected boolean shouldSkipDepsFile(SourceFile file)
private java.util.Map<java.lang.String,DependencyInfo> parseDepsFiles() throws java.io.IOException
java.io.IOException
private java.util.Map<java.lang.String,DependencyInfo> parseSources(java.util.Set<java.lang.String> preparsedFiles) throws java.io.IOException
preparsedFiles
- A set of closure-relative paths.
Files in this set are not parsed if they are encountered in srcs.java.io.IOException
- Occurs upon an IO error.private void writeDepsContent(java.util.Map<java.lang.String,DependencyInfo> depsFiles, java.util.Map<java.lang.String,DependencyInfo> jsFiles, java.io.PrintStream out) throws java.io.IOException
java.io.IOException
- Occurs upon an IO error.protected java.lang.String formatPathToDepsFile(java.lang.String path)
private void writeDepInfos(java.io.PrintStream out, java.util.Collection<DependencyInfo> depInfos)
private void writeJsBoolean(java.io.PrintStream out, boolean value)
private static void writeJsArray(java.io.PrintStream out, java.util.Collection<java.lang.String> values)
static java.util.List<SourceFile> createSourceFilesFromPaths(java.util.Collection<java.lang.String> paths)
static java.util.List<SourceFile> createSourceFilesFromZipPaths(java.util.Collection<java.lang.String> paths) throws java.io.IOException
java.io.IOException
static java.util.List<SourceFile> createSourceFilesFromPaths(java.lang.String... paths)