Interface IElementImpl
- All Superinterfaces:
IElement
- All Known Subinterfaces:
IElementImplExtension
,IElementImplSupport
,ISourceConstructImpl
,ISourceConstructImplExtension
,ISourceConstructImplSupport
,ISourceElementImpl
,ISourceElementImplSupport
,ISourceFileImpl
,ISourceFileImplExtension
,ISourceFileImplSupport
- All Known Implementing Classes:
BaseSourceFile
,Element
,FsSourceFile
,SourceConstruct
,SourceFile
,WorkspaceSourceFile
IElement
s must implement this interface.- Restriction:
- This interface is not intended to be extended by clients.
-
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
Returns whether this element is equal to the given element and belongs to the same parent chain as the given element.boolean
exists_()
Returns whether this element exists in the model.default void
fetchChildren_
(IContext context, ICollector<? super IElement> collector, org.eclipse.core.runtime.IProgressMonitor monitor) Adds the immediate children of this element to the given collector.default <T> void
fetchChildrenOfType_
(Class<T> type, IContext context, ICollector<? super T> collector, org.eclipse.core.runtime.IProgressMonitor monitor) Adds the immediate children of this element that have the given type to the given collector.IElement[]
getChildren_
(IContext context, org.eclipse.core.runtime.IProgressMonitor monitor) Returns the immediate children of this element.default <T> T[]
getChildrenOfType_
(Class<T> type, IContext context, org.eclipse.core.runtime.IProgressMonitor monitor) Returns the immediate children of this element that have the given type.default String
Returns a string representation of this element handle that can be used to recreate the handle via the model'sIElementHandleFactory
.default URI
Returns a file system location for this element.Returns the model that owns this element.getName_()
Returns the name of this element, ornull
if this element has no name.Returns the element directly containing this element, ornull
if this element has no parent.default org.eclipse.core.resources.IResource
Returns the innermost resource enclosing this element, ornull
if this element is not enclosed in a workspace resource.default IElement
getRoot_()
Returns the root element containing this element.default String
toDisplayString_
(IContext context) Returns a string representation of this element in a form suitable for displaying to the user, e.g., in message dialogs.Returns a string representation of this element in a form suitable for debugging purposes.
-
Method Details
-
getName_
String getName_()Returns the name of this element, ornull
if this element has no name. This is a handle-only method.- Returns:
- the element name, or
null
if this element has no name
-
getParent_
IElement getParent_()Returns the element directly containing this element, ornull
if this element has no parent. This is a handle-only method.- Returns:
- the parent element, or
null
if this element has no parent
-
getRoot_
Returns the root element containing this element. Returns this element if it has no parent. This is a handle-only method.- Returns:
- the root element (never
null
)
-
equalsAndSameParentChain_
Returns whether this element is equal to the given element and belongs to the same parent chain as the given element. This is a handle-only method.This implementation accounts for the most general case where equal elements may belong to different parent chains. For example, in JDT, equal JarPackageFragmentRoots may belong to different Java projects. Specific models can provide an optimized implementation. For example, it would be possible to just return
equals(other)
if it were known for a model that equal elements might not belong to different parent chains.- Parameters:
other
- may benull
- Returns:
true
if this element is equal to the given element and belongs to the same parent chain, andfalse
otherwise
-
getModel_
IModel getModel_()Returns the model that owns this element. This is a handle-only method.- Returns:
- the element's model (never
null
)
-
getHandleMemento_
Returns a string representation of this element handle that can be used to recreate the handle via the model'sIElementHandleFactory
. The format of the string is not specified, but the representation is stable across workbench sessions. This is a handle-only method.- Returns:
- the handle memento for this element, or
null
if this element is unable to provide a handle memento
-
getResource_
default org.eclipse.core.resources.IResource getResource_()Returns the innermost resource enclosing this element, ornull
if this element is not enclosed in a workspace resource. This is a handle-only method.Note that it is safe to call this method and test the return value for
null
even whenorg.eclipse.core.resources
bundle is not available.Since 1.3, this method is no longer abstract. The default implementation always returns
null
.- Returns:
- the innermost resource enclosing this element, or
null
if this element is not enclosed in a workspace resource
-
getLocationUri_
Returns a file system location for this element. The resulting URI is suitable to passing toEFS.getStore(URI)
. Returnsnull
if no location can be determined.- Returns:
- a file system location for this element,
or
null
if no location can be determined
-
exists_
boolean exists_()Returns whether this element exists in the model.Handles may or may not be backed by an actual element. Handles that are backed by an actual element are said to "exist".
- Returns:
true
if this element exists in the model, andfalse
if this element does not exist
-
getChildren_
IElement[] getChildren_(IContext context, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException Returns the immediate children of this element. Unless otherwise specified by the implementing element, the children are in no particular order.- Parameters:
context
- the operation context (notnull
)monitor
- a progress monitor, ornull
if progress reporting is not desired. The caller must not rely onIProgressMonitor.done()
having been called by the receiver- Returns:
- the immediate children of this element (never
null
). Clients must not modify the returned array. - Throws:
org.eclipse.core.runtime.CoreException
- if this element does not exist or if an exception occurs while accessing its corresponding resource
-
getChildrenOfType_
default <T> T[] getChildrenOfType_(Class<T> type, IContext context, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException Returns the immediate children of this element that have the given type. Unless otherwise specified by the implementing element, the children are in no particular order.- Parameters:
type
- notnull
context
- the operation context (notnull
)monitor
- a progress monitor, ornull
if progress reporting is not desired. The caller must not rely onIProgressMonitor.done()
having been called by the receiver- Returns:
- the immediate children of this element that have the given type
(never
null
). Clients must not modify the returned array. - Throws:
org.eclipse.core.runtime.CoreException
- if this element does not exist or if an exception occurs while accessing its corresponding resource
-
fetchChildren_
default void fetchChildren_(IContext context, ICollector<? super IElement> collector, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException Adds the immediate children of this element to the given collector. Unless otherwise specified by the implementing element, the children are added in no particular order.- Parameters:
context
- the operation context (notnull
)collector
- the element collector (notnull
)monitor
- a progress monitor, ornull
if progress reporting is not desired. The caller must not rely onIProgressMonitor.done()
having been called by the receiver- Throws:
org.eclipse.core.runtime.CoreException
- if this element does not exist or if an exception occurs while accessing its corresponding resourceorg.eclipse.core.runtime.OperationCanceledException
- if this method is canceled- Since:
- 1.5
-
fetchChildrenOfType_
default <T> void fetchChildrenOfType_(Class<T> type, IContext context, ICollector<? super T> collector, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException Adds the immediate children of this element that have the given type to the given collector. Unless otherwise specified by the implementing element, the children are added in no particular order.- Parameters:
type
- notnull
context
- the operation context (notnull
)collector
- the element collector (notnull
)monitor
- a progress monitor, ornull
if progress reporting is not desired. The caller must not rely onIProgressMonitor.done()
having been called by the receiver- Throws:
org.eclipse.core.runtime.CoreException
- if this element does not exist or if an exception occurs while accessing its corresponding resourceorg.eclipse.core.runtime.OperationCanceledException
- if this method is canceled- Since:
- 1.5
-
toString_
Returns a string representation of this element in a form suitable for debugging purposes. Clients can influence the result with format options specified in the given context; unrecognized options are ignored and an empty context is permitted.Implementations are encouraged to support common options defined in
ToStringOptions
and interpret theFORMAT_STYLE
as follows:- Parameters:
context
- notnull
- Returns:
- a string representation of this element (never
null
)
-
toDisplayString_
Returns a string representation of this element in a form suitable for displaying to the user, e.g., in message dialogs. Clients can influence the result with format options specified in the given context; unrecognized options are ignored and an empty context is permitted.Implementations are encouraged to support common options defined in
ToStringOptions
and may interpret theFORMAT_STYLE
as they see fit in a way that is specific to the model. No hard rules apply, but usually the string representation does not list the element's children regardless of the format style, and aFULL
representation fully identifies the element within the model.- Parameters:
context
- notnull
- Returns:
- a string representation of this element (never
null
)
-