diff --git a/org.eclipse.jdt.core.javac/META-INF/MANIFEST.MF b/org.eclipse.jdt.core.javac/META-INF/MANIFEST.MF
index e4223227ebd..6a02b1d6316 100644
--- a/org.eclipse.jdt.core.javac/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.core.javac/META-INF/MANIFEST.MF
@@ -1,11 +1,14 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Javac
-Bundle-SymbolicName: org.eclipse.jdt.core.javac
+Bundle-SymbolicName: org.eclipse.jdt.core.javac;singleton:=true
Bundle-Version: 1.0.0.qualifier
-Fragment-Host: org.eclipse.jdt.core
Automatic-Module-Name: org.eclipse.jdt.core.javac
Require-Capability: osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=22))"
Import-Package: org.eclipse.jdt.core.dom
-Export-Package: org.eclipse.jdt.internal.javac;x-friends:="org.eclipse.jdt.core.tests.javac",
- org.eclipse.jdt.internal.javac.dom;x-friends:="org.eclipse.jdt.core.tests.javac"
+Require-Bundle: org.eclipse.jdt.core;bundle-version="3.38.100",
+ org.eclipse.core.runtime;bundle-version="3.31.0",
+ org.eclipse.core.resources;bundle-version="3.20.200",
+ org.eclipse.jface.text;bundle-version="3.25.100"
+Export-Package: org.eclipse.jdt.internal.javac;manipulation=split;mandatory:=manipulation;x-friends:="org.eclipse.jdt.core.tests.javac",
+ org.eclipse.jdt.internal.javac.dom;manipulation=split;mandatory:=manipulation;x-friends:="org.eclipse.jdt.core.tests.javac"
diff --git a/org.eclipse.jdt.core.javac/plugin.xml b/org.eclipse.jdt.core.javac/plugin.xml
new file mode 100644
index 00000000000..c48e881395a
--- /dev/null
+++ b/org.eclipse.jdt.core.javac/plugin.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
diff --git a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacAnnotationBinding.java b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacAnnotationBinding.java
index 4e0d05423dd..95962e330d7 100644
--- a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacAnnotationBinding.java
+++ b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacAnnotationBinding.java
@@ -19,7 +19,6 @@
import org.eclipse.jdt.core.dom.IBinding;
import org.eclipse.jdt.core.dom.IMemberValuePairBinding;
import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.JavacBindingResolver;
import com.sun.tools.javac.code.Attribute.Compound;
diff --git a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacBindingResolver.java b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacBindingResolver.java
similarity index 87%
rename from org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacBindingResolver.java
rename to org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacBindingResolver.java
index 525aa1e13ce..9dd97ebf3ec 100644
--- a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacBindingResolver.java
+++ b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacBindingResolver.java
@@ -8,7 +8,7 @@
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
-package org.eclipse.jdt.core.dom;
+package org.eclipse.jdt.internal.javac.dom;
import java.io.IOException;
import java.util.Arrays;
@@ -21,14 +21,44 @@
import org.eclipse.core.runtime.ILog;
import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.internal.javac.dom.JavacAnnotationBinding;
-import org.eclipse.jdt.internal.javac.dom.JavacMemberValuePairBinding;
-import org.eclipse.jdt.internal.javac.dom.JavacMethodBinding;
-import org.eclipse.jdt.internal.javac.dom.JavacModuleBinding;
-import org.eclipse.jdt.internal.javac.dom.JavacPackageBinding;
-import org.eclipse.jdt.internal.javac.dom.JavacTypeBinding;
-import org.eclipse.jdt.internal.javac.dom.JavacTypeVariableBinding;
-import org.eclipse.jdt.internal.javac.dom.JavacVariableBinding;
+import org.eclipse.jdt.core.dom.ASTNode;
+import org.eclipse.jdt.core.dom.Annotation;
+import org.eclipse.jdt.core.dom.AnnotationTypeDeclaration;
+import org.eclipse.jdt.core.dom.AnnotationTypeMemberDeclaration;
+import org.eclipse.jdt.core.dom.AnonymousClassDeclaration;
+import org.eclipse.jdt.core.dom.BindingResolver;
+import org.eclipse.jdt.core.dom.ClassInstanceCreation;
+import org.eclipse.jdt.core.dom.ConstructorInvocation;
+import org.eclipse.jdt.core.dom.EnumConstantDeclaration;
+import org.eclipse.jdt.core.dom.EnumDeclaration;
+import org.eclipse.jdt.core.dom.Expression;
+import org.eclipse.jdt.core.dom.FieldAccess;
+import org.eclipse.jdt.core.dom.IAnnotationBinding;
+import org.eclipse.jdt.core.dom.IBinding;
+import org.eclipse.jdt.core.dom.IMethodBinding;
+import org.eclipse.jdt.core.dom.IModuleBinding;
+import org.eclipse.jdt.core.dom.IPackageBinding;
+import org.eclipse.jdt.core.dom.ITypeBinding;
+import org.eclipse.jdt.core.dom.IVariableBinding;
+import org.eclipse.jdt.core.dom.ImportDeclaration;
+import org.eclipse.jdt.core.dom.LambdaExpression;
+import org.eclipse.jdt.core.dom.MethodDeclaration;
+import org.eclipse.jdt.core.dom.MethodInvocation;
+import org.eclipse.jdt.core.dom.MethodReference;
+import org.eclipse.jdt.core.dom.ModuleDeclaration;
+import org.eclipse.jdt.core.dom.Name;
+import org.eclipse.jdt.core.dom.PackageDeclaration;
+import org.eclipse.jdt.core.dom.ParameterizedType;
+import org.eclipse.jdt.core.dom.PrimitiveType;
+import org.eclipse.jdt.core.dom.RecordDeclaration;
+import org.eclipse.jdt.core.dom.SimpleName;
+import org.eclipse.jdt.core.dom.SimpleType;
+import org.eclipse.jdt.core.dom.SuperConstructorInvocation;
+import org.eclipse.jdt.core.dom.SuperFieldAccess;
+import org.eclipse.jdt.core.dom.Type;
+import org.eclipse.jdt.core.dom.TypeDeclaration;
+import org.eclipse.jdt.core.dom.TypeParameter;
+import org.eclipse.jdt.core.dom.VariableDeclaration;
import com.sun.source.util.JavacTask;
import com.sun.tools.javac.code.Attribute;
@@ -79,7 +109,7 @@ public class JavacBindingResolver extends BindingResolver {
private Map symbolToDom;
public final IJavaProject javaProject;
private JavacConverter converter;
- boolean isRecoveringBindings = false;
+ public boolean isRecoveringBindings = false;
public class Bindings {
private Map annotationBindings = new HashMap<>();
@@ -233,7 +263,7 @@ private Optional symbol(JCTree value) {
}
@Override
- ITypeBinding resolveType(Type type) {
+ public ITypeBinding resolveType(Type type) {
resolve();
JCTree jcTree = this.converter.domToJavac.get(type);
if (jcTree instanceof JCIdent ident && ident.type != null) {
@@ -280,7 +310,7 @@ ITypeBinding resolveType(Type type) {
}
@Override
- ITypeBinding resolveType(AnnotationTypeDeclaration type) {
+ public ITypeBinding resolveType(AnnotationTypeDeclaration type) {
resolve();
JCTree javacNode = this.converter.domToJavac.get(type);
if (javacNode instanceof JCClassDecl jcClassDecl && jcClassDecl.type != null) {
@@ -290,7 +320,7 @@ ITypeBinding resolveType(AnnotationTypeDeclaration type) {
}
@Override
- ITypeBinding resolveType(RecordDeclaration type) {
+ public ITypeBinding resolveType(RecordDeclaration type) {
resolve();
JCTree javacNode = this.converter.domToJavac.get(type);
if (javacNode instanceof JCClassDecl jcClassDecl && jcClassDecl.type != null) {
@@ -301,7 +331,7 @@ ITypeBinding resolveType(RecordDeclaration type) {
@Override
- ITypeBinding resolveType(TypeDeclaration type) {
+ public ITypeBinding resolveType(TypeDeclaration type) {
resolve();
JCTree javacNode = this.converter.domToJavac.get(type);
if (javacNode instanceof JCClassDecl jcClassDecl && jcClassDecl.type != null) {
@@ -311,7 +341,7 @@ ITypeBinding resolveType(TypeDeclaration type) {
}
@Override
- ITypeBinding resolveType(EnumDeclaration enumDecl) {
+ public ITypeBinding resolveType(EnumDeclaration enumDecl) {
resolve();
JCTree javacNode = this.converter.domToJavac.get(enumDecl);
if (javacNode instanceof JCClassDecl jcClassDecl && jcClassDecl.type != null) {
@@ -321,7 +351,7 @@ ITypeBinding resolveType(EnumDeclaration enumDecl) {
}
@Override
- ITypeBinding resolveType(AnonymousClassDeclaration anonymousClassDecl) {
+ public ITypeBinding resolveType(AnonymousClassDeclaration anonymousClassDecl) {
resolve();
JCTree javacNode = this.converter.domToJavac.get(anonymousClassDecl);
if (javacNode instanceof JCClassDecl jcClassDecl && jcClassDecl.type != null) {
@@ -329,7 +359,7 @@ ITypeBinding resolveType(AnonymousClassDeclaration anonymousClassDecl) {
}
return null;
}
- ITypeBinding resolveTypeParameter(TypeParameter typeParameter) {
+ public ITypeBinding resolveTypeParameter(TypeParameter typeParameter) {
resolve();
JCTree javacNode = this.converter.domToJavac.get(typeParameter);
if (javacNode instanceof JCTypeParameter jcClassDecl) {
@@ -339,7 +369,7 @@ ITypeBinding resolveTypeParameter(TypeParameter typeParameter) {
}
@Override
- IVariableBinding resolveField(FieldAccess fieldAccess) {
+ public IVariableBinding resolveField(FieldAccess fieldAccess) {
resolve();
JCTree javacElement = this.converter.domToJavac.get(fieldAccess);
if (javacElement instanceof JCFieldAccess javacFieldAccess && javacFieldAccess.sym instanceof VarSymbol varSymbol) {
@@ -349,7 +379,7 @@ IVariableBinding resolveField(FieldAccess fieldAccess) {
}
@Override
- IVariableBinding resolveField(SuperFieldAccess fieldAccess) {
+ public IVariableBinding resolveField(SuperFieldAccess fieldAccess) {
resolve();
JCTree javacElement = this.converter.domToJavac.get(fieldAccess);
if (javacElement instanceof JCFieldAccess javacFieldAccess && javacFieldAccess.sym instanceof VarSymbol varSymbol) {
@@ -359,7 +389,7 @@ IVariableBinding resolveField(SuperFieldAccess fieldAccess) {
}
@Override
- IMethodBinding resolveMethod(MethodInvocation method) {
+ public IMethodBinding resolveMethod(MethodInvocation method) {
resolve();
JCTree javacElement = this.converter.domToJavac.get(method);
if (javacElement instanceof JCMethodInvocation javacMethodInvocation) {
@@ -376,7 +406,7 @@ IMethodBinding resolveMethod(MethodInvocation method) {
}
@Override
- IMethodBinding resolveMethod(MethodDeclaration method) {
+ public IMethodBinding resolveMethod(MethodDeclaration method) {
resolve();
JCTree javacElement = this.converter.domToJavac.get(method);
if (javacElement instanceof JCMethodDecl methodDecl) {
@@ -386,7 +416,7 @@ IMethodBinding resolveMethod(MethodDeclaration method) {
}
@Override
- IMethodBinding resolveMethod(LambdaExpression lambda) {
+ public IMethodBinding resolveMethod(LambdaExpression lambda) {
resolve();
JCTree javacElement = this.converter.domToJavac.get(lambda);
if (javacElement instanceof JCLambda jcLambda) {
@@ -399,7 +429,7 @@ IMethodBinding resolveMethod(LambdaExpression lambda) {
}
@Override
- IMethodBinding resolveMethod(MethodReference methodReference) {
+ public IMethodBinding resolveMethod(MethodReference methodReference) {
resolve();
JCTree javacElement = this.converter.domToJavac.get(methodReference);
if (javacElement instanceof JCMemberReference memberRef && memberRef.sym instanceof MethodSymbol methodSymbol) {
@@ -409,7 +439,7 @@ IMethodBinding resolveMethod(MethodReference methodReference) {
}
@Override
- IMethodBinding resolveMember(AnnotationTypeMemberDeclaration member) {
+ public IMethodBinding resolveMember(AnnotationTypeMemberDeclaration member) {
resolve();
JCTree javacElement = this.converter.domToJavac.get(member);
if (javacElement instanceof JCMethodDecl methodDecl) {
@@ -419,7 +449,7 @@ IMethodBinding resolveMember(AnnotationTypeMemberDeclaration member) {
}
@Override
- IMethodBinding resolveConstructor(EnumConstantDeclaration enumConstantDeclaration) {
+ public IMethodBinding resolveConstructor(EnumConstantDeclaration enumConstantDeclaration) {
resolve();
JCTree javacElement = this.converter.domToJavac.get(enumConstantDeclaration);
if( javacElement instanceof JCVariableDecl jcvd ) {
@@ -432,7 +462,7 @@ IMethodBinding resolveConstructor(EnumConstantDeclaration enumConstantDeclaratio
}
@Override
- IMethodBinding resolveConstructor(SuperConstructorInvocation expression) {
+ public IMethodBinding resolveConstructor(SuperConstructorInvocation expression) {
resolve();
JCTree javacElement = this.converter.domToJavac.get(expression);
if (javacElement instanceof JCMethodInvocation javacMethodInvocation) {
@@ -448,7 +478,7 @@ IMethodBinding resolveConstructor(SuperConstructorInvocation expression) {
}
@Override
- IBinding resolveName(Name name) {
+ public IBinding resolveName(Name name) {
resolve();
JCTree tree = this.converter.domToJavac.get(name);
if( tree != null ) {
@@ -495,7 +525,7 @@ IBinding resolveNameToJavac(Name name, JCTree tree) {
}
@Override
- IVariableBinding resolveVariable(EnumConstantDeclaration enumConstant) {
+ public IVariableBinding resolveVariable(EnumConstantDeclaration enumConstant) {
resolve();
if (this.converter.domToJavac.get(enumConstant) instanceof JCVariableDecl decl) {
// the decl.type can be null when there are syntax errors
@@ -507,7 +537,7 @@ IVariableBinding resolveVariable(EnumConstantDeclaration enumConstant) {
}
@Override
- IVariableBinding resolveVariable(VariableDeclaration variable) {
+ public IVariableBinding resolveVariable(VariableDeclaration variable) {
resolve();
if (this.converter.domToJavac.get(variable) instanceof JCVariableDecl decl) {
// the decl.type can be null when there are syntax errors
@@ -563,7 +593,7 @@ public ITypeBinding resolveExpressionType(Expression expr) {
}
@Override
- IMethodBinding resolveConstructor(ClassInstanceCreation expression) {
+ public IMethodBinding resolveConstructor(ClassInstanceCreation expression) {
resolve();
return this.converter.domToJavac.get(expression) instanceof JCNewClass jcExpr
&& !jcExpr.constructor.type.isErroneous()?
@@ -572,7 +602,7 @@ IMethodBinding resolveConstructor(ClassInstanceCreation expression) {
}
@Override
- IMethodBinding resolveConstructor(ConstructorInvocation invocation) {
+ public IMethodBinding resolveConstructor(ConstructorInvocation invocation) {
resolve();
JCTree javacElement = this.converter.domToJavac.get(invocation);
if (javacElement instanceof JCMethodInvocation javacMethodInvocation) {
@@ -651,8 +681,7 @@ private java.util.List getTypeArguments(final MethodInvocation metho
}) //
.collect(Collectors.toList());
}
-
- IModuleBinding resolveModule(ModuleDeclaration module) {
+ public IModuleBinding resolveModule(ModuleDeclaration module) {
resolve();
JCTree javacElement = this.converter.domToJavac.get(module);
if( javacElement instanceof JCModuleDecl jcmd) {
@@ -700,7 +729,7 @@ public Object getValueFromAttribute(Attribute attribute) {
}
@Override
- IBinding resolveImport(ImportDeclaration importDeclaration) {
+ public IBinding resolveImport(ImportDeclaration importDeclaration) {
var javac = this.converter.domToJavac.get(importDeclaration.getName());
if (javac instanceof JCFieldAccess fieldAccess) {
if (fieldAccess.sym != null) {
@@ -720,7 +749,7 @@ IBinding resolveImport(ImportDeclaration importDeclaration) {
}
@Override
- ITypeBinding resolveWellKnownType(String typeName) {
+ public ITypeBinding resolveWellKnownType(String typeName) {
com.sun.tools.javac.code.Symtab symtab = com.sun.tools.javac.code.Symtab.instance(this.context);
com.sun.tools.javac.code.Type type = switch (typeName) {
case "byte", "java.lang.Byte" -> symtab.byteType;
@@ -751,7 +780,7 @@ ITypeBinding resolveWellKnownType(String typeName) {
}
@Override
- IAnnotationBinding resolveAnnotation(Annotation annotation) {
+ public IAnnotationBinding resolveAnnotation(Annotation annotation) {
resolve();
var javac = this.converter.domToJavac.get(annotation);
if (javac instanceof JCAnnotation jcAnnotation) {
diff --git a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacCompilationUnitResolver.java b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacCompilationUnitResolver.java
similarity index 79%
rename from org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacCompilationUnitResolver.java
rename to org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacCompilationUnitResolver.java
index 6a4bcc73e73..ce83db4ae4d 100644
--- a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacCompilationUnitResolver.java
+++ b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacCompilationUnitResolver.java
@@ -8,7 +8,7 @@
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
-package org.eclipse.jdt.core.dom;
+package org.eclipse.jdt.internal.javac.dom;
import java.io.File;
import java.io.IOException;
@@ -42,6 +42,30 @@
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.core.compiler.InvalidInputException;
+import org.eclipse.jdt.core.dom.AST;
+import org.eclipse.jdt.core.dom.ASTNode;
+import org.eclipse.jdt.core.dom.ASTRequestor;
+import org.eclipse.jdt.core.dom.ASTVisitor;
+import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
+import org.eclipse.jdt.core.dom.AnnotationTypeDeclaration;
+import org.eclipse.jdt.core.dom.Comment;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.EnumDeclaration;
+import org.eclipse.jdt.core.dom.FileASTRequestor;
+import org.eclipse.jdt.core.dom.IBinding;
+import org.eclipse.jdt.core.dom.ICompilationUnitResolver;
+import org.eclipse.jdt.core.dom.IModuleBinding;
+import org.eclipse.jdt.core.dom.IPackageBinding;
+import org.eclipse.jdt.core.dom.ITypeBinding;
+import org.eclipse.jdt.core.dom.JavacEnhancementPackagePrivateUtility;
+import org.eclipse.jdt.core.dom.JavacEnhancementPackagePrivateUtility.InternalNameEnvironmentWithProgress;
+import org.eclipse.jdt.core.dom.Javadoc;
+import org.eclipse.jdt.core.dom.MethodDeclaration;
+import org.eclipse.jdt.core.dom.NodeSearcher;
+import org.eclipse.jdt.core.dom.RecordDeclaration;
+import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
+import org.eclipse.jdt.core.dom.TypeDeclaration;
+import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
import org.eclipse.jdt.internal.compiler.batch.FileSystem.Classpath;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
@@ -74,7 +98,11 @@
* Allows to create and resolve DOM ASTs using Javac
* @implNote Cannot move to another package because parent class is package visible only
*/
-class JavacCompilationUnitResolver implements ICompilationUnitResolver {
+public class JavacCompilationUnitResolver implements ICompilationUnitResolver {
+ public JavacCompilationUnitResolver() {
+ // 0-arg constructor
+ }
+
private interface GenericRequestor {
public void acceptBinding(String bindingKey, IBinding binding);
}
@@ -84,12 +112,12 @@ private List createSourc
List sourceUnitList = new ArrayList<>(length);
for (int i = 0; i < length; i++) {
org.eclipse.jdt.internal.compiler.env.ICompilationUnit obj = createSourceUnit(sourceFilePaths[i], encodings[i]);
- if( obj != null )
+ if( obj != null )
sourceUnitList.add(obj);
}
return sourceUnitList;
}
-
+
private org.eclipse.jdt.internal.compiler.env.ICompilationUnit createSourceUnit(String sourceFilePath, String encoding) {
char[] contents = null;
try {
@@ -103,7 +131,7 @@ private org.eclipse.jdt.internal.compiler.env.ICompilationUnit createSourceUnit(
return new org.eclipse.jdt.internal.compiler.batch.CompilationUnit(contents, sourceFilePath, encoding);
}
-
+
@Override
public void resolve(String[] sourceFilePaths, String[] encodings, String[] bindingKeys, FileASTRequestor requestor,
int apiLevel, Map compilerOptions, List classpaths, int flags,
@@ -112,18 +140,18 @@ public void resolve(String[] sourceFilePaths, String[] encodings, String[] bindi
JavacBindingResolver bindingResolver = null;
// parse source units
- Map res =
+ Map res =
parse(sourceUnitList.toArray(org.eclipse.jdt.internal.compiler.env.ICompilationUnit[]::new), apiLevel, compilerOptions, flags, (IJavaProject)null, monitor);
for (var entry : res.entrySet()) {
CompilationUnit cu = entry.getValue();
requestor.acceptAST(new String(entry.getKey().getFileName()), cu);
- if (bindingResolver == null && (JavacBindingResolver)cu.ast.getBindingResolver() != null) {
- bindingResolver = (JavacBindingResolver)cu.ast.getBindingResolver();
+ if (bindingResolver == null && JavacEnhancementPackagePrivateUtility.getBindingResolver(cu) != null) {
+ bindingResolver = (JavacBindingResolver)JavacEnhancementPackagePrivateUtility.getBindingResolver(cu);
}
}
- resolveRequestedBindingKeys(bindingResolver, bindingKeys,
+ resolveRequestedBindingKeys(bindingResolver, bindingKeys,
(a,b) -> requestor.acceptBinding(a,b),
classpaths.stream().toArray(Classpath[]::new),
new CompilerOptions(compilerOptions),
@@ -139,14 +167,14 @@ public void resolve(ICompilationUnit[] compilationUnits, String[] bindingKeys, A
final JavacBindingResolver[] bindingResolver = new JavacBindingResolver[1];
bindingResolver[0] = null;
units.forEach((a,b) -> {
- if (bindingResolver[0] == null && (JavacBindingResolver)b.ast.getBindingResolver() != null) {
- bindingResolver[0] = (JavacBindingResolver)b.ast.getBindingResolver();
+ if (bindingResolver[0] == null && JavacEnhancementPackagePrivateUtility.getBindingResolver(b) != null) {
+ bindingResolver[0] = (JavacBindingResolver)JavacEnhancementPackagePrivateUtility.getBindingResolver(b);
}
- requestor.acceptAST(a,b);
+ requestor.acceptAST(a,b);
resolveBindings(b, bindingKeys, requestor, apiLevel);
});
- resolveRequestedBindingKeys(bindingResolver[0], bindingKeys,
+ resolveRequestedBindingKeys(bindingResolver[0], bindingKeys,
(a,b) -> requestor.acceptBinding(a,b),
new Classpath[0], // TODO need some classpaths
new CompilerOptions(compilerOptions),
@@ -158,8 +186,8 @@ public void resolve(ICompilationUnit[] compilationUnits, String[] bindingKeys, A
}
}
}
-
-
+
+
private void resolveRequestedBindingKeys(JavacBindingResolver bindingResolver, String[] bindingKeys, GenericRequestor requestor,
Classpath[] cp,CompilerOptions opts,
Collection units,
@@ -176,7 +204,7 @@ private void resolveRequestedBindingKeys(JavacBindingResolver bindingResolver, S
cu.accept(new BindingBuilder(bindingMap));
}
- NameEnvironmentWithProgress environment = new NameEnvironmentWithProgress(cp, null, monitor);
+ InternalNameEnvironmentWithProgress environment = new InternalNameEnvironmentWithProgress(cp, null, monitor);
LookupEnvironment lu = new LookupEnvironment(new ITypeRequestor() {
@Override
@@ -207,7 +235,7 @@ public void accept(ISourceType[] sourceType, PackageBinding packageBinding,
// from parsed files
requestor.acceptBinding(bindingKey, bindingFromMap);
} else {
-
+
CustomBindingKeyParser bkp = new CustomBindingKeyParser(bindingKey);
bkp.parse(true);
char[][] name = bkp.compoundName;
@@ -223,7 +251,8 @@ public void accept(ISourceType[] sourceType, PackageBinding packageBinding,
IBinaryType binaryType = answer.getBinaryType();
if (binaryType != null) {
BinaryTypeBinding binding = lu.cacheBinaryType(binaryType, null);
- requestor.acceptBinding(bindingKey, new TypeBinding(bindingResolver, binding));
+ requestor.acceptBinding(bindingKey,
+ JavacEnhancementPackagePrivateUtility.createTypeBinding(bindingResolver, binding));
}
}
}
@@ -251,7 +280,7 @@ public void consumeFullyQualifiedName(char[] fullyQualifiedName) {
this.compoundName = CharOperation.splitOn('/', fullyQualifiedName);
}
}
-
+
@Override
public void parse(ICompilationUnit[] compilationUnits, ASTRequestor requestor, int apiLevel,
Map compilerOptions, int flags, IProgressMonitor monitor) {
@@ -288,10 +317,10 @@ private Map parse(ICompilationUnit[] compilat
@Override
public void parse(String[] sourceFilePaths, String[] encodings, FileASTRequestor requestor, int apiLevel,
Map compilerOptions, int flags, IProgressMonitor monitor) {
-
+
for( int i = 0; i < sourceFilePaths.length; i++ ) {
org.eclipse.jdt.internal.compiler.env.ICompilationUnit ast = createSourceUnit(sourceFilePaths[i], encodings[i]);
- Map res =
+ Map res =
parse(new org.eclipse.jdt.internal.compiler.env.ICompilationUnit[] {ast}, apiLevel, compilerOptions, flags, (IJavaProject)null, monitor);
CompilationUnit result = res.get(ast);
requestor.acceptAST(sourceFilePaths[i], result);
@@ -304,29 +333,29 @@ private void respondBinding(IBinding binding, List bindingKeys, ASTReque
String k = binding.getKey();
if( k != null && bindingKeys.contains(k)) {
requestor.acceptBinding(k, binding);
- }
+ }
}
}
-
+
private void resolveBindings(CompilationUnit unit, int apiLevel) {
resolveBindings(unit, new String[0], null, apiLevel);
}
-
+
private void resolveBindings(CompilationUnit unit, String[] bindingKeys, ASTRequestor requestor, int apiLevel) {
List keys = Arrays.asList(bindingKeys);
-
+
if (unit.getPackage() != null) {
IPackageBinding pb = unit.getPackage().resolveBinding();
respondBinding(pb, keys, requestor);
- }
+ }
if (!unit.types().isEmpty()) {
List types = unit.types();
for( int i = 0; i < types.size(); i++ ) {
ITypeBinding tb = ((AbstractTypeDeclaration) types.get(i)).resolveBinding();
respondBinding(tb, keys, requestor);
}
- }
- if( apiLevel >= AST.JLS9_INTERNAL) {
+ }
+ if( apiLevel >= AST.JLS9) {
if (unit.getModule() != null) {
IModuleBinding mb = unit.getModule().resolveBinding();
respondBinding(mb, keys, requestor);
@@ -343,7 +372,7 @@ public CompilationUnit toCompilationUnit(org.eclipse.jdt.internal.compiler.env.I
CompilationUnit res = parse(new org.eclipse.jdt.internal.compiler.env.ICompilationUnit[] { sourceUnit},
apiLevel, compilerOptions, flags, project, monitor).get(sourceUnit);
if (initialNeedsToResolveBinding) {
- ((JavacBindingResolver)res.ast.getBindingResolver()).isRecoveringBindings = (flags & ICompilationUnit.ENABLE_BINDINGS_RECOVERY) != 0;
+ ((JavacBindingResolver)JavacEnhancementPackagePrivateUtility.getBindingResolver(res)).isRecoveringBindings = (flags & ICompilationUnit.ENABLE_BINDINGS_RECOVERY) != 0;
resolveBindings(res, apiLevel);
}
// For comparison
@@ -376,7 +405,7 @@ private Map 0) {
- int initialSize = res.getProblems().length;
- var newProblems = Arrays.copyOf(res.getProblems(), initialSize + javadocProblems.length);
- System.arraycopy(javadocProblems, 0, newProblems, initialSize, javadocProblems.length);
- res.setProblems(newProblems);
- }
- List javadocComments = new ArrayList<>();
- res.accept(new ASTVisitor(true) {
- @Override
- public void postVisit(ASTNode node) { // fix some positions
- if( node.getParent() != null ) {
- if( node.getStartPosition() < node.getParent().getStartPosition()) {
- int parentEnd = node.getParent().getStartPosition() + node.getParent().getLength();
- if( node.getStartPosition() >= 0 ) {
- node.getParent().setSourceRange(node.getStartPosition(), parentEnd - node.getStartPosition());
- }
+ rawText = fileObjects.get(i).getCharContent(true).toString();
+ } catch( IOException ioe) {
+ // ignore
+ }
+ CompilationUnit res = result.get(sourceUnits[i]);
+ AST ast = res.getAST();
+ int savedDefaultNodeFlag = JavacEnhancementPackagePrivateUtility.getDefaultNodeFlag(ast);
+ JavacEnhancementPackagePrivateUtility.setDefaultNodeFlag(ast, ASTNode.ORIGINAL);
+ JavacConverter converter = new JavacConverter(ast, javacCompilationUnit, context, rawText);
+ converter.populateCompilationUnit(res, javacCompilationUnit);
+ // javadoc problems explicitly set as they're not sent to DiagnosticListener (maybe find a flag to do it?)
+ var javadocProblems = converter.javadocDiagnostics.stream()
+ .map(problemConverter::createJavacProblem)
+ .filter(Objects::nonNull)
+ .toArray(IProblem[]::new);
+ if (javadocProblems.length > 0) {
+ int initialSize = res.getProblems().length;
+ var newProblems = Arrays.copyOf(res.getProblems(), initialSize + javadocProblems.length);
+ System.arraycopy(javadocProblems, 0, newProblems, initialSize, javadocProblems.length);
+ JavacEnhancementPackagePrivateUtility.setCompilationUnitProblems(res, newProblems);
+ }
+ List javadocComments = new ArrayList<>();
+ res.accept(new ASTVisitor(true) {
+ @Override
+ public void postVisit(ASTNode node) { // fix some positions
+ if( node.getParent() != null ) {
+ if( node.getStartPosition() < node.getParent().getStartPosition()) {
+ int parentEnd = node.getParent().getStartPosition() + node.getParent().getLength();
+ if( node.getStartPosition() >= 0 ) {
+ node.getParent().setSourceRange(node.getStartPosition(), parentEnd - node.getStartPosition());
}
}
}
- @Override
- public boolean visit(Javadoc javadoc) {
- javadocComments.add(javadoc);
- return true;
- }
- });
- addCommentsToUnit(javadocComments, res);
- attachNonDocComments(res, context, rawText, converter, compilerOptions);
- ast.setBindingResolver(new JavacBindingResolver(javaProject, task, context, converter));
- //
- ast.setOriginalModificationCount(ast.modificationCount()); // "un-dirty" AST so Rewrite can process it
- ast.setDefaultNodeFlag(savedDefaultNodeFlag);
- } catch (Throwable thrown) {
- if (cachedThrown == null) {
- cachedThrown = thrown;
}
- ILog.get().error("Internal failure while parsing or converting AST for unit " + new String(sourceUnits[i].getFileName()));
- ILog.get().error(thrown.getMessage(), thrown);
- }
- }
- if (cachedThrown != null) {
- throw new RuntimeException(cachedThrown);
+ @Override
+ public boolean visit(Javadoc javadoc) {
+ javadocComments.add(javadoc);
+ return true;
+ }
+ });
+ addCommentsToUnit(javadocComments, res);
+ attachNonDocComments(res, context, rawText, converter, compilerOptions);
+ JavacEnhancementPackagePrivateUtility.setBindingResolver(ast, new JavacBindingResolver(javaProject, task, context, converter));
+ JavacEnhancementPackagePrivateUtility.setOriginalModificationCount(ast, ast.modificationCount());
+ JavacEnhancementPackagePrivateUtility.setDefaultNodeFlag(ast, savedDefaultNodeFlag);
}
} catch (IOException ex) {
ILog.get().error(ex.getMessage(), ex);
@@ -509,22 +524,23 @@ private Optional findTargetDOM(Map options, int level, Context context, int flags) {
AST ast = AST.newAST(level, JavaCore.ENABLED.equals(options.get(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES)));
- ast.setFlag(flags);
+ JavacEnhancementPackagePrivateUtility.setAstFlag(ast, flags);
String sourceModeSetting = options.get(JavaCore.COMPILER_SOURCE);
long sourceLevel = CompilerOptions.versionToJdkLevel(sourceModeSetting);
if (sourceLevel == 0) {
// unknown sourceModeSetting
sourceLevel = ClassFileConstants.getLatestJDKLevel();
}
- ast.scanner.sourceLevel = sourceLevel;
+ org.eclipse.jdt.internal.compiler.parser.Scanner scanner = JavacEnhancementPackagePrivateUtility.getAstScanner(ast);
+ scanner.sourceLevel = sourceLevel;
String compliance = options.get(JavaCore.COMPILER_COMPLIANCE);
long complianceLevel = CompilerOptions.versionToJdkLevel(compliance);
if (complianceLevel == 0) {
// unknown sourceModeSetting
complianceLevel = sourceLevel;
}
- ast.scanner.complianceLevel = complianceLevel;
- ast.scanner.previewEnabled = JavaCore.ENABLED.equals(options.get(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES));
+ scanner.complianceLevel = complianceLevel;
+ scanner.previewEnabled = JavaCore.ENABLED.equals(options.get(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES));
return ast;
}
@@ -568,7 +584,7 @@ private boolean noCommentAt(int pos) {
do { // consume all tokens to populate comments
javacScanner.nextToken();
} while (javacScanner.token() != null && javacScanner.token().kind != TokenKind.EOF);
- org.eclipse.jdt.internal.compiler.parser.Scanner ecjScanner = new ASTConverter(compilerOptions, false, null).scanner;
+ org.eclipse.jdt.internal.compiler.parser.Scanner ecjScanner = JavacEnhancementPackagePrivateUtility.getScannerForNewASTConverter(compilerOptions, false, null);
ecjScanner.recordLineSeparator = true;
ecjScanner.skipComments = false;
try {
@@ -583,14 +599,14 @@ private boolean noCommentAt(int pos) {
// need to scan with ecjScanner first to populate some line indexes used by the CommentMapper
// on longer-term, implementing an alternative comment mapper based on javac scanner might be best
addCommentsToUnit(nonJavadocComments, unit);
- unit.initCommentMapper(ecjScanner);
+ JavacEnhancementPackagePrivateUtility.initCommentMapper(unit, ecjScanner);
}
private static void addCommentsToUnit(Collection comments, CompilationUnit res) {
List before = res.getCommentList() == null ? new ArrayList<>() : new ArrayList<>(res.getCommentList());
before.addAll(comments);
before.sort(Comparator.comparingInt(Comment::getStartPosition));
- res.setCommentTable(before.toArray(Comment[]::new));
+ JavacEnhancementPackagePrivateUtility.setCompilationUnitCommentTable(res, before.toArray(Comment[]::new));
}
private static class BindingBuilder extends ASTVisitor {
diff --git a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacConverter.java b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacConverter.java
similarity index 92%
rename from org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacConverter.java
rename to org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacConverter.java
index 2c4660b89d6..058c1537364 100644
--- a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacConverter.java
+++ b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacConverter.java
@@ -8,7 +8,7 @@
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
-package org.eclipse.jdt.core.dom;
+package org.eclipse.jdt.internal.javac.dom;
import static com.sun.tools.javac.code.Flags.VARARGS;
import static com.sun.tools.javac.tree.JCTree.Tag.TYPEARRAY;
@@ -31,6 +31,7 @@
import javax.lang.model.type.TypeKind;
import org.eclipse.core.runtime.ILog;
+import org.eclipse.jdt.core.dom.*;
import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword;
import org.eclipse.jdt.core.dom.ModuleModifier.ModuleModifierKeyword;
import org.eclipse.jdt.core.dom.PrefixExpression.Operator;
@@ -126,7 +127,7 @@
* @implNote Cannot move to another package as it uses some package protected methods
*/
@SuppressWarnings("unchecked")
-class JavacConverter {
+public class JavacConverter {
private static final String ERROR = "";
private static final String FAKE_IDENTIFIER = new String(RecoveryScanner.FAKE_IDENTIFIER);
@@ -134,8 +135,8 @@ class JavacConverter {
private final JCCompilationUnit javacCompilationUnit;
private final Context context;
final Map domToJavac = new HashMap<>();
- final String rawText;
- final Set javadocDiagnostics = new HashSet<>();
+ public final String rawText;
+ public final Set javadocDiagnostics = new HashSet<>();
public JavacConverter(AST ast, JCCompilationUnit javacCompilationUnit, Context context, String rawText) {
this.ast = ast;
@@ -144,20 +145,20 @@ public JavacConverter(AST ast, JCCompilationUnit javacCompilationUnit, Context c
this.rawText = rawText;
}
- CompilationUnit convertCompilationUnit() {
+ public CompilationUnit convertCompilationUnit() {
return convertCompilationUnit(this.javacCompilationUnit);
}
- CompilationUnit convertCompilationUnit(JCCompilationUnit javacCompilationUnit) {
+ public CompilationUnit convertCompilationUnit(JCCompilationUnit javacCompilationUnit) {
CompilationUnit res = this.ast.newCompilationUnit();
populateCompilationUnit(res, javacCompilationUnit);
return res;
}
- void populateCompilationUnit(CompilationUnit res, JCCompilationUnit javacCompilationUnit) {
+ public void populateCompilationUnit(CompilationUnit res, JCCompilationUnit javacCompilationUnit) {
commonSettings(res, javacCompilationUnit);
res.setSourceRange(0, this.rawText.length());
- res.setLineEndTable(toLineEndPosTable(javacCompilationUnit.getLineMap(), res.getLength()));
+ JavacEnhancementPackagePrivateUtility.setLineEndTable(res, toLineEndPosTable(javacCompilationUnit.getLineMap(), res.getLength()));
if (javacCompilationUnit.getPackage() != null) {
res.setPackage(convert(javacCompilationUnit.getPackage()));
}
@@ -172,7 +173,8 @@ void populateCompilationUnit(CompilationUnit res, JCCompilationUnit javacCompila
res.accept(new FixPositions());
}
- private int[] toLineEndPosTable(LineMap lineMap, int fileLength) {
+
+ private int[] toLineEndPosTable(LineMap lineMap, int fileLength) {
List lineEnds = new ArrayList<>();
int line = 1;
try {
@@ -328,7 +330,7 @@ private ImportDeclaration convert(JCImport javac) {
ImportDeclaration res = this.ast.newImportDeclaration();
commonSettings(res, javac);
if (javac.isStatic()) {
- if( this.ast.apiLevel != AST.JLS2_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) != AST.JLS2) {
res.setStatic(true);
}
}
@@ -364,7 +366,7 @@ void commonSettings(ASTNode res, JCTree javac) {
private Name toName(JCTree expression) {
return toName(expression, this::commonSettings);
}
- Name toName(JCTree expression, BiConsumer extraSettings ) {
+ public Name toName(JCTree expression, BiConsumer extraSettings ) {
if (expression instanceof JCIdent ident) {
Name res = convertName(ident.getName());
extraSettings.accept(res, ident);
@@ -406,13 +408,13 @@ Name toName(JCTree expression, BiConsumer extraSettings ) {
}
private AbstractTypeDeclaration convertClassDecl(JCClassDecl javacClassDecl, ASTNode parent) {
- if( javacClassDecl.getKind() == Kind.ANNOTATION_TYPE && this.ast.apiLevel == AST.JLS2_INTERNAL) {
+ if( javacClassDecl.getKind() == Kind.ANNOTATION_TYPE && JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) == AST.JLS2) {
return null;
}
- if( javacClassDecl.getKind() == Kind.ENUM && this.ast.apiLevel == AST.JLS2_INTERNAL) {
+ if( javacClassDecl.getKind() == Kind.ENUM && JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) == AST.JLS2) {
return null;
}
- if( javacClassDecl.getKind() == Kind.RECORD && this.ast.apiLevel < AST.JLS16_INTERNAL) {
+ if( javacClassDecl.getKind() == Kind.RECORD && JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) < AST.JLS16) {
return null;
}
AbstractTypeDeclaration res = switch (javacClassDecl.getKind()) {
@@ -435,16 +437,16 @@ private AbstractTypeDeclaration convertClassDecl(JCClassDecl javacClassDecl, AST
SimpleName simpName = (SimpleName)convertName(javacClassDecl.getSimpleName());
if( simpName != null )
res.setName(simpName);
- if( this.ast.apiLevel != AST.JLS2_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) != AST.JLS2) {
res.modifiers().addAll(convert(javacClassDecl.mods, res));
} else {
int jls2Flags = getJLS2ModifiersFlags(javacClassDecl.mods);
jls2Flags &= ~Flags.INTERFACE; // remove AccInterface flags, see ASTConverter
- res.internalSetModifiers(jls2Flags);
+ JavacEnhancementPackagePrivateUtility.internalSetModifiers(res, jls2Flags);
}
if (res instanceof TypeDeclaration typeDeclaration) {
if (javacClassDecl.getExtendsClause() != null) {
- if( this.ast.apiLevel != AST.JLS2_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) != AST.JLS2) {
typeDeclaration.setSuperclassType(convertToType(javacClassDecl.getExtendsClause()));
} else {
JCExpression e = javacClassDecl.getExtendsClause();
@@ -455,7 +457,7 @@ private AbstractTypeDeclaration convertClassDecl(JCClassDecl javacClassDecl, AST
}
}
if (javacClassDecl.getImplementsClause() != null) {
- if( this.ast.apiLevel != AST.JLS2_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) != AST.JLS2) {
javacClassDecl.getImplementsClause().stream()
.map(this::convertToType)
.filter(Objects::nonNull)
@@ -473,7 +475,7 @@ private AbstractTypeDeclaration convertClassDecl(JCClassDecl javacClassDecl, AST
}
if( javacClassDecl.getTypeParameters() != null ) {
- if( this.ast.apiLevel != AST.JLS2_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) != AST.JLS2) {
Iterator i = javacClassDecl.getTypeParameters().iterator();
while(i.hasNext()) {
JCTypeParameter next = i.next();
@@ -483,7 +485,7 @@ private AbstractTypeDeclaration convertClassDecl(JCClassDecl javacClassDecl, AST
}
if (javacClassDecl.getPermitsClause() != null) {
- if( this.ast.apiLevel >= AST.JLS17_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) >= AST.JLS17) {
javacClassDecl.getPermitsClause().stream()
.map(this::convertToType)
.filter(Objects::nonNull)
@@ -531,14 +533,14 @@ private AbstractTypeDeclaration convertClassDecl(JCClassDecl javacClassDecl, AST
}
} else if (res instanceof AnnotationTypeDeclaration annotDecl) {
//setModifiers(annotationTypeMemberDeclaration2, annotationTypeMemberDeclaration);
- final SimpleName name = new SimpleName(this.ast);
- name.internalSetIdentifier(new String(annotDecl.typeName.toString()));
+ final SimpleName name = JavacEnhancementPackagePrivateUtility.createSimpleName(this.ast);
+ JavacEnhancementPackagePrivateUtility.internalSetIdentifier(name, new String(annotDecl.getName().toString()));
res.setName(name);
if( javacClassDecl.defs != null ) {
for( Iterator i = javacClassDecl.defs.iterator(); i.hasNext(); ) {
ASTNode converted = convertBodyDeclaration(i.next(), res);
if( converted != null ) {
- res.bodyDeclarations.add(converted);
+ res.bodyDeclarations().add(converted);
}
}
}
@@ -568,7 +570,7 @@ private AbstractTypeDeclaration convertClassDecl(JCClassDecl javacClassDecl, AST
} else {
ASTNode converted = convertBodyDeclaration(node, res);
if( converted != null ) {
- res.bodyDeclarations.add(converted);
+ res.bodyDeclarations().add(converted);
}
}
}
@@ -577,10 +579,10 @@ private AbstractTypeDeclaration convertClassDecl(JCClassDecl javacClassDecl, AST
}
private TypeParameter convert(JCTypeParameter typeParameter) {
- final TypeParameter ret = new TypeParameter(this.ast);
+ final TypeParameter ret = JavacEnhancementPackagePrivateUtility.createTypeParameter(this.ast);
commonSettings(ret, typeParameter);
- final SimpleName simpleName = new SimpleName(this.ast);
- simpleName.internalSetIdentifier(typeParameter.getName().toString());
+ final SimpleName simpleName = JavacEnhancementPackagePrivateUtility.createSimpleName(this.ast);
+ JavacEnhancementPackagePrivateUtility.internalSetIdentifier(simpleName, typeParameter.getName().toString());
int start = typeParameter.pos;
int end = typeParameter.pos + typeParameter.getName().length();
simpleName.setSourceRange(start, end - start);
@@ -593,7 +595,7 @@ private TypeParameter convert(JCTypeParameter typeParameter) {
ret.typeBounds().add(type);
end = typeParameter.getEndPosition(this.javacCompilationUnit.endPositions);
}
- if (typeParameter.getAnnotations() != null && this.ast.apiLevel() >= AST.JLS8) {
+ if (typeParameter.getAnnotations() != null && JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) >= AST.JLS8) {
typeParameter.getAnnotations().stream()
.map(this::convert)
.forEach(ret.modifiers()::add);
@@ -647,11 +649,11 @@ private ASTNode convertBodyDeclaration(JCTree tree, ASTNode parent) {
if (tree instanceof JCBlock block) {
Initializer res = this.ast.newInitializer();
commonSettings(res, tree);
- if( this.ast.apiLevel != AST.JLS2_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) != AST.JLS2) {
// Now we have the tough task of going from a flags number to actual modifiers with source ranges
res.modifiers().addAll(convertModifiersFromFlags(block.getStartPosition(), block.endpos, block.flags));
} else {
- res.internalSetModifiers(getJLS2ModifiersFlags(block.flags));
+ JavacEnhancementPackagePrivateUtility.internalSetModifiers(res, getJLS2ModifiersFlags(block.flags));
}
res.setBody(convertBlock(block));
return res;
@@ -665,8 +667,9 @@ private ASTNode convertBodyDeclaration(JCTree tree, ASTNode parent) {
return substitute;
}
+
private ASTNode convertMethodInAnnotationTypeDecl(JCMethodDecl javac, ASTNode parent) {
- AnnotationTypeMemberDeclaration res = new AnnotationTypeMemberDeclaration(this.ast);
+ AnnotationTypeMemberDeclaration res = JavacEnhancementPackagePrivateUtility.createAnnotationTypeMemberDeclaration(this.ast);
commonSettings(res, javac);
res.modifiers().addAll(convert(javac.getModifiers(), res));
res.setType(convertToType(javac.getReturnType()));
@@ -719,10 +722,10 @@ private String getMethodDeclName(JCMethodDecl javac, ASTNode parent, boolean rec
private MethodDeclaration convertMethodDecl(JCMethodDecl javac, ASTNode parent) {
MethodDeclaration res = this.ast.newMethodDeclaration();
commonSettings(res, javac);
- if( this.ast.apiLevel != AST.JLS2_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) != AST.JLS2) {
res.modifiers().addAll(convert(javac.getModifiers(), res));
} else {
- res.internalSetModifiers(getJLS2ModifiersFlags(javac.mods));
+ JavacEnhancementPackagePrivateUtility.internalSetModifiers(res, getJLS2ModifiersFlags(javac.mods));
}
String javacName = javac.getName().toString();
@@ -738,7 +741,7 @@ private MethodDeclaration convertMethodDecl(JCMethodDecl javac, ASTNode parent)
String postName = this.rawText.substring(javac.pos + methodDeclName.length()).trim();
String firstChar = postName != null && postName.length() > 0 ? postName.substring(0,1) : null;
isCompactConstructor = ("{".equals(firstChar));
- if( this.ast.apiLevel >= AST.JLS16_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) >= AST.JLS16) {
res.setCompactConstructor(isCompactConstructor);
}
}
@@ -767,7 +770,7 @@ private MethodDeclaration convertMethodDecl(JCMethodDecl javac, ASTNode parent)
}
if( retTypeTree == null ) {
- if( isConstructor && this.ast.apiLevel == AST.JLS2_INTERNAL ) {
+ if( isConstructor && JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) == AST.JLS2 ) {
retType = this.ast.newPrimitiveType(convert(TypeKind.VOID));
// // TODO need to find the right range
retType.setSourceRange(javac.mods.pos + getJLS2ModifiersFlagsAsStringLength(javac.mods.flags), 0);
@@ -779,7 +782,7 @@ private MethodDeclaration convertMethodDecl(JCMethodDecl javac, ASTNode parent)
// The array dimensions are part of the variable name
if (jcatt.getType() != null) {
int dims = countDimensionsAfterPosition(jcatt, javac.pos);
- if( this.ast.apiLevel < AST.JLS8_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) < AST.JLS8) {
res.setExtraDimensions(dims);
} else {
// TODO might be buggy
@@ -797,10 +800,10 @@ private MethodDeclaration convertMethodDecl(JCMethodDecl javac, ASTNode parent)
}
if( retType != null || isConstructor) {
- if( this.ast.apiLevel != AST.JLS2_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) != AST.JLS2) {
res.setReturnType2(retType);
} else {
- res.internalSetReturnType(retType);
+ JavacEnhancementPackagePrivateUtility.internalSetReturnType(res, retType);
}
}
@@ -827,7 +830,7 @@ private MethodDeclaration convertMethodDecl(JCMethodDecl javac, ASTNode parent)
Iterator i = javac.getTypeParameters().iterator();
while(i.hasNext()) {
JCTypeParameter next = i.next();
- if( this.ast.apiLevel != AST.JLS2_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) != AST.JLS2) {
res.typeParameters().add(convert(next));
} else {
// TODO
@@ -842,8 +845,8 @@ private MethodDeclaration convertMethodDecl(JCMethodDecl javac, ASTNode parent)
boolean isInterface = td instanceof TypeDeclaration td1 && td1.isInterface();
long modFlags = javac.getModifiers() == null ? 0 : javac.getModifiers().flags;
boolean isAbstractOrNative = (modFlags & (Flags.ABSTRACT | Flags.NATIVE)) != 0;
- boolean isJlsBelow8 = this.ast.apiLevel < AST.JLS8_INTERNAL;
- boolean isJlsAbove8 = this.ast.apiLevel > AST.JLS8_INTERNAL;
+ boolean isJlsBelow8 = JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) < AST.JLS8;
+ boolean isJlsAbove8 = JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) > AST.JLS8;
long flagsToCheckForAboveJLS8 = Flags.STATIC | Flags.DEFAULT | (isJlsAbove8 ? Flags.PRIVATE : 0);
boolean notAllowed = (isAbstractOrNative || (isInterface && (isJlsBelow8 || (modFlags & flagsToCheckForAboveJLS8) == 0)));
if (notAllowed) {
@@ -862,7 +865,7 @@ private MethodDeclaration convertMethodDecl(JCMethodDecl javac, ASTNode parent)
}
for (JCExpression thrown : javac.getThrows()) {
- if (this.ast.apiLevel < AST.JLS8_INTERNAL) {
+ if (JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) < AST.JLS8) {
res.thrownExceptions().add(toName(thrown));
} else {
Type type = convertToType(thrown);
@@ -905,16 +908,16 @@ private VariableDeclaration convertVariableDeclaration(JCVariableDecl javac) {
}
res.setName(simpleName);
}
- if( this.ast.apiLevel != AST.JLS2_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) != AST.JLS2) {
res.modifiers().addAll(convert(javac.getModifiers(), res));
} else {
- res.internalSetModifiers(getJLS2ModifiersFlags(javac.mods));
+ JavacEnhancementPackagePrivateUtility.internalSetModifiers(res, getJLS2ModifiersFlags(javac.mods));
}
if( javac.getType() instanceof JCArrayTypeTree jcatt && javac.vartype.pos > javac.pos ) {
// The array dimensions are part of the variable name
if (jcatt.getType() != null) {
int dims = countDimensionsAfterPosition(jcatt, javac.vartype.pos);
- if( this.ast.apiLevel < AST.JLS8_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) < AST.JLS8) {
res.setExtraDimensions(dims);
} else {
// TODO might be buggy
@@ -941,7 +944,7 @@ private VariableDeclaration convertVariableDeclaration(JCVariableDecl javac) {
if(type instanceof JCArrayTypeTree arr) {
res.setType(convertToType(arr.elemtype));
}
- if( this.ast.apiLevel > AST.JLS2_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) > AST.JLS2) {
res.setVarargs(true);
}
} else {
@@ -988,7 +991,7 @@ private VariableDeclarationFragment createVariableDeclarationFragment(JCVariable
// The array dimensions are part of the variable name
if (jcatt.getType() != null) {
int dims = countDimensionsAfterPosition(jcatt, fragmentStart);
- if( this.ast.apiLevel < AST.JLS8_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) < AST.JLS8) {
fragment.setExtraDimensions(dims);
} else {
// TODO might be buggy
@@ -1030,10 +1033,10 @@ private FieldDeclaration convertFieldDeclaration(JCVariableDecl javac, ASTNode p
} else {
FieldDeclaration res = this.ast.newFieldDeclaration(fragment);
commonSettings(res, javac);
- if( this.ast.apiLevel != AST.JLS2_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) != AST.JLS2) {
res.modifiers().addAll(convert(javac.getModifiers(), res));
} else {
- res.internalSetModifiers(getJLS2ModifiersFlags(javac.mods));
+ JavacEnhancementPackagePrivateUtility.internalSetModifiers(res, getJLS2ModifiersFlags(javac.mods));
}
int count = fragment.getExtraDimensions();
@@ -1080,7 +1083,7 @@ private void setJavadocForNode(JCTree javac, ASTNode node) {
moduleDeclaration.setJavadoc(javadoc);
moduleDeclaration.setSourceRange(javadoc.getStartPosition(), moduleDeclaration.getStartPosition() + moduleDeclaration.getLength() - javadoc.getStartPosition());
} else if (node instanceof PackageDeclaration packageDeclaration) {
- if( this.ast.apiLevel != AST.JLS2_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) != AST.JLS2) {
packageDeclaration.setJavadoc(javadoc);
}
packageDeclaration.setSourceRange(javadoc.getStartPosition(), packageDeclaration.getStartPosition() + packageDeclaration.getLength() - javadoc.getStartPosition());
@@ -1189,7 +1192,7 @@ private Expression convertExpressionImpl(JCExpression javac) {
SuperMethodInvocation res2 = this.ast.newSuperMethodInvocation();
commonSettings(res2, javac);
methodInvocation.getArguments().stream().map(this::convertExpression).forEach(res2.arguments()::add);
- if( this.ast.apiLevel != AST.JLS2_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) != AST.JLS2) {
methodInvocation.getTypeArguments().stream()
.map(this::convertToType)
.filter(Objects::nonNull)
@@ -1220,7 +1223,7 @@ private Expression convertExpressionImpl(JCExpression javac) {
SuperMethodInvocation res2 = this.ast.newSuperMethodInvocation();
commonSettings(res2, javac);
methodInvocation.getArguments().stream().map(this::convertExpression).forEach(res.arguments()::add);
- if( this.ast.apiLevel != AST.JLS2_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) != AST.JLS2) {
methodInvocation.getTypeArguments().stream()
.map(this::convertToType)
.filter(Objects::nonNull)
@@ -1243,7 +1246,7 @@ private Expression convertExpressionImpl(JCExpression javac) {
.forEach(res.arguments()::add);
}
if (methodInvocation.getTypeArguments() != null) {
- if( this.ast.apiLevel != AST.JLS2_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) != AST.JLS2) {
methodInvocation.getTypeArguments().stream()
.map(this::convertToType)
.filter(Objects::nonNull)
@@ -1255,7 +1258,7 @@ private Expression convertExpressionImpl(JCExpression javac) {
if (javac instanceof JCNewClass newClass) {
ClassInstanceCreation res = this.ast.newClassInstanceCreation();
commonSettings(res, javac);
- if( this.ast.apiLevel != AST.JLS2_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) != AST.JLS2) {
res.setType(convertToType(newClass.getIdentifier()));
} else {
Name n = toName(newClass.clazz);
@@ -1274,7 +1277,7 @@ private Expression convertExpressionImpl(JCExpression javac) {
if (newClass.encl != null) {
res.setExpression(convertExpression(newClass.encl));
}
- if( newClass.getTypeArguments() != null && this.ast.apiLevel != AST.JLS2_INTERNAL) {
+ if( newClass.getTypeArguments() != null && JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) != AST.JLS2) {
Iterator it = newClass.getTypeArguments().iterator();
while(it.hasNext()) {
Type e = convertToType(it.next());
@@ -1499,7 +1502,7 @@ private Expression convertExpressionImpl(JCExpression javac) {
ArrayType arrayType;
if (type instanceof ArrayType childArrayType) {
arrayType = childArrayType;
- if( this.ast.apiLevel >= AST.JLS8_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) >= AST.JLS8) {
arrayType.dimensions().addFirst(this.ast.newDimension());
} else {
arrayType = this.ast.newArrayType(childArrayType);
@@ -1508,7 +1511,7 @@ private Expression convertExpressionImpl(JCExpression javac) {
arrayType = this.ast.newArrayType(type);
int dims = jcNewArray.dims.size();
for( int i = 0; i < dims - 1; i++ ) {
- if( this.ast.apiLevel >= AST.JLS8_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) >= AST.JLS8) {
arrayType.dimensions().addFirst(this.ast.newDimension());
} else {
arrayType = this.ast.newArrayType(arrayType);
@@ -1701,7 +1704,7 @@ private SuperMethodInvocation convertSuperMethodInvocation(JCMethodInvocation ja
javac.getArguments().stream().map(this::convertExpression).forEach(res.arguments()::add);
//res.setFlags(javac.getFlags() | ASTNode.MALFORMED);
- if( this.ast.apiLevel > AST.JLS2_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) > AST.JLS2) {
javac.getTypeArguments().stream().map(this::convertToType).forEach(res.typeArguments()::add);
}
return res;
@@ -1718,7 +1721,7 @@ private SuperConstructorInvocation convertSuperConstructorInvocation(JCMethodInv
javac.getArguments().stream().map(this::convertExpression).forEach(res.arguments()::add);
//res.setFlags(javac.getFlags() | ASTNode.MALFORMED);
- if( this.ast.apiLevel > AST.JLS2_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) > AST.JLS2) {
javac.getTypeArguments().stream()
.map(this::convertToType)
.filter(Objects::nonNull)
@@ -1735,7 +1738,7 @@ private ConstructorInvocation convertThisConstructorInvocation(JCMethodInvocatio
ConstructorInvocation res = this.ast.newConstructorInvocation();
commonSettings(res, javac);
javac.getArguments().stream().map(this::convertExpression).forEach(res.arguments()::add);
- if( this.ast.apiLevel > AST.JLS2_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) > AST.JLS2) {
javac.getTypeArguments().stream()
.map(this::convertToType)
.filter(Objects::nonNull)
@@ -1775,7 +1778,7 @@ private Expression convertLiteral(JCLiteral literal) {
TextBlock res = this.ast.newTextBlock();
commonSettings(res, literal);
String rawValue = this.rawText.substring(literal.pos, literal.getEndPosition(this.javacCompilationUnit.endPositions));
- res.internalSetEscapedValue(rawValue, string);
+ JavacEnhancementPackagePrivateUtility.internalSetEscapedValue(res, rawValue, string);
return res;
} else {
StringLiteral res = this.ast.newStringLiteral();
@@ -1893,9 +1896,9 @@ private Statement convertStatement(JCStatement javac, ASTNode parent) {
if (jcVariableDecl.vartype != null) {
if( jcVariableDecl.vartype instanceof JCArrayTypeTree jcatt) {
int extraDims = 0;
- if( fragment.extraArrayDimensions > 0 ) {
- extraDims = fragment.extraArrayDimensions;
- } else if( this.ast.apiLevel > AST.JLS4_INTERNAL && fragment.extraDimensions() != null && fragment.extraDimensions().size() > 0 ) {
+ if( JavacEnhancementPackagePrivateUtility.getExtraArrayDimensions(fragment) > 0 ) {
+ extraDims = JavacEnhancementPackagePrivateUtility.getExtraArrayDimensions(fragment);
+ } else if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) > AST.JLS4 && fragment.extraDimensions() != null && fragment.extraDimensions().size() > 0 ) {
extraDims = fragment.extraDimensions().size();
}
res.setType(convertToType(unwrapDimensions(jcatt, extraDims)));
@@ -1907,13 +1910,13 @@ private Statement convertStatement(JCStatement javac, ASTNode parent) {
st.setSourceRange(javac.getStartPosition(), 3);
res.setType(st);
}
- if( this.ast.apiLevel > AST.JLS2_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) > AST.JLS2) {
res.modifiers().addAll(convert(jcVariableDecl.getModifiers(), res));
} else {
JCModifiers mods = jcVariableDecl.getModifiers();
int[] total = new int[] {0};
mods.getFlags().forEach(x -> {total[0] += modifierToFlagVal(x);});
- res.internalSetModifiers(total[0]);
+ JavacEnhancementPackagePrivateUtility.internalSetModifiers(res, total[0]);
}
return res;
}
@@ -1967,7 +1970,7 @@ private Statement convertStatement(JCStatement javac, ASTNode parent) {
return res;
}
if (javac instanceof JCEnhancedForLoop jcEnhancedForLoop) {
- if( this.ast.apiLevel != AST.JLS2_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) != AST.JLS2) {
EnhancedForStatement res = this.ast.newEnhancedForStatement();
commonSettings(res, javac);
res.setParameter((SingleVariableDeclaration)convertVariableDeclaration(jcEnhancedForLoop.getVariable()));
@@ -2017,7 +2020,7 @@ private Statement convertStatement(JCStatement javac, ASTNode parent) {
if (javac instanceof JCCase jcCase) {
SwitchCase res = this.ast.newSwitchCase();
commonSettings(res, javac);
- if( this.ast.apiLevel >= AST.JLS14_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) >= AST.JLS14) {
if (jcCase.getGuard() != null && (jcCase.getLabels().size() > 1 || jcCase.getLabels().get(0) instanceof JCPatternCaseLabel)) {
GuardedPattern guardedPattern = this.ast.newGuardedPattern();
guardedPattern.setExpression(convertExpression(jcCase.getGuard()));
@@ -2144,6 +2147,7 @@ private Statement convertStatement(JCStatement javac, ASTNode parent) {
throw new UnsupportedOperationException("Missing support to convert " + javac + "of type " + javac.getClass().getName());
}
+
private Expression convertStatementToExpression(JCStatement javac, ASTNode parent) {
if (javac instanceof JCExpressionStatement jcExpressionStatement) {
return convertExpression(jcExpressionStatement.getExpression());
@@ -2158,9 +2162,9 @@ private Expression convertStatementToExpression(JCStatement javac, ASTNode paren
if (javac instanceof JCVariableDecl jcvd && jcvd.vartype != null) {
if( jcvd.vartype instanceof JCArrayTypeTree jcatt) {
int extraDims = 0;
- if( fragment.extraArrayDimensions > 0 ) {
- extraDims = fragment.extraArrayDimensions;
- } else if( this.ast.apiLevel > AST.JLS4_INTERNAL && fragment.extraDimensions() != null && fragment.extraDimensions().size() > 0 ) {
+ if( JavacEnhancementPackagePrivateUtility.getExtraArrayDimensions(fragment) > 0 ) {
+ extraDims = JavacEnhancementPackagePrivateUtility.getExtraArrayDimensions(fragment);
+ } else if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) > AST.JLS4 && fragment.extraDimensions() != null && fragment.extraDimensions().size() > 0 ) {
extraDims = fragment.extraDimensions().size();
}
jdtVariableDeclarationExpression.setType(convertToType(unwrapDimensions(jcatt, extraDims)));
@@ -2203,7 +2207,7 @@ private TryStatement convertTryStatement(JCTry javac, ASTNode parent) {
res.setFinally(convertBlock(javac.getFinallyBlock()));
}
- if( this.ast.apiLevel >= AST.JLS4_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) >= AST.JLS4) {
Iterator it = javac.getResources().iterator();
while(it.hasNext()) {
ASTNode working = convertTryResource(it.next(), parent);
@@ -2231,7 +2235,7 @@ private TryStatement convertTryStatement(JCTry javac, ASTNode parent) {
fragment = this.ast.newVariableDeclarationFragment();
commonSettings(fragment, javac);
fragment.setFlags(single.getFlags());
- SimpleName name = (SimpleName)single.getName().clone(this.ast);
+ SimpleName name = JavacEnhancementPackagePrivateUtility.cloneSimpleName(single.getName(), this.ast);
fragment.setName(name);
Expression initializer = single.getInitializer();
if (initializer != null) {
@@ -2248,13 +2252,13 @@ private TryStatement convertTryStatement(JCTry javac, ASTNode parent) {
VariableDeclarationExpression res = this.ast.newVariableDeclarationExpression(fragment);
commonSettings(res, javac);
res.setType(convertToType(decl.getType()));
- if( this.ast.apiLevel > AST.JLS2_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) > AST.JLS2) {
res.modifiers().addAll(convert(decl.getModifiers(), res));
} else {
JCModifiers mods = decl.getModifiers();
int[] total = new int[] {0};
mods.getFlags().forEach(x -> {total[0] += modifierToFlagVal(x);});
- res.internalSetModifiers(total[0]);
+ JavacEnhancementPackagePrivateUtility.internalSetModifiers(res, total[0]);
}
return res;
}
@@ -2296,7 +2300,7 @@ private IfStatement convertIfStatement(JCIf javac) {
return res;
}
- Type convertToType(JCTree javac) {
+ public Type convertToType(JCTree javac) {
if (javac instanceof JCIdent ident) {
SimpleType res = this.ast.newSimpleType(convertName(ident.name));
commonSettings(res, ident);
@@ -2318,7 +2322,7 @@ Type convertToType(JCTree javac) {
if(qualifierType instanceof SimpleType simpleType && (ast.apiLevel() < AST.JLS8 || simpleType.annotations().isEmpty())) {
simpleType.delete();
Name parentName = simpleType.getName();
- parentName.setParent(null, null);
+ JavacEnhancementPackagePrivateUtility.setParentName(parentName, null, null);
QualifiedName name = this.ast.newQualifiedName(simpleType.getName(), (SimpleName)convertName(qualified.getIdentifier()));
SimpleType res = this.ast.newSimpleType(name);
commonSettings(res, javac);
@@ -2349,7 +2353,7 @@ Type convertToType(JCTree javac) {
return null;
}
ArrayType res;
- if (t instanceof ArrayType childArrayType && this.ast.apiLevel > AST.JLS4_INTERNAL) {
+ if (t instanceof ArrayType childArrayType && JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) > AST.JLS4) {
res = childArrayType;
res.dimensions().addFirst(this.ast.newDimension());
} else {
@@ -2359,7 +2363,7 @@ Type convertToType(JCTree javac) {
return res;
}
if (javac instanceof JCTypeApply jcTypeApply) {
- if( this.ast.apiLevel != AST.JLS2_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) != AST.JLS2) {
ParameterizedType res = this.ast.newParameterizedType(convertToType(jcTypeApply.getType()));
commonSettings(res, javac);
jcTypeApply.getTypeArguments().stream()
@@ -2397,17 +2401,17 @@ Type convertToType(JCTree javac) {
JCExpression jcpe = jcAnnotatedType.getUnderlyingType();
if( jcAnnotatedType.getAnnotations() != null //
&& !jcAnnotatedType.getAnnotations().isEmpty() //
- && this.ast.apiLevel >= AST.JLS8_INTERNAL
+ && JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) >= AST.JLS8
&& !(jcpe instanceof JCWildcard)) {
if( jcpe instanceof JCFieldAccess jcfa2) {
if( jcfa2.selected instanceof JCAnnotatedType || jcfa2.selected instanceof JCTypeApply) {
- QualifiedType nameQualifiedType = new QualifiedType(this.ast);
+ QualifiedType nameQualifiedType = JavacEnhancementPackagePrivateUtility.createQualifiedType(this.ast);
commonSettings(nameQualifiedType, javac);
nameQualifiedType.setQualifier(convertToType(jcfa2.selected));
nameQualifiedType.setName(this.ast.newSimpleName(jcfa2.name.toString()));
res = nameQualifiedType;
} else {
- NameQualifiedType nameQualifiedType = new NameQualifiedType(this.ast);
+ NameQualifiedType nameQualifiedType = JavacEnhancementPackagePrivateUtility.createNameQualifiedType(this.ast);
commonSettings(nameQualifiedType, javac);
nameQualifiedType.setQualifier(toName(jcfa2.selected));
nameQualifiedType.setName(this.ast.newSimpleName(jcfa2.name.toString()));
@@ -2420,12 +2424,12 @@ Type convertToType(JCTree javac) {
} else {
res = convertToType(jcAnnotatedType.getUnderlyingType());
}
- if (res instanceof AnnotatableType annotatableType && this.ast.apiLevel() >= AST.JLS8) {
+ if (res instanceof AnnotatableType annotatableType && JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) >= AST.JLS8) {
for (JCAnnotation annotation : jcAnnotatedType.getAnnotations()) {
annotatableType.annotations().add(convert(annotation));
}
} else if (res instanceof ArrayType arrayType) {
- if (this.ast.apiLevel() >= AST.JLS8 && !arrayType.dimensions().isEmpty()) {
+ if (JavacEnhancementPackagePrivateUtility.getApiLevel(this.ast) >= AST.JLS8 && !arrayType.dimensions().isEmpty()) {
for (JCAnnotation annotation : jcAnnotatedType.getAnnotations()) {
((Dimension)arrayType.dimensions().get(0)).annotations().add(convert(annotation));
}
@@ -2489,10 +2493,10 @@ private Annotation convert(JCAnnotation javac) {
JCExpression expr = it.next();
if( expr instanceof JCAssign jcass) {
if( jcass.lhs instanceof JCIdent jcid ) {
- final MemberValuePair pair = new MemberValuePair(this.ast);
- final SimpleName simpleName = new SimpleName(this.ast);
+ final MemberValuePair pair = JavacEnhancementPackagePrivateUtility.createMemberValuePair(this.ast);
+ final SimpleName simpleName = JavacEnhancementPackagePrivateUtility.createSimpleName(this.ast);
commonSettings(simpleName, jcid);
- simpleName.internalSetIdentifier(new String(jcid.getName().toString()));
+ JavacEnhancementPackagePrivateUtility.internalSetIdentifier(simpleName, new String(jcid.getName().toString()));
int start = jcid.pos;
int end = start + jcid.getName().toString().length();
simpleName.setSourceRange(start, end - start );
@@ -2518,6 +2522,7 @@ private Annotation convert(JCAnnotation javac) {
return res;
}
}
+
//
// public Annotation addAnnotation(IAnnotationBinding annotation, AST ast, ImportRewriteContext context) {
// Type type = addImport(annotation.getAnnotationType(), ast, context, TypeLocation.OTHER);
@@ -2846,11 +2851,11 @@ private EnumConstantDeclaration convertEnumConstantDeclaration(JCTree var, ASTNo
String o = jcid.getName().toString();
String o2 = enumDecl.getName().toString();
if( o.equals(o2)) {
- enumConstantDeclaration = new EnumConstantDeclaration(this.ast);
+ enumConstantDeclaration = JavacEnhancementPackagePrivateUtility.createEnumConstantDeclaration(this.ast);
commonSettings(enumConstantDeclaration, enumConstant);
- final SimpleName typeName = new SimpleName(this.ast);
+ final SimpleName typeName = JavacEnhancementPackagePrivateUtility.createSimpleName(this.ast);
enumName = enumConstant.getName().toString();
- typeName.internalSetIdentifier(enumName);
+ JavacEnhancementPackagePrivateUtility.internalSetIdentifier(typeName, enumName);
typeName.setSourceRange(enumConstant.getStartPosition(), Math.max(0, enumName.length()));
enumConstantDeclaration.setName(typeName);
}
@@ -2912,5 +2917,6 @@ private static List childrenOf(ASTNode node) {
.toList();
}
+
}
diff --git a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacMemberValuePairBinding.java b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacMemberValuePairBinding.java
index 563bd6f1c17..17f9ba41ece 100644
--- a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacMemberValuePairBinding.java
+++ b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacMemberValuePairBinding.java
@@ -17,7 +17,6 @@
import org.eclipse.jdt.core.dom.IBinding;
import org.eclipse.jdt.core.dom.IMemberValuePairBinding;
import org.eclipse.jdt.core.dom.IMethodBinding;
-import org.eclipse.jdt.core.dom.JavacBindingResolver;
import com.sun.tools.javac.code.Attribute;
import com.sun.tools.javac.code.Symbol.MethodSymbol;
diff --git a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacMethodBinding.java b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacMethodBinding.java
index 2e401c72177..cf28cbb5a7f 100644
--- a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacMethodBinding.java
+++ b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacMethodBinding.java
@@ -26,7 +26,6 @@
import org.eclipse.jdt.core.dom.IMethodBinding;
import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.core.dom.IVariableBinding;
-import org.eclipse.jdt.core.dom.JavacBindingResolver;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.Modifier;
import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
diff --git a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacModuleBinding.java b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacModuleBinding.java
index 773373862a8..818358304d7 100644
--- a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacModuleBinding.java
+++ b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacModuleBinding.java
@@ -21,7 +21,6 @@
import org.eclipse.jdt.core.dom.IModuleBinding;
import org.eclipse.jdt.core.dom.IPackageBinding;
import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.JavacBindingResolver;
import com.sun.tools.javac.code.Attribute;
import com.sun.tools.javac.code.Directive.ExportsDirective;
diff --git a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacPackageBinding.java b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacPackageBinding.java
index 140790fbfc0..5327befbd94 100644
--- a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacPackageBinding.java
+++ b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacPackageBinding.java
@@ -20,7 +20,6 @@
import org.eclipse.jdt.core.dom.IBinding;
import org.eclipse.jdt.core.dom.IModuleBinding;
import org.eclipse.jdt.core.dom.IPackageBinding;
-import org.eclipse.jdt.core.dom.JavacBindingResolver;
import com.sun.tools.javac.code.Symbol.PackageSymbol;
diff --git a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacTypeBinding.java b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacTypeBinding.java
index f73211dfd33..3ddd58d7787 100644
--- a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacTypeBinding.java
+++ b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacTypeBinding.java
@@ -32,7 +32,6 @@
import org.eclipse.jdt.core.dom.IPackageBinding;
import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.core.dom.IVariableBinding;
-import org.eclipse.jdt.core.dom.JavacBindingResolver;
import org.eclipse.jdt.core.dom.Modifier;
import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.codegen.ConstantPool;
diff --git a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacVariableBinding.java b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacVariableBinding.java
index f5864b6a933..12b6de3d537 100644
--- a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacVariableBinding.java
+++ b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacVariableBinding.java
@@ -23,7 +23,6 @@
import org.eclipse.jdt.core.dom.IMethodBinding;
import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.core.dom.IVariableBinding;
-import org.eclipse.jdt.core.dom.JavacBindingResolver;
import org.eclipse.jdt.core.dom.Modifier;
import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
import org.eclipse.jdt.core.dom.VariableDeclarationExpression;
diff --git a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavadocConverter.java b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavadocConverter.java
similarity index 91%
rename from org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavadocConverter.java
rename to org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavadocConverter.java
index 8841ac048fd..da4c804f122 100644
--- a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavadocConverter.java
+++ b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavadocConverter.java
@@ -8,7 +8,7 @@
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
-package org.eclipse.jdt.core.dom;
+package org.eclipse.jdt.internal.javac.dom;
import java.lang.reflect.Field;
import java.util.HashSet;
@@ -18,13 +18,28 @@
import java.util.stream.Stream;
import org.eclipse.core.runtime.ILog;
+import org.eclipse.jdt.core.dom.AST;
+import org.eclipse.jdt.core.dom.ASTNode;
+import org.eclipse.jdt.core.dom.ASTVisitor;
+import org.eclipse.jdt.core.dom.IDocElement;
+import org.eclipse.jdt.core.dom.JavaDocTextElement;
+import org.eclipse.jdt.core.dom.Javadoc;
+import org.eclipse.jdt.core.dom.MemberRef;
+import org.eclipse.jdt.core.dom.MethodRef;
+import org.eclipse.jdt.core.dom.MethodRefParameter;
+import org.eclipse.jdt.core.dom.Name;
+import org.eclipse.jdt.core.dom.JavacEnhancementPackagePrivateUtility;
+import org.eclipse.jdt.core.dom.QualifiedName;
+import org.eclipse.jdt.core.dom.SimpleName;
+import org.eclipse.jdt.core.dom.TagElement;
+import org.eclipse.jdt.core.dom.TextElement;
import com.sun.tools.javac.parser.UnicodeReader;
import com.sun.tools.javac.tree.DCTree;
import com.sun.tools.javac.tree.DCTree.DCAuthor;
import com.sun.tools.javac.tree.DCTree.DCBlockTag;
-import com.sun.tools.javac.tree.DCTree.DCDeprecated;
import com.sun.tools.javac.tree.DCTree.DCComment;
+import com.sun.tools.javac.tree.DCTree.DCDeprecated;
import com.sun.tools.javac.tree.DCTree.DCDocComment;
import com.sun.tools.javac.tree.DCTree.DCEndElement;
import com.sun.tools.javac.tree.DCTree.DCEntity;
@@ -50,7 +65,7 @@
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.util.JCDiagnostic;
-class JavadocConverter {
+public class JavadocConverter {
private final AST ast;
private final JavacConverter javacConverter;
@@ -71,7 +86,7 @@ class JavadocConverter {
}
}
- JavadocConverter(JavacConverter javacConverter, DCDocComment docComment) {
+ public JavadocConverter(JavacConverter javacConverter, DCDocComment docComment) {
this.javacConverter = javacConverter;
this.ast = javacConverter.ast;
this.docComment = docComment;
@@ -103,10 +118,10 @@ private void commonSettings(ASTNode res, DCTree javac) {
//this.domToJavac.put(res, javac);
}
- Javadoc convertJavadoc() {
+ public Javadoc convertJavadoc() {
Javadoc res = this.ast.newJavadoc();
res.setSourceRange(this.initialOffset, this.endOffset - this.initialOffset);
- if( this.javacConverter.ast.apiLevel == AST.JLS2_INTERNAL) {
+ if( JavacEnhancementPackagePrivateUtility.getApiLevel(this.javacConverter.ast) == AST.JLS2) {
String rawContent = this.javacConverter.rawText.substring(this.initialOffset, this.endOffset);
res.setComment(rawContent);
}
@@ -139,8 +154,7 @@ Javadoc convertJavadoc() {
}
return res;
}
-
- Set getDiagnostics() {
+ public Set getDiagnostics() {
return diagnostics;
}
@@ -163,37 +177,37 @@ private Optional convertBlockTag(DCTree javac) {
commonSettings(res, javac);
if (javac instanceof DCAuthor author) {
res.setTagName(TagElement.TAG_AUTHOR);
- author.name.stream().map(this::convertElement).forEach(res.fragments::add);
+ author.name.stream().map(this::convertElement).forEach(res.fragments()::add);
} else if (javac instanceof DCSince since) {
res.setTagName(TagElement.TAG_SINCE);
- since.body.stream().map(this::convertElement).forEach(res.fragments::add);
+ since.body.stream().map(this::convertElement).forEach(res.fragments()::add);
} else if (javac instanceof DCVersion version) {
res.setTagName(TagElement.TAG_VERSION);
- version.body.stream().map(this::convertElement).forEach(res.fragments::add);
+ version.body.stream().map(this::convertElement).forEach(res.fragments()::add);
} else if (javac instanceof DCSee see) {
res.setTagName(TagElement.TAG_SEE);
- see.reference.stream().map(this::convertElement).forEach(res.fragments::add);
+ see.reference.stream().map(this::convertElement).forEach(res.fragments()::add);
} else if (javac instanceof DCDeprecated deprecated) {
res.setTagName(TagElement.TAG_DEPRECATED);
- deprecated.body.stream().map(this::convertElement).forEach(res.fragments::add);
+ deprecated.body.stream().map(this::convertElement).forEach(res.fragments()::add);
} else if (javac instanceof DCParam param) {
res.setTagName(TagElement.TAG_PARAM);
res.fragments().add(convertElement(param.name));
- param.description.stream().map(this::convertElement).forEach(res.fragments::add);
+ param.description.stream().map(this::convertElement).forEach(res.fragments()::add);
} else if (javac instanceof DCReturn ret) {
res.setTagName(TagElement.TAG_RETURN);
- ret.description.stream().map(this::convertElement).forEach(res.fragments::add);
+ ret.description.stream().map(this::convertElement).forEach(res.fragments()::add);
} else if (javac instanceof DCThrows thrown) {
res.setTagName(TagElement.TAG_THROWS);
res.fragments().add(convertElement(thrown.name));
- thrown.description.stream().map(this::convertElement).forEach(res.fragments::add);
+ thrown.description.stream().map(this::convertElement).forEach(res.fragments()::add);
} else if (javac instanceof DCUses uses) {
res.setTagName(TagElement.TAG_USES);
res.fragments().add(convertElement(uses.serviceType));
- uses.description.stream().map(this::convertElement).forEach(res.fragments::add);
+ uses.description.stream().map(this::convertElement).forEach(res.fragments()::add);
} else if (javac instanceof DCUnknownBlockTag unknown) {
res.setTagName(unknown.getTagName());
- unknown.content.stream().map(this::convertElement).forEach(res.fragments::add);
+ unknown.content.stream().map(this::convertElement).forEach(res.fragments()::add);
} else {
return Optional.empty();
}
@@ -321,13 +335,13 @@ private IDocElement convertElement(DCTree javac) {
} else if (javac instanceof DCErroneous erroneous) {
JavaDocTextElement res = this.ast.newJavaDocTextElement();
commonSettings(res, erroneous);
- res.setText(res.text);
+ res.setText(res.getText());
diagnostics.add(erroneous.diag);
return res;
} else if (javac instanceof DCComment comment) {
TextElement res = this.ast.newTextElement();
commonSettings(res, comment);
- res.setText(res.text);
+ res.setText(res.getText());
return res;
} else {
Optional inlineTag = convertInlineTag(javac);
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/JavacEnhancementPackagePrivateUtility.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/JavacEnhancementPackagePrivateUtility.java
new file mode 100644
index 00000000000..f1c95b59a6f
--- /dev/null
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/JavacEnhancementPackagePrivateUtility.java
@@ -0,0 +1,160 @@
+/*******************************************************************************
+ * Copyright (c) 2024, Red Hat, Inc. and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************/
+package org.eclipse.jdt.core.dom;
+
+import java.util.Map;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.core.compiler.IProblem;
+import org.eclipse.jdt.internal.compiler.parser.Scanner;
+
+/**
+ * This class is an addition made in the incubator repository with the intention of
+ * exposing some package-private details to an interested extender, without having to make
+ * changes to more files.
+ *
+ * This should not be committed to JDT master.
+ *
+ * @since 3.38
+ */
+public class JavacEnhancementPackagePrivateUtility {
+ public static BindingResolver getBindingResolver(CompilationUnit cu) {
+ return cu.getAST().getBindingResolver();
+ }
+ public static void setBindingResolver(AST ast, BindingResolver resolver) {
+ ast.setBindingResolver(resolver);
+ }
+ public static class InternalNameEnvironmentWithProgress extends NameEnvironmentWithProgress {
+ public InternalNameEnvironmentWithProgress(Classpath[] paths, String[] initialFileNames,
+ IProgressMonitor monitor) {
+ super(paths, initialFileNames, monitor);
+ }
+ }
+
+ public static int getDefaultNodeFlag(AST ast) {
+ return ast.getDefaultNodeFlag();
+ }
+
+ public static void setDefaultNodeFlag(AST ast, int val) {
+ ast.setDefaultNodeFlag(val);
+ }
+
+ public static void setOriginalModificationCount(AST ast, long count) {
+ ast.setOriginalModificationCount(count);
+ }
+
+ public static void setAstFlag(AST ast, int flag) {
+ ast.setFlag(flag);
+ }
+
+ public static Scanner getAstScanner(AST ast) {
+ return ast.scanner;
+ }
+
+ public static ASTConverter createASTConverter(Map options, boolean resolveBindings, IProgressMonitor monitor) {
+ return new ASTConverter(options, resolveBindings, monitor);
+ }
+ public static org.eclipse.jdt.internal.compiler.parser.Scanner getScannerForNewASTConverter(Map options, boolean resolveBindings, IProgressMonitor monitor) {
+ return createASTConverter(options, resolveBindings, monitor).scanner;
+ }
+
+ public static void setCompilationUnitCommentTable(CompilationUnit cu, Comment[] commentTable) {
+ cu.setCommentTable(commentTable);
+ }
+
+ public static void initCommentMapper(CompilationUnit cu, Scanner scanner) {
+ cu.initCommentMapper(scanner);
+ }
+
+ public static void setCompilationUnitProblems(CompilationUnit cu, IProblem[] problems) {
+ cu.setProblems(problems);
+ }
+
+ public static ITypeBinding createTypeBinding(BindingResolver resolver, org.eclipse.jdt.internal.compiler.lookup.TypeBinding binding) {
+ return new TypeBinding(resolver, binding);
+ }
+
+ public static int getApiLevel(AST ast) {
+ return ast.apiLevel;
+ }
+
+
+ public static void internalSetModifiers(VariableDeclarationStatement res, int jls2Flags) {
+ res.internalSetModifiers(jls2Flags);
+ }
+
+ public static void internalSetModifiers(BodyDeclaration res, int jls2Flags) {
+ res.internalSetModifiers(jls2Flags);
+ }
+
+ public static void internalSetModifiers(SingleVariableDeclaration res, int jls2ModifiersFlags) {
+ res.internalSetModifiers(jls2ModifiersFlags);
+ }
+ public static void setLineEndTable(CompilationUnit res, int[] lineEndPosTable) {
+ res.setLineEndTable(lineEndPosTable);
+ }
+
+ public static void internalSetIdentifier(SimpleName name, String string) {
+ name.internalSetIdentifier(string);
+ }
+
+ public static void internalSetReturnType(MethodDeclaration res, Type retType) {
+ res.internalSetReturnType(retType);
+ }
+ public static void internalSetEscapedValue(TextBlock res, String rawValue, String string) {
+ res.internalSetEscapedValue(rawValue, string);
+ }
+ public static void internalSetModifiers(VariableDeclarationExpression res, int jls2Flags) {
+ res.internalSetModifiers(jls2Flags);
+ }
+
+ public static int getExtraArrayDimensions(VariableDeclarationFragment fragment) {
+ return fragment.extraArrayDimensions;
+ }
+ public static void setParentName(Name parentName, ASTNode parent, StructuralPropertyDescriptor property) {
+ parentName.setParent(parent, property);
+ }
+
+
+
+ public static SimpleName cloneSimpleName(SimpleName name, AST ast2) {
+ return (SimpleName)name.clone(ast2);
+ }
+
+ public static SimpleName createSimpleName(AST ast2) {
+ return new SimpleName(ast2);
+ }
+
+ public static TypeParameter createTypeParameter(AST ast2) {
+ return new TypeParameter(ast2);
+ }
+
+ public static AnnotationTypeMemberDeclaration createAnnotationTypeMemberDeclaration(AST ast2) {
+ return new AnnotationTypeMemberDeclaration(ast2);
+ }
+
+ public static NameQualifiedType createNameQualifiedType(AST ast2) {
+ return new NameQualifiedType(ast2);
+ }
+
+ public static QualifiedType createQualifiedType(AST ast2) {
+ return new QualifiedType(ast2);
+ }
+ public static MemberValuePair createMemberValuePair(AST ast2) {
+ return new MemberValuePair(ast2);
+ }
+
+ public static EnumConstantDeclaration createEnumConstantDeclaration(AST ast2) {
+ return new EnumConstantDeclaration(ast2);
+ }
+
+
+}