• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1package me.tomassetti.symbolsolver.javaparser;
2
3import com.github.javaparser.ast.CompilationUnit;
4import com.github.javaparser.ast.Node;
5import com.github.javaparser.ast.body.BodyDeclaration;
6import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
7import com.github.javaparser.ast.body.MethodDeclaration;
8import com.github.javaparser.ast.body.TypeDeclaration;
9import com.github.javaparser.ast.expr.NameExpr;
10
11import java.util.Optional;
12
13/**
14 * This class can be used to conveniently retrieve certain node from a JavaParser AST.
15 */
16public final class Navigator {
17
18    private Navigator() {
19        // prevent instantiation
20    }
21
22    public static Optional<TypeDeclaration> findType(CompilationUnit cu, String name) {
23        return cu.getTypes().stream().filter((t) -> t.getName().equals(name)).findFirst();
24    }
25
26}