Package de.fraunhofer.aisec.cpg
Class TranslationConfiguration.Builder
java.lang.Object
de.fraunhofer.aisec.cpg.TranslationConfiguration.Builder
- Enclosing class:
- TranslationConfiguration
public static class TranslationConfiguration.Builder
extends java.lang.Object
Builds a
TranslationConfiguration.
Example:
TranslationManager.builder()
.config( TranslationConfiguration.builder()
.sourceLocations(new File("example.cpp"))
.defaultPasses()
.debugParser(true)
.build())
.build();
-
Constructor Summary
Constructors Constructor Description Builder() -
Method Summary
Modifier and Type Method Description TranslationConfigurationbuild()TranslationConfiguration.BuildercodeInNodes(boolean b)TranslationConfiguration.BuilderdebugParser(boolean debugParser)Dump parser debug output to the logs (Caution: this will generate a lot of output).TranslationConfiguration.BuilderdefaultLanguages()Register all default languages.TranslationConfiguration.BuilderdefaultPasses()Register all defaultPasses.TranslationConfiguration.BuilderdisableCleanup()TranslationConfiguration.BuilderfailOnError(boolean failOnError)Fail analysis on first error.TranslationConfiguration.BuilderincludeBlacklist(java.lang.String includeFile)Adds the specified file to the include blacklist.TranslationConfiguration.BuilderincludePath(java.lang.String includePath)Directory containing include headers.TranslationConfiguration.BuilderincludeWhitelist(java.lang.String includeFile)Adds the specified file to the include whitelist.TranslationConfiguration.BuilderinferenceConfiguration(de.fraunhofer.aisec.cpg.InferenceConfiguration configuration)TranslationConfiguration.BuilderloadIncludes(boolean loadIncludes)Load C/C++ include headers before the analysis.TranslationConfiguration.BuildermatchCommentsToNodes(boolean matchCommentsToNodes)Match comments found in source files to nodes according to a heuristic.TranslationConfiguration.BuilderprocessAnnotations(boolean b)Specifies, whether annotations should be process or not.TranslationConfiguration.BuilderregisterLanguage(@NonNull java.lang.Class<? extends LanguageFrontend> frontend, java.util.List<java.lang.String> fileTypes)Registers an additionalLanguageFrontend.TranslationConfiguration.BuilderregisterPass(@NonNull Pass pass)Register an additionalPass.TranslationConfiguration.BuildersoftwareComponents(java.util.Map<java.lang.String,java.util.List<java.io.File>> softwareComponents)Files or directories containing the source code to analyze organized by different componentsTranslationConfiguration.BuildersourceLocations(java.io.File... sourceLocations)Files or directories containing the source code to analyze.TranslationConfiguration.BuildersourceLocations(java.util.List<java.io.File> sourceLocations)Files or directories containing the source code to analyze.TranslationConfiguration.Buildersymbols(java.util.Map<java.lang.String,java.lang.String> symbols)TranslationConfiguration.BuildertopLevel(java.io.File topLevel)TranslationConfiguration.BuildertypeSystemActiveInFrontend(boolean b)If false, the type system is only activated once the frontends are done building the initial AST structure.TranslationConfiguration.BuilderunregisterLanguage(@NonNull java.lang.Class<? extends LanguageFrontend> frontend)Unregisters a registeredLanguageFrontend.TranslationConfiguration.BuilderuseCompilationDatabase(de.fraunhofer.aisec.cpg.frontends.CompilationDatabase compilationDatabase)TranslationConfiguration.BuilderuseParallelFrontends(boolean b)If true, the ASTs for the source files are parsed in parallel, but the passes afterwards will still run in a single thread.TranslationConfiguration.BuilderuseUnityBuild(boolean b)Only relevant for C++.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
symbols
public TranslationConfiguration.Builder symbols(java.util.Map<java.lang.String,java.lang.String> symbols) -
sourceLocations
Files or directories containing the source code to analyze. Generates a dummy software component called "application".- Parameters:
sourceLocations- The files with the source code- Returns:
- this
-
sourceLocations
public TranslationConfiguration.Builder sourceLocations(java.util.List<java.io.File> sourceLocations)Files or directories containing the source code to analyze. Generates a dummy software component called "application".- Parameters:
sourceLocations- The files with the source code- Returns:
- this
-
softwareComponents
public TranslationConfiguration.Builder softwareComponents(java.util.Map<java.lang.String,java.util.List<java.io.File>> softwareComponents)Files or directories containing the source code to analyze organized by different components- Parameters:
softwareComponents- A map holding the different components with their files- Returns:
- this
-
useCompilationDatabase
public TranslationConfiguration.Builder useCompilationDatabase(de.fraunhofer.aisec.cpg.frontends.CompilationDatabase compilationDatabase) -
topLevel
-
debugParser
Dump parser debug output to the logs (Caution: this will generate a lot of output).- Parameters:
debugParser-- Returns:
-
matchCommentsToNodes
Match comments found in source files to nodes according to a heuristic.- Parameters:
matchCommentsToNodes-- Returns:
-
failOnError
Fail analysis on first error. Try to continue otherwise.- Parameters:
failOnError-- Returns:
-
loadIncludes
Load C/C++ include headers before the analysis.Required for macro expansion.
- Parameters:
loadIncludes-- Returns:
-
includePath
Directory containing include headers.- Parameters:
includePath-- Returns:
-
includeWhitelist
Adds the specified file to the include whitelist. Relative and absolute paths are supported.- Parameters:
includeFile-- Returns:
-
disableCleanup
-
includeBlacklist
Adds the specified file to the include blacklist. Relative and absolute paths are supported.- Parameters:
includeFile-- Returns:
-
registerPass
Register an additionalPass.- Parameters:
pass-- Returns:
-
registerLanguage
public TranslationConfiguration.Builder registerLanguage(@NonNull java.lang.Class<? extends LanguageFrontend> frontend, java.util.List<java.lang.String> fileTypes)Registers an additionalLanguageFrontend. -
unregisterLanguage
public TranslationConfiguration.Builder unregisterLanguage(@NonNull java.lang.Class<? extends LanguageFrontend> frontend)Unregisters a registeredLanguageFrontend. -
defaultPasses
Register all defaultPasses.This will register
- FilenameMapper
- TypeHierarchyResolver
- ImportResolver
- VariableUsageResolver
- CallResolver
- EvaluationOrderGraphPass
- TypeResolver
- Returns:
-
defaultLanguages
Register all default languages.- Returns:
-
codeInNodes
-
processAnnotations
Specifies, whether annotations should be process or not. By default, they are not processed, since they might populate the graph too much.- Parameters:
b- the new value- Returns:
-
useUnityBuild
Only relevant for C++. A unity build refers to a build that consolidates all translation units into a single one, which has the advantage that header files are only processed once, adding far less duplicate nodes to the graph- Parameters:
b- the new value- Returns:
-
useParallelFrontends
If true, the ASTs for the source files are parsed in parallel, but the passes afterwards will still run in a single thread. This speeds up initial parsing but makes sure that further graph enrichment algorithms remain correct. Please make sure to also settypeSystemActiveInFrontend(boolean)to false to avoid probabilistic errors that appear depending on the parsing order.- Parameters:
b- the new value- Returns:
-
typeSystemActiveInFrontend
If false, the type system is only activated once the frontends are done building the initial AST structure. This avoids errors where the type of a node may depend on the order in which the source files have been parsed.- Parameters:
b- the new value- Returns:
-
inferenceConfiguration
public TranslationConfiguration.Builder inferenceConfiguration(de.fraunhofer.aisec.cpg.InferenceConfiguration configuration) -
build
-