Example usage for org.eclipse.jdt.core JavaCore VERSION_10

List of usage examples for org.eclipse.jdt.core JavaCore VERSION_10

Introduction

In this page you can find the example usage for org.eclipse.jdt.core JavaCore VERSION_10.

Prototype

String VERSION_10

To view the source code for org.eclipse.jdt.core JavaCore VERSION_10.

Click Source Link

Document

Configurable option value: .

Usage

From source file:org.springframework.ide.vscode.boot.java.handlers.BootJavaReferencesHandler.java

License:Open Source License

private List<? extends Location> provideReferences(TextDocument document, int offset) throws Exception {
    ASTParser parser = ASTParser.newParser(AST.JLS10);
    Map<String, String> options = JavaCore.getOptions();
    JavaCore.setComplianceOptions(JavaCore.VERSION_10, options);
    parser.setCompilerOptions(options);/*  www  .ja  v  a 2  s  . c  o  m*/
    parser.setKind(ASTParser.K_COMPILATION_UNIT);
    parser.setStatementsRecovery(true);
    parser.setBindingsRecovery(true);
    parser.setResolveBindings(true);

    String[] classpathEntries = getClasspathEntries(document);
    String[] sourceEntries = new String[] {};
    parser.setEnvironment(classpathEntries, sourceEntries, null, true);

    String docURI = document.getUri();
    String unitName = docURI.substring(docURI.lastIndexOf("/"));
    parser.setUnitName(unitName);
    parser.setSource(document.get(0, document.getLength()).toCharArray());

    CompilationUnit cu = (CompilationUnit) parser.createAST(null);
    ASTNode node = NodeFinder.perform(cu, offset, 0);

    if (node != null) {
        return provideReferencesForAnnotation(node, offset, document);
    }

    return null;
}