Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 60773 Details for
Bug 168077
[classpath] Let classpath containers define what is configurable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
3 API methods with no check for values
v02.txt (text/plain), 14.80 KB, created by
Frederic Fusier
on 2007-03-14 06:15:51 EDT
(
hide
)
Description:
3 API methods with no check for values
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2007-03-14 06:15:51 EDT
Size:
14.80 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: model/org/eclipse/jdt/core/ClasspathContainerInitializer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ClasspathContainerInitializer.java,v >retrieving revision 1.34 >diff -u -r1.34 ClasspathContainerInitializer.java >--- model/org/eclipse/jdt/core/ClasspathContainerInitializer.java 30 Oct 2006 20:23:37 -0000 1.34 >+++ model/org/eclipse/jdt/core/ClasspathContainerInitializer.java 14 Mar 2007 10:04:12 -0000 >@@ -19,6 +19,9 @@ > > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.jdt.internal.core.JavaModelStatus; > > /** > * Abstract base implementation of all classpath container initializer. >@@ -42,8 +45,30 @@ > * @since 2.0 > */ > public abstract class ClasspathContainerInitializer { >- >- /** >+ >+ /** >+ * Status code indicating that an attribute is not supported. >+ * >+ * @see #validateAccessRules(IPath, IJavaProject, IAccessRule[]) >+ * @see #validateExtraAttribute(IPath, IJavaProject, IClasspathAttribute, boolean) >+ * @see #validateSourceAttachment(IPath, IJavaProject, IPath, boolean) >+ * >+ * @since 3.3 >+ */ >+ public static final int ATTRIBUTE_NOT_SUPPORTED= 1; >+ >+ /** >+ * Status code indicating that an attribute is not modifiable. >+ * >+ * @see #validateAccessRules(IPath, IJavaProject, IAccessRule[]) >+ * @see #validateExtraAttribute(IPath, IJavaProject, IClasspathAttribute, boolean) >+ * @see #validateSourceAttachment(IPath, IJavaProject, IPath, boolean) >+ * >+ * @since 3.3 >+ */ >+ public static final int ATTRIBUTE_NOT_MODIFIABLE= 2; >+ >+ /** > * Creates a new classpath container initializer. > */ > public ClasspathContainerInitializer() { >@@ -51,6 +76,22 @@ > } > > /** >+ * Returns <code>true</code> if this container initializer can be requested to perform updates >+ * on its own container values. If so, then an update request will be performed using >+ * {@link #requestClasspathContainerUpdate(IPath, IJavaProject, IClasspathContainer)}. >+ * <p> >+ * @param containerPath the path of the container which requires to be updated >+ * @param project the project for which the container is to be updated >+ * @return returns <code>true</code> if the container can be updated >+ * @since 2.1 >+ */ >+ public boolean canUpdateClasspathContainer(IPath containerPath, IJavaProject project) { >+ >+ // By default, classpath container initializers do not accept updating containers >+ return false; >+ } >+ >+ /** > * Binds a classpath container to a <code>IClasspathContainer</code> for a given project, > * or silently fails if unable to do so. > * <p> >@@ -108,55 +149,36 @@ > * @see IClasspathContainer > */ > public abstract void initialize(IPath containerPath, IJavaProject project) throws CoreException; >- >- /** >- * Returns <code>true</code> if this container initializer can be requested to perform updates >- * on its own container values. If so, then an update request will be performed using >- * <code>ClasspathContainerInitializer#requestClasspathContainerUpdate</code>/ >- * <p> >- * @param containerPath the path of the container which requires to be updated >- * @param project the project for which the container is to be updated >- * @return returns <code>true</code> if the container can be updated >- * @since 2.1 >- */ >- public boolean canUpdateClasspathContainer(IPath containerPath, IJavaProject project) { >- >- // By default, classpath container initializers do not accept updating containers >- return false; >- } > > /** >- * Request a registered container definition to be updated according to a container suggestion. The container suggestion >- * only acts as a place-holder to pass along the information to update the matching container definition(s) held by the >- * container initializer. In particular, it is not expected to store the container suggestion as is, but rather adjust >- * the actual container definition based on suggested changes. >- * <p> >- * IMPORTANT: In reaction to receiving an update request, a container initializer will update the corresponding >- * container definition (after reconciling changes) at its earliest convenience, using >- * <code>JavaCore#setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], IProgressMonitor)</code>. >- * Until it does so, the update will not be reflected in the Java Model. >- * <p> >- * In order to anticipate whether the container initializer allows to update its containers, the predicate >- * <code>JavaCore#canUpdateClasspathContainer</code> should be used. >+ * Returns an object which identifies a container for comparison purpose. This allows >+ * to eliminate redundant containers when accumulating classpath entries (e.g. >+ * runtime classpath computation). When requesting a container comparison ID, one >+ * should ensure using its corresponding container initializer. Indeed, a random container >+ * initializer cannot be held responsible for determining comparison IDs for arbitrary >+ * containers. > * <p> >- * @param containerPath the path of the container which requires to be updated >- * @param project the project for which the container is to be updated >- * @param containerSuggestion a suggestion to update the corresponding container definition >- * @throws CoreException when <code>JavaCore#setClasspathContainer</code> would throw any. >- * @see JavaCore#setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], org.eclipse.core.runtime.IProgressMonitor) >- * @see ClasspathContainerInitializer#canUpdateClasspathContainer(IPath, IJavaProject) >- * @since 2.1 >+ * @param containerPath the path of the container which is being checked >+ * @param project the project for which the container is to being checked >+ * @return returns an Object identifying the container for comparison >+ * @since 3.0 > */ >- public void requestClasspathContainerUpdate(IPath containerPath, IJavaProject project, IClasspathContainer containerSuggestion) throws CoreException { >+ public Object getComparisonID(IPath containerPath, IJavaProject project) { > >- // By default, classpath container initializers do not accept updating containers >- } >+ // By default, containers are identical if they have the same containerPath first segment, >+ // but this may be refined by other container initializer implementations. >+ if (containerPath == null) { >+ return null; >+ } else { >+ return containerPath.segment(0); >+ } >+ } > > /** > * Returns a readable description for a container path. A readable description for a container path can be > * used for improving the display of references to container, without actually needing to resolve them. > * A good implementation should answer a description consistent with the description of the associated >- * target container (see <code>IClasspathContainer.getDescription()</code>). >+ * target container (see {@link IClasspathContainer#getDescription()}). > * > * @param containerPath the path of the container which requires a readable description > * @param project the project from which the container is referenced >@@ -171,7 +193,7 @@ > > /** > * Returns a classpath container that is used after this initializer failed to bind a classpath container >- * to a <code>IClasspathContainer</code> for the given project. A non-<code>null</code> >+ * to a {@link IClasspathContainer} for the given project. A non-<code>null</code> > * failure container indicates that there will be no more request to initialize the given container > * for the given project. > * <p> >@@ -208,27 +230,132 @@ > } > > /** >- * Returns an object which identifies a container for comparison purpose. This allows >- * to eliminate redundant containers when accumulating classpath entries (e.g. >- * runtime classpath computation). When requesting a container comparison ID, one >- * should ensure using its corresponding container initializer. Indeed, a random container >- * initializer cannot be held responsible for determining comparison IDs for arbitrary >- * containers. >+ * Request a registered container definition to be updated according to a container suggestion. The container suggestion >+ * only acts as a place-holder to pass along the information to update the matching container definition(s) held by the >+ * container initializer. In particular, it is not expected to store the container suggestion as is, but rather adjust >+ * the actual container definition based on suggested changes. > * <p> >- * @param containerPath the path of the container which is being checked >- * @param project the project for which the container is to being checked >- * @return returns an Object identifying the container for comparison >- * @since 3.0 >+ * IMPORTANT: In reaction to receiving an update request, a container initializer will update the corresponding >+ * container definition (after reconciling changes) at its earliest convenience, using >+ * {@link JavaCore#setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], org.eclipse.core.runtime.IProgressMonitor)}. >+ * Until it does so, the update will not be reflected in the Java Model. >+ * <p> >+ * In order to anticipate whether the container initializer allows to update its containers, the predicate >+ * {@link #canUpdateClasspathContainer(IPath, IJavaProject)} should be used. >+ * <p> >+ * @param containerPath the path of the container which requires to be updated >+ * @param project the project for which the container is to be updated >+ * @param containerSuggestion a suggestion to update the corresponding container definition >+ * @throws CoreException when <code>JavaCore#setClasspathContainer</code> would throw any. >+ * @see JavaCore#setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], org.eclipse.core.runtime.IProgressMonitor) >+ * @see ClasspathContainerInitializer#canUpdateClasspathContainer(IPath, IJavaProject) >+ * @since 2.1 > */ >- public Object getComparisonID(IPath containerPath, IJavaProject project) { >+ public void requestClasspathContainerUpdate(IPath containerPath, IJavaProject project, IClasspathContainer containerSuggestion) throws CoreException { > >- // By default, containers are identical if they have the same containerPath first segment, >- // but this may be refined by other container initializer implementations. >- if (containerPath == null) { >- return null; >- } else { >- return containerPath.segment(0); >+ // By default, classpath container initializers do not accept updating containers >+ } >+ >+ /** >+ * Returns whether access rules may be updated on a container or not. >+ * <p> >+ * If the access rules attribute is modifiable then the returned status is >+ * {@link IStatus#OK ok}. Otherwise, the returned status is in >+ * {@link IStatus#ERROR error} and its {@link IStatus#getCode() code} >+ * will have the {@link #ATTRIBUTE_NOT_MODIFIABLE} value. >+ * </p><p> >+ * The status message can contain more information. >+ * </p><p> >+ * If the subclass does not override this method, then default behavior is >+ * to return {@link IStatus#OK} if and only if the classpath container can be >+ * updated (see {@link #canUpdateClasspathContainer(IPath, IJavaProject)}). >+ * </p> >+ * >+ * @param containerPath the path of the container which requires to be >+ * updated >+ * @param project the project for which the container is to be updated >+ * @param rules the access rule to validate >+ * @return returns the resulting status for all tested attributes >+ * >+ * @since 3.3 >+ */ >+ public IStatus validateAccessRules(IPath containerPath, >+ IJavaProject project, >+ IAccessRule[] rules) { >+ >+ if (canUpdateClasspathContainer(containerPath, project)) { >+ return Status.OK_STATUS; >+ } >+ return new JavaModelStatus(ATTRIBUTE_NOT_MODIFIABLE); >+ } >+ >+ /** >+ * Returns whether an extra attribute may be updated on a container or not. >+ * <p> >+ * If the extra attribute is supported <strong>and</strong> modifiable >+ * then the returned status is {@link IStatus#OK ok}. Otherwise, the returned >+ * status is in {@link IStatus#ERROR error} and its {@link IStatus#getCode() code} >+ * will have the {@link #ATTRIBUTE_NOT_SUPPORTED} value if it is not supported >+ * or the {@link #ATTRIBUTE_NOT_MODIFIABLE} value if it is supported but not >+ * modifiable. >+ * </p><p> >+ * The status message can contain more information. >+ * </p><p> >+ * If the subclass does not override this method, then default behavior is >+ * to return {@link IStatus#OK} if and only if the classpath container can be >+ * updated (see {@link #canUpdateClasspathContainer(IPath, IJavaProject)}). >+ * </p> >+ * >+ * @param containerPath the path of the container which requires to be >+ * updated >+ * @param project the project for which the container is to be updated >+ * @param extraAttribute the extra attribute to validate >+ * @return returns the resulting status for all tested attributes >+ * >+ * @since 3.3 >+ */ >+ public IStatus validateExtraAttribute(IPath containerPath, >+ IJavaProject project, >+ IClasspathAttribute extraAttribute) { >+ >+ if (canUpdateClasspathContainer(containerPath, project)) { >+ return Status.OK_STATUS; >+ } >+ return new JavaModelStatus(ATTRIBUTE_NOT_MODIFIABLE); >+ } >+ >+ /** >+ * Returns whether a source attachment may be updated >+ * on a container or not. >+ * <p> >+ * If the source attachment attribute is modifiable then the returned >+ * status is {@link IStatus#OK ok}. Otherwise, the returned status is in >+ * {@link IStatus#ERROR error} and its {@link IStatus#getCode() code} >+ * will have the {@link #ATTRIBUTE_NOT_MODIFIABLE} value. >+ * </p><p> >+ * The status message can contain more information. >+ * </p><p> >+ * If the subclass does not override this method, then default behavior is >+ * to return {@link IStatus#OK} if and only if the classpath container can >+ * be updated (see {@link #canUpdateClasspathContainer(IPath, IJavaProject)}). >+ * </p> >+ * >+ * @param containerPath the path of the container which requires to be >+ * updated >+ * @param project the project for which the container is to be updated >+ * @param path the source attachment path to validate >+ * @return returns the resulting status for all tested attributes >+ * >+ * @since 3.3 >+ */ >+ public IStatus validateSourceAttachment(IPath containerPath, >+ IJavaProject project, >+ IPath path) { >+ >+ if (canUpdateClasspathContainer(containerPath, project)) { >+ return Status.OK_STATUS; > } >+ return new JavaModelStatus(ATTRIBUTE_NOT_MODIFIABLE); > } > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 168077
:
59665
|
60315
|
60773
|
60979