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 inherited from class de.fraunhofer.aisec.cpg.frontends.LanguageFrontend
config, log, objectListeners, predicateListeners, processedMapping, scopeManager
-
-
Constructor Summary
Constructors Constructor Description JavaLanguageFrontend(@NonNull TranslationConfiguration config, ScopeManager scopeManager)
-
Method Summary
All Methods Instance Methods Concrete Methods 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.java.lang.StringgetQualifiedMethodNameAsGoodAsPossible(com.github.javaparser.ast.expr.MethodCallExpr callExpr)java.lang.StringgetQualifiedNameFromImports(java.lang.String className)TypegetReturnTypeAsGoodAsPossible(com.github.javaparser.ast.nodeTypes.NodeWithType nodeWithType, com.github.javaparser.resolution.declarations.ResolvedMethodDeclaration resolved)StatementAnalyzergetStatementHandler()TypegetTypeAsGoodAsPossible(com.github.javaparser.ast.nodeTypes.NodeWithType 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)java.lang.StringrecoverTypeFromUnsolvedException(java.lang.Throwable ex)<S,T>
voidsetComment(S s, T ctx)-
Methods inherited from class de.fraunhofer.aisec.cpg.frontends.LanguageFrontend
addRecord, clearProcessed, getCodeOfSubregion, getNamespaceDelimiter, getNewLineType, getRecordForName, getRecords, getScopeManager, mergeRegions, parseAll, process, registerObjectListener, registerPredicateListener, setCodeAndRegion, setScopeManager
-
-
-
-
Constructor Detail
-
JavaLanguageFrontend
public JavaLanguageFrontend(@NonNull TranslationConfiguration config, ScopeManager scopeManager)
-
-
Method Detail
-
parse
public TranslationUnitDeclaration parse(java.io.File file) throws TranslationException
- 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
public <T> @Nullable PhysicalLocation getLocationFromRawNode(T astNode)
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 Type getTypeAsGoodAsPossible(com.github.javaparser.ast.nodeTypes.NodeWithType nodeWithType, com.github.javaparser.resolution.declarations.ResolvedValueDeclaration resolved)
-
getQualifiedMethodNameAsGoodAsPossible
public java.lang.String getQualifiedMethodNameAsGoodAsPossible(com.github.javaparser.ast.expr.MethodCallExpr callExpr)
-
recoverTypeFromUnsolvedException
public java.lang.String recoverTypeFromUnsolvedException(java.lang.Throwable ex)
-
getQualifiedNameFromImports
public java.lang.String getQualifiedNameFromImports(java.lang.String className)
-
getTypeAsGoodAsPossible
public Type getTypeAsGoodAsPossible(com.github.javaparser.ast.type.Type type)
-
getReturnTypeAsGoodAsPossible
public Type getReturnTypeAsGoodAsPossible(com.github.javaparser.ast.nodeTypes.NodeWithType 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
public ExpressionHandler getExpressionHandler()
-
getStatementHandler
public StatementAnalyzer getStatementHandler()
-
getDeclarationHandler
public DeclarationHandler getDeclarationHandler()
-
getContext
public com.github.javaparser.ast.CompilationUnit getContext()
-
-