)method.thrownExceptionTypes()).stream()
+ .map(Type::resolveBinding)
+ .toArray(ITypeBinding[]::new);
+ }
+ return new ITypeBinding[0];
+ }
+
+ @Override
+ public ITypeBinding[] getTypeParameters() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'getTypeParameters'");
+ }
+
+ @Override
+ public boolean isAnnotationMember() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'isAnnotationMember'");
+ }
+
+ @Override
+ public boolean isGenericMethod() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'isGenericMethod'");
+ }
+
+ @Override
+ public boolean isParameterizedMethod() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'isParameterizedMethod'");
+ }
+
+ @Override
+ public ITypeBinding[] getTypeArguments() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'getTypeArguments'");
+ }
+
+ @Override
+ public IMethodBinding getMethodDeclaration() {
+ return this;
+ }
+
+ @Override
+ public boolean isRawMethod() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'isRawMethod'");
+ }
+
+ @Override
+ public boolean isSubsignature(IMethodBinding otherMethod) {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'isSubsignature'");
+ }
+
+ @Override
+ public boolean isVarargs() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'isVarargs'");
+ }
+
+ @Override
+ public boolean overrides(IMethodBinding method) {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'overrides'");
+ }
+
+ @Override
+ public IVariableBinding[] getSyntheticOuterLocals() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'getSyntheticOuterLocals'");
+ }
+
+ @Override
+ public boolean isSyntheticRecordMethod() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'isSyntheticRecordMethod'");
+ }
+
+ @Override
+ public String[] getParameterNames() {
+ if (this.methodSymbol.getParameters() == null) {
+ return new String[0];
+ }
+ return this.methodSymbol.getParameters().stream() //
+ .map(VarSymbol::getSimpleName) //
+ .map(Object::toString) //
+ .toArray(String[]::new);
+ }
+
+}
diff --git a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacPackageBinding.java b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacPackageBinding.java
new file mode 100644
index 00000000000..69ae3fec22e
--- /dev/null
+++ b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacPackageBinding.java
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2023, 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.Arrays;
+import java.util.Objects;
+
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.JavaModelException;
+
+import com.sun.tools.javac.code.Symbol.PackageSymbol;
+
+class JavacPackageBinding implements IPackageBinding {
+
+ final PackageSymbol packageSymbol;
+ final JavacBindingResolver resolver;
+
+ JavacPackageBinding(PackageSymbol packge, JavacBindingResolver resolver) {
+ this.packageSymbol = packge;
+ this.resolver = resolver;
+ }
+
+ @Override
+ public IAnnotationBinding[] getAnnotations() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'getAnnotations'");
+ }
+
+ @Override
+ public int getKind() {
+ return PACKAGE;
+ }
+
+ @Override
+ public int getModifiers() {
+ return JavacMethodBinding.toInt(this.packageSymbol.getModifiers());
+ }
+
+ @Override
+ public boolean isDeprecated() {
+ return this.packageSymbol.isDeprecated();
+ }
+
+ @Override
+ public boolean isRecovered() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'isRecovered'");
+ }
+
+ @Override
+ public boolean isSynthetic() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'isSynthetic'");
+ }
+
+ @Override
+ public IJavaElement getJavaElement() {
+ System.err.println("Hardocded binding->IJavaElement to 1st package");
+ try {
+ return Arrays.stream(this.resolver.javaProject.getAllPackageFragmentRoots())
+ .map(root -> root.getPackageFragment(this.packageSymbol.getQualifiedName().toString()))
+ .filter(Objects::nonNull)
+ .filter(IPackageFragment::exists)
+ .findFirst()
+ .orElse(null);
+ } catch (JavaModelException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ @Override
+ public String getKey() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'getKey'");
+ }
+
+ @Override
+ public boolean isEqualTo(IBinding binding) {
+ return binding instanceof JavacPackageBinding other && //
+ Objects.equals(this.packageSymbol, other.packageSymbol) && //
+ Objects.equals(this.resolver, other.resolver);
+ }
+
+ @Override
+ public String getName() {
+ return isUnnamed() ? "" : this.packageSymbol.getQualifiedName().toString(); //$NON-NLS-1$
+ }
+
+ @Override
+ public boolean isUnnamed() {
+ return this.packageSymbol.isUnnamed();
+ }
+
+ @Override
+ public String[] getNameComponents() {
+ return isUnnamed()? new String[0] : this.packageSymbol.getQualifiedName().toString().split("."); //$NON-NLS-1$
+ }
+
+}
diff --git a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacTypeBinding.java b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacTypeBinding.java
new file mode 100644
index 00000000000..2479b0387e1
--- /dev/null
+++ b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacTypeBinding.java
@@ -0,0 +1,437 @@
+/*******************************************************************************
+ * Copyright (c) 2023, 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.Objects;
+import java.util.stream.StreamSupport;
+
+import org.eclipse.core.runtime.ILog;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+
+import com.sun.tools.javac.code.Flags;
+import com.sun.tools.javac.code.Symbol;
+import com.sun.tools.javac.code.Symbol.ClassSymbol;
+import com.sun.tools.javac.code.Symbol.MethodSymbol;
+import com.sun.tools.javac.code.Symbol.TypeSymbol;
+import com.sun.tools.javac.code.Symbol.VarSymbol;
+import com.sun.tools.javac.code.Type;
+import com.sun.tools.javac.code.Type.ArrayType;
+import com.sun.tools.javac.code.Types;
+
+class JavacTypeBinding implements ITypeBinding {
+
+ final JavacBindingResolver resolver;
+ final TypeSymbol typeSymbol;
+ private final Types types;
+
+ public JavacTypeBinding(final TypeSymbol classSymbol, final JavacBindingResolver resolver) {
+ this.typeSymbol = classSymbol;
+ this.resolver = resolver;
+ this.types = this.resolver.context.get(Types.class);
+ }
+
+ JavacTypeBinding(final Type type, final JavacBindingResolver resolver) {
+ this(type.tsym, resolver);
+ }
+
+ @Override
+ public IAnnotationBinding[] getAnnotations() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'getAnnotations'");
+ }
+
+ @Override
+ public int getKind() {
+ return TYPE;
+ }
+
+ @Override
+ public boolean isDeprecated() {
+ return this.typeSymbol.isDeprecated();
+ }
+
+ @Override
+ public boolean isRecovered() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'isRecovered'");
+ }
+
+ @Override
+ public boolean isSynthetic() {
+ return (this.typeSymbol.flags() & Flags.SYNTHETIC) != 0;
+ }
+
+ @Override
+ public IType getJavaElement() {
+ if (this.typeSymbol instanceof final ClassSymbol classSymbol) {
+ try {
+ return this.resolver.javaProject.findType(classSymbol.className());
+ } catch (JavaModelException ex) {
+ ILog.get().error(ex.getMessage(), ex);
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public String getKey() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'getKey'");
+ }
+
+ @Override
+ public boolean isEqualTo(final IBinding binding) {
+ return binding instanceof final JavacTypeBinding other && //
+ Objects.equals(this.resolver, other.resolver) && //
+ Objects.equals(this.typeSymbol, other.typeSymbol);
+ }
+
+ @Override
+ public ITypeBinding createArrayType(final int dimension) {
+ Type type = this.typeSymbol.type;
+ for (int i = 0; i < dimension; i++) {
+ type = this.types.makeArrayType(type);
+ }
+ return new JavacTypeBinding(type, this.resolver);
+ }
+
+ @Override
+ public String getBinaryName() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'getBinaryName'");
+ }
+
+ @Override
+ public ITypeBinding getBound() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'getBound'");
+ }
+
+ @Override
+ public ITypeBinding getGenericTypeOfWildcardType() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'getGenericTypeOfWildcardType'");
+ }
+
+ @Override
+ public int getRank() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'getRank'");
+ }
+
+ @Override
+ public ITypeBinding getComponentType() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'getComponentType'");
+ }
+
+ @Override
+ public IVariableBinding[] getDeclaredFields() {
+ return StreamSupport.stream(this.typeSymbol.members().getSymbols().spliterator(), false)
+ .filter(VarSymbol.class::isInstance)
+ .map(VarSymbol.class::cast)
+ .map(sym -> new JavacVariableBinding(sym, this.resolver))
+ .toArray(IVariableBinding[]::new);
+ }
+
+ @Override
+ public IMethodBinding[] getDeclaredMethods() {
+ return StreamSupport.stream(this.typeSymbol.members().getSymbols().spliterator(), false)
+ .filter(MethodSymbol.class::isInstance)
+ .map(MethodSymbol.class::cast)
+ .map(sym -> new JavacMethodBinding(sym, this.resolver))
+ .toArray(IMethodBinding[]::new);
+ }
+
+ @Override
+ public int getDeclaredModifiers() {
+ return this.resolver.findNode(this.typeSymbol) instanceof TypeDeclaration typeDecl ?
+ typeDecl.getModifiers() :
+ 0;
+ }
+
+ @Override
+ public ITypeBinding[] getDeclaredTypes() {
+ return StreamSupport.stream(this.typeSymbol.members().getSymbols().spliterator(), false)
+ .filter(TypeSymbol.class::isInstance)
+ .map(TypeSymbol.class::cast)
+ .map(sym -> new JavacTypeBinding(sym, this.resolver))
+ .toArray(ITypeBinding[]::new);
+ }
+
+ @Override
+ public ITypeBinding getDeclaringClass() {
+ Symbol parentSymbol = this.typeSymbol.owner;
+ do {
+ if (parentSymbol instanceof final ClassSymbol clazz) {
+ return new JavacTypeBinding(clazz, this.resolver);
+ }
+ parentSymbol = parentSymbol.owner;
+ } while (parentSymbol != null);
+ return null;
+ }
+
+ @Override
+ public IMethodBinding getDeclaringMethod() {
+ Symbol parentSymbol = this.typeSymbol.owner;
+ do {
+ if (parentSymbol instanceof final MethodSymbol method) {
+ return new JavacMethodBinding(method, this.resolver);
+ }
+ parentSymbol = parentSymbol.owner;
+ } while (parentSymbol != null);
+ return null;
+ }
+
+ @Override
+ public IBinding getDeclaringMember() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'getDeclaringMember'");
+ }
+
+ @Override
+ public int getDimensions() {
+ return this.types.dimensions(this.typeSymbol.type);
+ }
+
+ @Override
+ public ITypeBinding getElementType() {
+ return new JavacTypeBinding(this.types.elemtype(this.typeSymbol.type), this.resolver);
+ }
+
+ @Override
+ public ITypeBinding getErasure() {
+ return new JavacTypeBinding(this.types.erasure(this.typeSymbol.type), this.resolver);
+ }
+
+ @Override
+ public IMethodBinding getFunctionalInterfaceMethod() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'getFunctionalInterfaceMethod'");
+ }
+
+ @Override
+ public ITypeBinding[] getInterfaces() {
+ return this.typeSymbol instanceof final ClassSymbol classSymbol && classSymbol.getInterfaces() != null ?
+ classSymbol.getInterfaces().map(t -> new JavacTypeBinding(t, this.resolver)).toArray(ITypeBinding[]::new) :
+ null;
+ }
+
+ @Override
+ public int getModifiers() {
+ return JavacMethodBinding.toInt(this.typeSymbol.getModifiers());
+ }
+
+ @Override
+ public String getName() {
+ return this.typeSymbol.getSimpleName().toString();
+ }
+
+ @Override
+ public IPackageBinding getPackage() {
+ return this.typeSymbol.packge() != null ?
+ new JavacPackageBinding(this.typeSymbol.packge(), this.resolver) :
+ null;
+ }
+
+ @Override
+ public String getQualifiedName() {
+ return this.typeSymbol.getQualifiedName().toString();
+ }
+
+ @Override
+ public ITypeBinding getSuperclass() {
+ if (this.typeSymbol instanceof final ClassSymbol classSymbol && classSymbol.getSuperclass() != null && classSymbol.getSuperclass().tsym != null) {
+ return new JavacTypeBinding(classSymbol.getSuperclass().tsym, this.resolver);
+ }
+ return null;
+ }
+
+ @Override
+ public IAnnotationBinding[] getTypeAnnotations() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'getTypeAnnotations'");
+ }
+
+ @Override
+ public ITypeBinding[] getTypeArguments() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'getTypeBounds'");
+ }
+
+ @Override
+ public ITypeBinding[] getTypeBounds() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'getTypeBounds'");
+ }
+
+ @Override
+ public ITypeBinding getTypeDeclaration() {
+ return this;
+ }
+
+ @Override
+ public ITypeBinding[] getTypeParameters() {
+ return this.typeSymbol.getTypeParameters().stream()
+ .map(symbol -> new JavacTypeBinding(symbol, this.resolver))
+ .toArray(ITypeBinding[]::new);
+ }
+
+ @Override
+ public ITypeBinding getWildcard() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'getWildcard'");
+ }
+
+ @Override
+ public boolean isAnnotation() {
+ return this.typeSymbol.isAnnotationType();
+ }
+
+ @Override
+ public boolean isAnonymous() {
+ return this.typeSymbol.isAnonymous();
+ }
+
+ @Override
+ public boolean isArray() {
+ return this.typeSymbol.type instanceof ArrayType;
+ }
+
+ @Override
+ public boolean isAssignmentCompatible(final ITypeBinding variableType) {
+ if (variableType instanceof JavacTypeBinding other) {
+ return this.types.isAssignable(other.typeSymbol.type, this.typeSymbol.type);
+ }
+ throw new UnsupportedOperationException("Cannot mix with non Javac binding"); //$NON-NLS-1$
+ }
+
+ @Override
+ public boolean isCapture() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'isCapture'");
+ }
+
+ @Override
+ public boolean isCastCompatible(final ITypeBinding type) {
+ if (type instanceof JavacTypeBinding other) {
+ return this.types.isCastable(this.typeSymbol.type, other.typeSymbol.type);
+ }
+ throw new UnsupportedOperationException("Cannot mix with non Javac binding"); //$NON-NLS-1$
+ }
+
+ @Override
+ public boolean isClass() {
+ return this.typeSymbol instanceof final ClassSymbol classSymbol && !(
+ classSymbol.isEnum() || classSymbol.isRecord());
+ }
+
+ @Override
+ public boolean isEnum() {
+ return this.typeSymbol.isEnum();
+ }
+
+ @Override
+ public boolean isRecord() {
+ return this.typeSymbol instanceof final ClassSymbol classSymbol && classSymbol.isRecord();
+ }
+
+ @Override
+ public boolean isFromSource() {
+ return this.resolver.findDeclaringNode(this) != null;
+ }
+
+ @Override
+ public boolean isGenericType() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'isGenericType'");
+ }
+
+ @Override
+ public boolean isInterface() {
+ return this.typeSymbol.isInterface();
+ }
+
+ @Override
+ public boolean isIntersectionType() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'isIntersectionType'");
+ }
+
+ @Override
+ public boolean isLocal() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'isLocal'");
+ }
+
+ @Override
+ public boolean isMember() {
+ return this.typeSymbol.owner instanceof TypeSymbol;
+ }
+
+ @Override
+ public boolean isNested() {
+ return getDeclaringClass() != null;
+ }
+
+ @Override
+ public boolean isNullType() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'isNullType'");
+ }
+
+ @Override
+ public boolean isParameterizedType() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'isParameterizedType'");
+ }
+
+ @Override
+ public boolean isPrimitive() {
+ return this.typeSymbol.type.isPrimitive();
+ }
+
+ @Override
+ public boolean isRawType() {
+ return this.typeSymbol.type.isRaw();
+ }
+
+ @Override
+ public boolean isSubTypeCompatible(final ITypeBinding type) {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'isSubTypeCompatible'");
+ }
+
+ @Override
+ public boolean isTopLevel() {
+ return getDeclaringClass() == null;
+ }
+
+ @Override
+ public boolean isTypeVariable() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'isTypeVariable'");
+ }
+
+ @Override
+ public boolean isUpperbound() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'isUpperbound'");
+ }
+
+ @Override
+ public boolean isWildcardType() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'isWildcardType'");
+ }
+
+}
diff --git a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacVariableBinding.java b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacVariableBinding.java
new file mode 100644
index 00000000000..de93fc1f7f7
--- /dev/null
+++ b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacVariableBinding.java
@@ -0,0 +1,158 @@
+/*******************************************************************************
+ * Copyright (c) 2023, 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.Objects;
+
+import org.eclipse.jdt.core.IField;
+
+import com.sun.tools.javac.code.Flags;
+import com.sun.tools.javac.code.Symbol;
+import com.sun.tools.javac.code.Symbol.ClassSymbol;
+import com.sun.tools.javac.code.Symbol.MethodSymbol;
+import com.sun.tools.javac.code.Symbol.TypeSymbol;
+import com.sun.tools.javac.code.Symbol.VarSymbol;
+
+class JavacVariableBinding implements IVariableBinding {
+
+ private VarSymbol variableSymbol;
+ private JavacBindingResolver resolver;
+
+ public JavacVariableBinding(VarSymbol sym, JavacBindingResolver resolver) {
+ this.variableSymbol = sym;
+ this.resolver = resolver;
+ }
+
+ @Override
+ public IAnnotationBinding[] getAnnotations() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'getAnnotations'");
+ }
+
+ @Override
+ public int getKind() {
+ return VARIABLE;
+ }
+
+ @Override
+ public int getModifiers() {
+ return JavacMethodBinding.toInt(this.variableSymbol.getModifiers());
+ }
+
+ @Override
+ public boolean isDeprecated() {
+ return this.variableSymbol.isDeprecated();
+ }
+
+ @Override
+ public boolean isRecovered() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'isRecovered'");
+ }
+
+ @Override
+ public boolean isSynthetic() {
+ return (this.variableSymbol.flags() & Flags.SYNTHETIC) != 0;
+ }
+
+ @Override
+ public IField getJavaElement() {
+ if (this.variableSymbol.owner instanceof TypeSymbol parentType) {//field
+ return new JavacTypeBinding(parentType, this.resolver).getJavaElement().getField(this.variableSymbol.name.toString());
+ }
+ return null;
+ }
+
+ @Override
+ public String getKey() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'getKey'");
+ }
+
+ @Override
+ public boolean isEqualTo(IBinding binding) {
+ return binding instanceof JavacVariableBinding other && //
+ Objects.equals(this.variableSymbol, other.variableSymbol) && //
+ Objects.equals(this.resolver, other.resolver);
+ }
+
+ @Override
+ public boolean isField() {
+ return this.variableSymbol.owner instanceof ClassSymbol;
+ }
+
+ @Override
+ public boolean isEnumConstant() {
+ return this.variableSymbol.isEnum();
+ }
+
+ @Override
+ public boolean isParameter() {
+ return this.variableSymbol.owner instanceof MethodSymbol;
+ }
+
+ @Override
+ public String getName() {
+ return this.variableSymbol.getSimpleName().toString();
+ }
+
+ @Override
+ public ITypeBinding getDeclaringClass() {
+ Symbol parentSymbol = this.variableSymbol.owner;
+ do {
+ if (parentSymbol instanceof ClassSymbol clazz) {
+ return new JavacTypeBinding(clazz, this.resolver);
+ }
+ parentSymbol = parentSymbol.owner;
+ } while (parentSymbol != null);
+ return null;
+ }
+
+ @Override
+ public ITypeBinding getType() {
+ return new JavacTypeBinding(this.variableSymbol.type, this.resolver);
+ }
+
+ @Override
+ public int getVariableId() {
+ return variableSymbol.adr; // ?
+ }
+
+ @Override
+ public Object getConstantValue() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'getConstantValue'");
+ }
+
+ @Override
+ public IMethodBinding getDeclaringMethod() {
+ Symbol parentSymbol = this.variableSymbol.owner;
+ do {
+ if (parentSymbol instanceof MethodSymbol method) {
+ return new JavacMethodBinding(method, this.resolver);
+ }
+ parentSymbol = parentSymbol.owner;
+ } while (parentSymbol != null);
+ return null;
+ }
+
+ @Override
+ public IVariableBinding getVariableDeclaration() {
+ return this;
+ }
+
+ @Override
+ public boolean isEffectivelyFinal() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'isEffectivelyFinal'");
+ }
+
+}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTParser.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTParser.java
index a582c04cb1d..c5da0918764 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTParser.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTParser.java
@@ -33,7 +33,6 @@
import org.eclipse.jdt.core.WorkingCopyOwner;
import org.eclipse.jdt.core.compiler.CategorizedProblem;
import org.eclipse.jdt.core.compiler.CharOperation;
-import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
import org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall;
import org.eclipse.jdt.internal.compiler.batch.FileSystem.Classpath;
@@ -221,6 +220,8 @@ public static ASTParser newParser(int level) {
*/
private int bits;
+ private final ICompilationUnitResolver unitResolver;
+
/**
* Creates a new AST parser for the given API level.
*
@@ -233,6 +234,7 @@ public static ASTParser newParser(int level) {
ASTParser(int level) {
DOMASTUtil.checkASTLevel(level);
this.apiLevel = level;
+ this.unitResolver = ICompilationUnitResolver.getInstance();
initializeDefaults();
}
@@ -245,17 +247,23 @@ private List getClasspath() throws IllegalStateException {
}
if (this.sourcepaths != null) {
for (int i = 0, max = this.sourcepaths.length; i < max; i++) {
- String encoding = this.sourcepathsEncodings == null ? null : this.sourcepathsEncodings[i];
- main.processPathEntries(
- Main.DEFAULT_SIZE_CLASSPATH,
- allClasspaths, this.sourcepaths[i], encoding, true, false);
+ String sourcePath = this.sourcepaths[i];
+ if (sourcePath != null) {
+ String encoding = this.sourcepathsEncodings == null ? null : this.sourcepathsEncodings[i];
+ main.processPathEntries(
+ Main.DEFAULT_SIZE_CLASSPATH,
+ allClasspaths, sourcePath, encoding, true, false);
+ }
}
}
if (this.classpaths != null) {
for (int i = 0, max = this.classpaths.length; i < max; i++) {
- main.processPathEntries(
- Main.DEFAULT_SIZE_CLASSPATH,
- allClasspaths, this.classpaths[i], null, false, false);
+ String classpath = this.classpaths[i];
+ if (classpath != null) {
+ main.processPathEntries(
+ Main.DEFAULT_SIZE_CLASSPATH,
+ allClasspaths, classpath, null, false, false);
+ }
}
}
ArrayList pendingErrors = main.pendingErrors;
@@ -951,9 +959,9 @@ public void createASTs(ICompilationUnit[] compilationUnits, String[] bindingKeys
if ((this.bits & CompilationUnitResolver.BINDING_RECOVERY) != 0) {
flags |= ICompilationUnit.ENABLE_BINDINGS_RECOVERY;
}
- CompilationUnitResolver.resolve(compilationUnits, bindingKeys, requestor, this.apiLevel, this.compilerOptions, this.project, this.workingCopyOwner, flags, monitor);
+ this.unitResolver.resolve(compilationUnits, bindingKeys, requestor, this.apiLevel, this.compilerOptions, this.project, this.workingCopyOwner, flags, monitor);
} else {
- CompilationUnitResolver.parse(compilationUnits, requestor, this.apiLevel, this.compilerOptions, flags, monitor);
+ this.unitResolver.parse(compilationUnits, requestor, this.apiLevel, this.compilerOptions, flags, monitor);
}
} finally {
// reset to defaults to allow reuse (and avoid leaking)
@@ -1046,9 +1054,9 @@ public void createASTs(String[] sourceFilePaths, String[] encodings, String[] bi
if ((this.bits & CompilationUnitResolver.BINDING_RECOVERY) != 0) {
flags |= ICompilationUnit.ENABLE_BINDINGS_RECOVERY;
}
- CompilationUnitResolver.resolve(sourceFilePaths, encodings, bindingKeys, requestor, this.apiLevel, this.compilerOptions, getClasspath(), flags, monitor);
+ this.unitResolver.resolve(sourceFilePaths, encodings, bindingKeys, requestor, this.apiLevel, this.compilerOptions, getClasspath(), flags, monitor);
} else {
- CompilationUnitResolver.parse(sourceFilePaths, encodings, requestor, this.apiLevel, this.compilerOptions, flags, monitor);
+ this.unitResolver.parse(sourceFilePaths, encodings, requestor, this.apiLevel, this.compilerOptions, flags, monitor);
}
} finally {
// reset to defaults to allow reuse (and avoid leaking)
@@ -1109,7 +1117,7 @@ public IBinding[] createBindings(IJavaElement[] elements, IProgressMonitor monit
if ((this.bits & CompilationUnitResolver.IGNORE_METHOD_BODIES) != 0) {
flags |= ICompilationUnit.IGNORE_METHOD_BODIES;
}
- return CompilationUnitResolver.resolve(elements, this.apiLevel, this.compilerOptions, this.project, this.workingCopyOwner, flags, monitor);
+ return this.unitResolver.resolve(elements, this.apiLevel, this.compilerOptions, this.project, this.workingCopyOwner, flags, monitor);
} finally {
// reset to defaults to allow reuse (and avoid leaking)
initializeDefaults();
@@ -1120,11 +1128,8 @@ private ASTNode internalCreateAST(IProgressMonitor monitor) {
return JavaModelManager.cacheZipFiles(() -> internalCreateASTCached(monitor));
}
private ASTNode internalCreateASTCached(IProgressMonitor monitor) {
- boolean needToResolveBindings = (this.bits & CompilationUnitResolver.RESOLVE_BINDING) != 0;
- switch(this.astKind) {
- case K_CLASS_BODY_DECLARATIONS :
- case K_EXPRESSION :
- case K_STATEMENTS :
+ return switch(this.astKind) {
+ case K_CLASS_BODY_DECLARATIONS, K_EXPRESSION, K_STATEMENTS -> {
if (this.rawSource == null) {
if (this.typeRoot != null) {
// get the source from the type root
@@ -1149,145 +1154,101 @@ private ASTNode internalCreateASTCached(IProgressMonitor monitor) {
if (this.sourceOffset + this.sourceLength > this.rawSource.length) {
throw new IllegalStateException();
}
- return internalCreateASTForKind();
+ yield internalCreateASTForKind();
}
- break;
- case K_COMPILATION_UNIT :
- CompilationUnitDeclaration compilationUnitDeclaration = null;
- try {
- NodeSearcher searcher = null;
- org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit = null;
- WorkingCopyOwner wcOwner = this.workingCopyOwner;
- if (this.typeRoot instanceof ClassFileWorkingCopy) {
- // special case: class file mimics as compilation unit, but that would use a wrong file name below, so better unwrap now:
- this.typeRoot = ((ClassFileWorkingCopy) this.typeRoot).classFile;
- }
- if (this.typeRoot instanceof ICompilationUnit) {
- /*
- * this.compilationUnitSource is an instance of org.eclipse.jdt.internal.core.CompilationUnit that implements
- * both org.eclipse.jdt.core.ICompilationUnit and org.eclipse.jdt.internal.compiler.env.ICompilationUnit
- */
- sourceUnit = (org.eclipse.jdt.internal.compiler.env.ICompilationUnit) this.typeRoot;
- /*
- * use a BasicCompilation that caches the source instead of using the compilationUnitSource directly
- * (if it is a working copy, the source can change between the parse and the AST convertion)
- * (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=75632)
- */
- sourceUnit = new BasicCompilationUnit(sourceUnit.getContents(), sourceUnit.getPackageName(), new String(sourceUnit.getFileName()), this.project);
- wcOwner = ((ICompilationUnit) this.typeRoot).getOwner();
- } else if (this.typeRoot instanceof IClassFile) {
- try {
- String sourceString = this.typeRoot.getSource();
- if (sourceString == null) {
- throw new IllegalStateException();
- }
- PackageFragment packageFragment = (PackageFragment) this.typeRoot.getParent();
- BinaryType type = (BinaryType) this.typeRoot.findPrimaryType();
- String fileNameString = null;
- if (type != null) {
- IBinaryType binaryType = type.getElementInfo();
- // file name is used to recreate the Java element, so it has to be the toplevel .class file name
- char[] fileName = binaryType.getFileName();
+ throw new IllegalStateException();
+ }
+ case K_COMPILATION_UNIT -> internalCreateCompilationUnit(monitor);
+ default -> throw new IllegalStateException();
+ };
+ }
- int firstDollar = CharOperation.indexOf('$', fileName);
- if (firstDollar != -1) {
- char[] suffix = SuffixConstants.SUFFIX_class;
- int suffixLength = suffix.length;
- char[] newFileName = new char[firstDollar + suffixLength];
- System.arraycopy(fileName, 0, newFileName, 0, firstDollar);
- System.arraycopy(suffix, 0, newFileName, firstDollar, suffixLength);
- fileName = newFileName;
- }
- fileNameString = new String(fileName);
- } else {
- // assumed to be "module-info.class" (which has no type):
- fileNameString = this.typeRoot.getElementName();
- }
- sourceUnit = new BasicCompilationUnit(sourceString.toCharArray(), Util.toCharArrays(packageFragment.names), fileNameString, this.typeRoot);
- } catch(JavaModelException e) {
- // an error occured accessing the java element
- CharSequence stackTrace = org.eclipse.jdt.internal.compiler.util.Util.getStackTrace(e);
- throw new IllegalStateException(stackTrace.toString());
- }
- } else if (this.rawSource != null) {
- needToResolveBindings =
- ((this.bits & CompilationUnitResolver.RESOLVE_BINDING) != 0)
- && this.unitName != null
- && (this.project != null
- || this.classpaths != null
- || this.sourcepaths != null
- || ((this.bits & CompilationUnitResolver.INCLUDE_RUNNING_VM_BOOTCLASSPATH) != 0))
- && this.compilerOptions != null;
- sourceUnit = new BasicCompilationUnit(this.rawSource, null, this.unitName == null ? "" : this.unitName, this.project); //$NON-NLS-1$
- } else {
- throw new IllegalStateException();
- }
- if ((this.bits & CompilationUnitResolver.PARTIAL) != 0) {
- searcher = new NodeSearcher(this.focalPointPosition);
- }
- int flags = 0;
- if ((this.bits & CompilationUnitResolver.STATEMENT_RECOVERY) != 0) {
- flags |= ICompilationUnit.ENABLE_STATEMENTS_RECOVERY;
- }
- if (searcher == null && ((this.bits & CompilationUnitResolver.IGNORE_METHOD_BODIES) != 0)) {
- flags |= ICompilationUnit.IGNORE_METHOD_BODIES;
- }
- if (needToResolveBindings) {
- if ((this.bits & CompilationUnitResolver.BINDING_RECOVERY) != 0) {
- flags |= ICompilationUnit.ENABLE_BINDINGS_RECOVERY;
- }
- try {
- // parse and resolve
- compilationUnitDeclaration =
- CompilationUnitResolver.resolve(
- sourceUnit,
- this.project,
- getClasspath(),
- searcher,
- this.compilerOptions,
- this.workingCopyOwner,
- flags,
- monitor);
- } catch (JavaModelException e) {
- flags &= ~ICompilationUnit.ENABLE_BINDINGS_RECOVERY;
- compilationUnitDeclaration = CompilationUnitResolver.parse(
- sourceUnit,
- searcher,
- this.compilerOptions,
- flags);
- needToResolveBindings = false;
- }
- } else {
- compilationUnitDeclaration = CompilationUnitResolver.parse(
- sourceUnit,
- searcher,
- this.compilerOptions,
- flags,
- this.project);
- needToResolveBindings = false;
- }
- CompilationUnit result = CompilationUnitResolver.convert(
- compilationUnitDeclaration,
- sourceUnit.getContents(),
- this.apiLevel,
- this.compilerOptions,
- needToResolveBindings,
- wcOwner,
- needToResolveBindings ? new DefaultBindingResolver.BindingTables() : null,
- flags,
- monitor,
- this.project != null,
- this.project);
- result.setTypeRoot(this.typeRoot);
- return result;
- } finally {
- if (compilationUnitDeclaration != null
- && ((this.bits & CompilationUnitResolver.RESOLVE_BINDING) != 0)) {
- compilationUnitDeclaration.cleanUp();
+ private CompilationUnit internalCreateCompilationUnit(IProgressMonitor monitor) {
+ boolean needToResolveBindings = (this.bits & CompilationUnitResolver.RESOLVE_BINDING) != 0;
+ NodeSearcher searcher = null;
+ org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit = null;
+ WorkingCopyOwner wcOwner = this.workingCopyOwner;
+ if (this.typeRoot instanceof ClassFileWorkingCopy) {
+ // special case: class file mimics as compilation unit, but that would use a wrong file name below, so better unwrap now:
+ this.typeRoot = ((ClassFileWorkingCopy) this.typeRoot).classFile;
+ }
+ if (this.typeRoot instanceof ICompilationUnit) {
+ /*
+ * this.compilationUnitSource is an instance of org.eclipse.jdt.internal.core.CompilationUnit that implements
+ * both org.eclipse.jdt.core.ICompilationUnit and org.eclipse.jdt.internal.compiler.env.ICompilationUnit
+ */
+ sourceUnit = (org.eclipse.jdt.internal.compiler.env.ICompilationUnit) this.typeRoot;
+ /*
+ * use a BasicCompilation that caches the source instead of using the compilationUnitSource directly
+ * (if it is a working copy, the source can change between the parse and the AST convertion)
+ * (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=75632)
+ */
+ sourceUnit = new BasicCompilationUnit(sourceUnit.getContents(), sourceUnit.getPackageName(), new String(sourceUnit.getFileName()), this.project);
+ wcOwner = ((ICompilationUnit) this.typeRoot).getOwner();
+ } else if (this.typeRoot instanceof IClassFile) {
+ try {
+ String sourceString = this.typeRoot.getSource();
+ if (sourceString == null) {
+ throw new IllegalStateException();
+ }
+ PackageFragment packageFragment = (PackageFragment) this.typeRoot.getParent();
+ BinaryType type = (BinaryType) this.typeRoot.findPrimaryType();
+ String fileNameString = null;
+ if (type != null) {
+ IBinaryType binaryType = type.getElementInfo();
+ // file name is used to recreate the Java element, so it has to be the toplevel .class file name
+ char[] fileName = binaryType.getFileName();
+
+ int firstDollar = CharOperation.indexOf('$', fileName);
+ if (firstDollar != -1) {
+ char[] suffix = SuffixConstants.SUFFIX_class;
+ int suffixLength = suffix.length;
+ char[] newFileName = new char[firstDollar + suffixLength];
+ System.arraycopy(fileName, 0, newFileName, 0, firstDollar);
+ System.arraycopy(suffix, 0, newFileName, firstDollar, suffixLength);
+ fileName = newFileName;
}
+ fileNameString = new String(fileName);
+ } else {
+ // assumed to be "module-info.class" (which has no type):
+ fileNameString = this.typeRoot.getElementName();
}
+ sourceUnit = new BasicCompilationUnit(sourceString.toCharArray(), Util.toCharArrays(packageFragment.names), fileNameString, this.typeRoot);
+ } catch(JavaModelException e) {
+ // an error occured accessing the java element
+ CharSequence stackTrace = org.eclipse.jdt.internal.compiler.util.Util.getStackTrace(e);
+ throw new IllegalStateException(stackTrace.toString());
+ }
+ } else if (this.rawSource != null) {
+ needToResolveBindings =
+ ((this.bits & CompilationUnitResolver.RESOLVE_BINDING) != 0)
+ && this.unitName != null
+ && (this.project != null
+ || this.classpaths != null
+ || this.sourcepaths != null
+ || ((this.bits & CompilationUnitResolver.INCLUDE_RUNNING_VM_BOOTCLASSPATH) != 0))
+ && this.compilerOptions != null;
+ sourceUnit = new BasicCompilationUnit(this.rawSource, null, this.unitName == null ? "" : this.unitName, this.project); //$NON-NLS-1$
+ } else {
+ throw new IllegalStateException();
}
- throw new IllegalStateException();
+ if ((this.bits & CompilationUnitResolver.PARTIAL) != 0) {
+ searcher = new NodeSearcher(this.focalPointPosition);
+ }
+ int flags = 0;
+ if ((this.bits & CompilationUnitResolver.STATEMENT_RECOVERY) != 0) {
+ flags |= ICompilationUnit.ENABLE_STATEMENTS_RECOVERY;
+ }
+ if (searcher == null && ((this.bits & CompilationUnitResolver.IGNORE_METHOD_BODIES) != 0)) {
+ flags |= ICompilationUnit.IGNORE_METHOD_BODIES;
+ }
+ if (needToResolveBindings && (this.bits & CompilationUnitResolver.BINDING_RECOVERY) != 0) {
+ flags |= ICompilationUnit.ENABLE_BINDINGS_RECOVERY;
+ }
+
+ CompilationUnit result = this.unitResolver.toCompilationUnit(sourceUnit, needToResolveBindings, this.project, getClasspath(), searcher, this.apiLevel, this.compilerOptions, this.workingCopyOwner, wcOwner, flags, monitor);
+ result.setTypeRoot(this.typeRoot);
+ return result;
}
/**
@@ -1362,6 +1323,7 @@ private ASTNode internalCreateASTCached(IProgressMonitor monitor) {
* @see ASTNode#getLength()
*/
private ASTNode internalCreateASTForKind() {
+ // TODO make it independent from ECJ
final ASTConverter converter = new ASTConverter(this.compilerOptions, false, null);
converter.compilationUnitSource = this.rawSource;
converter.compilationUnitSourceLength = this.rawSource.length;
@@ -1546,4 +1508,5 @@ private void rootNodeToCompilationUnit(AST ast, CompilationUnit compilationUnit,
}
}
}
+
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java
index 7a6e5f24b84..2ff5ba9f32c 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java
@@ -81,6 +81,101 @@
@SuppressWarnings({ "rawtypes", "unchecked" })
class CompilationUnitResolver extends Compiler {
+
+ private static final class ECJCompilationUnitResolver implements ICompilationUnitResolver {
+
+ @Override
+ public void resolve(String[] sourceFilePaths, String[] encodings, String[] bindingKeys,
+ FileASTRequestor requestor, int apiLevel, Map compilerOptions, List classpath,
+ int flags, IProgressMonitor monitor) {
+ CompilationUnitResolver.resolve(sourceFilePaths, encodings, bindingKeys, requestor, apiLevel, compilerOptions, classpath, flags, monitor);
+ }
+
+ @Override
+ public void parse(ICompilationUnit[] compilationUnits, ASTRequestor requestor, int apiLevel,
+ Map compilerOptions, int flags, IProgressMonitor monitor) {
+ CompilationUnitResolver.parse(compilationUnits, requestor, apiLevel, compilerOptions, flags, monitor);
+ }
+
+ @Override
+ public void parse(String[] sourceFilePaths, String[] encodings, FileASTRequestor requestor, int apiLevel,
+ Map compilerOptions, int flags, IProgressMonitor monitor) {
+ CompilationUnitResolver.parse(sourceFilePaths, encodings, requestor, apiLevel, compilerOptions, flags, monitor);
+ }
+
+ @Override
+ public void resolve(ICompilationUnit[] compilationUnits, String[] bindingKeys, ASTRequestor requestor,
+ int apiLevel, Map compilerOptions, IJavaProject project,
+ WorkingCopyOwner workingCopyOwner, int flags, IProgressMonitor monitor) {
+ CompilationUnitResolver.resolve(compilationUnits, bindingKeys, requestor, apiLevel, compilerOptions, project, workingCopyOwner, flags, monitor);
+ }
+
+ @Override
+ public IBinding[] resolve(IJavaElement[] elements, int apiLevel, Map compilerOptions,
+ IJavaProject project, WorkingCopyOwner workingCopyOwner, int flags, IProgressMonitor monitor) {
+ return CompilationUnitResolver.resolve(elements, apiLevel, compilerOptions, project, workingCopyOwner, flags, monitor);
+ }
+
+ @Override
+ public CompilationUnit toCompilationUnit(org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit, final boolean initialNeedsToResolveBinding, IJavaProject project, List classpaths, NodeSearcher nodeSearcher,
+ int apiLevel, Map compilerOptions, WorkingCopyOwner parsedUnitWorkingCopyOwner, WorkingCopyOwner typeRootWorkingCopyOwner, int flags, IProgressMonitor monitor) {
+ // this -> astParser, pass as args
+ CompilationUnitDeclaration compilationUnitDeclaration = null;
+ boolean needsToResolveBindingsState = initialNeedsToResolveBinding;
+ try {
+ if (initialNeedsToResolveBinding) {
+ try {
+ // parse and resolve
+ compilationUnitDeclaration =
+ CompilationUnitResolver.resolve(
+ sourceUnit,
+ project,
+ classpaths,
+ nodeSearcher,
+ compilerOptions,
+ parsedUnitWorkingCopyOwner,
+ flags,
+ monitor);
+ } catch (JavaModelException e) {
+ flags &= ~ICompilationUnit.ENABLE_BINDINGS_RECOVERY;
+ compilationUnitDeclaration = CompilationUnitResolver.parse(
+ sourceUnit,
+ nodeSearcher,
+ compilerOptions,
+ flags);
+ needsToResolveBindingsState = false;
+ }
+ } else {
+ compilationUnitDeclaration = CompilationUnitResolver.parse(
+ sourceUnit,
+ nodeSearcher,
+ compilerOptions,
+ flags,
+ project);
+ needsToResolveBindingsState = false;
+ }
+ return CompilationUnitResolver.convert(
+ compilationUnitDeclaration,
+ sourceUnit.getContents(),
+ apiLevel,
+ compilerOptions,
+ needsToResolveBindingsState,
+ typeRootWorkingCopyOwner,
+ needsToResolveBindingsState ? new DefaultBindingResolver.BindingTables() : null,
+ flags,
+ monitor,
+ project != null,
+ project);
+ } finally {
+ if (compilationUnitDeclaration != null && initialNeedsToResolveBinding) {
+ compilationUnitDeclaration.cleanUp();
+ }
+ }
+ }
+ }
+
+ public static final ECJCompilationUnitResolver FACADE = new ECJCompilationUnitResolver();
+
public static final int RESOLVE_BINDING = 0x1;
public static final int PARTIAL = 0x2;
public static final int STATEMENT_RECOVERY = 0x4;
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ICompilationUnitResolver.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ICompilationUnitResolver.java
new file mode 100644
index 00000000000..7798dd82d34
--- /dev/null
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ICompilationUnitResolver.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2023 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.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.ILog;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.WorkingCopyOwner;
+import org.eclipse.jdt.internal.compiler.batch.FileSystem.Classpath;
+
+interface ICompilationUnitResolver {
+
+ void resolve(String[] sourceFilePaths, String[] encodings, String[] bindingKeys, FileASTRequestor requestor,
+ int apiLevel, Map compilerOptions, List list, int flags,
+ IProgressMonitor monitor);
+
+ void parse(ICompilationUnit[] compilationUnits, ASTRequestor requestor, int apiLevel,
+ Map compilerOptions, int flags, IProgressMonitor monitor);
+
+ void parse(String[] sourceFilePaths, String[] encodings, FileASTRequestor requestor, int apiLevel,
+ Map compilerOptions, int flags, IProgressMonitor monitor);
+
+ void resolve(ICompilationUnit[] compilationUnits, String[] bindingKeys, ASTRequestor requestor, int apiLevel,
+ Map compilerOptions, IJavaProject project, WorkingCopyOwner workingCopyOwner, int flags,
+ IProgressMonitor monitor);
+
+ IBinding[] resolve(IJavaElement[] elements, int apiLevel, Map compilerOptions, IJavaProject project,
+ WorkingCopyOwner workingCopyOwner, int flags, IProgressMonitor monitor);
+
+ CompilationUnit toCompilationUnit(org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit, final boolean initialNeedsToResolveBinding, IJavaProject project, List classpaths, NodeSearcher nodeSearcher,
+ int apiLevel, Map compilerOptions, WorkingCopyOwner parsedUnitWorkingCopyOwner, WorkingCopyOwner typeRootWorkingCopyOwner, int flags, IProgressMonitor monitor);
+
+ @SuppressWarnings("unchecked")
+ static ICompilationUnitResolver getInstance() {
+ String compilationUnitResolverClass = System.getProperty(ICompilationUnitResolver.class.getSimpleName());
+ if (compilationUnitResolverClass != null) {
+ try {
+ Class extends ICompilationUnitResolver> clazz = (Class extends ICompilationUnitResolver>) Class.forName(compilationUnitResolverClass);
+ return clazz.getDeclaredConstructor().newInstance();
+ } catch (Exception e) {
+ ILog.get().error(e.getMessage(), e);
+ }
+ }
+ return CompilationUnitResolver.FACADE;
+ }
+
+}
diff --git a/pom.xml b/pom.xml
index 181684c7e2b..0d2a91f56e3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -55,6 +55,7 @@
org.eclipse.jdt.annotation_v1
org.eclipse.jdt.core.compiler.batch
org.eclipse.jdt.core
+ org.eclipse.jdt.core.javac
org.eclipse.jdt.core.formatterapp
org.eclipse.jdt.compiler.tool.tests
org.eclipse.jdt.core.tests.builder
@@ -72,6 +73,13 @@
+
+ org.eclipse.tycho
+ target-platform-configuration
+
+ JavaSE-21
+
+
org.apache.maven.plugins
maven-toolchains-plugin