diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java index cee22e767f4..a7ab47a2525 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java @@ -502,8 +502,9 @@ public org.eclipse.jdt.core.dom.CompilationUnit getOrBuildAST(WorkingCopyOwner w return this.ast; } Map options = getOptions(true); - int jlsLevel = Integer.parseInt(options.getOrDefault(JavaCore.COMPILER_SOURCE, Integer.toString(AST.getJLSLatest()))); - ASTParser parser = ASTParser.newParser(jlsLevel); + ASTParser parser = ASTParser.newParser(new AST(options).apiLevel()); // go through AST constructor to convert options to apiLevel + // but we should probably instead just use the latest Java version + // supported by the compiler parser.setWorkingCopyOwner(workingCopyOwner); parser.setSource(this); // greedily enable everything assuming the AST will be used extensively for edition