Class AbstractJavaParserContext<N extends Node>
- java.lang.Object
-
- com.github.javaparser.symbolsolver.javaparsermodel.contexts.AbstractJavaParserContext<N>
-
- All Implemented Interfaces:
Context
- Direct Known Subclasses:
AbstractMethodLikeDeclarationContext,AnnotationDeclarationContext,AnonymousClassDeclarationContext,CatchClauseContext,ClassOrInterfaceDeclarationContext,ClassOrInterfaceDeclarationExtendsContext,CompilationUnitContext,EnumDeclarationContext,ExpressionContext,RecordDeclarationContext,StatementContext,SwitchEntryContext,VariableDeclaratorContext
public abstract class AbstractJavaParserContext<N extends Node> extends java.lang.Object implements Context
-
-
Field Summary
Fields Modifier and Type Field Description protected TypeSolvertypeSolverprotected NwrappedNode
-
Constructor Summary
Constructors Constructor Description AbstractJavaParserContext(N wrappedNode, TypeSolver typeSolver)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)SymbolReference<? extends ResolvedValueDeclaration>findExposedPatternInParentContext(Node parent, java.lang.String name)protected java.util.Collection<ResolvedReferenceTypeDeclaration>findTypeDeclarations(java.util.Optional<Expression> optScope)java.util.Optional<Context>getParent()protected NodegetScope(Node node)NgetWrappedNode()Returns the node wrapped in the contextinthashCode()java.util.List<TypePatternExpr>negatedTypePatternExprsExposedFromChildren()java.util.Optional<MethodUsage>solveMethodAsUsage(java.lang.String name, java.util.List<ResolvedType> argumentsTypes)Similar to solveMethod but we return a MethodUsage.SymbolReference<? extends ResolvedValueDeclaration>solveSymbolInParentContext(java.lang.String name)static SymbolReference<ResolvedValueDeclaration>solveWith(SymbolDeclarator symbolDeclarator, java.lang.String name)protected java.util.Optional<Value>solveWithAsValue(SymbolDeclarator symbolDeclarator, java.lang.String name)java.util.List<TypePatternExpr>typePatternExprsDiscoveredInPattern(ComponentPatternExpr patternExpr)When looking for a variable declaration in a pattern expression, there are 2 cases: 1.java.util.List<TypePatternExpr>typePatternExprsExposedFromChildren()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.github.javaparser.resolution.Context
fieldDeclarationInScope, fieldsExposedToChild, localVariableDeclarationInScope, localVariablesExposedToChild, parameterDeclarationInScope, parametersExposedToChild, solveConstructor, solveGenericType, solveGenericTypeInParentContext, solveMethod, solveMethodInParentContext, solveSymbol, solveSymbolAsValue, solveSymbolAsValueInParentContext, solveType, solveType, solveTypeInParentContext, solveTypeInParentContext, typePatternExprInScope, typePatternExprsExposedToChild
-
-
-
-
Field Detail
-
typeSolver
protected TypeSolver typeSolver
-
-
Constructor Detail
-
AbstractJavaParserContext
public AbstractJavaParserContext(N wrappedNode, TypeSolver typeSolver)
-
-
Method Detail
-
solveWith
public static SymbolReference<ResolvedValueDeclaration> solveWith(SymbolDeclarator symbolDeclarator, java.lang.String name)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getParent
public final java.util.Optional<Context> getParent()
-
solveSymbolInParentContext
public SymbolReference<? extends ResolvedValueDeclaration> solveSymbolInParentContext(java.lang.String name)
- Specified by:
solveSymbolInParentContextin interfaceContext
-
solveWithAsValue
protected java.util.Optional<Value> solveWithAsValue(SymbolDeclarator symbolDeclarator, java.lang.String name)
-
findTypeDeclarations
protected java.util.Collection<ResolvedReferenceTypeDeclaration> findTypeDeclarations(java.util.Optional<Expression> optScope)
-
solveMethodAsUsage
public java.util.Optional<MethodUsage> solveMethodAsUsage(java.lang.String name, java.util.List<ResolvedType> argumentsTypes)
Similar to solveMethod but we return a MethodUsage. A MethodUsage corresponds to a MethodDeclaration plus the resolved type variables.- Specified by:
solveMethodAsUsagein interfaceContext
-
getWrappedNode
public N getWrappedNode()
Description copied from interface:ContextReturns the node wrapped in the context- Specified by:
getWrappedNodein interfaceContext
-
typePatternExprsDiscoveredInPattern
public java.util.List<TypePatternExpr> typePatternExprsDiscoveredInPattern(ComponentPatternExpr patternExpr)
When looking for a variable declaration in a pattern expression, there are 2 cases: 1. The pattern expression is a type pattern expression (e.g.Foo f), in which case we can just compare the name of the variable we're trying to resolve with the name declared in the pattern. 2. The pattern expression is a record pattern expression (e.g.Foo (Bar b, Baz (...) )), in which case we need to traverse the "pattern tree" to find all type pattern expressions, so that we can compare names for all of these. In both cases, we only really care about the type pattern expressions, so this method simply does a traversal of the pattern tree to find all type pattern expressions contained in it.- Parameters:
patternExpr- the root of the pattern tree to traverse- Returns:
- all type pattern expressions discovered in the tree
-
findExposedPatternInParentContext
public SymbolReference<? extends ResolvedValueDeclaration> findExposedPatternInParentContext(Node parent, java.lang.String name)
-
typePatternExprsExposedFromChildren
public java.util.List<TypePatternExpr> typePatternExprsExposedFromChildren()
- Specified by:
typePatternExprsExposedFromChildrenin interfaceContext
-
negatedTypePatternExprsExposedFromChildren
public java.util.List<TypePatternExpr> negatedTypePatternExprsExposedFromChildren()
- Specified by:
negatedTypePatternExprsExposedFromChildrenin interfaceContext
-
-