public abstract class JsGlobalScopeContainerInitializer extends java.lang.Object implements IJsGlobalScopeContainerInitializer, IJsGlobalScopeContainer
Clients should subclass this class to implement a specific includepath
container initializer. The subclass must have a public 0-argument
constructor and a concrete implementation of initialize
.
Multiple includepath containers can be registered, each of them declares the container ID they can handle, so as to narrow the set of containers they can resolve, in other words, a container initializer is guaranteed to only be activated to resolve containers which match the ID they registered onto.
In case multiple container initializers collide on the same container ID, the first registered one will be invoked.
IIncludePathEntry
,
Provisional API: This class/interface is part of an interim API that is still under development and expected to
change significantly before reaching stability. It is being made available at this early stage to solicit feedback
from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
(repeatedly) as the API evolves.
Modifier and Type | Field and Description |
---|---|
static int |
ATTRIBUTE_NOT_SUPPORTED
Status code indicating that an attribute is not supported.
|
static int |
ATTRIBUTE_READ_ONLY
Status code indicating that an attribute is not modifiable.
|
K_APPLICATION, K_DEFAULT_SYSTEM, K_SYSTEM
Constructor and Description |
---|
JsGlobalScopeContainerInitializer()
Creates a new includepath container initializer.
|
Modifier and Type | Method and Description |
---|---|
boolean |
allowAttachJsDoc() |
boolean |
canUpdateJsGlobalScopeContainer(IPath containerPath,
IJavaScriptProject project)
Returns
true if this container initializer can be requested to perform updates
on its own container values. |
java.lang.String[] |
containerSuperTypes()
returns a String of all SuperTypes provided by this library.
|
IStatus |
getAccessRulesStatus(IPath containerPath,
IJavaScriptProject project)
Returns the access rules attribute status according to this initializer.
|
IStatus |
getAttributeStatus(IPath containerPath,
IJavaScriptProject project,
java.lang.String attributeKey)
Returns the extra attribute status according to this initializer.
|
java.lang.Object |
getComparisonID(IPath containerPath,
IJavaScriptProject project)
Returns an object which identifies a container for comparison purpose.
|
protected IJsGlobalScopeContainer |
getContainer(IPath containerPath,
IJavaScriptProject project) |
java.lang.String |
getDescription()
Answers a readable description of this container
|
java.lang.String |
getDescription(IPath containerPath,
IJavaScriptProject project)
Returns a readable description for a container path.
|
IJsGlobalScopeContainer |
getFailureContainer(IPath containerPath,
IJavaScriptProject project)
Returns a includepath container that is used after this initializer failed to bind a includepath container
to a
IJsGlobalScopeContainer for the given project. |
java.net.URI |
getHostPath(IPath path,
IJavaScriptProject project) |
IIncludePathEntry[] |
getIncludepathEntries()
Answers the set of includepath entries this container is mapping to.
|
java.lang.String |
getInferenceID()
Get the id of the inference provider for this library
|
int |
getKind()
Answers the kind of this container.
|
IPath |
getPath()
Answers the container path identifying this container.
|
IStatus |
getSourceAttachmentStatus(IPath containerPath,
IJavaScriptProject project)
Returns the source attachment attribute status according to this initializer.
|
void |
initialize(IPath containerPath,
IJavaScriptProject project)
Binds a includepath container to a
IJsGlobalScopeContainer for a given project,
or silently fails if unable to do so. |
void |
removeFromProject(IJavaScriptProject project) |
void |
requestJsGlobalScopeContainerUpdate(IPath containerPath,
IJavaScriptProject project,
IJsGlobalScopeContainer containerSuggestion)
Request a registered container definition to be updated according to a container suggestion.
|
java.lang.String[] |
resolvedLibraryImport(java.lang.String realImport) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getLibraryLocation
public static final int ATTRIBUTE_NOT_SUPPORTED
public static final int ATTRIBUTE_READ_ONLY
public JsGlobalScopeContainerInitializer()
public void initialize(IPath containerPath, IJavaScriptProject project) throws CoreException
IJsGlobalScopeContainerInitializer
IJsGlobalScopeContainer
for a given project,
or silently fails if unable to do so.
A container is identified by a container path, which must be formed of two segments. The first segment is used as a unique identifier (which this initializer did register onto), and the second segment can be used as an additional hint when performing the resolution.
The initializer is invoked if a container path needs to be resolved for a given project, and no
value for it was recorded so far. The implementation of the initializer would typically set the
corresponding container using JavaScriptCore#setJsGlobalScopeContainer
.
A container initialization can be indirectly performed while attempting to resolve a project
includepath using IJavaScriptProject#getResolvedClasspath(
; or directly when using
JavaScriptCore#getJsGlobalScopeContainer
. During the initialization process, any attempt
to further obtain the same container will simply return null
so as to avoid an
infinite regression of initializations.
A container initialization may also occur indirectly when setting a project includepath, as the operation needs to resolve the includepath for validation purpose. While the operation is in progress, a referenced container initializer may be invoked. If the initializer further tries to access the referring project includepath, it will not see the new assigned includepath until the operation has completed. Note that once the JavaScript change notification occurs (at the end of the operation), the model has been updated, and the project includepath can be queried normally.
This method is called by the JavaScript model to give the party that defined this particular kind of includepath container the chance to install includepath container objects that will be used to convert includepath container entries into simpler includepath entries. The method is typically called exactly once for a given JavaScript project and includepath container entry. This method must not be called by other clients.
There are a wide variety of conditions under which this method may be invoked. To ensure that the implementation does not interfere with correct functioning of the JavaScript model, the implementation should use only the following JavaScript model APIs:
JavaScriptCore#setJsGlobalScopeContainer(IPath, IJavaScriptProject[], IJsGlobalScopeContainer[], org.eclipse.core.runtime.IProgressMonitor)
JavaScriptCore.getJsGlobalScopeContainer(IPath, IJavaScriptProject)
JavaScriptCore#create(org.eclipse.core.resources.IWorkspaceRoot)
JavaScriptCore#create(org.eclipse.core.resources.IProject)
IJavaScriptModel.getJavaScriptProjects()
initialize
in interface IJsGlobalScopeContainerInitializer
containerPath
- a two-segment path (ID/hint) identifying the container that needs
to be resolvedproject
- the JavaScript project in which context the container is to be resolved.
This allows generic containers to be bound with project specific values.CoreException
- if an exception occurs during the initializationJavaScriptCore.getJsGlobalScopeContainer(IPath, IJavaScriptProject)
,
JavaScriptCore#setJsGlobalScopeContainer(IPath, IJavaScriptProject[], IJsGlobalScopeContainer[], org.eclipse.core.runtime.IProgressMonitor)
,
IJsGlobalScopeContainer
protected IJsGlobalScopeContainer getContainer(IPath containerPath, IJavaScriptProject project)
public boolean canUpdateJsGlobalScopeContainer(IPath containerPath, IJavaScriptProject project)
IJsGlobalScopeContainerInitializer
true
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
JsGlobalScopeContainerInitializer#requestJsGlobalScopeContainerUpdate
/
canUpdateJsGlobalScopeContainer
in interface IJsGlobalScopeContainerInitializer
containerPath
- the path of the container which requires to be updatedproject
- the project for which the container is to be updatedtrue
if the container can be updatedpublic void requestJsGlobalScopeContainerUpdate(IPath containerPath, IJavaScriptProject project, IJsGlobalScopeContainer containerSuggestion) throws CoreException
IJsGlobalScopeContainerInitializer
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
JavaScriptCore#setJsGlobalScopeContainer(IPath, IJavaScriptProject[], IJsGlobalScopeContainer[], IProgressMonitor)
.
Until it does so, the update will not be reflected in the JavaScript Model.
In order to anticipate whether the container initializer allows to update its containers, the predicate
JavaScriptCore#canUpdateJsGlobalScopeContainer
should be used.
requestJsGlobalScopeContainerUpdate
in interface IJsGlobalScopeContainerInitializer
containerPath
- the path of the container which requires to be updatedproject
- the project for which the container is to be updatedcontainerSuggestion
- a suggestion to update the corresponding container definitionCoreException
- when JavaScriptCore#setJsGlobalScopeContainer
would throw any.JavaScriptCore#setJsGlobalScopeContainer(IPath, IJavaScriptProject[], IJsGlobalScopeContainer[], org.eclipse.core.runtime.IProgressMonitor)
,
canUpdateJsGlobalScopeContainer(IPath, IJavaScriptProject)
public java.lang.String getDescription(IPath containerPath, IJavaScriptProject project)
IJsGlobalScopeContainerInitializer
IJsGlobalScopeContainer.getDescription()
).getDescription
in interface IJsGlobalScopeContainerInitializer
containerPath
- the path of the container which requires a readable descriptionproject
- the project from which the container is referencedpublic IJsGlobalScopeContainer getFailureContainer(IPath containerPath, IJavaScriptProject project)
IJsGlobalScopeContainerInitializer
IJsGlobalScopeContainer
for the given project. A non-null
failure container indicates that there will be no more request to initialize the given container
for the given project.
By default a non-null
failure container with no includepath entries is returned.
Clients wishing to get a chance to run the initializer again should override this method
and return null
.
getFailureContainer
in interface IJsGlobalScopeContainerInitializer
containerPath
- the path of the container which failed to initializeproject
- the project from which the container is referencednull
if wishing to run the initializer againpublic java.lang.Object getComparisonID(IPath containerPath, IJavaScriptProject project)
IJsGlobalScopeContainerInitializer
getComparisonID
in interface IJsGlobalScopeContainerInitializer
containerPath
- the path of the container which is being checkedproject
- the project for which the container is to being checkedpublic java.net.URI getHostPath(IPath path, IJavaScriptProject project)
getHostPath
in interface IJsGlobalScopeContainerInitializer
public boolean allowAttachJsDoc()
allowAttachJsDoc
in interface IJsGlobalScopeContainerInitializer
public java.lang.String[] containerSuperTypes()
IJsGlobalScopeContainerInitializer
containerSuperTypes
in interface IJsGlobalScopeContainerInitializer
public java.lang.String[] resolvedLibraryImport(java.lang.String realImport)
resolvedLibraryImport
in interface IJsGlobalScopeContainer
public IIncludePathEntry[] getIncludepathEntries()
IJsGlobalScopeContainer
The set of entries associated with a includepath container may contain any of the following:
CPE_LIBRARY
) CPE_PROJECT
) This method is called by the JavaScript model when it needs to resolve this includepath container entry into a list of library and project entries. The method is typically called exactly once for a given JavaScript project, and the resulting list of entries cached internally by the JavaScript model. This method must not be called by other clients.
There are a wide variety of conditions under which this method may be invoked. To ensure that the implementation does not interfere with correct functioning of the JavaScript model, the implementation should use only the following JavaScript model APIs:
JavaScriptCore.newLibraryEntry(IPath, IPath, IPath, boolean)
and variantsJavaScriptCore.newProjectEntry(IPath, boolean)
and variantsJavaScriptCore#create(org.eclipse.core.resources.IWorkspaceRoot)
JavaScriptCore#create(org.eclipse.core.resources.IProject)
IJavaScriptModel.getJavaScriptProjects()
IJavaScriptProject.getRawIncludepath()
IJavaScriptProject.readRawIncludepath()
IJavaScriptProject#getOutputLocation()
IJavaScriptProject#readOutputLocation()
getIncludepathEntries
in interface IJsGlobalScopeContainer
IIncludePathEntry
public java.lang.String getDescription()
IJsGlobalScopeContainer
getDescription
in interface IJsGlobalScopeContainer
public int getKind()
IJsGlobalScopeContainer
K_APPLICATION
if this container maps to an application libraryK_SYSTEM
if this container maps to a system libraryK_DEFAULT_SYSTEM
if this container maps to a default system library (library
implicitly contributed by the runtime).getKind
in interface IJsGlobalScopeContainer
public IPath getPath()
IJsGlobalScopeContainer
The container ID is also used to identify aJsGlobalScopeContainerInitializer
registered on the extension point "org.eclipse.wst.jsdt.core.JsGlobalScopeContainerInitializer", which can
be invoked if needing to resolve the container before it is explicitly set.
getPath
in interface IJsGlobalScopeContainer
public IStatus getAccessRulesStatus(IPath containerPath, IJavaScriptProject project)
The returned status
can have one of the following severities:
OK
: means that the attribute is supported
and is modifiableERROR
: means that either the attribute
is not supported or is not modifiable.code
will have
respectively the ATTRIBUTE_NOT_SUPPORTED
value
or the ATTRIBUTE_READ_ONLY
value.The status message can contain more information.
If the subclass does not override this method, then the default behavior is
to return OK
if and only if the includepath container can
be updated (see canUpdateJsGlobalScopeContainer(IPath, IJavaScriptProject)
).
containerPath
- the path of the container which requires to be
updatedproject
- the project for which the container is to be updatedpublic IStatus getAttributeStatus(IPath containerPath, IJavaScriptProject project, java.lang.String attributeKey)
The returned status
can have one of the following severities:
OK
: means that the attribute is supported
and is modifiableERROR
: means that either the attribute
is not supported or is not modifiable.code
will have
respectively the ATTRIBUTE_NOT_SUPPORTED
value
or the ATTRIBUTE_READ_ONLY
value.The status message can contain more information.
If the subclass does not override this method, then the default behavior is
to return OK
if and only if the includepath container can
be updated (see canUpdateJsGlobalScopeContainer(IPath, IJavaScriptProject)
).
containerPath
- the path of the container which requires to be
updatedproject
- the project for which the container is to be updatedattributeKey
- the key of the extra attributeIIncludePathAttribute
public IStatus getSourceAttachmentStatus(IPath containerPath, IJavaScriptProject project)
The returned status
can have one of the following severities:
OK
: means that the attribute is supported
and is modifiableERROR
: means that either the attribute
is not supported or is not modifiable.code
will have
respectively the ATTRIBUTE_NOT_SUPPORTED
value
or the ATTRIBUTE_READ_ONLY
value.The status message can contain more information.
If the subclass does not override this method, then the default behavior is
to return OK
if and only if the includepath container can
be updated (see canUpdateJsGlobalScopeContainer(IPath, IJavaScriptProject)
).
containerPath
- the path of the container which requires to be
updatedproject
- the project for which the container is to be updatedpublic java.lang.String getInferenceID()
IJsGlobalScopeContainerInitializer
getInferenceID
in interface IJsGlobalScopeContainerInitializer
public void removeFromProject(IJavaScriptProject project)
removeFromProject
in interface IJsGlobalScopeContainerInitializer
Copyright (c) IBM Corp. and others 2000, 2016. All Rights Reserved.