org.eclipse.wst.jsdt.core
Interface IClassFile

All Superinterfaces:
ICodeAssist, IFunctionContainer, IJavaScriptElement, ILookupScope, IOpenable, IParent, ISourceReference, ITypeRoot

public interface IClassFile
extends ITypeRoot

Represents an entire non-editable JavaScript file. non-editable JavaScript file elements need to be opened before they can be navigated. If a file cannot be parsed, its structure remains unknown. Use IJavaScriptElement.isStructureKnown to determine whether this is the case.

This interface is not intended to be implemented by clients.

Provisional API: This class/interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.


Field Summary
 
Fields inherited from interface org.eclipse.wst.jsdt.core.IJavaScriptElement
CLASS_FILE, FIELD, IMPORT_CONTAINER, IMPORT_DECLARATION, INITIALIZER, JAVASCRIPT_MODEL, JAVASCRIPT_PROJECT, JAVASCRIPT_UNIT, LOCAL_VARIABLE, METHOD, PACKAGE_DECLARATION, PACKAGE_FRAGMENT, PACKAGE_FRAGMENT_ROOT, TYPE, TYPE_PARAMETER
 
Method Summary
 IJavaScriptUnit becomeWorkingCopy(IProblemRequestor problemRequestor, WorkingCopyOwner owner, IProgressMonitor monitor)
          Deprecated. Use ITypeRoot.getWorkingCopy(WorkingCopyOwner, IProgressMonitor) instead. Note that if this deprecated method is used, problems will be reported to the given problem requestor as well as the problem requestor returned by the working copy owner (if not null).
 byte[] getBytes()
          Returns the bytes contained in this file.
 IType getType()
          Returns the first type contained in this file.
 IType[] getTypes()
           
 boolean isClass()
           
 boolean isInterface()
          Returns whether this type represents an interface.
 
Methods inherited from interface org.eclipse.wst.jsdt.core.ITypeRoot
findPrimaryType, getElementAt, getWorkingCopy
 
Methods inherited from interface org.eclipse.wst.jsdt.core.IJavaScriptElement
exists, getAncestor, getAttachedJavadoc, getCommonSuperType, getCorrespondingResource, getDisplayName, getElementName, getElementType, getHandleIdentifier, getHostPath, getJavaScriptModel, getJavaScriptProject, getOpenable, getParent, getPath, getPrimaryElement, getResource, getSchedulingRule, getUnderlyingResource, isReadOnly, isStructureKnown, isVirtual
 
Methods inherited from interface org.eclipse.wst.jsdt.core.ILookupScope
newNameLookup, newNameLookup, newSearchableNameEnvironment, newSearchableNameEnvironment
 
Methods inherited from interface org.eclipse.wst.jsdt.core.IParent
getChildren, hasChildren
 
Methods inherited from interface org.eclipse.wst.jsdt.core.IOpenable
close, findRecommendedLineSeparator, getBuffer, hasUnsavedChanges, isConsistent, isOpen, makeConsistent, open, save
 
Methods inherited from interface org.eclipse.wst.jsdt.core.ISourceReference
exists, getSource, getSourceRange
 
Methods inherited from interface org.eclipse.wst.jsdt.core.ICodeAssist
codeComplete, codeComplete, codeSelect, codeSelect
 
Methods inherited from interface org.eclipse.wst.jsdt.core.IFunctionContainer
getField, getFields, getFunction, getFunctions, getMethods, getType
 

Method Detail

becomeWorkingCopy

IJavaScriptUnit becomeWorkingCopy(IProblemRequestor problemRequestor,
                                  WorkingCopyOwner owner,
                                  IProgressMonitor monitor)
                                  throws JavaScriptModelException
Deprecated. Use ITypeRoot.getWorkingCopy(WorkingCopyOwner, IProgressMonitor) instead. Note that if this deprecated method is used, problems will be reported to the given problem requestor as well as the problem requestor returned by the working copy owner (if not null).

Changes this file handle into a working copy. A new IBuffer is created using the given owner. Uses the primary owner if null is specified.

When switching to working copy mode, problems are reported to the given IProblemRequestor. Note that once in working copy mode, the given IProblemRequestor is ignored. Only the original IProblemRequestor is 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 IJavaScriptUnit.commitWorkingCopy(boolean, IProgressMonitor) on the working copy will throw a JavaScriptModelException as a file is implicitly read-only.

If this 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), IJavaScriptUnit.discardWorkingCopy() must be call as many times as becomeWorkingCopy(IProblemRequestor, WorkingCopyOwner, IProgressMonitor).

The primary javaScript unit of a file's working copy does not exist if the file is not in working copy mode (classFileWorkingCopy.getPrimary().exists() == false).

Parameters:
problemRequestor - a requestor which will get notified of problems detected during reconciling as they are discovered. The requestor can be set to null indicating that the client is not interested in problems.
owner - the given WorkingCopyOwner, or null for the primary owner
monitor - a progress monitor used to report progress while opening this compilation unit or null if no progress should be reported
Returns:
a working copy for this file
Throws:
JavaScriptModelException - if this javaScript unit could not become a working copy.
See Also:
IJavaScriptUnit.discardWorkingCopy()

getBytes

byte[] getBytes()
                throws JavaScriptModelException
Returns the bytes contained in this file.

Returns:
the bytes contained in this file
Throws:
JavaScriptModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource

getType

IType getType()
Returns the first type contained in this file. This is a handle-only method. The type may or may not exist.

Returns:
the type contained in this file

getTypes

IType[] getTypes()
                 throws JavaScriptModelException
Throws:
JavaScriptModelException

isClass

boolean isClass()
                throws JavaScriptModelException
Throws:
JavaScriptModelException

isInterface

boolean isInterface()
                    throws JavaScriptModelException
Returns whether this type represents an interface. This is not guaranteed to be instantaneous, as it may require parsing the underlying file.

Returns:
true if the file represents an interface.
Throws:
JavaScriptModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource