Interface Context
- All Known Implementing Classes:
AbstractJavaParserContext
,AbstractMethodLikeDeclarationContext
,AnnotationDeclarationContext
,AnonymousClassDeclarationContext
,BinaryExprContext
,BlockStmtContext
,CatchClauseContext
,ClassOrInterfaceDeclarationContext
,ClassOrInterfaceDeclarationExtendsContext
,CompilationUnitContext
,ConstructorContext
,EnclosedExprContext
,EnumDeclarationContext
,FieldAccessContext
,ForEachStatementContext
,ForStatementContext
,IfStatementContext
,InstanceOfExprContext
,LambdaExprContext
,MethodCallExprContext
,MethodContext
,MethodReferenceExprContext
,ObjectCreationContext
,StatementContext
,SwitchEntryContext
,TryWithResourceContext
,UnaryExprContext
,VariableDeclarationExprContext
,VariableDeclaratorContext
- Author:
- Federico Tomassetti
-
Method Summary
Modifier and TypeMethodDescriptiondefault Optional<ResolvedFieldDeclaration>
fieldDeclarationInScope(String name)
default List<ResolvedFieldDeclaration>
fieldsExposedToChild(Node child)
The fields that are declared and in this immediate context made visible to a given child.default Optional<VariableDeclarator>
Aim to resolve the given name by looking for a variable matching it.default List<VariableDeclarator>
localVariablesExposedToChild(Node child)
The local variables that are declared in this immediate context and made visible to a given child.default List<PatternExpr>
parametersExposedToChild(Node child)
The parameters that are declared in this immediate context and made visible to a given child.default Optional<PatternExpr>
patternExprInScope(String name)
With respect to solving, the AST "parent" of a block statement is not necessarily the same as the scope parent.default List<PatternExpr>
default List<PatternExpr>
patternExprsExposedToChild(Node child)
The pattern expressions that are declared in this immediate context and made visible to a given child.solveConstructor(List<ResolvedType> argumentsTypes)
We find the method declaration which is the best match for the given name and list of typeParametersValues.default Optional<ResolvedType>
solveGenericType(String name)
Default to no generics available in this context, delegating solving to the parent context.default Optional<ResolvedType>
default SymbolReference<ResolvedMethodDeclaration>
solveMethod(String name, List<ResolvedType> argumentsTypes, boolean staticOnly)
We find the method declaration which is the best match for the given name and list of typeParametersValues.default Optional<MethodUsage>
solveMethodAsUsage(String name, List<ResolvedType> argumentsTypes)
Similar to solveMethod but we return a MethodUsage.default SymbolReference<ResolvedMethodDeclaration>
solveMethodInParentContext(String name, List<ResolvedType> argumentsTypes, boolean staticOnly)
default SymbolReference<? extends ResolvedValueDeclaration>
solveSymbol(String name)
Used where a symbol is being used (e.g.solveSymbolAsValue(String name)
Used where a symbol is being used (e.g.default SymbolReference<? extends ResolvedValueDeclaration>
solveSymbolInParentContext(String name)
default SymbolReference<ResolvedTypeDeclaration>
Default to being unable to solve any reference in this context, delegating solving to the parent context.default SymbolReference<ResolvedTypeDeclaration>
solveTypeInParentContext(String name)
-
Method Details
-
getParent
- Returns:
- The parent context, if there is one. For example, a method exists within a compilation unit.
-
solveGenericType
Default to no generics available in this context, delegating solving to the parent context. Contexts which have generics available to it will override this method. For example class and method declarations, and method calls.- Parameters:
name
- For example, solvingT
withinclass Foo<T> {}
or- Returns:
- The resolved generic type, if found.
-
solveGenericTypeInParentContext
-
solveType
Default to being unable to solve any reference in this context, delegating solving to the parent context. Contexts which exist as the "parent" of a resolvable type will override this method. For example, a compilation unit can contain classes. A class declaration can also contain types (e.g. a subclass).- Parameters:
name
- For example, solvingList
orjava.util.List
.- Returns:
- The declaration associated with the given type name.
-
solveTypeInParentContext
-
solveSymbol
Used where a symbol is being used (e.g. solvingx
when used as an argumentdoubleThis(x)
, or calculationreturn x * 2;
).- Parameters:
name
- the variable / reference / identifier used.- Returns:
- // FIXME: Better documentation on how this is different to solveSymbolAsValue()
-
solveSymbolInParentContext
default SymbolReference<? extends ResolvedValueDeclaration> solveSymbolInParentContext(String name) -
solveSymbolAsValue
Used where a symbol is being used (e.g. solvingx
when used as an argumentdoubleThis(x)
, or calculationreturn x * 2;
).- Parameters:
name
- the variable / reference / identifier used.- Returns:
- // FIXME: Better documentation on how this is different to solveSymbol()
-
solveSymbolAsValueInParentContext
-
fieldsExposedToChild
The fields that are declared and in this immediate context made visible to a given child. This list could include values which are shadowed. -
localVariablesExposedToChild
The local variables that are declared in this immediate context and made visible to a given child. This list could include values which are shadowed. -
parametersExposedToChild
The parameters that are declared in this immediate context and made visible to a given child. This list could include values which are shadowed. -
patternExprsExposedToChild
The pattern expressions that are declared in this immediate context and made visible to a given child. This list could include values which are shadowed. -
patternExprsExposedFromChildren
-
negatedPatternExprsExposedFromChildren
-
localVariableDeclarationInScope
Aim to resolve the given name by looking for a variable matching it.To do it consider local variables that are visible in a certain scope as defined in JLS 6.3. Scope of a Declaration.
1. The scope of a local variable declaration in a block (§14.4) is the rest of the block in which the declaration appears, starting with its own initializer and including any further declarators to the right in the local variable declaration statement.
2. The scope of a local variable declared in the ForInit part of a basic for statement (§14.14.1) includes all of the following: 2.1 Its own initializer 2.2 Any further declarators to the right in the ForInit part of the for statement 2.3 The Expression and ForUpdate parts of the for statement 2.4 The contained Statement
3. The scope of a local variable declared in the FormalParameter part of an enhanced for statement (§14.14.2) is the contained Statement. 4. The scope of a parameter of an exception handler that is declared in a catch clause of a try statement (§14.20) is the entire block associated with the catch.
5. The scope of a variable declared in the ResourceSpecification of a try-with-resources statement (§14.20.3) is from the declaration rightward over the remainder of the ResourceSpecification and the entire try block associated with the try-with-resources statement.
-
parameterDeclarationInScope
-
patternExprInScope
With respect to solving, the AST "parent" of a block statement is not necessarily the same as the scope parent.
Example:
public String x() { if(x) { // Parent node: the block attached to the method declaration // Scope-parent: the block attached to the method declaration } else if { // Parent node: the if // Scope-parent: the block attached to the method declaration } else { // Parent node: the elseif // Scope-parent: the block attached to the method declaration } }
-
fieldDeclarationInScope
-
solveConstructor
default SymbolReference<ResolvedConstructorDeclaration> solveConstructor(List<ResolvedType> argumentsTypes)We find the method declaration which is the best match for the given name and list of typeParametersValues. -
solveMethod
default SymbolReference<ResolvedMethodDeclaration> solveMethod(String name, List<ResolvedType> argumentsTypes, boolean staticOnly)We find the method declaration which is the best match for the given name and list of typeParametersValues. -
solveMethodInParentContext
default SymbolReference<ResolvedMethodDeclaration> solveMethodInParentContext(String name, List<ResolvedType> argumentsTypes, boolean staticOnly) -
solveMethodAsUsage
Similar to solveMethod but we return a MethodUsage. A MethodUsage corresponds to a MethodDeclaration plus the resolved type variables.
-