Class JavaParserFacade
- java.lang.Object
-
- com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade
-
public class JavaParserFacade extends Object
Class to be used by final users to solve symbols for JavaParser ASTs.- Author:
- Federico Tomassetti
-
-
Method Summary
-
-
-
Method Detail
-
getTypeSolver
public TypeSolver getTypeSolver()
-
getSymbolSolver
public SymbolSolver getSymbolSolver()
-
get
public static JavaParserFacade get(TypeSolver typeSolver)
-
clearInstances
public static void clearInstances()
This method is used to clear internal caches for the sake of releasing memory.
-
solveGenericTypes
protected static ResolvedType solveGenericTypes(ResolvedType type, Context context)
-
solve
public SymbolReference<? extends ResolvedValueDeclaration> solve(NameExpr nameExpr)
-
solve
public SymbolReference<? extends ResolvedValueDeclaration> solve(SimpleName nameExpr)
-
solve
public SymbolReference<? extends ResolvedValueDeclaration> solve(Expression expr)
-
solve
public SymbolReference<ResolvedMethodDeclaration> solve(MethodCallExpr methodCallExpr)
-
solve
public SymbolReference<ResolvedMethodDeclaration> solve(MethodReferenceExpr methodReferenceExpr)
-
solve
public SymbolReference<ResolvedConstructorDeclaration> solve(ObjectCreationExpr objectCreationExpr)
-
solve
public SymbolReference<ResolvedConstructorDeclaration> solve(ExplicitConstructorInvocationStmt explicitConstructorInvocationStmt)
-
solve
public SymbolReference<ResolvedConstructorDeclaration> solve(ExplicitConstructorInvocationStmt explicitConstructorInvocationStmt, boolean solveLambdas)
-
solve
public SymbolReference<ResolvedTypeDeclaration> solve(ThisExpr node)
-
solve
public SymbolReference<ResolvedConstructorDeclaration> solve(ObjectCreationExpr objectCreationExpr, boolean solveLambdas)
Given a constructor call find out to which constructor declaration it corresponds.
-
solve
public SymbolReference<ResolvedMethodDeclaration> solve(MethodCallExpr methodCallExpr, boolean solveLambdas)
Given a method call find out to which method declaration it corresponds.
-
solve
public SymbolReference<ResolvedMethodDeclaration> solve(MethodReferenceExpr methodReferenceExpr, boolean solveLambdas)
Given a method reference find out to which method declaration it corresponds.
-
solve
public SymbolReference<ResolvedAnnotationDeclaration> solve(AnnotationExpr annotationExpr)
-
solve
public SymbolReference<ResolvedValueDeclaration> solve(FieldAccessExpr fieldAccessExpr)
-
getType
public ResolvedType getType(Node node)
Get the type associated with the 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 accomodate this usage and avoid confusion this method return the type itself when used on the name of type.
-
getType
public ResolvedType getType(Node node, boolean solveLambdas)
-
toMethodUsage
protected MethodUsage toMethodUsage(MethodReferenceExpr methodReferenceExpr)
-
getBinaryTypeConcrete
protected ResolvedType getBinaryTypeConcrete(Node left, Node right, boolean solveLambdas, BinaryExpr.Operator operator)
-
findContainingTypeDecl
protected TypeDeclaration<?> findContainingTypeDecl(Node node)
Where a node has an interface/class/enum declaration as its ancestor, return the nearest one.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 ... }
- Parameters:
node
- The Node whose ancestors will be traversed,- Returns:
- The first class/interface/enum declaration in the Node's ancestry.
-
findContainingTypeDeclOrObjectCreationExpr
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.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 ... } }
- Parameters:
node
- The Node whose ancestors will be traversed,- Returns:
- The first class/interface/enum declaration -- or object creation expression (anonymous inner class) -- in the Node's ancestry.
-
convertToUsageVariableType
public ResolvedType convertToUsageVariableType(VariableDeclarator var)
-
convertToUsage
public ResolvedType convertToUsage(Type type, Node context)
-
convertToUsage
public ResolvedType convertToUsage(Type type)
-
convertToUsage
protected ResolvedType convertToUsage(Type type, Context context)
-
convert
public ResolvedType convert(Type type, Node node)
-
convert
public ResolvedType convert(Type type, Context context)
-
solveMethodAsUsage
public MethodUsage solveMethodAsUsage(MethodCallExpr call)
-
getTypeDeclaration
public ResolvedReferenceTypeDeclaration getTypeDeclaration(Node node)
-
getTypeDeclaration
public ResolvedReferenceTypeDeclaration getTypeDeclaration(ClassOrInterfaceDeclaration classOrInterfaceDeclaration)
-
getTypeOfThisIn
public ResolvedType getTypeOfThisIn(Node node)
"this" inserted in the given point, which type would have?
-
getTypeDeclaration
public ResolvedReferenceTypeDeclaration getTypeDeclaration(TypeDeclaration<?> typeDeclaration)
-
classToResolvedType
public ResolvedType classToResolvedType(Class<?> clazz)
-
-