public class PotentialVariableDeclarationFunction extends java.lang.Object implements CtConsumableFunction<CtElement>, CtQueryAware
CtVariable
instances,
which might be a declaration of an input CtElement
.
CtLocalVariable
instances,
or it returns CtCatchVariable
instances of catch blocks,
or i returns CtParameter
instances of methods, lambdas and catch blocks.
or it returns CtField
instances from wrapping classes and their super classes too.
CtVariable
declarations
CtVariableReference varRef = ...;
varRef.map(new PotentialVariableDeclarationFunction()).forEach(...process result...);
Example: Search for CtVariable
declaration of variable named `varName` in scope "scope"
CtElement scope = ...;
String varName = "anVariableName";
CtVariable varOrNull = scope.map(new PotentialVariableDeclarationFunction(varName)).first();
Constructor and Description |
---|
PotentialVariableDeclarationFunction() |
PotentialVariableDeclarationFunction(java.lang.String variableName)
Searches for a variable with exact name.
|
Modifier and Type | Method and Description |
---|---|
void |
apply(CtElement input,
CtConsumer<java.lang.Object> outputConsumer)
Evaluates the function on the given input.
|
boolean |
isTypeOnTheWay()
This method provides access to current state of this function.
|
void |
setQuery(CtQuery query)
This method is called when the filter/function is added as a step to a
CtQuery by the query engine (CtQueryImpl ). |
public PotentialVariableDeclarationFunction()
public PotentialVariableDeclarationFunction(java.lang.String variableName)
variableName
- public void apply(CtElement input, CtConsumer<java.lang.Object> outputConsumer)
CtConsumableFunction
apply
in interface CtConsumableFunction<CtElement>
input
- the input of the functionoutputConsumer
- the consumer which accepts the results of this function.public boolean isTypeOnTheWay()
public void setQuery(CtQuery query)
CtQueryAware
CtQuery
by the query engine (CtQueryImpl
).setQuery
in interface CtQueryAware
query
- an instance registering this function/filter.Copyright © 2007–2021 Inria. All rights reserved.