use of com.github.javaparser.symbolsolver.resolution.SymbolDeclarator in project javaparser by javaparser.
the class AbstractMethodLikeDeclarationContext method solveSymbol.
public final SymbolReference<? extends ResolvedValueDeclaration> solveSymbol(String name, TypeSolver typeSolver) {
for (Parameter parameter : wrappedNode.getParameters()) {
SymbolDeclarator sb = JavaParserFactory.getSymbolDeclarator(parameter, typeSolver);
SymbolReference<? extends ResolvedValueDeclaration> symbolReference = AbstractJavaParserContext.solveWith(sb, name);
if (symbolReference.isSolved()) {
return symbolReference;
}
}
// if nothing is found we should ask the parent context
return getParent().solveSymbol(name, typeSolver);
}
use of com.github.javaparser.symbolsolver.resolution.SymbolDeclarator in project javaparser by javaparser.
the class CatchClauseContext method solveSymbol.
public final SymbolReference<? extends ResolvedValueDeclaration> solveSymbol(String name, TypeSolver typeSolver) {
SymbolDeclarator sb = JavaParserFactory.getSymbolDeclarator(wrappedNode.getParameter(), typeSolver);
SymbolReference<? extends ResolvedValueDeclaration> symbolReference = AbstractJavaParserContext.solveWith(sb, name);
if (symbolReference.isSolved()) {
return symbolReference;
}
// if nothing is found we should ask the parent context
return getParent().solveSymbol(name, typeSolver);
}
use of com.github.javaparser.symbolsolver.resolution.SymbolDeclarator in project javaparser by javaparser.
the class StatementContext method solveInBlockAsValue.
public static Optional<Value> solveInBlockAsValue(String name, TypeSolver typeSolver, Statement stmt) {
if (!(requireParentNode(stmt) instanceof NodeWithStatements)) {
throw new IllegalArgumentException();
}
NodeWithStatements<?> blockStmt = (NodeWithStatements<?>) requireParentNode(stmt);
int position = -1;
for (int i = 0; i < blockStmt.getStatements().size(); i++) {
if (blockStmt.getStatements().get(i).equals(stmt)) {
position = i;
}
}
if (position == -1) {
throw new RuntimeException();
}
for (int i = position - 1; i >= 0; i--) {
SymbolDeclarator symbolDeclarator = JavaParserFactory.getSymbolDeclarator(blockStmt.getStatements().get(i), typeSolver);
SymbolReference<? extends ResolvedValueDeclaration> symbolReference = solveWith(symbolDeclarator, name);
if (symbolReference.isSolved()) {
return Optional.of(Value.from(symbolReference.getCorrespondingDeclaration()));
}
}
// if nothing is found we should ask the parent context
return JavaParserFactory.getContext(requireParentNode(stmt), typeSolver).solveSymbolAsValue(name, typeSolver);
}
use of com.github.javaparser.symbolsolver.resolution.SymbolDeclarator in project javaparser by javaparser.
the class AbstractMethodLikeDeclarationContext method solveSymbolAsValue.
@Override
public final Optional<Value> solveSymbolAsValue(String name, TypeSolver typeSolver) {
for (Parameter parameter : wrappedNode.getParameters()) {
SymbolDeclarator sb = JavaParserFactory.getSymbolDeclarator(parameter, typeSolver);
Optional<Value> symbolReference = solveWithAsValue(sb, name, typeSolver);
if (symbolReference.isPresent()) {
// Perform parameter type substitution as needed
return symbolReference;
}
}
// if nothing is found we should ask the parent context
return getParent().solveSymbolAsValue(name, typeSolver);
}
use of com.github.javaparser.symbolsolver.resolution.SymbolDeclarator in project javaparser by javaparser.
the class CatchClauseContext method solveSymbolAsValue.
@Override
public final Optional<Value> solveSymbolAsValue(String name, TypeSolver typeSolver) {
SymbolDeclarator sb = JavaParserFactory.getSymbolDeclarator(wrappedNode.getParameter(), typeSolver);
Optional<Value> symbolReference = solveWithAsValue(sb, name, typeSolver);
if (symbolReference.isPresent()) {
// Perform parameter type substitution as needed
return symbolReference;
}
// if nothing is found we should ask the parent context
return getParent().solveSymbolAsValue(name, typeSolver);
}
Aggregations