TypeInfoSearcher { @SuppressWarnings("try") public static Optional<TypeInfo> search(File file, int line, int column, String symbol) throws ExecutionException, IOException { try (TelemetryUtils.ScopedSpan ss = TelemetryUtils.startScopedSpan("TypeInfoSearcher.search")) { TelemetryUtils.ScopedSpan.addAnnotation( TelemetryUtils.annotationBuilder() .put("file", file.getPath()) .put("line", line) .put("column", column) .build("args")); return getSource(file) .flatMap( src -> { Optional<String> cond = searchClassCondition(src, line, column, symbol); if (cond.isPresent()) { String fqcn = cond.get(); return Optional.of(createTypeInfo(fqcn)); } return searchClass(src, line, column, symbol); }); } } TypeInfoSearcher(Supplier<Project> supplier); @SuppressWarnings("try") static Optional<TypeInfo> search(File file, int line, int column, String symbol);  }
@Test public void testSearch01() throws Exception { File f = new File(project.getProjectRootPath(), "./src/main/java/meghanada/analyze/ClassScope.java") .getCanonicalFile(); assertTrue(f.exists()); TypeInfoSearcher searcher = getSearcher(); Optional<TypeInfo> result = TypeInfoSearcher.search(f, 20, 10, ""); TypeInfo typeInfo = result.get(); assertEquals(6, typeInfo.getHierarchy().size()); }
@Test public void testSearch02() throws Exception { File f = new File(project.getProjectRootPath(), "./src/main/java/meghanada/analyze/ClassScope.java") .getCanonicalFile(); assertTrue(f.exists()); TypeInfoSearcher searcher = getSearcher(); Optional<TypeInfo> result = TypeInfoSearcher.search(f, 23, 50, "ArrayList"); TypeInfo typeInfo = result.get(); assertEquals(4, typeInfo.getHierarchy().size()); assertEquals(6, typeInfo.getInterfaces().size()); }