Search in sources :

Example 1 with Declaration

use of meghanada.docs.declaration.Declaration in project meghanada-server by mopemope.

the class JavaAnalyzerTest method analyze04.

@Test
public void analyze04() throws Exception {
    final JavaAnalyzer analyzer = getAnalyzer();
    final String cp = getClasspath();
    List<File> files = new ArrayList<>();
    final File file = new File("./src/test/java/meghanada/Gen4.java").getCanonicalFile();
    assertTrue(file.exists());
    files.add(file);
    final String tmp = System.getProperty("java.io.tmpdir");
    timeIt(() -> {
        final CompileResult compileResult = analyzer.analyzeAndCompile(files, cp, tmp);
        compileResult.getSources().values().forEach(Source::dump);
        return compileResult;
    });
    timeIt(() -> {
        return analyzer.analyzeAndCompile(files, cp, tmp);
    });
    final DeclarationSearcher searcher = new DeclarationSearcher(getProject());
    final Optional<Declaration> declaration = searcher.searchDeclaration(file, 9, 22, "value");
    assertNotNull(declaration);
}
Also used : ArrayList(java.util.ArrayList) DeclarationSearcher(meghanada.docs.declaration.DeclarationSearcher) Declaration(meghanada.docs.declaration.Declaration) File(java.io.File) Test(org.junit.Test)

Example 2 with Declaration

use of meghanada.docs.declaration.Declaration in project meghanada-server by mopemope.

the class CommandHandler method showDeclaration.

public void showDeclaration(final long id, final String path, final String line, final String col, final String symbol) {
    final int lineInt = Integer.parseInt(line);
    final int columnInt = Integer.parseInt(col);
    try {
        final Declaration declaration = session.showDeclaration(path, lineInt, columnInt, symbol).orElse(new Declaration("", "", Declaration.Type.OTHER, 0));
        final String out = outputFormatter.showDeclaration(id, declaration);
        writer.write(out);
        writer.newLine();
        writer.flush();
    } catch (Throwable t) {
        writeError(id, t);
    }
}
Also used : Declaration(meghanada.docs.declaration.Declaration)

Aggregations

Declaration (meghanada.docs.declaration.Declaration)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 DeclarationSearcher (meghanada.docs.declaration.DeclarationSearcher)1 Test (org.junit.Test)1