Klasse ModularClassFile

Alle implementierten Schnittstellen:
IBufferChangedListener, IClassFile, ICodeAssist, IJavaElement, IModularClassFile, IOpenable, IParent, ISourceReference, ITypeRoot, SuffixConstants, org.eclipse.core.runtime.IAdaptable

public class ModularClassFile extends AbstractClassFile implements IModularClassFile
A handle to a modular class file.
  • Konstruktordetails

  • Methodendetails

    • buildStructure

      protected boolean buildStructure(OpenableElementInfo info, org.eclipse.core.runtime.IProgressMonitor pm, Map newElements, org.eclipse.core.resources.IResource underlyingResource) throws JavaModelException
      Creates the single child element for this class file adding the resulting new handle (of type IBinaryModule) and info object to the newElements table. Returns true if successful, or false if an error is encountered parsing the class file.
      Angegeben von:
      buildStructure in Klasse Openable
      Löst aus:
      JavaModelException
      Siehe auch:
    • codeComplete

      public void codeComplete(int offset, CompletionRequestor requestor, WorkingCopyOwner owner, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
      Beschreibung aus Schnittstelle kopiert: ICodeAssist
      Performs code completion at the given offset position in this compilation unit, reporting results to the given completion requestor. The offset is the 0-based index of the character, after which code assist is desired. An offset of -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 IProgressMonitor is not null then some proposals which can be very long to compute are proposed. To avoid that the code assist operation take too much time a IProgressMonitor which 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 Ungültige Eingabe: "<"= System.currentTimeMillis();
           }
           ...
       };
       
      Angegeben von:
      codeComplete in Schnittstelle ICodeAssist
      Angegeben von:
      codeComplete in Klasse AbstractClassFile
      Parameter:
      offset - the given offset position
      requestor - the given completion requestor
      owner - the owner of working copies that take precedence over their original compilation units
      monitor - the progress monitor used to report progress
      Löst aus:
      JavaModelException - if code assist could not be performed. Reasons include:
      • This Java element does not exist (ELEMENT_DOES_NOT_EXIST)
      • The position specified is Ungültige Eingabe: "<" -1 or is greater than this compilation unit's source length (INDEX_OUT_OF_BOUNDS)
    • codeSelect

      public IJavaElement[] codeSelect(int offset, int length, WorkingCopyOwner owner) throws JavaModelException
      Beschreibung aus Schnittstelle kopiert: ICodeAssist
      Returns the Java elements corresponding to the given selected text in this compilation unit. The offset is the 0-based index of the first selected character. The length is 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 length is 0 and the offset is 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.

      Angegeben von:
      codeSelect in Schnittstelle ICodeAssist
      Angegeben von:
      codeSelect in Klasse AbstractClassFile
      Parameter:
      offset - the given offset position
      length - the number of selected characters
      owner - the owner of working copies that take precedence over their original compilation units
      Gibt zurück:
      the Java elements corresponding to the given selected text
      Löst aus:
      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)
    • findPrimaryType

      public IType findPrimaryType()
      Beschreibung aus Schnittstelle kopiert: ITypeRoot
      Finds 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), or null if no such a type exists.
      Angegeben von:
      findPrimaryType in Schnittstelle ITypeRoot
      Gibt zurück:
      the found primary type of this Java type root, or null if no such a type exists
    • isClass

      public boolean isClass() throws JavaModelException
      Beschreibung aus Schnittstelle kopiert: IClassFile
      Returns whether this type represents a class. This is not guaranteed to be instantaneous, as it may require parsing the underlying file.
      Angegeben von:
      isClass in Schnittstelle IClassFile
      Gibt zurück:
      true if the class file represents a class.
      Löst aus:
      JavaModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource
    • isInterface

      public boolean isInterface() throws JavaModelException
      Beschreibung aus Schnittstelle kopiert: IClassFile
      Returns whether this type represents an interface. This is not guaranteed to be instantaneous, as it may require parsing the underlying file.
      Angegeben von:
      isInterface in Schnittstelle IClassFile
      Gibt zurück:
      true if the class file represents an interface.
      Löst aus:
      JavaModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource
    • getType

      @Deprecated public IType getType()
      Veraltet.
      should only be used as IOrdinaryClassFile.getType().
      Beschreibung aus Schnittstelle kopiert: IClassFile
      Returns the type contained in this class file. This is a handle-only method. The type may or may not exist.
      Angegeben von:
      getType in Schnittstelle IClassFile
      Gibt zurück:
      never returns.
      Löst aus:
      UnsupportedOperationException - always.
      Siehe auch:
    • getBinaryModuleInfo

      public IBinaryModule getBinaryModuleInfo() throws JavaModelException
      Returns the IBinaryModule specific for this IClassFile, based on its underlying resource, or null if unable to create the diet class file. There are two cases to consider:
      • a class file corresponding to an IFile resource
      • a class file corresponding to a zip entry in a JAR
      Löst aus:
      JavaModelException - when the IFile resource or JAR is not available or when this class file is not present in the JAR
    • getElementAt

      public IJavaElement getElementAt(int position) throws JavaModelException
      Beschreibung aus Schnittstelle kopiert: ITypeRoot
      Returns the smallest element within this Java type root that includes the given source position (that is, a method, field, etc.), or null if 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.
      Angegeben von:
      getElementAt in Schnittstelle ITypeRoot
      Parameter:
      position - a source position inside the Java type root
      Gibt zurück:
      the innermost Java element enclosing a given source position or null if none (excluding the Java type root).
      Löst aus:
      JavaModelException - if the Java type root does not exist or if an exception occurs while accessing its corresponding resource
      Siehe auch:
    • getHandleFromMemento

      public IJavaElement getHandleFromMemento(String token, MementoTokenizer memento, WorkingCopyOwner owner)
      Angegeben von:
      getHandleFromMemento in Klasse JavaElement
    • getHandleMementoDelimiter

      protected char getHandleMementoDelimiter()
      Beschreibung aus Klasse kopiert: JavaElement
      Returns the char that marks the start of this handles contribution to a memento.
      Angegeben von:
      getHandleMementoDelimiter in Klasse JavaElement
      Siehe auch:
    • escapeMementoName

      protected void escapeMementoName(StringBuffer buffer, String mementoName)
      Setzt außer Kraft:
      escapeMementoName in Klasse JavaElement
    • getWorkingCopy

      public ICompilationUnit getWorkingCopy(WorkingCopyOwner owner, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
      Beschreibung aus Schnittstelle kopiert: ITypeRoot
      Returns a shared working copy on this compilation unit or class file using the given working copy owner to create the buffer. If this is already a working copy of the given owner, the element itself is returned. This API can only answer an already existing working copy if it is based on the same original Java type root AND was using the same working copy owner (that is, as defined by Object.equals(java.lang.Object)).

      The life time of a shared working copy is as follows:

      So users of this method must discard exactly once the working copy.

      Note that the working copy owner will be used for the life time of the shared working copy, that is if the working copy is closed then reopened, this owner will be used. The buffer will be automatically initialized with the original's Java type root content upon creation.

      When the shared working copy instance is created, an ADDED IJavaElementDelta is reported on this working copy.

      A working copy can be created on a not-yet existing compilation unit. In particular, such a working copy can then be committed in order to create the corresponding compilation unit.

      Note that possible problems of this working copy are reported using this method only if the given working copy owner returns a problem requestor for this working copy (see WorkingCopyOwner.getProblemRequestor(ICompilationUnit)).

      Angegeben von:
      getWorkingCopy in Schnittstelle ITypeRoot
      Parameter:
      owner - the working copy owner that creates a buffer that is used to get the content of the working copy
      monitor - a progress monitor used to report progress while opening this compilation unit or null if no progress should be reported
      Gibt zurück:
      a new working copy of this Java type root using the given owner to create the buffer, or this Java type root if it is already a working copy
      Löst aus:
      JavaModelException - if the contents of this element can not be determined.
    • openBuffer

      protected IBuffer openBuffer(org.eclipse.core.runtime.IProgressMonitor pm, Object info) throws JavaModelException
      Opens and returns buffer on the source code associated with this class file. Maps the source code to the children elements of this class file. If no source code is associated with this class file, null is returned.
      Setzt außer Kraft:
      openBuffer in Klasse Openable
      Löst aus:
      JavaModelException
      Siehe auch:
    • getModule

      public IModuleDescription getModule() throws JavaModelException
      Beschreibung aus Schnittstelle kopiert: IModularClassFile
      Returns the module description contained in this type root. An error-free IModularClassFile should always have a module.
      Angegeben von:
      getModule in Schnittstelle IModularClassFile
      Angegeben von:
      getModule in Schnittstelle ITypeRoot
      Gibt zurück:
      the module description contained in the type root.
      Löst aus:
      JavaModelException
    • exists

      public boolean exists()
      Beschreibung aus Schnittstelle kopiert: IJavaElement
      Returns whether this Java element exists in the model.

      Java elements are handle objects that may or may not be backed by an actual element. Java elements that are backed by an actual element are said to "exist", and this method returns true. For Java elements that are not working copies, it is always the case that if the element exists, then its parent also exists (provided it has one) and includes the element as one of its children. It is therefore possible to navigated to any existing Java element from the root of the Java model along a chain of existing Java elements. On the other hand, working copies are said to exist until they are destroyed (with IWorkingCopy.destroy). Unlike regular Java elements, a working copy never shows up among the children of its parent element (which may or may not exist).

      Angegeben von:
      exists in Schnittstelle IJavaElement
      Angegeben von:
      exists in Schnittstelle ISourceReference
      Setzt außer Kraft:
      exists in Klasse Openable
      Gibt zurück:
      true if this element exists in the Java model, and false if this element does not exist
      Siehe auch: