Class JavaSymbolSolver
- java.lang.Object
-
- com.github.javaparser.symbolsolver.JavaSymbolSolver
-
- All Implemented Interfaces:
SymbolResolver
public class JavaSymbolSolver extends java.lang.Object implements SymbolResolver
This implementation of the SymbolResolver wraps the functionality of the library to make them easily usable from JavaParser nodes.An instance of this class should be created once and then injected in all the CompilationUnit for which we want to enable symbol resolution. To do so the method inject can be used, or you can use
ParserConfiguration.setSymbolResolver(SymbolResolver)
and the parser will do the injection for you.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
JavaSymbolSolver.ArrayLengthValueDeclaration
-
Field Summary
Fields Modifier and Type Field Description private TypeSolver
typeSolver
-
Constructor Summary
Constructors Constructor Description JavaSymbolSolver(TypeSolver typeSolver)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResolvedType
calculateType(Expression expression)
For an expression it would find the corresponding resolved type.void
inject(CompilationUnit destination)
Register this SymbolResolver into a CompilationUnit, so that symbol resolution becomes available to all nodes part of the CompilationUnit.<T> T
resolveDeclaration(Node node, java.lang.Class<T> resultClass)
For a reference it would find the corresponding declaration.private java.util.Optional<ResolvedParameterDeclaration>
resolveParameterDeclaration(Parameter parameter)
private java.util.Optional<ResolvedParameterDeclaration>
resolveParameterDeclaration(ResolvedMethodLikeDeclaration resolvedMethodLikeDeclaration, Parameter parameter)
private java.util.Optional<ResolvedParameterDeclaration>
resolveParameterDeclaration(ResolvedReferenceTypeDeclaration resolvedReferenceTypeDeclaration, Parameter parameter)
<T> T
toResolvedType(Type javaparserType, java.lang.Class<T> resultClass)
For types it would find the corresponding resolved types.ResolvedReferenceTypeDeclaration
toTypeDeclaration(Node node)
For a node it would find the corresponding reference type declaration.
-
-
-
Field Detail
-
typeSolver
private TypeSolver typeSolver
-
-
Constructor Detail
-
JavaSymbolSolver
public JavaSymbolSolver(@NotNull TypeSolver typeSolver)
-
-
Method Detail
-
inject
public void inject(CompilationUnit destination)
Register this SymbolResolver into a CompilationUnit, so that symbol resolution becomes available to all nodes part of the CompilationUnit.
-
resolveDeclaration
public <T> T resolveDeclaration(Node node, java.lang.Class<T> resultClass)
Description copied from interface:SymbolResolver
For a reference it would find the corresponding declaration.- Specified by:
resolveDeclaration
in interfaceSymbolResolver
-
resolveParameterDeclaration
private java.util.Optional<ResolvedParameterDeclaration> resolveParameterDeclaration(ResolvedMethodLikeDeclaration resolvedMethodLikeDeclaration, Parameter parameter)
-
resolveParameterDeclaration
private java.util.Optional<ResolvedParameterDeclaration> resolveParameterDeclaration(ResolvedReferenceTypeDeclaration resolvedReferenceTypeDeclaration, Parameter parameter)
-
resolveParameterDeclaration
private java.util.Optional<ResolvedParameterDeclaration> resolveParameterDeclaration(Parameter parameter)
-
toResolvedType
public <T> T toResolvedType(Type javaparserType, java.lang.Class<T> resultClass)
Description copied from interface:SymbolResolver
For types it would find the corresponding resolved types.- Specified by:
toResolvedType
in interfaceSymbolResolver
-
calculateType
public ResolvedType calculateType(Expression expression)
Description copied from interface:SymbolResolver
For an expression it would find the corresponding resolved type.- Specified by:
calculateType
in interfaceSymbolResolver
-
toTypeDeclaration
public ResolvedReferenceTypeDeclaration toTypeDeclaration(Node node)
Description copied from interface:SymbolResolver
For a node it would find the corresponding reference type declaration.- Specified by:
toTypeDeclaration
in interfaceSymbolResolver
-
-