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..c72e4b97e36 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(); } @@ -957,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) @@ -1052,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) @@ -1126,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 @@ -1155,145 +1154,102 @@ 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; } /** @@ -1552,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 1988de8c26b..8605012654d 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,95 @@ @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) { + // 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/CompilationUnitResolverDiscovery.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolverDiscovery.java new file mode 100644 index 00000000000..0dfc2ee86e5 --- /dev/null +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolverDiscovery.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * 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() { + IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(JavaCore.PLUGIN_ID, COMPILATION_UNIT_RESOLVER_EXTPOINT_ID); + if (extension != null) { + IExtension[] extensions = extension.getExtensions(); + for (IExtension ext : extensions) { + IConfigurationElement[] configElements = ext.getConfigurationElements(); + // for all config elements named "resolver" + for (final IConfigurationElement configElement : configElements) { + 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) { + if( !ERROR_LOGGED) { + ILog.get().error("Could not instantiate ICompilationUnitResolver: " + 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/ICompilationUnitResolver.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ICompilationUnitResolver.java new file mode 100644 index 00000000000..2931ec75eb0 --- /dev/null +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ICompilationUnitResolver.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * 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; + +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/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..1c477b5f207 --- /dev/null +++ b/org.eclipse.jdt.core/schema/compilationUnitResolver.exsd @@ -0,0 +1,127 @@ + + + + + + + + + This extension point allows clients to participate in the compilation process by receiving notifications at various stages of build and reconcile, via a org.eclipse.jdt.core.compiler.CompilationParticipant. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + definition of a compilation participant. This definition allows to order participants. Participants are run by group. The group of participants that modify the environment is run first, then the group of participants that create problems is run, finally the group of other participants is run. Inside each group, participants are ordered using their 'requires' attributes. If a 'requires' attribute point to a participant that doesn't belong to the group, it is ignored. + + + + + + + + + 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 participant + + + + + + + + + + + + 3.2 + + + + + + + + + Example of a declaration of a <code>compilationParticipant</code>: <pre> +<extension + id="apt" + name="%annotationProcessingName" + point="org.eclipse.jdt.core.compilationParticipant"> + <compilationParticipant + class="org.eclipse.jdt.apt.core.internal.AptCompilationParticipant" + id="APT" + requiredSourceLevel="1.5"> + <managedMarker markerType="org.eclipse.jdt.apt.core.compile.problem"/> + </compilationParticipant> +</extension> +</pre> + + + + + + + + + + + Copyright (c) 2006 BEA Systems, 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 + + + +