public class JavaParserFacade extends Object
Modifier and Type | Method and Description |
---|---|
ResolvedType |
classToResolvedType(Class<?> clazz)
Deprecated.
instead consider SymbolSolver.classToResolvedType(Class> clazz)
|
static void |
clearInstances()
This method is used to clear internal caches for the sake of releasing memory.
|
ResolvedType |
convert(Type type,
Context context) |
ResolvedType |
convert(Type type,
Node node) |
ResolvedType |
convertToUsage(Type type)
Convert a
Type into the corresponding ResolvedType . |
protected ResolvedType |
convertToUsage(Type type,
Context context)
Convert a
Type into the corresponding ResolvedType . |
protected TypeDeclaration<?> |
findContainingTypeDecl(Node node)
Where a node has an interface/class/enum declaration as its ancestor, return the nearest one.
|
protected Node |
findContainingTypeDeclOrObjectCreationExpr(Node node)
Where a node has an interface/class/enum declaration -- or an object creation expression (anonymous inner class)
-- as its ancestor, return the nearest one.
|
protected Node |
findContainingTypeDeclOrObjectCreationExpr(Node node,
String className)
Where a node has an interface/class/enum declaration -- or an object creation expression in an inner class
references an outer class -- as its ancestor, return the declaration corresponding to the class name specified.
|
static JavaParserFacade |
get(TypeSolver typeSolver)
Note that the addition of the modifier
synchronized is specific and directly in response to issue #2668. |
protected ResolvedType |
getBinaryTypeConcrete(Node left,
Node right,
boolean solveLambdas,
BinaryExpr.Operator operator) |
Solver |
getSymbolSolver() |
ResolvedType |
getType(Node node)
Get the type associated with the node.
|
ResolvedType |
getType(Node node,
boolean solveLambdas) |
ResolvedReferenceTypeDeclaration |
getTypeDeclaration(ClassOrInterfaceDeclaration classOrInterfaceDeclaration) |
ResolvedReferenceTypeDeclaration |
getTypeDeclaration(Node node) |
ResolvedReferenceTypeDeclaration |
getTypeDeclaration(TypeDeclaration<?> typeDeclaration) |
ResolvedType |
getTypeOfThisIn(Node node)
"this" inserted in the given point, which type would have?
|
TypeSolver |
getTypeSolver() |
SymbolReference<ResolvedAnnotationDeclaration> |
solve(AnnotationExpr annotationExpr) |
SymbolReference<ResolvedConstructorDeclaration> |
solve(ExplicitConstructorInvocationStmt explicitConstructorInvocationStmt) |
SymbolReference<ResolvedConstructorDeclaration> |
solve(ExplicitConstructorInvocationStmt explicitConstructorInvocationStmt,
boolean solveLambdas) |
SymbolReference<? extends ResolvedValueDeclaration> |
solve(Expression expr) |
SymbolReference<ResolvedValueDeclaration> |
solve(FieldAccessExpr fieldAccessExpr) |
SymbolReference<ResolvedMethodDeclaration> |
solve(MethodCallExpr methodCallExpr) |
SymbolReference<ResolvedMethodDeclaration> |
solve(MethodCallExpr methodCallExpr,
boolean solveLambdas)
Given a method call find out to which method declaration it corresponds.
|
SymbolReference<ResolvedMethodDeclaration> |
solve(MethodReferenceExpr methodReferenceExpr) |
SymbolReference<ResolvedMethodDeclaration> |
solve(MethodReferenceExpr methodReferenceExpr,
boolean solveLambdas)
Given a method reference find out to which method declaration it corresponds.
|
SymbolReference<? extends ResolvedValueDeclaration> |
solve(NameExpr nameExpr) |
SymbolReference<ResolvedConstructorDeclaration> |
solve(ObjectCreationExpr objectCreationExpr) |
SymbolReference<ResolvedConstructorDeclaration> |
solve(ObjectCreationExpr objectCreationExpr,
boolean solveLambdas)
Given a constructor call find out to which constructor declaration it corresponds.
|
SymbolReference<? extends ResolvedValueDeclaration> |
solve(SimpleName nameExpr) |
SymbolReference<ResolvedTypeDeclaration> |
solve(ThisExpr node) |
MethodUsage |
solveMethodAsUsage(MethodCallExpr call) |
protected MethodUsage |
toMethodUsage(MethodReferenceExpr methodReferenceExpr,
List<ResolvedType> paramTypes) |
public static JavaParserFacade get(TypeSolver typeSolver)
synchronized
is specific and directly in response to issue #2668.
public static void clearInstances()
public TypeSolver getTypeSolver()
public Solver getSymbolSolver()
public SymbolReference<? extends ResolvedValueDeclaration> solve(NameExpr nameExpr)
public SymbolReference<? extends ResolvedValueDeclaration> solve(SimpleName nameExpr)
public SymbolReference<? extends ResolvedValueDeclaration> solve(Expression expr)
public SymbolReference<ResolvedMethodDeclaration> solve(MethodCallExpr methodCallExpr)
public SymbolReference<ResolvedMethodDeclaration> solve(MethodReferenceExpr methodReferenceExpr)
public SymbolReference<ResolvedConstructorDeclaration> solve(ObjectCreationExpr objectCreationExpr)
public SymbolReference<ResolvedConstructorDeclaration> solve(ExplicitConstructorInvocationStmt explicitConstructorInvocationStmt)
public SymbolReference<ResolvedConstructorDeclaration> solve(ExplicitConstructorInvocationStmt explicitConstructorInvocationStmt, boolean solveLambdas)
public SymbolReference<ResolvedTypeDeclaration> solve(ThisExpr node)
public SymbolReference<ResolvedConstructorDeclaration> solve(ObjectCreationExpr objectCreationExpr, boolean solveLambdas)
public SymbolReference<ResolvedMethodDeclaration> solve(MethodCallExpr methodCallExpr, boolean solveLambdas)
public SymbolReference<ResolvedMethodDeclaration> solve(MethodReferenceExpr methodReferenceExpr, boolean solveLambdas)
public SymbolReference<ResolvedAnnotationDeclaration> solve(AnnotationExpr annotationExpr)
public SymbolReference<ResolvedValueDeclaration> solve(FieldAccessExpr fieldAccessExpr)
public ResolvedType getType(Node node)
This method was originally intended to get the type of a value: any value has a type.
For example:
int foo(int a) { return a; // when getType is invoked on "a" it returns the type "int" }
Now, users started using also of names of types itself, which do not have a type.
For example:
class A { int foo(int a) { return A.someStaticField; // when getType is invoked on "A", which represents a class, it returns // the type "A" itself while it used to throw UnsolvedSymbolException }
To accommodate this usage and avoid confusion this method return the type itself when used on the name of type.
public ResolvedType getType(Node node, boolean solveLambdas)
protected MethodUsage toMethodUsage(MethodReferenceExpr methodReferenceExpr, List<ResolvedType> paramTypes)
protected ResolvedType getBinaryTypeConcrete(Node left, Node right, boolean solveLambdas, BinaryExpr.Operator operator)
protected TypeDeclaration<?> findContainingTypeDecl(Node node)
NOTE: See findContainingTypeDeclOrObjectCreationExpr(com.github.javaparser.ast.Node)
if wanting to include anonymous inner classes.
For example, these all return X:
public interface X { ... node here ... }
public class X { ... node here ... }
public enum X { ... node here ... }
node
- The Node whose ancestors will be traversed,protected Node findContainingTypeDeclOrObjectCreationExpr(Node node)
NOTE: See findContainingTypeDecl(com.github.javaparser.ast.Node)
if wanting to not include anonymous inner classes.
For example, these all return X:
public interface X { ... node here ... }
public class X { ... node here ... }
public enum X { ... node here ... }
new ActionListener() {
... node here ...
public void actionPerformed(ActionEvent e) {
... or node here ...
}
}
node
- The Node whose ancestors will be traversed,protected Node findContainingTypeDeclOrObjectCreationExpr(Node node, String className)
protected ResolvedType convertToUsage(Type type, Context context)
Type
into the corresponding ResolvedType
.type
- The type to be converted.context
- The current context.public ResolvedType convertToUsage(Type type)
Type
into the corresponding ResolvedType
.type
- The type to be converted.public ResolvedType convert(Type type, Node node)
public ResolvedType convert(Type type, Context context)
public MethodUsage solveMethodAsUsage(MethodCallExpr call)
public ResolvedReferenceTypeDeclaration getTypeDeclaration(Node node)
public ResolvedReferenceTypeDeclaration getTypeDeclaration(ClassOrInterfaceDeclaration classOrInterfaceDeclaration)
public ResolvedType getTypeOfThisIn(Node node)
public ResolvedReferenceTypeDeclaration getTypeDeclaration(TypeDeclaration<?> typeDeclaration)
@Deprecated public ResolvedType classToResolvedType(Class<?> clazz)
Class
into the corresponding ResolvedType
.clazz
- The class to be converted.Copyright © 2007–2023. All rights reserved.