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 0a247a25dd1..a09ea0b8426 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 = CompilationUnitResolverDiscovery.getInstance(); initializeDefaults(); } @@ -245,10 +247,13 @@ 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) { @@ -957,9 +962,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) @@ -1052,9 +1057,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) @@ -1159,7 +1164,6 @@ private ASTNode internalCreateASTCached(IProgressMonitor monitor) { } break; case K_COMPILATION_UNIT : - CompilationUnitDeclaration compilationUnitDeclaration = null; try { NodeSearcher searcher = null; org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit = null; @@ -1238,59 +1242,19 @@ private ASTNode internalCreateASTCached(IProgressMonitor monitor) { 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; + + CompilationUnit result2 = this.unitResolver.toCompilationUnit(sourceUnit, needToResolveBindings, this.project, getClasspath(), searcher, this.apiLevel, this.compilerOptions, this.workingCopyOwner, wcOwner, flags, monitor); + result2.setTypeRoot(this.typeRoot); + return result2; } finally { - if (compilationUnitDeclaration != null - && ((this.bits & CompilationUnitResolver.RESOLVE_BINDING) != 0)) { - compilationUnitDeclaration.cleanUp(); - } + // unitResolver should already handle this. + // Leaving this finally in place to avoid changing indentation } } throw new IllegalStateException(); diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BindingResolver.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BindingResolver.java index 16800ba68e9..1cd179798b6 100644 --- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BindingResolver.java +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BindingResolver.java @@ -30,13 +30,14 @@ *

* * @see AST#getBindingResolver + * @since 3.38 */ -class BindingResolver { +public class BindingResolver { /** * Creates a binding resolver. */ - BindingResolver() { + public BindingResolver() { // default implementation: do nothing } @@ -79,7 +80,7 @@ class BindingResolver { * @return the corresponding node where the bindings is declared, * or null if none */ - ASTNode findDeclaringNode(IBinding binding) { + public ASTNode findDeclaringNode(IBinding binding) { return null; } @@ -94,7 +95,7 @@ ASTNode findDeclaringNode(IBinding binding) { * @return the corresponding node where the bindings is declared, * or null if none */ - ASTNode findDeclaringNode(String bindingKey) { + public ASTNode findDeclaringNode(String bindingKey) { return null; } @@ -109,7 +110,7 @@ ASTNode findDeclaringNode(String bindingKey) { * @return the corresponding node where the bindings is declared, * or null if none */ - ASTNode findDeclaringNode(IAnnotationBinding instance) { + public ASTNode findDeclaringNode(IAnnotationBinding instance) { return null; } @@ -396,7 +397,7 @@ Object resolveConstantExpressionValue(Expression expression) { * @return the binding for the constructor being invoked, or * null if no binding is available */ - IMethodBinding resolveConstructor(ClassInstanceCreation expression) { + public IMethodBinding resolveConstructor(ClassInstanceCreation expression) { return null; } @@ -418,7 +419,7 @@ IMethodBinding resolveConstructor(ClassInstanceCreation expression) { * @return the binding for the constructor being invoked, or * null if no binding is available */ - IMethodBinding resolveConstructor(ConstructorInvocation expression) { + public IMethodBinding resolveConstructor(ConstructorInvocation expression) { return null; } /** @@ -439,7 +440,7 @@ IMethodBinding resolveConstructor(ConstructorInvocation expression) { * @return the binding for the constructor being invoked, or * null if no binding is available */ - IMethodBinding resolveConstructor(EnumConstantDeclaration enumConstantDeclaration) { + public IMethodBinding resolveConstructor(EnumConstantDeclaration enumConstantDeclaration) { return null; } /** @@ -460,7 +461,7 @@ IMethodBinding resolveConstructor(EnumConstantDeclaration enumConstantDeclaratio * @return the binding for the constructor being invoked, or * null if no binding is available */ - IMethodBinding resolveConstructor(SuperConstructorInvocation expression) { + public IMethodBinding resolveConstructor(SuperConstructorInvocation expression) { return null; } /** @@ -481,7 +482,7 @@ IMethodBinding resolveConstructor(SuperConstructorInvocation expression) { * @return the binding for the type of the given expression, or * null if no binding is available */ - ITypeBinding resolveExpressionType(Expression expression) { + public ITypeBinding resolveExpressionType(Expression expression) { return null; } @@ -502,7 +503,7 @@ ITypeBinding resolveExpressionType(Expression expression) { * @return the binding for the given field access, or * null if no binding is available */ - IVariableBinding resolveField(FieldAccess fieldAccess) { + public IVariableBinding resolveField(FieldAccess fieldAccess) { return null; } @@ -523,7 +524,7 @@ IVariableBinding resolveField(FieldAccess fieldAccess) { * @return the binding for the given field access, or * null if no binding is available */ - IVariableBinding resolveField(SuperFieldAccess fieldAccess) { + public IVariableBinding resolveField(SuperFieldAccess fieldAccess) { return null; } @@ -544,7 +545,7 @@ IVariableBinding resolveField(SuperFieldAccess fieldAccess) { * (for single-type imports), or null if no binding is * available */ - IBinding resolveImport(ImportDeclaration importDeclaration) { + public IBinding resolveImport(ImportDeclaration importDeclaration) { return null; } @@ -567,7 +568,7 @@ IBinding resolveImport(ImportDeclaration importDeclaration) { * if no binding is available * @since 3.0 */ - IMethodBinding resolveMember(AnnotationTypeMemberDeclaration member) { + public IMethodBinding resolveMember(AnnotationTypeMemberDeclaration member) { return null; } @@ -588,7 +589,7 @@ IMethodBinding resolveMember(AnnotationTypeMemberDeclaration member) { * @return the binding for the given method declaration, or * null if no binding is available */ - IMethodBinding resolveMethod(MethodDeclaration method) { + public IMethodBinding resolveMethod(MethodDeclaration method) { return null; } @@ -610,7 +611,7 @@ IMethodBinding resolveMethod(MethodDeclaration method) { * null if no binding is available * @since 3.10 */ - IMethodBinding resolveMethod(MethodReference methodReference) { + public IMethodBinding resolveMethod(MethodReference methodReference) { return null; } @@ -631,7 +632,7 @@ IMethodBinding resolveMethod(MethodReference methodReference) { * @return the binding for the given lambda expression, or * null if no binding is available */ - IMethodBinding resolveMethod(LambdaExpression lambda) { + public IMethodBinding resolveMethod(LambdaExpression lambda) { return null; } @@ -652,7 +653,7 @@ IMethodBinding resolveMethod(LambdaExpression lambda) { * @return the binding for the given method invocation, or * null if no binding is available */ - IMethodBinding resolveMethod(MethodInvocation method) { + public IMethodBinding resolveMethod(MethodInvocation method) { return null; } @@ -673,7 +674,7 @@ IMethodBinding resolveMethod(MethodInvocation method) { * @return the binding for the given method invocation, or * null if no binding is available */ - IMethodBinding resolveMethod(SuperMethodInvocation method) { + public IMethodBinding resolveMethod(SuperMethodInvocation method) { return null; } @@ -696,7 +697,7 @@ IMethodBinding resolveMethod(SuperMethodInvocation method) { * * @since 3.14 */ - IModuleBinding resolveModule(ModuleDeclaration module) { + public IModuleBinding resolveModule(ModuleDeclaration module) { return null; } @@ -716,7 +717,7 @@ IModuleBinding resolveModule(ModuleDeclaration module) { * @return the binding for the name, or null if no binding is * available */ - IBinding resolveName(Name name) { + public IBinding resolveName(Name name) { return null; } @@ -735,7 +736,7 @@ IBinding resolveName(Name name) { * @return the binding for the given package declaration, or * null if no binding is available */ - IPackageBinding resolvePackage(PackageDeclaration pkg) { + public IPackageBinding resolvePackage(PackageDeclaration pkg) { return null; } @@ -756,7 +757,7 @@ IPackageBinding resolvePackage(PackageDeclaration pkg) { * available * @since 3.0 */ - IBinding resolveReference(MemberRef ref) { + public IBinding resolveReference(MemberRef ref) { return null; } @@ -777,7 +778,7 @@ IBinding resolveReference(MemberRef ref) { * available * @since 3.2 */ - IMemberValuePairBinding resolveMemberValuePair(MemberValuePair memberValuePair) { + public IMemberValuePairBinding resolveMemberValuePair(MemberValuePair memberValuePair) { return null; } @@ -798,7 +799,7 @@ IMemberValuePairBinding resolveMemberValuePair(MemberValuePair memberValuePair) * available * @since 3.0 */ - IBinding resolveReference(MethodRef ref) { + public IBinding resolveReference(MethodRef ref) { return null; } @@ -821,7 +822,7 @@ IBinding resolveReference(MethodRef ref) { * if no binding is available * @since 3.0 */ - ITypeBinding resolveType(AnnotationTypeDeclaration type) { + public ITypeBinding resolveType(AnnotationTypeDeclaration type) { return null; } @@ -843,7 +844,7 @@ ITypeBinding resolveType(AnnotationTypeDeclaration type) { * @return the binding for the given class declaration, or null * if no binding is available */ - ITypeBinding resolveType(AnonymousClassDeclaration type) { + public ITypeBinding resolveType(AnonymousClassDeclaration type) { return null; } @@ -866,7 +867,7 @@ ITypeBinding resolveType(AnonymousClassDeclaration type) { * if no binding is available * @since 3.0 */ - ITypeBinding resolveType(EnumDeclaration type) { + public ITypeBinding resolveType(EnumDeclaration type) { return null; } @@ -889,7 +890,7 @@ ITypeBinding resolveType(EnumDeclaration type) { * if no binding is available * @since 3.22 */ - ITypeBinding resolveType(RecordDeclaration type) { + public ITypeBinding resolveType(RecordDeclaration type) { return null; } @@ -910,7 +911,7 @@ ITypeBinding resolveType(RecordDeclaration type) { * @return the binding for the given type, or null * if no binding is available */ - ITypeBinding resolveType(Type type) { + public ITypeBinding resolveType(Type type) { return null; } @@ -933,11 +934,11 @@ ITypeBinding resolveType(Type type) { * @return the binding for the given type declaration, or null * if no binding is available */ - ITypeBinding resolveType(TypeDeclaration type) { + public ITypeBinding resolveType(TypeDeclaration type) { return null; } - ITypeBinding resolveType(ImplicitTypeDeclaration type) { + public ITypeBinding resolveType(ImplicitTypeDeclaration type) { return null; } @@ -960,7 +961,7 @@ ITypeBinding resolveType(ImplicitTypeDeclaration type) { * if no binding is available * @since 3.1 */ - ITypeBinding resolveTypeParameter(TypeParameter typeParameter) { + public ITypeBinding resolveTypeParameter(TypeParameter typeParameter) { return null; } @@ -981,7 +982,7 @@ ITypeBinding resolveTypeParameter(TypeParameter typeParameter) { * null if no binding is available * @since 3.0 */ - IVariableBinding resolveVariable(EnumConstantDeclaration enumConstant) { + public IVariableBinding resolveVariable(EnumConstantDeclaration enumConstant) { return null; } @@ -1005,7 +1006,7 @@ IVariableBinding resolveVariable(EnumConstantDeclaration enumConstant) { * @return the binding for the given variable declaration, or * null if no binding is available */ - IVariableBinding resolveVariable(VariableDeclaration variable) { + public IVariableBinding resolveVariable(VariableDeclaration variable) { return null; } @@ -1026,7 +1027,7 @@ IVariableBinding resolveVariable(VariableDeclaration variable) { * named type is not considered well known or if no binding can be found * for it */ - ITypeBinding resolveWellKnownType(String name) { + public ITypeBinding resolveWellKnownType(String name) { return null; } @@ -1045,7 +1046,7 @@ ITypeBinding resolveWellKnownType(String name) { * @return the DOM annotation representation for the given ast node, or * null if none is available */ - IAnnotationBinding resolveAnnotation(Annotation annotation) { + public IAnnotationBinding resolveAnnotation(Annotation annotation) { return null; } @@ -1068,7 +1069,7 @@ IAnnotationBinding resolveAnnotation(Annotation annotation) { * dimensions * @throws IllegalArgumentException if the type binding represents the void type binding */ - ITypeBinding resolveArrayType(ITypeBinding typeBinding, int dimensions) { + public ITypeBinding resolveArrayType(ITypeBinding typeBinding, int dimensions) { return null; } 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 1988de8c26b..959a8c6afbf 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 @@ -82,6 +82,45 @@ @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 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) { + return CompilationUnitResolver.toCompilationUnit(sourceUnit, initialNeedsToResolveBinding, project, + classpaths, nodeSearcher, apiLevel, compilerOptions, parsedUnitWorkingCopyOwner, typeRootWorkingCopyOwner, flags, monitor); + } + } + + 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; @@ -1408,6 +1447,62 @@ public CompilationUnitDeclaration resolve( generateCode); } + public static 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(); + } + } + } + private void worked(int work) { if (this.monitor != null) { if (this.monitor.isCanceled()) diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolverDiscovery.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolverDiscovery.java new file mode 100644 index 00000000000..8038b0c0d87 --- /dev/null +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolverDiscovery.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * 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 org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.ILog; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jdt.core.JavaCore; + +class CompilationUnitResolverDiscovery { + private static final String COMPILATION_UNIT_RESOLVER_EXTPOINT_ID = "compilationUnitResolver" ; //$NON-NLS-1$ + private static boolean ERROR_LOGGED = false; + + + @SuppressWarnings("unchecked") + static ICompilationUnitResolver getInstance() { + String compilationUnitResolverId = System.getProperty(ICompilationUnitResolver.class.getSimpleName()); + IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(JavaCore.PLUGIN_ID, COMPILATION_UNIT_RESOLVER_EXTPOINT_ID); + if (extension != null && compilationUnitResolverId != null && !compilationUnitResolverId.isEmpty()) { + IExtension[] extensions = extension.getExtensions(); + for (IExtension ext : extensions) { + IConfigurationElement[] configElements = ext.getConfigurationElements(); + for (final IConfigurationElement configElement : configElements) { + String elementId = configElement.getAttribute("id"); + if( compilationUnitResolverId.equals(elementId)) { + String elementName =configElement.getName(); + if (!("resolver".equals(elementName))) { //$NON-NLS-1$ + continue; + } + try { + Object executableExtension = configElement.createExecutableExtension("class"); + if( executableExtension instanceof ICompilationUnitResolver icur) { + return icur; + } + } catch (CoreException e) { + e.printStackTrace(); + if( !ERROR_LOGGED) { + ILog.get().error("Could not instantiate ICompilationUnitResolver: '" + elementId + "' with class: " + configElement.getAttribute("class"), e); //$NON-NLS-1$ + ERROR_LOGGED = true; + } + } + } + } + } + } + return CompilationUnitResolver.FACADE; + } + +} diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java index 29ce757fd96..07191bc9500 100644 --- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java @@ -195,7 +195,7 @@ static class BindingTables { } @Override - synchronized ASTNode findDeclaringNode(IBinding binding) { + synchronized public ASTNode findDeclaringNode(IBinding binding) { if (binding == null) { return null; } @@ -213,7 +213,7 @@ synchronized ASTNode findDeclaringNode(IBinding binding) { } @Override - synchronized ASTNode findDeclaringNode(String bindingKey) { + synchronized public ASTNode findDeclaringNode(String bindingKey) { if (bindingKey == null) { return null; } @@ -667,7 +667,7 @@ Object resolveConstantExpressionValue(Expression expression) { } @Override - synchronized IMethodBinding resolveConstructor(ClassInstanceCreation expression) { + synchronized public IMethodBinding resolveConstructor(ClassInstanceCreation expression) { org.eclipse.jdt.internal.compiler.ast.ASTNode node = (org.eclipse.jdt.internal.compiler.ast.ASTNode) this.newAstToOldAst.get(expression); if (node != null && (node.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.IsAnonymousType) != 0) { org.eclipse.jdt.internal.compiler.ast.TypeDeclaration anonymousLocalTypeDeclaration = (org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) node; @@ -679,7 +679,7 @@ synchronized IMethodBinding resolveConstructor(ClassInstanceCreation expression) } @Override - synchronized IMethodBinding resolveConstructor(ConstructorInvocation expression) { + synchronized public IMethodBinding resolveConstructor(ConstructorInvocation expression) { org.eclipse.jdt.internal.compiler.ast.ASTNode node = (org.eclipse.jdt.internal.compiler.ast.ASTNode) this.newAstToOldAst.get(expression); if (node instanceof ExplicitConstructorCall) { ExplicitConstructorCall explicitConstructorCall = (ExplicitConstructorCall) node; @@ -689,7 +689,7 @@ synchronized IMethodBinding resolveConstructor(ConstructorInvocation expression) } @Override - IMethodBinding resolveConstructor(EnumConstantDeclaration enumConstantDeclaration) { + public IMethodBinding resolveConstructor(EnumConstantDeclaration enumConstantDeclaration) { org.eclipse.jdt.internal.compiler.ast.ASTNode node = (org.eclipse.jdt.internal.compiler.ast.ASTNode) this.newAstToOldAst.get(enumConstantDeclaration); if (node instanceof org.eclipse.jdt.internal.compiler.ast.FieldDeclaration) { org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDeclaration = (org.eclipse.jdt.internal.compiler.ast.FieldDeclaration) node; @@ -702,7 +702,7 @@ IMethodBinding resolveConstructor(EnumConstantDeclaration enumConstantDeclaratio } @Override - synchronized IMethodBinding resolveConstructor(SuperConstructorInvocation expression) { + synchronized public IMethodBinding resolveConstructor(SuperConstructorInvocation expression) { org.eclipse.jdt.internal.compiler.ast.ASTNode node = (org.eclipse.jdt.internal.compiler.ast.ASTNode) this.newAstToOldAst.get(expression); if (node instanceof ExplicitConstructorCall) { ExplicitConstructorCall explicitConstructorCall = (ExplicitConstructorCall) node; @@ -712,7 +712,7 @@ synchronized IMethodBinding resolveConstructor(SuperConstructorInvocation expres } @Override - synchronized ITypeBinding resolveExpressionType(Expression expression) { + synchronized public ITypeBinding resolveExpressionType(Expression expression) { try { switch(expression.getNodeType()) { case ASTNode.CLASS_INSTANCE_CREATION : @@ -808,7 +808,7 @@ synchronized ITypeBinding resolveExpressionType(Expression expression) { } @Override - synchronized IVariableBinding resolveField(FieldAccess fieldAccess) { + synchronized public IVariableBinding resolveField(FieldAccess fieldAccess) { Object oldNode = this.newAstToOldAst.get(fieldAccess); if (oldNode instanceof FieldReference) { FieldReference fieldReference = (FieldReference) oldNode; @@ -818,7 +818,7 @@ synchronized IVariableBinding resolveField(FieldAccess fieldAccess) { } @Override - synchronized IVariableBinding resolveField(SuperFieldAccess fieldAccess) { + synchronized public IVariableBinding resolveField(SuperFieldAccess fieldAccess) { Object oldNode = this.newAstToOldAst.get(fieldAccess); if (oldNode instanceof FieldReference) { FieldReference fieldReference = (FieldReference) oldNode; @@ -828,7 +828,7 @@ synchronized IVariableBinding resolveField(SuperFieldAccess fieldAccess) { } @Override - synchronized IBinding resolveImport(ImportDeclaration importDeclaration) { + synchronized public IBinding resolveImport(ImportDeclaration importDeclaration) { if (this.scope == null) return null; try { org.eclipse.jdt.internal.compiler.ast.ASTNode node = (org.eclipse.jdt.internal.compiler.ast.ASTNode) this.newAstToOldAst.get(importDeclaration); @@ -895,7 +895,7 @@ synchronized IBinding resolveImport(ImportDeclaration importDeclaration) { } @Override - IMethodBinding resolveMember(AnnotationTypeMemberDeclaration declaration) { + public IMethodBinding resolveMember(AnnotationTypeMemberDeclaration declaration) { Object oldNode = this.newAstToOldAst.get(declaration); if (oldNode instanceof AbstractMethodDeclaration) { AbstractMethodDeclaration methodDeclaration = (AbstractMethodDeclaration) oldNode; @@ -922,7 +922,7 @@ private IVariableBinding[] getSyntheticOuterLocalVariables(org.eclipse.jdt.inter return syntheticOuterLocals; } @Override - synchronized IMethodBinding resolveMethod(LambdaExpression lambda) { + synchronized public IMethodBinding resolveMethod(LambdaExpression lambda) { Object oldNode = this.newAstToOldAst.get(lambda); if (oldNode instanceof org.eclipse.jdt.internal.compiler.ast.LambdaExpression) { org.eclipse.jdt.internal.compiler.ast.LambdaExpression lambdaExpression = (org.eclipse.jdt.internal.compiler.ast.LambdaExpression) oldNode; @@ -989,7 +989,7 @@ private IBinding getDeclaringMember(org.eclipse.jdt.internal.compiler.ast.ASTNod } @Override - synchronized IMethodBinding resolveMethod(MethodDeclaration method) { + synchronized public IMethodBinding resolveMethod(MethodDeclaration method) { Object oldNode = this.newAstToOldAst.get(method); if (oldNode instanceof AbstractMethodDeclaration) { AbstractMethodDeclaration methodDeclaration = (AbstractMethodDeclaration) oldNode; @@ -1008,7 +1008,7 @@ synchronized IMethodBinding resolveMethod(MethodDeclaration method) { } @Override - synchronized IMethodBinding resolveMethod(MethodInvocation method) { + synchronized public IMethodBinding resolveMethod(MethodInvocation method) { Object oldNode = this.newAstToOldAst.get(method); if (oldNode instanceof MessageSend) { MessageSend messageSend = (MessageSend) oldNode; @@ -1018,7 +1018,7 @@ synchronized IMethodBinding resolveMethod(MethodInvocation method) { } @Override - synchronized IMethodBinding resolveMethod(MethodReference methodReference) { + synchronized public IMethodBinding resolveMethod(MethodReference methodReference) { Object oldNode = this.newAstToOldAst.get(methodReference); if (oldNode instanceof org.eclipse.jdt.internal.compiler.ast.ReferenceExpression) { org.eclipse.jdt.internal.compiler.ast.ReferenceExpression referenceExpression = (org.eclipse.jdt.internal.compiler.ast.ReferenceExpression) oldNode; @@ -1034,7 +1034,7 @@ synchronized IMethodBinding resolveMethod(MethodReference methodReference) { } @Override - synchronized IMethodBinding resolveMethod(SuperMethodInvocation method) { + synchronized public IMethodBinding resolveMethod(SuperMethodInvocation method) { Object oldNode = this.newAstToOldAst.get(method); if (oldNode instanceof MessageSend) { MessageSend messageSend = (MessageSend) oldNode; @@ -1270,7 +1270,7 @@ synchronized ITypeBinding resolveTypeBindingForName(Name name) { } @Override - synchronized IBinding resolveName(Name name) { + synchronized public IBinding resolveName(Name name) { org.eclipse.jdt.internal.compiler.ast.ASTNode node = (org.eclipse.jdt.internal.compiler.ast.ASTNode) this.newAstToOldAst.get(name); int index = name.index; if (node instanceof QualifiedNameReference) { @@ -1565,7 +1565,7 @@ synchronized IBinding resolveName(Name name) { } @Override - synchronized IPackageBinding resolvePackage(PackageDeclaration pkg) { + synchronized public IPackageBinding resolvePackage(PackageDeclaration pkg) { if (this.scope == null) return null; try { org.eclipse.jdt.internal.compiler.ast.ASTNode node = (org.eclipse.jdt.internal.compiler.ast.ASTNode) this.newAstToOldAst.get(pkg); @@ -1601,7 +1601,7 @@ synchronized IPackageBinding resolvePackage(PackageDeclaration pkg) { } @Override - synchronized IBinding resolveReference(MemberRef ref) { + synchronized public IBinding resolveReference(MemberRef ref) { org.eclipse.jdt.internal.compiler.ast.Expression expression = (org.eclipse.jdt.internal.compiler.ast.Expression) this.newAstToOldAst.get(ref); if (expression instanceof TypeReference) { return getTypeBinding(expression.resolvedType); @@ -1616,7 +1616,7 @@ synchronized IBinding resolveReference(MemberRef ref) { } @Override - synchronized IMemberValuePairBinding resolveMemberValuePair(org.eclipse.jdt.core.dom.MemberValuePair memberValuePair) { + synchronized public IMemberValuePairBinding resolveMemberValuePair(org.eclipse.jdt.core.dom.MemberValuePair memberValuePair) { MemberValuePair valuePair = (MemberValuePair) this.newAstToOldAst.get(memberValuePair); if (valuePair != null) { return getMemberValuePairBinding(valuePair.compilerElementPair); @@ -1629,7 +1629,7 @@ synchronized IMemberValuePairBinding resolveMemberValuePair(org.eclipse.jdt.core * @since 3.14 */ @Override - IModuleBinding resolveModule(ModuleDeclaration module) { + public IModuleBinding resolveModule(ModuleDeclaration module) { Object oldNode = this.newAstToOldAst.get(module); if (oldNode instanceof org.eclipse.jdt.internal.compiler.ast.ModuleDeclaration) { org.eclipse.jdt.internal.compiler.ast.ModuleDeclaration moduleDeclaration = (org.eclipse.jdt.internal.compiler.ast.ModuleDeclaration) oldNode; @@ -1649,7 +1649,7 @@ IModuleBinding resolveModule(ModuleDeclaration module) { } @Override - synchronized IBinding resolveReference(MethodRef ref) { + synchronized public IBinding resolveReference(MethodRef ref) { org.eclipse.jdt.internal.compiler.ast.Expression expression = (org.eclipse.jdt.internal.compiler.ast.Expression) this.newAstToOldAst.get(ref); if (expression instanceof JavadocMessageSend) { return getMethodBinding(((JavadocMessageSend)expression).binding); @@ -1661,7 +1661,7 @@ else if (expression instanceof JavadocAllocationExpression) { } @Override - ITypeBinding resolveType(AnnotationTypeDeclaration type) { + public ITypeBinding resolveType(AnnotationTypeDeclaration type) { final Object node = this.newAstToOldAst.get(type); if (node instanceof org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) { org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration = (org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) node; @@ -1680,7 +1680,7 @@ ITypeBinding resolveType(AnnotationTypeDeclaration type) { } @Override - synchronized ITypeBinding resolveType(AnonymousClassDeclaration type) { + synchronized public ITypeBinding resolveType(AnonymousClassDeclaration type) { org.eclipse.jdt.internal.compiler.ast.ASTNode node = (org.eclipse.jdt.internal.compiler.ast.ASTNode) this.newAstToOldAst.get(type); if (node != null && (node.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.IsAnonymousType) != 0) { org.eclipse.jdt.internal.compiler.ast.TypeDeclaration anonymousLocalTypeDeclaration = (org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) node; @@ -1700,7 +1700,7 @@ synchronized ITypeBinding resolveType(AnonymousClassDeclaration type) { } @Override - ITypeBinding resolveType(EnumDeclaration type) { + public ITypeBinding resolveType(EnumDeclaration type) { final Object node = this.newAstToOldAst.get(type); if (node instanceof org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) { org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration = (org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) node; @@ -1719,7 +1719,7 @@ ITypeBinding resolveType(EnumDeclaration type) { } @Override - ITypeBinding resolveType(RecordDeclaration type) { + public ITypeBinding resolveType(RecordDeclaration type) { final Object node = this.newAstToOldAst.get(type); if (node instanceof org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) { org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration = (org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) node; @@ -1740,7 +1740,7 @@ ITypeBinding resolveType(RecordDeclaration type) { @Override - synchronized ITypeBinding resolveType(Type type) { + synchronized public ITypeBinding resolveType(Type type) { // retrieve the old ast node org.eclipse.jdt.internal.compiler.ast.ASTNode node = (org.eclipse.jdt.internal.compiler.ast.ASTNode) this.newAstToOldAst.get(type); org.eclipse.jdt.internal.compiler.lookup.TypeBinding binding = null; @@ -1860,7 +1860,7 @@ private org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding[] getTypeAnno } @Override - synchronized ITypeBinding resolveType(TypeDeclaration type) { + synchronized public ITypeBinding resolveType(TypeDeclaration type) { final Object node = this.newAstToOldAst.get(type); if (node instanceof org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) { org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration = (org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) node; @@ -1880,7 +1880,7 @@ synchronized ITypeBinding resolveType(TypeDeclaration type) { } @Override - synchronized ITypeBinding resolveType(ImplicitTypeDeclaration type) { + synchronized public ITypeBinding resolveType(ImplicitTypeDeclaration type) { final Object node = this.newAstToOldAst.get(type); if (node instanceof org.eclipse.jdt.internal.compiler.ast.ImplicitTypeDeclaration implicitTypeDeclaration) { ITypeBinding typeBinding = internalGetTypeBinding(implicitTypeDeclaration.binding, null); @@ -1898,7 +1898,7 @@ synchronized ITypeBinding resolveType(ImplicitTypeDeclaration type) { } @Override - synchronized ITypeBinding resolveTypeParameter(TypeParameter typeParameter) { + synchronized public ITypeBinding resolveTypeParameter(TypeParameter typeParameter) { final Object node = this.newAstToOldAst.get(typeParameter); if (node instanceof org.eclipse.jdt.internal.compiler.ast.TypeParameter) { org.eclipse.jdt.internal.compiler.ast.TypeParameter typeParameter2 = (org.eclipse.jdt.internal.compiler.ast.TypeParameter) node; @@ -1917,7 +1917,7 @@ synchronized ITypeBinding resolveTypeParameter(TypeParameter typeParameter) { } @Override - synchronized IVariableBinding resolveVariable(EnumConstantDeclaration enumConstant) { + synchronized public IVariableBinding resolveVariable(EnumConstantDeclaration enumConstant) { final Object node = this.newAstToOldAst.get(enumConstant); if (node instanceof org.eclipse.jdt.internal.compiler.ast.FieldDeclaration) { org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDeclaration = (org.eclipse.jdt.internal.compiler.ast.FieldDeclaration) node; @@ -1936,7 +1936,7 @@ synchronized IVariableBinding resolveVariable(EnumConstantDeclaration enumConsta } @Override - synchronized IVariableBinding resolveVariable(VariableDeclaration variable) { + synchronized public IVariableBinding resolveVariable(VariableDeclaration variable) { final Object node = this.newAstToOldAst.get(variable); if (node instanceof AbstractVariableDeclaration) { AbstractVariableDeclaration abstractVariableDeclaration = (AbstractVariableDeclaration) node; @@ -1964,7 +1964,7 @@ synchronized IVariableBinding resolveVariable(VariableDeclaration variable) { } @Override - synchronized ITypeBinding resolveWellKnownType(String name) { + synchronized public ITypeBinding resolveWellKnownType(String name) { if (this.scope == null) return null; ITypeBinding typeBinding = null; try { @@ -2029,7 +2029,7 @@ synchronized ITypeBinding resolveWellKnownType(String name) { } @Override - synchronized IAnnotationBinding resolveAnnotation(final Annotation domASTNode) { + synchronized public IAnnotationBinding resolveAnnotation(final Annotation domASTNode) { Object oldNode = this.newAstToOldAst.get(domASTNode); if (oldNode instanceof org.eclipse.jdt.internal.compiler.ast.Annotation) { org.eclipse.jdt.internal.compiler.ast.Annotation internalAstNode = @@ -2063,7 +2063,7 @@ synchronized void updateKey(ASTNode node, ASTNode newNode) { } @Override - ITypeBinding resolveArrayType(ITypeBinding typeBinding, int dimensions) { + public ITypeBinding resolveArrayType(ITypeBinding typeBinding, int dimensions) { if (typeBinding instanceof RecoveredTypeBinding) throw new IllegalArgumentException("Cannot be called on a recovered type binding"); //$NON-NLS-1$ ITypeBinding leafComponentType = typeBinding; int actualDimensions = dimensions; 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..8d379504309 --- /dev/null +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ICompilationUnitResolver.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * 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.IProgressMonitor; +import org.eclipse.jdt.core.ICompilationUnit; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.core.WorkingCopyOwner; +import org.eclipse.jdt.internal.compiler.batch.FileSystem.Classpath; + +/** + * @since 3.38 + */ +public 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); + + 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); +} diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NodeSearcher.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NodeSearcher.java index 30537d2152b..4028ab16425 100644 --- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NodeSearcher.java +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NodeSearcher.java @@ -23,7 +23,10 @@ import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope; import org.eclipse.jdt.internal.compiler.lookup.MethodScope; -class NodeSearcher extends ASTVisitor { +/** + * @since 3.38 + */ +public class NodeSearcher extends ASTVisitor { public org.eclipse.jdt.internal.compiler.ast.ASTNode found; public TypeDeclaration enclosingType; public int position; diff --git a/org.eclipse.jdt.core/plugin.properties b/org.eclipse.jdt.core/plugin.properties index 7611e97e290..f901126dae0 100644 --- a/org.eclipse.jdt.core/plugin.properties +++ b/org.eclipse.jdt.core/plugin.properties @@ -23,6 +23,7 @@ classpathVariableInitializersName=Classpath Variable Initializers classpathContainerInitializersName=Classpath Container Initializers codeFormattersName=Source Code Formatters compilationParticipantsName=Compilation Participants +compilationUnitResolverName=Compilation Unit Resolver annotationProcessorManagerName=Java 6 Annotation Processor Manager javaTaskName=Java Task javaPropertiesName=Java Properties File diff --git a/org.eclipse.jdt.core/plugin.xml b/org.eclipse.jdt.core/plugin.xml index 0569dff3f86..1a5c84cb82e 100644 --- a/org.eclipse.jdt.core/plugin.xml +++ b/org.eclipse.jdt.core/plugin.xml @@ -63,6 +63,14 @@ id="compilationParticipant" schema="schema/compilationParticipant.exsd"/> + + + + + + diff --git a/org.eclipse.jdt.core/schema/compilationUnitResolver.exsd b/org.eclipse.jdt.core/schema/compilationUnitResolver.exsd new file mode 100644 index 00000000000..c2391cccebd --- /dev/null +++ b/org.eclipse.jdt.core/schema/compilationUnitResolver.exsd @@ -0,0 +1,121 @@ + + + + + + + + + This extension point provides the ability to override the default behavior of converting source files into the JDT DOM tree. Only one extension will be used, and only when the system property `ICompilationUnitResolver` is set to the id of that extension. This extension point is not intended to be implemented by clients. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Definition of a compilation unit resolver. + + + + + + + The class that implements this compilation unit resolver. This class must implement the <code>org.eclipse.jdt.core.dom.ICompilationUnitResolver</code> interface with a public 0-arg constructor. + + + + + + + + + + A unique identifier for this resolver. + + + + + + + + + + + + 3.38 + + + + + + + + + Example of a declaration of a <code>compilationUnitResolver</code>: <pre> +<extension + point="org.eclipse.jdt.core.compilationParticipant"> + <resolver + class="org.eclipse.jdt.core.CompilationUnitResolver1" + id="org.eclipse.jdt.core.MyCustomResolver"> + </resolver> +</extension> +</pre> + + + + + + + + + + + Copyright (c) 2024 Red Hat, Inc. and others.<br> + +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 +<a href="https://www.eclipse.org/legal/epl-2.0">https://www.eclipse.org/legal/epl-v20.html</a>/ + +SPDX-License-Identifier: EPL-2.0 + + + +