Package org.antlr.mojo.antlr4
Class GrammarDependencies
- java.lang.Object
-
- org.antlr.mojo.antlr4.GrammarDependencies
-
class GrammarDependencies extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.io.File,java.util.Map.Entry<byte[],java.util.Collection<java.lang.String>>>
grammars
Map grammars to their checksum and references.private Graph<java.lang.String>
graph
private java.io.File
libDirectory
private org.apache.maven.plugin.logging.Log
log
private java.lang.String
packageName
private java.io.File
sourceDirectory
private java.io.File
statusFile
-
Constructor Summary
Constructors Constructor Description GrammarDependencies(java.io.File sourceDirectory, java.io.File libDirectory, java.util.List<java.lang.String> arguments, java.io.File status, org.apache.maven.plugin.logging.Log log)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
analyse(java.io.File grammarFile, java.util.Collection<java.io.File> grammarFiles, Tool tool)
GrammarDependencies
analyze(java.util.Set<java.io.File> grammarFiles, java.util.Set<java.io.File> importGrammarFiles, Tool tool)
Performs dependency analysis for the given grammar files.private void
explore(java.lang.String grammarName, java.util.Collection<java.lang.String> result)
private java.util.Collection<java.lang.String>
findUsages(java.lang.String grammarFileName)
Returns the grammar file names that directly or indirectly use the given grammar.private java.lang.String
getPackage(java.util.List<java.lang.String> arguments)
Determines the package to use.private java.lang.String
getRelativePath(java.io.File grammarFile)
Determines the relative target path of the given grammar file.boolean
isDependencyChanged(java.io.File grammarFile)
Determines whether a grammar used by the given grammar was modified since the last build.private java.util.Map<java.io.File,java.util.Map.Entry<byte[],java.util.Collection<java.lang.String>>>
loadStatus(java.io.File statusFile)
private java.io.File
resolve(java.lang.String name, java.lang.String path)
Resolves the given grammar name.void
save()
private java.lang.String
stripPath(java.lang.String str)
private java.lang.String
stripQuotes(java.lang.String str)
-
-
-
Field Detail
-
graph
private final Graph<java.lang.String> graph
-
sourceDirectory
private final java.io.File sourceDirectory
-
libDirectory
private final java.io.File libDirectory
-
statusFile
private final java.io.File statusFile
-
packageName
private final java.lang.String packageName
-
grammars
private final java.util.Map<java.io.File,java.util.Map.Entry<byte[],java.util.Collection<java.lang.String>>> grammars
Map grammars to their checksum and references.
-
log
private final org.apache.maven.plugin.logging.Log log
-
-
Method Detail
-
getPackage
private java.lang.String getPackage(java.util.List<java.lang.String> arguments)
Determines the package to use.- Parameters:
arguments
- the tool arguments.- Returns:
- the package. Returns
null
to indicate that no package should be used.
-
save
public void save() throws java.io.IOException
- Throws:
java.io.IOException
-
analyze
public GrammarDependencies analyze(java.util.Set<java.io.File> grammarFiles, java.util.Set<java.io.File> importGrammarFiles, Tool tool) throws java.io.IOException
Performs dependency analysis for the given grammar files.- Parameters:
grammarFiles
- the grammar files.importGrammarFiles
- the import grammar files.tool
- the tool to use.- Returns:
- self-reference.
- Throws:
java.io.IOException
-
isDependencyChanged
public boolean isDependencyChanged(java.io.File grammarFile) throws java.io.IOException
Determines whether a grammar used by the given grammar was modified since the last build.- Parameters:
grammarFile
- the grammar.- Returns:
true
if a grammar used by the given grammar has been modified.- Throws:
java.io.IOException
-
getRelativePath
private java.lang.String getRelativePath(java.io.File grammarFile)
Determines the relative target path of the given grammar file.- Parameters:
grammarFile
- the grammar file.- Returns:
- the relative path.
-
findUsages
private java.util.Collection<java.lang.String> findUsages(java.lang.String grammarFileName)
Returns the grammar file names that directly or indirectly use the given grammar.- Parameters:
grammarFileName
- the grammar file name.- Returns:
- the grammar file names that use the given grammar file.
-
explore
private void explore(java.lang.String grammarName, java.util.Collection<java.lang.String> result)
-
analyse
private void analyse(java.io.File grammarFile, java.util.Collection<java.io.File> grammarFiles, Tool tool)
-
resolve
private java.io.File resolve(java.lang.String name, java.lang.String path)
Resolves the given grammar name.- Parameters:
name
- the name.path
- the relative path.- Returns:
- the grammar file.
-
loadStatus
private java.util.Map<java.io.File,java.util.Map.Entry<byte[],java.util.Collection<java.lang.String>>> loadStatus(java.io.File statusFile)
-
stripPath
private java.lang.String stripPath(java.lang.String str)
-
stripQuotes
private java.lang.String stripQuotes(java.lang.String str)
-
-