Class JavaLanguageFrontend
java.lang.Object
de.fraunhofer.aisec.cpg.frontends.LanguageFrontend
de.fraunhofer.aisec.cpg.frontends.java.JavaLanguageFrontend
public class JavaLanguageFrontend extends LanguageFrontend
Main parser for ONE Java files.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringANNOTATION_MEMBER_VALUEstatic java.util.List<java.lang.String>JAVA_EXTENSIONSstatic java.lang.StringTHISFields inherited from class de.fraunhofer.aisec.cpg.frontends.LanguageFrontend
config, currentTU, log, objectListeners, predicateListeners, processedMapping, scopeManager -
Constructor Summary
Constructors Constructor Description JavaLanguageFrontend(@NonNull TranslationConfiguration config, de.fraunhofer.aisec.cpg.passes.scopes.ScopeManager scopeManager) -
Method Summary
Modifier and Type Method Description voidcleanup()<T> java.lang.StringgetCodeFromRawNode(T astNode)Returns the raw code of the ast node, generic for java or c++ ast nodes.com.github.javaparser.ast.CompilationUnitgetContext()DeclarationHandlergetDeclarationHandler()ExpressionHandlergetExpressionHandler()<T> @Nullable PhysicalLocationgetLocationFromRawNode(T astNode)Returns theRegionof the code with line and column, index starting at 1, generic for java or c++ ast nodes.com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolvergetNativeTypeResolver()java.lang.StringgetQualifiedMethodNameAsGoodAsPossible(com.github.javaparser.ast.expr.MethodCallExpr callExpr)@Nullable java.lang.StringgetQualifiedNameFromImports(java.lang.String className)<N extends com.github.javaparser.ast.Node, T extends com.github.javaparser.ast.type.Type>
TypegetReturnTypeAsGoodAsPossible(com.github.javaparser.ast.nodeTypes.NodeWithType<N,T> nodeWithType, com.github.javaparser.resolution.declarations.ResolvedMethodDeclaration resolved)StatementAnalyzergetStatementHandler()<N extends com.github.javaparser.ast.Node, T extends com.github.javaparser.ast.type.Type>
TypegetTypeAsGoodAsPossible(com.github.javaparser.ast.nodeTypes.NodeWithType<N,T> nodeWithType, com.github.javaparser.resolution.declarations.ResolvedValueDeclaration resolved)TypegetTypeAsGoodAsPossible(com.github.javaparser.ast.type.Type type)TranslationUnitDeclarationparse(java.io.File file)protected com.github.javaparser.ast.CompilationUnitparse(java.io.File file, com.github.javaparser.JavaParser parser)voidprocessAnnotations(de.fraunhofer.aisec.cpg.graph.Node node, com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?> owner)Processes Java annotations.@Nullable java.lang.StringrecoverTypeFromUnsolvedException(java.lang.Throwable ex)<S, T> voidsetComment(S s, T ctx)Methods inherited from class de.fraunhofer.aisec.cpg.frontends.LanguageFrontend
clearProcessed, getCodeOfSubregion, getConfig, getCurrentTU, getNamespaceDelimiter, getNewLineType, getScopeManager, mergeRegions, parseAll, process, registerObjectListener, registerPredicateListener, setCodeAndRegion, setCurrentTU, setScopeManagerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
JAVA_EXTENSIONS
public static final java.util.List<java.lang.String> JAVA_EXTENSIONS -
THIS
public static final java.lang.String THIS- See Also:
- Constant Field Values
-
ANNOTATION_MEMBER_VALUE
public static final java.lang.String ANNOTATION_MEMBER_VALUE- See Also:
- Constant Field Values
-
-
Constructor Details
-
JavaLanguageFrontend
public JavaLanguageFrontend(@NonNull TranslationConfiguration config, de.fraunhofer.aisec.cpg.passes.scopes.ScopeManager scopeManager)
-
-
Method Details
-
parse
- Specified by:
parsein classLanguageFrontend- Throws:
TranslationException
-
parse
protected com.github.javaparser.ast.CompilationUnit parse(java.io.File file, com.github.javaparser.JavaParser parser) throws TranslationException, java.io.FileNotFoundException- Throws:
TranslationExceptionjava.io.FileNotFoundException
-
getCodeFromRawNode
public <T> java.lang.String getCodeFromRawNode(T astNode)Description copied from class:LanguageFrontendReturns the raw code of the ast node, generic for java or c++ ast nodes.- Specified by:
getCodeFromRawNodein classLanguageFrontend- Type Parameters:
T- the raw ast type- Parameters:
astNode- the ast node- Returns:
- the source code
-
getLocationFromRawNode
Description copied from class:LanguageFrontendReturns theRegionof the code with line and column, index starting at 1, generic for java or c++ ast nodes.- Specified by:
getLocationFromRawNodein classLanguageFrontend- Type Parameters:
T- the raw ast type- Parameters:
astNode- the ast node- Returns:
- the location
-
getTypeAsGoodAsPossible
public <N extends com.github.javaparser.ast.Node, T extends com.github.javaparser.ast.type.Type> Type getTypeAsGoodAsPossible(com.github.javaparser.ast.nodeTypes.NodeWithType<N,T> nodeWithType, com.github.javaparser.resolution.declarations.ResolvedValueDeclaration resolved) -
getTypeAsGoodAsPossible
-
getQualifiedMethodNameAsGoodAsPossible
public java.lang.String getQualifiedMethodNameAsGoodAsPossible(com.github.javaparser.ast.expr.MethodCallExpr callExpr) -
recoverTypeFromUnsolvedException
public @Nullable java.lang.String recoverTypeFromUnsolvedException(java.lang.Throwable ex) -
getQualifiedNameFromImports
public @Nullable java.lang.String getQualifiedNameFromImports(java.lang.String className) -
getReturnTypeAsGoodAsPossible
public <N extends com.github.javaparser.ast.Node, T extends com.github.javaparser.ast.type.Type> Type getReturnTypeAsGoodAsPossible(com.github.javaparser.ast.nodeTypes.NodeWithType<N,T> nodeWithType, com.github.javaparser.resolution.declarations.ResolvedMethodDeclaration resolved) -
cleanup
public void cleanup()- Overrides:
cleanupin classLanguageFrontend
-
setComment
public <S, T> void setComment(S s, T ctx)- Specified by:
setCommentin classLanguageFrontend
-
getExpressionHandler
-
getStatementHandler
-
getDeclarationHandler
-
getContext
public com.github.javaparser.ast.CompilationUnit getContext() -
getNativeTypeResolver
public com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver getNativeTypeResolver() -
processAnnotations
public void processAnnotations(de.fraunhofer.aisec.cpg.graph.Node node, com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?> owner)Processes Java annotations.- Parameters:
node- the nodeowner- the AST owner node
-