public interface Context
Modifier and Type | Method and Description |
---|---|
default 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.
|
Optional<Context> |
getParent() |
<N extends Node> |
getWrappedNode()
Returns the node wrapped in the context
|
default Optional<VariableDeclarator> |
localVariableDeclarationInScope(String name)
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<TypePatternExpr> |
negatedTypePatternExprsExposedFromChildren() |
default Optional<Parameter> |
parameterDeclarationInScope(String name) |
default List<Parameter> |
parametersExposedToChild(Node child)
The parameters that are declared in this immediate context and made visible to a given child.
|
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.
|
default Optional<ResolvedType> |
solveGenericType(String name)
Default to no generics available in this context, delegating solving to the parent context.
|
default Optional<ResolvedType> |
solveGenericTypeInParentContext(String name) |
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.
|
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. solving
x when used as an argument doubleThis(x) , or calculation return x * 2; ). |
default Optional<Value> |
solveSymbolAsValue(String name)
Used where a symbol is being used (e.g. solving
x when used as an argument doubleThis(x) , or calculation return x * 2; ). |
default Optional<Value> |
solveSymbolAsValueInParentContext(String name) |
default SymbolReference<? extends ResolvedValueDeclaration> |
solveSymbolInParentContext(String name) |
default SymbolReference<ResolvedTypeDeclaration> |
solveType(String name)
Deprecated.
Consider using method
solveType(String, List) that also consider the type arguments.
If you want to keep to use the new function, but keep the same behavior consider passing type
arguments as null . |
default SymbolReference<ResolvedTypeDeclaration> |
solveType(String name,
List<ResolvedType> typeArguments)
Method used to solve a name with an expected list of type arguments.
|
default SymbolReference<ResolvedTypeDeclaration> |
solveTypeInParentContext(String name)
Deprecated.
Consider using method
solveTypeInParentContext(String, List) that also consider the type arguments.
If you want to keep to use the new function, but keep the same behavior consider passing type
arguments as null . |
default SymbolReference<ResolvedTypeDeclaration> |
solveTypeInParentContext(String name,
List<ResolvedType> typeArguments)
Solve a name with type arguments in the parent context.
|
default Optional<TypePatternExpr> |
typePatternExprInScope(String name)
With respect to solving, the AST "parent" of a block statement is not necessarily the same as the scope parent.
|
default List<TypePatternExpr> |
typePatternExprsExposedFromChildren() |
default List<TypePatternExpr> |
typePatternExprsExposedToChild(Node child)
The pattern expressions that are declared in this immediate context and made visible to a given child.
|
<N extends Node> N getWrappedNode()
Optional<Context> getParent()
default Optional<ResolvedType> solveGenericType(String name)
name
- For example, solving T
within class Foo<T> {}
ordefault Optional<ResolvedType> solveGenericTypeInParentContext(String name)
@Deprecated default SymbolReference<ResolvedTypeDeclaration> solveType(String name)
solveType(String, List)
that also consider the type arguments.
If you want to keep to use the new function, but keep the same behavior consider passing type
arguments as null
.name
- For example, solving List
or java.util.List
.default SymbolReference<ResolvedTypeDeclaration> solveType(String name, @Nullable List<ResolvedType> typeArguments)
solveType(String)
by taking the type arguments in consideration.
For example, lets imagine that we have a project containing the following classes:
name
- The name to be solved.typeArguments
- The list of expected type arguments.@Deprecated default SymbolReference<ResolvedTypeDeclaration> solveTypeInParentContext(String name)
solveTypeInParentContext(String, List)
that also consider the type arguments.
If you want to keep to use the new function, but keep the same behavior consider passing type
arguments as null
.name
- The name to be solved.default SymbolReference<ResolvedTypeDeclaration> solveTypeInParentContext(String name, @Nullable List<ResolvedType> typeArguments)
name
- The name to be solved.typeArguments
- The list of expected type arguments.default SymbolReference<? extends ResolvedValueDeclaration> solveSymbol(String name)
x
when used as an argument doubleThis(x)
, or calculation return x * 2;
).name
- the variable / reference / identifier used.default SymbolReference<? extends ResolvedValueDeclaration> solveSymbolInParentContext(String name)
default Optional<Value> solveSymbolAsValue(String name)
x
when used as an argument doubleThis(x)
, or calculation return x * 2;
).name
- the variable / reference / identifier used.default Optional<Value> solveSymbolAsValueInParentContext(String name)
default List<ResolvedFieldDeclaration> fieldsExposedToChild(Node child)
default List<VariableDeclarator> localVariablesExposedToChild(Node child)
default List<Parameter> parametersExposedToChild(Node child)
default List<TypePatternExpr> typePatternExprsExposedToChild(Node child)
default List<TypePatternExpr> typePatternExprsExposedFromChildren()
default List<TypePatternExpr> negatedTypePatternExprsExposedFromChildren()
default Optional<VariableDeclarator> localVariableDeclarationInScope(String name)
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.
default Optional<TypePatternExpr> typePatternExprInScope(String name)
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
}
}
default Optional<ResolvedFieldDeclaration> fieldDeclarationInScope(String name)
default SymbolReference<ResolvedConstructorDeclaration> solveConstructor(List<ResolvedType> argumentsTypes)
default SymbolReference<ResolvedMethodDeclaration> solveMethod(String name, List<ResolvedType> argumentsTypes, boolean staticOnly)
default SymbolReference<ResolvedMethodDeclaration> solveMethodInParentContext(String name, List<ResolvedType> argumentsTypes, boolean staticOnly)
Optional<MethodUsage> solveMethodAsUsage(String name, List<ResolvedType> argumentsTypes)
Copyright © 2007–2024. All rights reserved.