Class AbstractClassFile
- All Implemented Interfaces:
IBufferChangedListener, IClassFile, ICodeAssist, IJavaElement, IOpenable, IParent, ISourceReference, ITypeRoot, SuffixConstants, org.eclipse.core.runtime.IAdaptable
- Direct Known Subclasses:
ClassFile, ModularClassFile
-
Field Summary
FieldsFields 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.Fields inherited from interface SuffixConstants
EXTENSION_aj, EXTENSION_AJ, EXTENSION_class, EXTENSION_CLASS, EXTENSION_java, EXTENSION_JAVA, EXTENSION_jmod, EXTENSION_JMOD, SUFFIX_aj, SUFFIX_AJ, SUFFIX_class, SUFFIX_CLASS, SUFFIX_java, SUFFIX_JAVA, SUFFIX_STRING_aj, SUFFIX_STRING_AJ, SUFFIX_STRING_class, SUFFIX_STRING_CLASS, SUFFIX_STRING_java, SUFFIX_STRING_JAVAModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final char[]static final char[]static final char[]static final char[]static final char[]static final char[]static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractClassFile(PackageFragment parent, String nameWithoutExtension) -
Method Summary
Modifier and TypeMethodDescriptionbecomeWorkingCopy(IProblemRequestor problemRequestor, WorkingCopyOwner owner, org.eclipse.core.runtime.IProgressMonitor monitor) Changes this class file handle into a working copy.protected intvoidcodeComplete(int offset, CompletionRequestor requestor) Performs code completion at the given offset position in this compilation unit, reporting results to the given completion requestor.voidcodeComplete(int offset, CompletionRequestor requestor, WorkingCopyOwner owner) Performs code completion at the given offset position in this compilation unit, reporting results to the given completion requestor.abstract voidcodeComplete(int offset, CompletionRequestor requestor, WorkingCopyOwner owner, org.eclipse.core.runtime.IProgressMonitor monitor) Performs code completion at the given offset position in this compilation unit, reporting results to the given completion requestor.voidcodeComplete(int offset, CompletionRequestor requestor, org.eclipse.core.runtime.IProgressMonitor monitor) Performs code completion at the given offset position in this compilation unit, reporting results to the given completion requestor.voidcodeComplete(int offset, ICodeCompletionRequestor requestor) Deprecated.- should use codeComplete(int, ICompletionRequestor) insteadvoidcodeComplete(int offset, ICompletionRequestor requestor) Deprecated.voidcodeComplete(int offset, ICompletionRequestor requestor, WorkingCopyOwner owner) Deprecated.codeSelect(int offset, int length) Returns the Java elements corresponding to the given selected text in this compilation unit.abstract IJavaElement[]codeSelect(int offset, int length, WorkingCopyOwner owner) Returns the Java elements corresponding to the given selected text in this compilation unit.protected org.aspectj.org.eclipse.jdt.internal.core.ClassFileInfoReturns a new element info for this element.booleanReturns true if this handle represents the same Java element as the given handle.protected IJavaElementfindElement(IJavaElement elt, int position, SourceMapper mapper) Finds the deepestIJavaElementin the hierarchy ofelt's children (includingeltitself) which has a source range that enclosespositionaccording tomapper.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.byte[]getBytes()Returns the bytes contained in this class file.protected byte[]getClassFileContent(JarPackageFragmentRoot root, String className) org.eclipse.core.resources.IResourceA class file has a corresponding resource unless it is contained in a jar.getElementAtConsideringSibling(int position) Returns the name of this element.intReturns this element's kind encoded as an integer.Returns the name range associated with this element.org.eclipse.core.runtime.IPathgetPath()Returns the path to the innermost resource enclosing this element.Provide a way for clients (like debugger) to determine if two non-equalAbstractClassFileobjects point to the same physical storage.Returns the source code associated with this element.Returns the source range associated with this element.getWorkingCopy(org.eclipse.core.runtime.IProgressMonitor monitor, IBufferFactory factory) Deprecated.protected booleanReturns true if this element may have an associated source buffer, otherwise false.booleanReturns true - class files are always read only.org.eclipse.core.resources.IResourceresource(PackageFragmentRoot root) protected org.eclipse.core.runtime.IStatusvalidateExistence(org.eclipse.core.resources.IResource underlyingResource) Methods inherited from class Openable
bufferChanged, buildStructure, canBeRemovedFromCache, canBufferBeRemovedFromCache, closeBuffer, closing, codeComplete, codeSelect, exists, findRecommendedLineSeparator, generateInfos, getBufferFactory, getBufferManager, getOpenable, getPackageFragmentRoot, getResource, getUnderlyingResource, 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.protected abstract booleanbuildStructure(OpenableElementInfo info, org.eclipse.core.runtime.IProgressMonitor pm, Map<IJavaElement, IElementInfo> 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).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).Deprecated.protected BufferManagerReturns the buffer manager for this element.Returns the first openable parent.Find enclosing package fragment root if anyorg.eclipse.core.resources.IResourceReturns the innermost resource enclosing this element.org.eclipse.core.resources.IResourceReturns the smallest underlying resource that contains this element, ornullif this element is not contained in a resource.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, close, escapeMementoName, findNode, getAncestor, getAttachedJavadoc, getChildren, getChildrenOfType, getClassFile, getCompilationUnit, getElementInfo, getElementInfo, getHandleFromMemento, getHandleFromMemento, getHandleIdentifier, getHandleMemento, getHandleMemento, getHandleMementoDelimiter, getJavadocBaseLocation, getJavaModel, getJavaProject, getLibraryJavadocLocation, getOpenableParent, getParent, getPrimaryElement, getPrimaryElement, getSchedulingRule, getSourceElementAt, getSourceMapper, getURLContents, hasChildren, hashCode, isAncestorOf, newDoesNotExistStatus, newJavaModelException, newNotPresentException, openWhenClosed, readableName, resetHashCode, resolved, tabString, toDebugString, toString, toString, toStringAncestors, toStringChildren, toStringInfo, toStringInfo, toStringName, toStringWithAncestors, toStringWithAncestors, unresolved, validateAndCacheModifier and TypeMethodDescriptionprotected voidappendEscapedDelimiter(StringBuilder buffer, char delimiter) voidclose()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.abstract IJavaElementgetHandleFromMemento(String token, MementoTokenizer memento, WorkingCopyOwner owner) getHandleFromMemento(MementoTokenizer memento, WorkingCopyOwner owner) Returns a string representation of this element handle.protected voidprotected abstract charReturns thecharthat marks the start of this handles contribution to a memento.protected URLReturns the Java model.Returns 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.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 voidtoStringInfo(int tab, StringBuilder buffer, Object info, boolean showResolvedInfo) 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 IClassFile
getType, isClass, isInterfaceModifier and TypeMethodDescriptiongetType()Deprecated.should only be used asIOrdinaryClassFile.getType().booleanisClass()Returns whether this type represents a class.booleanReturns whether this type represents an interface.Methods inherited from interface IParent
getChildren, hasChildrenModifier and TypeMethodDescriptionReturns the immediate children of this element.booleanReturns whether this element has one or more immediate children.Methods inherited from interface ISourceReference
existsModifier and TypeMethodDescriptionbooleanexists()Returns whether this element exists in the model.Methods inherited from interface ITypeRoot
findPrimaryType, getElementAt, getModule, getWorkingCopyModifier and TypeMethodDescriptionFinds the primary type of this Java type root (that is, the type with the same name as the compilation unit, or the type of a class file), ornullif no such a type exists.getElementAt(int position) Returns the smallest element within this Java type root that includes the given source position (that is, a method, field, etc.), ornullif there is no element other than the Java type root itself at the given position, or if the given position is not within the source range of the source of this Java type root.default IModuleDescriptionReturns the module description contained in this type root or null if there is no module in this type root.getWorkingCopy(WorkingCopyOwner owner, org.eclipse.core.runtime.IProgressMonitor monitor) Returns a shared working copy on this compilation unit or class file using the given working copy owner to create the buffer.
-
Field Details
-
name
-
-
Constructor Details
-
AbstractClassFile
-
-
Method Details
-
becomeWorkingCopy
public ICompilationUnit becomeWorkingCopy(IProblemRequestor problemRequestor, WorkingCopyOwner owner, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException Description copied from interface:IClassFileChanges this class file handle into a working copy. A newIBufferis created using the given owner. Uses the primary owner ifnullis specified.When switching to working copy mode, problems are reported to the given
IProblemRequestor. Note that once in working copy mode, the givenIProblemRequestoris ignored. Only the originalIProblemRequestoris used to report subsequent problems.Once in working copy mode, changes to this working copy or its children are done in memory. Only the new buffer is affected.
Using
ICompilationUnit.commitWorkingCopy(boolean, IProgressMonitor)on the working copy will throw aJavaModelExceptionas a class file is implicetly read-only.If this class file was already in working copy mode, an internal counter is incremented and no other action is taken on this working copy. To bring this working copy back into the original mode (where it reflects the underlying resource),
ICompilationUnit.discardWorkingCopy()must be call as many times asIClassFile.becomeWorkingCopy(IProblemRequestor, WorkingCopyOwner, IProgressMonitor).The primary compilation unit of a class file's working copy does not exist if the class file is not in working copy mode (
classFileWorkingCopy.getPrimary().exists() == false).The resource of a class file's working copy is
nullif the class file is in an external jar file.- Specified by:
becomeWorkingCopyin interfaceIClassFile- Parameters:
problemRequestor- a requestor which will get notified of problems detected during reconciling as they are discovered. The requestor can be set tonullindicating that the client is not interested in problems.owner- the givenWorkingCopyOwner, ornullfor the primary ownermonitor- a progress monitor used to report progress while opening this compilation unit ornullif no progress should be reported- Returns:
- a working copy for this class file
- Throws:
JavaModelException- if this compilation unit could not become a working copy.- See Also:
-
codeComplete
@Deprecated public void codeComplete(int offset, ICompletionRequestor requestor) throws JavaModelException Deprecated.Description copied from interface:ICodeAssistPerforms code completion at the given offset position in this compilation unit, reporting results to the given completion requestor. Theoffsetis the 0-based index of the character, after which code assist is desired. Anoffsetof -1 indicates to code assist at the beginning of this compilation unit.- Specified by:
codeCompletein interfaceICodeAssist- Parameters:
offset- the given offset positionrequestor- the given completion requestor- Throws:
JavaModelException- if code assist could not be performed. Reasons include:- This Java element does not exist (ELEMENT_DOES_NOT_EXIST)
- The position specified is < -1 or is greater than this compilation unit's source length (INDEX_OUT_OF_BOUNDS)
- See Also:
-
codeComplete
@Deprecated public void codeComplete(int offset, ICompletionRequestor requestor, WorkingCopyOwner owner) throws JavaModelException Deprecated.Description copied from interface:ICodeAssistPerforms code completion at the given offset position in this compilation unit, reporting results to the given completion requestor. Theoffsetis the 0-based index of the character, after which code assist is desired. Anoffsetof -1 indicates to code assist at the beginning of this compilation unit. It considers types in the working copies with the given owner first. In other words, the owner's working copies will take precedence over their original compilation units in the workspace.Note that if a working copy is empty, it will be as if the original compilation unit had been deleted.
- Specified by:
codeCompletein interfaceICodeAssist- Parameters:
offset- the given offset positionrequestor- the given completion requestorowner- the owner of working copies that take precedence over their original compilation units- Throws:
JavaModelException- if code assist could not be performed. Reasons include:- This Java element does not exist (ELEMENT_DOES_NOT_EXIST)
- The position specified is < -1 or is greater than this compilation unit's source length (INDEX_OUT_OF_BOUNDS)
- See Also:
-
codeComplete
Description copied from interface:ICodeAssistPerforms code completion at the given offset position in this compilation unit, reporting results to the given completion requestor. Theoffsetis the 0-based index of the character, after which code assist is desired. Anoffsetof -1 indicates to code assist at the beginning of this compilation unit.- Specified by:
codeCompletein interfaceICodeAssist- Parameters:
offset- the given offset positionrequestor- the given completion requestor- Throws:
JavaModelException- if code assist could not be performed. Reasons include:- This Java element does not exist (ELEMENT_DOES_NOT_EXIST)
- The position specified is < -1 or is greater than this compilation unit's source length (INDEX_OUT_OF_BOUNDS)
-
codeComplete
public void codeComplete(int offset, CompletionRequestor requestor, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException Description copied from interface:ICodeAssistPerforms code completion at the given offset position in this compilation unit, reporting results to the given completion requestor. Theoffsetis the 0-based index of the character, after which code assist is desired. Anoffsetof -1 indicates to code assist at the beginning of this compilation unit.If
IProgressMonitoris notnullthen some proposals which can be very long to compute are proposed. To avoid that the code assist operation take too much time aIProgressMonitorwhich automatically cancel the code assist operation when a specified amount of time is reached could be used.new IProgressMonitor() { private final static int TIMEOUT = 500; //ms private long endTime; public void beginTask(String name, int totalWork) { fEndTime= System.currentTimeMillis() + TIMEOUT; } public boolean isCanceled() { return endTime <= System.currentTimeMillis(); } ... };- Specified by:
codeCompletein interfaceICodeAssist- Parameters:
offset- the given offset positionrequestor- the given completion requestormonitor- the progress monitor used to report progress- Throws:
JavaModelException- if code assist could not be performed. Reasons include:- This Java element does not exist (ELEMENT_DOES_NOT_EXIST)
- The position specified is < -1 or is greater than this compilation unit's source length (INDEX_OUT_OF_BOUNDS)
-
codeComplete
public void codeComplete(int offset, CompletionRequestor requestor, WorkingCopyOwner owner) throws JavaModelException Description copied from interface:ICodeAssistPerforms code completion at the given offset position in this compilation unit, reporting results to the given completion requestor. Theoffsetis the 0-based index of the character, after which code assist is desired. Anoffsetof -1 indicates to code assist at the beginning of this compilation unit. It considers types in the working copies with the given owner first. In other words, the owner's working copies will take precedence over their original compilation units in the workspace.Note that if a working copy is empty, it will be as if the original compilation unit had been deleted.
- Specified by:
codeCompletein interfaceICodeAssist- Parameters:
offset- the given offset positionrequestor- the given completion requestorowner- the owner of working copies that take precedence over their original compilation units- Throws:
JavaModelException- if code assist could not be performed. Reasons include:- This Java element does not exist (ELEMENT_DOES_NOT_EXIST)
- The position specified is < -1 or is greater than this compilation unit's source length (INDEX_OUT_OF_BOUNDS)
-
codeComplete
public abstract void codeComplete(int offset, CompletionRequestor requestor, WorkingCopyOwner owner, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException Description copied from interface:ICodeAssistPerforms code completion at the given offset position in this compilation unit, reporting results to the given completion requestor. Theoffsetis the 0-based index of the character, after which code assist is desired. Anoffsetof -1 indicates to code assist at the beginning of this compilation unit. It considers types in the working copies with the given owner first. In other words, the owner's working copies will take precedence over their original compilation units in the workspace.Note that if a working copy is empty, it will be as if the original compilation unit had been deleted.
If
IProgressMonitoris notnullthen some proposals which can be very long to compute are proposed. To avoid that the code assist operation take too much time aIProgressMonitorwhich automatically cancel the code assist operation when a specified amount of time is reached could be used.new IProgressMonitor() { private final static int TIMEOUT = 500; //ms private long endTime; public void beginTask(String name, int totalWork) { fEndTime= System.currentTimeMillis() + TIMEOUT; } public boolean isCanceled() { return endTime <= System.currentTimeMillis(); } ... };- Specified by:
codeCompletein interfaceICodeAssist- Parameters:
offset- the given offset positionrequestor- the given completion requestorowner- the owner of working copies that take precedence over their original compilation unitsmonitor- the progress monitor used to report progress- Throws:
JavaModelException- if code assist could not be performed. Reasons include:- This Java element does not exist (ELEMENT_DOES_NOT_EXIST)
- The position specified is < -1 or is greater than this compilation unit's source length (INDEX_OUT_OF_BOUNDS)
-
codeSelect
Description copied from interface:ICodeAssistReturns the Java elements corresponding to the given selected text in this compilation unit. Theoffsetis the 0-based index of the first selected character. Thelengthis the number of selected characters.Note that if the
lengthis 0 and theoffsetis inside an identifier or the index just after an identifier then this identifier is considered as the selection.- Specified by:
codeSelectin interfaceICodeAssist- Parameters:
offset- the given offset positionlength- the number of selected characters- Returns:
- the Java elements corresponding to the given selected text
- Throws:
JavaModelException- if code resolve could not be performed. Reasons include:- This Java element does not exist (ELEMENT_DOES_NOT_EXIST)
- The range specified is not within this element's source range (INDEX_OUT_OF_BOUNDS)
- See Also:
-
codeSelect
public abstract IJavaElement[] codeSelect(int offset, int length, WorkingCopyOwner owner) throws JavaModelException Description copied from interface:ICodeAssistReturns the Java elements corresponding to the given selected text in this compilation unit. Theoffsetis the 0-based index of the first selected character. Thelengthis the number of selected characters. It considers types in the working copies with the given owner first. In other words, the owner's working copies will take precedence over their original compilation units in the workspace.Note that if the
lengthis 0 and theoffsetis inside an identifier or the index just after an identifier then this identifier is considered as the selection.Note that if a working copy is empty, it will be as if the original compilation unit had been deleted.
- Specified by:
codeSelectin interfaceICodeAssist- Parameters:
offset- the given offset positionlength- the number of selected charactersowner- the owner of working copies that take precedence over their original compilation units- Returns:
- the Java elements corresponding to the given selected text
- Throws:
JavaModelException- if code resolve could not be performed. Reasons include:- This Java element does not exist (ELEMENT_DOES_NOT_EXIST)
- The range specified is not within this element's source range (INDEX_OUT_OF_BOUNDS)
-
createElementInfo
protected org.aspectj.org.eclipse.jdt.internal.core.ClassFileInfo createElementInfo()Returns a new element info for this element.- Overrides:
createElementInfoin classOpenable
-
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:
-
calculateHashCode
protected int calculateHashCode()- Overrides:
calculateHashCodein classJavaElement
-
findElement
Finds the deepestIJavaElementin the hierarchy ofelt's children (includingeltitself) which has a source range that enclosespositionaccording tomapper. -
getPathIdentifier
Provide a way for clients (like debugger) to determine if two non-equalAbstractClassFileobjects point to the same physical storage. The return value is constructed form the container path (if there is any) and the path of the class file itself (that could be either absolute or relative if it is inside container).- Returns:
- some kind of unique class file identifier based on path information only. The return value may look like a path in a file system, but is not guaranteed to be a valid path that could be resolved via NIO API.
-
getBytes
Description copied from interface:IClassFileReturns the bytes contained in this class file.- Specified by:
getBytesin interfaceIClassFile- Returns:
- the bytes contained in this class file
- Throws:
JavaModelException- if this element does not exist or if an exception occurs while accessing its corresponding resource
-
getClassFileContent
protected byte[] getClassFileContent(JarPackageFragmentRoot root, String className) throws org.eclipse.core.runtime.CoreException, IOException - Throws:
org.eclipse.core.runtime.CoreExceptionIOException
-
getBuffer
Description copied from class:OpenableNote: 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. If this is the first time a request is being made for the buffer, an attempt is made to create and fill this element's buffer. If the buffer has been closed since it was first opened, the buffer is re-created.- Specified by:
getBufferin interfaceIOpenable- Overrides:
getBufferin classOpenable- Returns:
- the buffer opened for this element, or
nullif this element does not have a buffer - Throws:
JavaModelException- if this element does not exist or if an exception occurs while accessing its corresponding resource.- See Also:
-
getTypeRoot
- See Also:
-
getCorrespondingResource
A class file has a corresponding resource unless it is contained in a jar.- Specified by:
getCorrespondingResourcein interfaceIJavaElement- Overrides:
getCorrespondingResourcein classOpenable- Returns:
- the corresponding resource, or
nullif none - Throws:
JavaModelException- if this element does not exist or if an exception occurs while accessing its corresponding resource- See Also:
-
getElementAtConsideringSibling
- Throws:
JavaModelException
-
getElementName
Description copied from interface:IJavaElementReturns the name of this element. This is a handle-only method.- Specified by:
getElementNamein interfaceIJavaElement- Overrides:
getElementNamein classJavaElement- Returns:
- the element name
- 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:
-
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
-
getSource
Description copied from interface:ISourceReferenceReturns the source code associated with this element. This extracts the substring from the source buffer containing this source element. This corresponds to the source range that would be returned bygetSourceRange.For class files, this returns the source of the entire compilation unit associated with the class file (if there is one).
- Specified by:
getSourcein interfaceISourceReference- Returns:
- the source code, or
nullif this element has no associated source code - Throws:
JavaModelException- if an exception occurs while accessing its corresponding resource- See Also:
-
getSourceRange
Description copied from interface:ISourceReferenceReturns the source range associated with this element.For class files, this returns the range of the entire compilation unit associated with the class file (if there is one).
If this element has no associated source code, either
nullis returned, or a source range with a -1 offset and a 0 length.SourceRange.isAvailable(ISourceRange)can be used to detect that case.- Specified by:
getSourceRangein interfaceISourceReference- Returns:
- the source range, or either
nullor [-1, 0] if this element has no associated source code - Throws:
JavaModelException- if an exception occurs while accessing its corresponding resource- See Also:
-
getWorkingCopy
@Deprecated public IJavaElement getWorkingCopy(org.eclipse.core.runtime.IProgressMonitor monitor, IBufferFactory factory) throws JavaModelException Deprecated.Description copied from interface:IClassFileReturns a working copy on the source associated with this class file using the given factory to create the buffer, ornullif there is no source associated with the class file.The buffer will be automatically initialized with the source of the class file upon creation.
The only valid operations on this working copy are
getBuffer()orgetOriginalElement.- Specified by:
getWorkingCopyin interfaceIClassFile- Parameters:
monitor- a progress monitor used to report progress while opening this compilation unit ornullif no progress should be reportedfactory- the factory that creates a buffer that is used to get the content of the working copy ornullif the internal factory should be used- Returns:
- a a working copy on the source associated with this class file
- Throws:
JavaModelException- if the source of this class file can not be determined. Reasons include:- This class file does not exist (ELEMENT_DOES_NOT_EXIST)
- See Also:
-
hasBuffer
-
isReadOnly
public boolean isReadOnly()Returns true - class files are always read only.- Specified by:
isReadOnlyin interfaceIJavaElement- Overrides:
isReadOnlyin classJavaElement- Returns:
trueif this element is read-only- See Also:
-
codeComplete
@Deprecated public void codeComplete(int offset, ICodeCompletionRequestor requestor) throws JavaModelException Deprecated.- should use codeComplete(int, ICompletionRequestor) insteadDescription copied from interface:ICodeAssistPerforms code completion at the given offset position in this compilation unit, reporting results to the given completion requestor. Theoffsetis the 0-based index of the character, after which code assist is desired. Anoffsetof -1 indicates to code assist at the beginning of this compilation unit.- Specified by:
codeCompletein interfaceICodeAssist- Parameters:
offset- the given offset positionrequestor- the given completion requestor- Throws:
JavaModelException- if code assist could not be performed. Reasons include:- This Java element does not exist (ELEMENT_DOES_NOT_EXIST)
- The position specified is < -1 or is greater than this compilation unit's source length (INDEX_OUT_OF_BOUNDS)
- See Also:
-
validateExistence
protected org.eclipse.core.runtime.IStatus validateExistence(org.eclipse.core.resources.IResource underlyingResource) - Specified by:
validateExistencein classOpenable
-
getNameRange
Description copied from interface:ISourceReferenceReturns the name range associated with this element.If the element is an
IMember, it returns the source range of this member's simple name, ornullif this member does not have a name (for example, an initializer), or if this member does not have associated source code (for example, a binary type).If this element is an
IImportDeclaration, the source range of this import declaration's name, ornullif this import declaration does not have associated source code (for example, a binary type).
The source range for the name includes the trailing '*' if the call toIImportDeclaration.isOnDemand()returns true.If this element is an
IPackageDeclaration, the source range of this package declaration's name, ornullif this package declaration does not have associated source code (for example, a binary type).If this element is an
IAnnotation, the source range of this annotation's name, ornullif this annotation does not have associated source code (for example, in a binary type).If this element is an
ITypeParameter, the source range of this type parameter's name, ornullif this type parameter does not have associated source code (for example, in a binary type).If this element is an
ITypeRootorIImportContainer, it returns null.- Specified by:
getNameRangein interfaceISourceReference- Returns:
- the name range associated with this element, or
nullif not available
-