Example usage for org.eclipse.jdt.core.dom AST JLS11

List of usage examples for org.eclipse.jdt.core.dom AST JLS11

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom AST JLS11.

Prototype

int JLS11

To view the source code for org.eclipse.jdt.core.dom AST JLS11.

Click Source Link

Document

Constant for indicating the AST API that handles JLS11.

Usage

From source file:org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache.java

License:Open Source License

public static CompilationUnit parse(char[] source, String docURI, String unitName, String[] classpathEntries)
        throws Exception {
    ASTParser parser = ASTParser.newParser(AST.JLS11);
    Map<String, String> options = JavaCore.getOptions();
    JavaCore.setComplianceOptions(JavaCore.VERSION_11, options);
    parser.setCompilerOptions(options);/*  w w  w .j av  a2 s  . c  o  m*/
    parser.setKind(ASTParser.K_COMPILATION_UNIT);
    parser.setStatementsRecovery(true);
    parser.setBindingsRecovery(true);
    parser.setResolveBindings(true);

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

    parser.setUnitName(unitName);
    parser.setSource(source);

    CompilationUnit cu = (CompilationUnit) parser.createAST(null);

    return cu;
}

From source file:org.springframework.ide.vscode.boot.java.utils.SpringIndexerJava.java

License:Open Source License

private ASTParser createParser(IJavaProject project) throws Exception {
    String[] classpathEntries = getClasspathEntries(project);

    ASTParser parser = ASTParser.newParser(AST.JLS11);
    Map<String, String> options = JavaCore.getOptions();
    JavaCore.setComplianceOptions(JavaCore.VERSION_11, options);
    parser.setCompilerOptions(options);/*from ww  w  .  j  a v  a2 s . co m*/
    parser.setKind(ASTParser.K_COMPILATION_UNIT);
    parser.setStatementsRecovery(true);
    parser.setBindingsRecovery(true);
    parser.setResolveBindings(true);

    boolean ignoreMethodBodies = "true"
            .equals(System.getProperty("boot.ls.symbols.ignoreMethodBodies", "false"));
    parser.setIgnoreMethodBodies(ignoreMethodBodies);

    String[] sourceEntries = new String[] {};
    parser.setEnvironment(classpathEntries, sourceEntries, null, false);
    return parser;
}