Class JavaModel
- All Implemented Interfaces:
IBufferChangedListener, IJavaElement, IJavaModel, IOpenable, IParent, org.eclipse.core.runtime.IAdaptable
IJavaModel. The Java Model maintains a cache of active
IJavaProjects in a workspace. A Java Model is specific to a workspace.
To retrieve a workspace's model, use the
#getJavaModel() method.- See Also:
-
Field Summary
Fields inherited from class JavaElement
JEM_ANNOTATION, JEM_CLASSFILE, JEM_COMPILATIONUNIT, JEM_COUNT, JEM_DELIMITER_ESCAPE, JEM_ESCAPE, JEM_FIELD, JEM_IMPORTDECLARATION, JEM_INITIALIZER, JEM_JAVAPROJECT, JEM_LAMBDA_EXPRESSION, JEM_LAMBDA_METHOD, JEM_LOCALVARIABLE, JEM_METHOD, JEM_MODULAR_CLASSFILE, JEM_MODULE, JEM_PACKAGEDECLARATION, JEM_PACKAGEFRAGMENT, JEM_PACKAGEFRAGMENTROOT, JEM_STRING, JEM_TYPE, JEM_TYPE_PARAMETER, NO_ELEMENTS, NO_INFO, NO_STRINGSModifier and TypeFieldDescriptionstatic final charstatic final charstatic final charstatic final charstatic final charBefore ')','&'and '"' became the newest additions as delimiters, the former two were allowed as part of element attributes and possibly stored.static final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charprotected static final JavaElement[]protected static final Objectstatic final String[]Fields inherited from interface IJavaElement
ANNOTATION, CLASS_FILE, COMPILATION_UNIT, FIELD, IMPORT_CONTAINER, IMPORT_DECLARATION, INITIALIZER, JAVA_MODEL, JAVA_MODULE, JAVA_PROJECT, LOCAL_VARIABLE, METHOD, PACKAGE_DECLARATION, PACKAGE_FRAGMENT, PACKAGE_FRAGMENT_ROOT, TYPE, TYPE_PARAMETERModifier and TypeFieldDescriptionstatic final intConstant representing an annotation.static final intConstant representing a class file.static final intConstant representing a Java compilation unit.static final intConstant representing a field.static final intConstant representing all import declarations within a compilation unit.static final intConstant representing an import declaration within a compilation unit.static final intConstant representing a stand-alone instance or class initializer.static final intConstant representing a Java model (workspace level object).static final intConstant represents a module descriptor.static final intConstant representing a Java project.static final intConstant representing a local variable declaration.static final intConstant representing a method or constructor.static final intConstant representing a package declaration within a compilation unit.static final intConstant representing a package fragment.static final intConstant representing a package fragment root.static final intConstant representing a type (a class or interface).static final intConstant representing a type parameter declaration. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructs a new Java Model on the given workspace. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanbuildStructure(OpenableElementInfo info, org.eclipse.core.runtime.IProgressMonitor pm, Map newElements, org.eclipse.core.resources.IResource underlyingResource) Builds this element's structure and properties in the given info object, based on this element's current contents (reuse buffer contents if this element has an open buffer, or resource contents if this element does not have an open buffer).booleancontains(org.eclipse.core.resources.IResource resource) Returns whether this Java model contains anIJavaElementwhose resource is the given resource or a non-Java resource which is the given resource.voidcopy(IJavaElement[] elements, IJavaElement[] containers, IJavaElement[] siblings, String[] renamings, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) Copies the given elements to the specified container(s).protected JavaModelInfoReturns a new element info for this element.voiddelete(IJavaElement[] elements, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) Deletes the given elements, forcing the operation if necessary and specified.booleanReturns true if this handle represents the same Java element as the given handle.intReturns this element's kind encoded as an integer.static ObjectgetExternalTarget(org.eclipse.core.runtime.IPath path, boolean checkResourceExistence) static FileHelper method - returns theFileitem iftargetis a file (i.e., the target returnstruetoFile.isFile().getHandleFromMemento(String token, MementoTokenizer memento, WorkingCopyOwner owner) protected voidprotected charReturns thecharthat marks the start of this handles contribution to a memento.Returns the Java model.getJavaProject(String projectName) Returns the Java project with the given name.getJavaProject(org.eclipse.core.resources.IResource resource) Returns the active Java project associated with the specified resource, ornullif no Java project yet exists for the resource.Returns the Java projects in this Java model, or an empty array if there are none.Object[]Returns an array of non-Java resources (that is, non-Java projects) in the workspace.org.eclipse.core.runtime.IPathgetPath()Returns the path to the innermost resource enclosing this element.static ObjectgetTarget(IClasspathEntry entry, boolean checkResourceExistence) Return same as callinggetTarget(IPath, boolean)forIClasspathEntry.getPath()static ObjectgetTarget(IPackageFragmentRoot root, boolean checkResourceExistence) Return same as callinggetTarget(IPath, boolean)forIJavaElement.getPath()static ObjectgetTarget(org.eclipse.core.runtime.IPath path, boolean checkResourceExistence) Helper method - for the providedIPath, returns: If the path corresponds to an internal file or folder, theIResourcefor that resource If the path corresponds to an external folder linked throughExternalFoldersManager, theIFolderfor that folder If the path corresponds to an external library archive, theFilefor that archive Can returnnullifcheckResourceExistenceistrueand the entity referred to by the path does not exist on the file system Internal items must be referred to using container-relative paths.org.eclipse.core.resources.IResourceReturns the smallest underlying resource that contains this element, ornullif this element is not contained in a resource.org.eclipse.core.resources.IWorkspaceReturns the workbench associated with this object.static org.eclipse.core.resources.IResourcegetWorkspaceTarget(org.eclipse.core.runtime.IPath path) Helper method - returns theIResourcecorresponding to the providedIPath, ornullif no such resource exists.static booleanHelper method - returns whether an object is a file (i.e., it returnstruetoFile.isFile().static booleanstatic booleanvoidmove(IJavaElement[] elements, IJavaElement[] containers, IJavaElement[] siblings, String[] renamings, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) Moves the given elements to the specified container(s).voidrefreshExternalArchives(IJavaElement[] elementsScope, org.eclipse.core.runtime.IProgressMonitor monitor) Triggers an update of the JavaModel with respect to the referenced external archives.voidrename(IJavaElement[] elements, IJavaElement[] destinations, String[] renamings, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) Renames the given elements as specified.org.eclipse.core.resources.IResourceresource(PackageFragmentRoot root) protected voidrunOperation(MultiOperation op, IJavaElement[] elements, IJavaElement[] siblings, String[] renamings, org.eclipse.core.runtime.IProgressMonitor monitor) Configures and runs theMultiOperation.protected voidtoStringInfo(int tab, StringBuilder buffer, Object info, boolean showResolvedInfo) for debugging onlyprotected org.eclipse.core.runtime.IStatusvalidateExistence(org.eclipse.core.resources.IResource underlyingResource) Methods inherited from class Openable
bufferChanged, canBeRemovedFromCache, canBufferBeRemovedFromCache, closeBuffer, closing, codeComplete, codeSelect, exists, findRecommendedLineSeparator, generateInfos, getBuffer, getBufferFactory, getBufferManager, getCorrespondingResource, getOpenable, getPackageFragmentRoot, getResource, hasBuffer, hasUnsavedChanges, ignoreErrorStatus, isConsistent, isOpen, isSourceElement, isStructureKnown, makeConsistent, open, openAncestors, openBuffer, resource, resourceExists, saveModifier and TypeMethodDescriptionvoidbufferChanged(BufferChangedEvent event) The buffer associated with this element has changed.booleanbooleancanBufferBeRemovedFromCache(IBuffer buffer) protected voidClose the buffer associated with this element, if any.protected voidThis element is being closed.protected voidcodeComplete(ICompilationUnit cu, ICompilationUnit unitToSkip, int position, CompletionRequestor requestor, WorkingCopyOwner owner, ITypeRoot typeRoot, org.eclipse.core.runtime.IProgressMonitor monitor) protected IJavaElement[]codeSelect(ICompilationUnit cu, int offset, int length, WorkingCopyOwner owner) booleanexists()Returns whether this Java element exists in the model.Finds and returns the recommended line separator for this element.protected voidgenerateInfos(IElementInfo info, Map<IJavaElement, IElementInfo> newElements, org.eclipse.core.runtime.IProgressMonitor monitor) Generates the element infos for this element, its ancestors (if they are not opened) and its children (if it is an Openable).Note: a buffer with no unsaved changes can be closed by the Java Model since it has a finite number of buffers allowed open at one time.Deprecated.protected BufferManagerReturns the buffer manager for this element.org.eclipse.core.resources.IResourceReturn my underlying resource.Returns the first openable parent.Find enclosing package fragment root if anyorg.eclipse.core.resources.IResourceReturns the innermost resource enclosing this element.protected booleanReturns true if this element may have an associated source buffer, otherwise false.booleanReturnstrueif this element is open and: its buffer has unsaved changes, or one of its descendants has unsaved changes, or a working copy has been created on one of this element's children and has not yet destroyedprotected booleanignoreErrorStatus(org.eclipse.core.runtime.IStatus status) booleanSubclasses must override as required.booleanisOpen()Returns whether this openable is open.protected booleanReturns true if this represents a source element.booleanReturns whether the structure of this element is known.voidmakeConsistent(org.eclipse.core.runtime.IProgressMonitor monitor) Makes this element consistent with its underlying resource or buffer by updating the element's structure and properties as necessary.voidopen(org.eclipse.core.runtime.IProgressMonitor pm) Opens this element and all parent elements that are not already open.protected voidopenAncestors(Map<IJavaElement, IElementInfo> newElements, org.eclipse.core.runtime.IProgressMonitor monitor) protected IBufferopenBuffer(org.eclipse.core.runtime.IProgressMonitor pm, IElementInfo info) Opens a buffer on the contents of this element, and returns the buffer, or returnsnullif opening fails.org.eclipse.core.resources.IResourceresource()protected booleanresourceExists(org.eclipse.core.resources.IResource underlyingResource) Returns whether the corresponding resource or associated file existsvoidsave(org.eclipse.core.runtime.IProgressMonitor pm, boolean force) Saves any changes in this element's buffer to its underlying resource via a workspace resource operation.Methods inherited from class JavaElement
appendEscapedDelimiter, calculateHashCode, close, escapeMementoName, findNode, getAncestor, getAttachedJavadoc, getChildren, getChildrenOfType, getClassFile, getCompilationUnit, getElementInfo, getElementInfo, getElementName, getHandleFromMemento, getHandleIdentifier, getHandleMemento, getJavadocBaseLocation, getJavaProject, getLibraryJavadocLocation, getOpenableParent, getParent, getPrimaryElement, getPrimaryElement, getSchedulingRule, getSourceElementAt, getSourceMapper, getURLContents, hasChildren, hashCode, isAncestorOf, isReadOnly, newDoesNotExistStatus, newJavaModelException, newNotPresentException, openWhenClosed, readableName, resetHashCode, resolved, tabString, toDebugString, toString, toString, toStringAncestors, toStringChildren, toStringInfo, toStringName, toStringWithAncestors, toStringWithAncestors, unresolved, validateAndCacheModifier and TypeMethodDescriptionprotected voidappendEscapedDelimiter(StringBuilder buffer, char delimiter) protected intvoidclose()protected voidescapeMementoName(StringBuilder buffer, String mementoName) findNode(CompilationUnit ast) Returns theASTNodethat corresponds to thisJavaElementornullif there is no corresponding node.getAncestor(int ancestorType) Returns this Java element or the first ancestor of this element that has the given type.getAttachedJavadoc(org.eclipse.core.runtime.IProgressMonitor monitor) Returns the Javadoc as HTML source if this element has attached Javadoc,nullotherwise.getChildrenOfType(int type) Returns a collection of (immediate) children of this node of the specified type.Returns the info for this handle.getElementInfo(org.eclipse.core.runtime.IProgressMonitor monitor) Returns the info for this handle.Returns the name of this element.getHandleFromMemento(MementoTokenizer memento, WorkingCopyOwner owner) Returns a string representation of this element handle.protected URLReturns the Java project this element is contained in, ornullif this element is not contained in any Java project (for instance, theIJavaModelis not contained in any Java project).protected static URLReturn the first instance of IOpenable in the parent hierarchy of this element.Returns the element directly containing this element, ornullif this element has no parent.Returns the primary element (whose compilation unit is the primary compilation unit) this working copy element was created from, or this element if it is a descendant of a primary compilation unit or if it is not a descendant of a working copy (e.g.getPrimaryElement(boolean checkOwner) org.eclipse.core.runtime.jobs.ISchedulingRuleReturns the scheduling rule associated with this Java element.protected IJavaElementgetSourceElementAt(int position) Returns the element that is located at the given source position in this element.Returns the SourceMapper facility for this element, ornullif this element does not have a SourceMapper.protected StringgetURLContents(URL baseLoc, String docUrlValue) booleanfinal inthashCode()Returns the hash code for this Java element.booleanReturns true if this element is an ancestor of the given element, otherwise false.booleanReturns whether this Java element is read-only.protected JavaModelStatusnewJavaModelException(org.eclipse.core.runtime.IStatus status) Creates and returns a new Java model exception for this element with the given status.Creates and returns a new not present exception for this element.protected IElementInfoopenWhenClosed(IElementInfo info, boolean forceAdd, org.eclipse.core.runtime.IProgressMonitor monitor) protected voidshould not be needed but some implementations do have mutable member "occurrenceCount"protected StringtabString(int tab) Debugging purposestoString()Debugging purposesprotected voidtoString(int tab, StringBuilder buffer) Debugging purposesprotected voidtoStringAncestors(StringBuilder buffer) Debugging purposesprotected voidtoStringChildren(int tab, StringBuilder buffer, Object info) Debugging purposestoStringInfo(int tab, StringBuilder buffer) Debugging purposesprotected voidtoStringName(StringBuilder buffer) Debugging purposesDebugging purposestoStringWithAncestors(boolean showResolvedInfo) Debugging purposesprotected voidvalidateAndCache(URL baseLoc, FileNotFoundException e) Methods inherited from class org.eclipse.core.runtime.PlatformObject
getAdapterMethods inherited from interface IParent
getChildren, hasChildrenModifier and TypeMethodDescriptionReturns the immediate children of this element.booleanReturns whether this element has one or more immediate children.
-
Constructor Details
-
JavaModel
-
-
Method Details
-
buildStructure
protected boolean buildStructure(OpenableElementInfo info, org.eclipse.core.runtime.IProgressMonitor pm, Map newElements, org.eclipse.core.resources.IResource underlyingResource) Description copied from class:OpenableBuilds this element's structure and properties in the given info object, based on this element's current contents (reuse buffer contents if this element has an open buffer, or resource contents if this element does not have an open buffer). Children are placed in the given newElements table (note, this element has already been placed in the newElements table). Returns true if successful, or false if an error is encountered while determining the structure of this element.- Specified by:
buildStructurein classOpenable
-
contains
public boolean contains(org.eclipse.core.resources.IResource resource) Description copied from interface:IJavaModelReturns whether this Java model contains anIJavaElementwhose resource is the given resource or a non-Java resource which is the given resource.Note: no existency check is performed on the argument resource. If it is not accessible (see
IResource.isAccessible()) yet but would be located in Java model range, then it will returntrue.If the resource is accessible, it can be reached by navigating the Java model down using the
getChildren()and/orgetNonJavaResources()methods.- Specified by:
containsin interfaceIJavaModel- Parameters:
resource- the resource to check- Returns:
- true if the resource is accessible through the Java model
-
copy
public void copy(IJavaElement[] elements, IJavaElement[] containers, IJavaElement[] siblings, String[] renamings, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException Description copied from interface:IJavaModelCopies the given elements to the specified container(s). If one container is specified, all elements are copied to that container. If more than one container is specified, the number of elements and containers must match, and each element is copied to its associated container.Optionally, each copy can positioned before a sibling element. If
nullis specified for a given sibling, the copy is inserted as the last child of its associated container.Optionally, each copy can be renamed. If
nullis specified for the new name, the copy is not renamed.Optionally, any existing child in the destination container with the same name can be replaced by specifying
truefor force. Otherwise an exception is thrown in the event that a name collision occurs.- Specified by:
copyin interfaceIJavaModel- Parameters:
elements- the elements to copycontainers- the container, or list of containerssiblings- the list of siblings element any of which may benull; ornullrenamings- the list of new names any of which may benull; ornullforce-trueif any existing child in a target container with the target name should be replaced, andfalseto throw an exception in the event of a name collisionmonitor- a progress monitor- Throws:
JavaModelException- if an element could not be copied. Reasons include:- There is no element to process (NO_ELEMENTS_TO_PROCESS). The given elements is null or empty
- A specified element, container, or sibling does not exist (ELEMENT_DOES_NOT_EXIST)
- A
CoreExceptionoccurred while updating an underlying resource - A container is of an incompatible type (
INVALID_DESTINATION) - A sibling is not a child of it associated container (
INVALID_SIBLING) - A new name is invalid (
INVALID_NAME) - A child in its associated container already exists with the same
name and
replacehas been specified asfalse(NAME_COLLISION) - A container or element is read-only (
READ_ONLY)
- See Also:
-
createElementInfo
Returns a new element info for this element.- Overrides:
createElementInfoin classOpenable
-
delete
public void delete(IJavaElement[] elements, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException Description copied from interface:IJavaModelDeletes the given elements, forcing the operation if necessary and specified.- Specified by:
deletein interfaceIJavaModel- Parameters:
elements- the elements to deleteforce- a flag controlling whether underlying resources that are not in sync with the local file system will be toleratedmonitor- a progress monitor- Throws:
JavaModelException- if an element could not be deleted. Reasons include:- There is no element to process (NO_ELEMENTS_TO_PROCESS). The given elements is null or empty
- A specified element does not exist (ELEMENT_DOES_NOT_EXIST)
- A
CoreExceptionoccurred while updating an underlying resource - An element is read-only (
READ_ONLY)
- See Also:
-
equals
Description copied from class:JavaElementReturns true if this handle represents the same Java element as the given handle. By default, two handles represent the same element if they are identical or if they represent the same type of element, have equal names, parents, and occurrence counts.If a subclass has other requirements for equality, this method must be overridden.
- Overrides:
equalsin classJavaElement- See Also:
-
getElementType
public int getElementType()Description copied from interface:IJavaElementReturns this element's kind encoded as an integer. This is a handle-only method.- Specified by:
getElementTypein interfaceIJavaElement- Returns:
- the kind of element; one of the constants declared in
IJavaElement - See Also:
-
getHandleFromMemento
public IJavaElement getHandleFromMemento(String token, MementoTokenizer memento, WorkingCopyOwner owner) - Specified by:
getHandleFromMementoin classJavaElement
-
getHandleMemento
- Overrides:
getHandleMementoin classJavaElement- See Also:
-
getHandleMementoDelimiter
protected char getHandleMementoDelimiter()Returns thecharthat marks the start of this handles contribution to a memento.- Specified by:
getHandleMementoDelimiterin classJavaElement
-
getJavaProject
Description copied from interface:IJavaModelReturns the Java project with the given name. The given name must be a valid path segment as defined byIPath.isValidSegment(String). This is a handle-only method. The project may or may not exist.- Specified by:
getJavaProjectin interfaceIJavaModel- Parameters:
projectName- the name of the Java project- Returns:
- the Java project with the given name
- See Also:
-
getJavaModel
Description copied from interface:IJavaElementReturns the Java model. This is a handle-only method.- Specified by:
getJavaModelin interfaceIJavaElement- Overrides:
getJavaModelin classJavaElement- Returns:
- the Java model
- See Also:
-
getJavaProject
Returns the active Java project associated with the specified resource, ornullif no Java project yet exists for the resource.- Throws:
IllegalArgumentException- if the given resource is not one of an IProject, IFolder, or IFile.
-
getJavaProjects
Description copied from interface:IJavaModelReturns the Java projects in this Java model, or an empty array if there are none.- Specified by:
getJavaProjectsin interfaceIJavaModel- Returns:
- the Java projects in this Java model, or an empty array if there are none
- Throws:
JavaModelException- if this request fails.- See Also:
-
getNonJavaResources
Description copied from interface:IJavaModelReturns an array of non-Java resources (that is, non-Java projects) in the workspace.Non-Java projects include all projects that are closed (even if they have the Java nature).
- Specified by:
getNonJavaResourcesin interfaceIJavaModel- Returns:
- an array of non-Java projects (
IProjects) contained in the workspace. - Throws:
JavaModelException- if this element does not exist or if an exception occurs while accessing its corresponding resource- See Also:
-
getPath
public org.eclipse.core.runtime.IPath getPath()Description copied from interface:IJavaElementReturns the path to the innermost resource enclosing this element. If this element is not included in an external library, the path returned is the full, absolute path to the underlying resource, relative to the workbench. If this element is included in an external library, the path returned is the absolute path to the archive or to the folder in the file system. This is a handle-only method.- Specified by:
getPathin interfaceIJavaElement- Returns:
- the path to the innermost resource enclosing this element
-
resource
-
getUnderlyingResource
public org.eclipse.core.resources.IResource getUnderlyingResource()Description copied from interface:IJavaElementReturns the smallest underlying resource that contains this element, ornullif this element is not contained in a resource.- Specified by:
getUnderlyingResourcein interfaceIJavaElement- Overrides:
getUnderlyingResourcein classOpenable- Returns:
- the underlying resource, or
nullif none - See Also:
-
getWorkspace
public org.eclipse.core.resources.IWorkspace getWorkspace()Returns the workbench associated with this object.- Specified by:
getWorkspacein interfaceIJavaModel- Returns:
- the workspace associated with this Java model
-
move
public void move(IJavaElement[] elements, IJavaElement[] containers, IJavaElement[] siblings, String[] renamings, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException Description copied from interface:IJavaModelMoves the given elements to the specified container(s). If one container is specified, all elements are moved to that container. If more than one container is specified, the number of elements and containers must match, and each element is moved to its associated container.Optionally, each element can positioned before a sibling element. If
nullis specified for sibling, the element is inserted as the last child of its associated container.Optionally, each element can be renamed. If
nullis specified for the new name, the element is not renamed.Optionally, any existing child in the destination container with the same name can be replaced by specifying
truefor force. Otherwise an exception is thrown in the event that a name collision occurs.- Specified by:
movein interfaceIJavaModel- Parameters:
elements- the elements to movecontainers- the container, or list of containerssiblings- the list of siblings element any of which may benull; ornullrenamings- the list of new names any of which may benull; ornullforce-trueif any existing child in a target container with the target name should be replaced, andfalseto throw an exception in the event of a name collisionmonitor- a progress monitor- Throws:
JavaModelException- if an element could not be moved. Reasons include:- There is no element to process (NO_ELEMENTS_TO_PROCESS). The given elements is null or empty
- A specified element, container, or sibling does not exist (ELEMENT_DOES_NOT_EXIST)
- A
CoreExceptionoccurred while updating an underlying resource - A container is of an incompatible type (
INVALID_DESTINATION) - A sibling is not a child of it associated container (
INVALID_SIBLING) - A new name is invalid (
INVALID_NAME) - A child in its associated container already exists with the same
name and
replacehas been specified asfalse(NAME_COLLISION) - A container or element is read-only (
READ_ONLY)
- See Also:
-
refreshExternalArchives
public void refreshExternalArchives(IJavaElement[] elementsScope, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException Description copied from interface:IJavaModelTriggers an update of the JavaModel with respect to the referenced external archives. This operation will issue a JavaModel delta describing the discovered changes, in term of Java element package fragment roots added, removed or changed. Note that a collection of elements can be passed so as to narrow the set of archives to refresh (passingnullalong is equivalent to refreshing the entire mode). The elements can be:- package fragment roots corresponding to external archives
- Java projects, which referenced external archives will be refreshed
- Java model, all referenced external archives will be refreshed.
In case an archive is used by multiple projects, the delta issued will account for all of them. This means that even if a project was not part of the elements scope, it may still be notified of changes if it is referencing a library comprised in the scope.
Since 3.7, a project refresh automatically triggers a refresh of external archives. Hence, this method doesn't need to be explicitly called after a project refresh.
- Specified by:
refreshExternalArchivesin interfaceIJavaModel- Parameters:
elementsScope- - a collection of elements defining the scope of the refreshmonitor- - a progress monitor used to report progress- Throws:
JavaModelException- in one of the corresponding situation:- an exception occurs while accessing project resources
- See Also:
-
rename
public void rename(IJavaElement[] elements, IJavaElement[] destinations, String[] renamings, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException Description copied from interface:IJavaModelRenames the given elements as specified. If one container is specified, all elements are renamed within that container. If more than one container is specified, the number of elements and containers must match, and each element is renamed within its associated container.- Specified by:
renamein interfaceIJavaModel- Parameters:
elements- the elements to renamedestinations- the container, or list of containersrenamings- the list of new namesforce-trueif an existing child in a target container with the target name should be replaced, andfalseto throw an exception in the event of a name collisionmonitor- a progress monitor- Throws:
JavaModelException- if an element could not be renamed. Reasons include:- There is no element to process (NO_ELEMENTS_TO_PROCESS). The given elements is null or empty
- A specified element does not exist (ELEMENT_DOES_NOT_EXIST)
- A
CoreExceptionoccurred while updating an underlying resource - A new name is invalid (
INVALID_NAME) - A child already exists with the same name and
replacehas been specified asfalse(NAME_COLLISION) - An element is read-only (
READ_ONLY)
- See Also:
-
runOperation
protected void runOperation(MultiOperation op, IJavaElement[] elements, IJavaElement[] siblings, String[] renamings, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException Configures and runs theMultiOperation.- Throws:
JavaModelException
-
toStringInfo
for debugging only- Overrides:
toStringInfoin classJavaElement- Parameters:
showResolvedInfo- TODO
-
getTarget
Helper method - for the providedIPath, returns:- If the path corresponds to an internal file or folder, the
IResourcefor that resource - If the path corresponds to an external folder linked through
ExternalFoldersManager, theIFolderfor that folder - If the path corresponds to an external library archive, the
Filefor that archive - Can return
nullifcheckResourceExistenceistrueand the entity referred to by the path does not exist on the file system
- If the path corresponds to an internal file or folder, the
-
getTarget
Return same as callinggetTarget(IPath, boolean)forIClasspathEntry.getPath() -
getTarget
Return same as callinggetTarget(IPath, boolean)forIJavaElement.getPath() -
getWorkspaceTarget
public static org.eclipse.core.resources.IResource getWorkspaceTarget(org.eclipse.core.runtime.IPath path) Helper method - returns theIResourcecorresponding to the providedIPath, ornullif no such resource exists. -
getExternalTarget
public static Object getExternalTarget(org.eclipse.core.runtime.IPath path, boolean checkResourceExistence) Helper method - returns either the linkedIFolderor theFilecorresponding to the providedIPath. IfcheckResourceExistenceisfalse, then the IFolder or File object is always returned, otherwisenullis returned if it does not exist on the file system. -
isFile
Helper method - returns whether an object is a file (i.e., it returnstruetoFile.isFile(). -
isJimage
-
isJmod
-
getFile
Helper method - returns theFileitem iftargetis a file (i.e., the target returnstruetoFile.isFile(). Otherwise returnsnull. -
validateExistence
protected org.eclipse.core.runtime.IStatus validateExistence(org.eclipse.core.resources.IResource underlyingResource) - Specified by:
validateExistencein classOpenable
-