use of com.github.javaparser.symbolsolver.resolution.SymbolDeclarator in project javaparser by javaparser.
the class SwitchEntryContext method solveSymbol.
@Override
public SymbolReference<? extends ResolvedValueDeclaration> solveSymbol(String name, TypeSolver typeSolver) {
SwitchStmt switchStmt = (SwitchStmt) requireParentNode(wrappedNode);
ResolvedType type = JavaParserFacade.get(typeSolver).getType(switchStmt.getSelector());
if (type.isReferenceType() && type.asReferenceType().getTypeDeclaration().isEnum()) {
if (type instanceof ReferenceTypeImpl) {
ReferenceTypeImpl typeUsageOfTypeDeclaration = (ReferenceTypeImpl) type;
if (typeUsageOfTypeDeclaration.getTypeDeclaration().hasField(name)) {
return SymbolReference.solved(typeUsageOfTypeDeclaration.getTypeDeclaration().getField(name));
}
} else {
throw new UnsupportedOperationException();
}
}
// look for declaration in other switch statements
for (SwitchEntryStmt seStmt : switchStmt.getEntries()) {
if (!seStmt.equals(wrappedNode)) {
for (Statement stmt : seStmt.getStatements()) {
SymbolDeclarator symbolDeclarator = JavaParserFactory.getSymbolDeclarator(stmt, typeSolver);
SymbolReference<? extends ResolvedValueDeclaration> symbolReference = solveWith(symbolDeclarator, name);
if (symbolReference.isSolved()) {
return symbolReference;
}
}
}
}
return getParent().solveSymbol(name, typeSolver);
}
Aggregations