CompilerSvc.I Interface

com.bea.ide.sourceeditor.compiler
CompilerSvc.I Interface

public static interface CompilerSvc.I
Enclosing class

CompilerSvc

Method Summary

public boolean
addFileStore(Object o)
Add a com.bea.compiler.IFileStore to the running Javelin compiler instance.
public boolean
canCompileFile(URI uri)
Checks to see if the URI points to a valid, compilable file.
public IFileFilter
getCompileFilter()
get a file filter that only accepts compilable files
public ILanguageDriver
getDefaultLanguageDriver(ISourceDocument doc, String languageName)
Returns a default language driver implementation appropriate to the language at the specified offset within the specified document.
public List
getDiagnostics(ISourceDocument doc, Range range)
Returns a list of the ICompilerDiagnostic objects found in the specified document in the specified range.
public CompilerSvc.ITwoWayEditLock
getEditLockObject(ISourceDocument doc)
Used by the two-way edit mechanism to ensure that the AWT thread waits for two-way edits to complete before continuing application execution.
public Object
getFeature(ISourceDocument doc, Class featureClass)
Allows access to compiler features associated with a specific document.
public Object
getFeature(IProject proj, Class featureClass)
Allows access to compiler features associated with a specific IDE project.
public List
getFieldsForType(ISourceDocument doc, String type, boolean includeSupers)
Get the fields on a given class/interface.
public IIdentifierInfo
getIdentifierInfo(ISourceDocument doc, int offset)
Get identifier info for an offset in a source document.
public Object
getIEncoding(IProject project, String ext)
Returns an instance of an encoding strategy for the given extension.
public String
getLanguageName(ISourceDocument doc, int offset)
Returns the name of the active language at the specified offset in the specified document.
public Iterator
getLanguages()
public String[]
getLanguageStack(ISourceDocument doc, int offset)
Returns an array of language names corresponding to the stack of languages present in the specified document at the specified offset.
public CompilerSvc.ICompilerLockManager
getLockManager(URI uri)
Retrieves a lock manager for the compiler project associated with the specified URI.
public CompilerSvc.ICompilerLockManager
getLockManager(IProject proj)
Retrieves a lock manager for the compiler project associated with the specified project.
public List
getMethodsForType(ISourceDocument doc, String type, boolean includeSupers)
Get the methods on a given class/interface.
public IPackageCache
getPackageCache()
Gets the package cache: this object is used to get general package information, such as that used for generating auto-import suggestions and generating searchable package/class name lists.
public IPackageCache
getPackageCache(int wait)
Gets the package cache: this object is used to get general package information, such as that used for generating auto-import suggestions and generating searchable package/class name lists.
public URI
getPathForType(ISourceDocument doc, String type)
Get the path to the definition of a type in the context of the given document.
public IProject
getProject(IProject proj)
public Object
getProperty(String name, Object defValue)
public Object
getProperty(IProject proj, String name, Object defValue)
public IPropertyViewDriver
getPropertyViewDriver(IDocument document)
Gets an IPropertyViewDriver for the given document.
public IElement
getRootElementForType(URI projectURI, String type)
Get an element tree that represents the given type.
public IElement
getRootElementForType(URI projectURI, String type, IElementChangeListener listener)
Get an element tree that represents the given type, or register a listener that will fire when the type has been resolved by the compiler.
public List
getSupersForType(ISourceDocument doc, String type)
Get the superclass and superinterfaces of a given class/interface.
public boolean
hasCompiler(IProject proj)
Determines whether a specific IDE project has an active compiler project.
public boolean
hasLanguage(String ext)
Returns true if the given file extension has a default language registered with the compiler
public boolean
isFeatureAvailable(ISourceDocument doc, Class featureClass)
Determines if a compiler feature is available for a given document.
public boolean
isFilenameRestricted(String ext)
Returns true if files with this extension have a restricted namespace in the filesystem.
public boolean
isNameRestricted(URI uri)
Returns a boolean indicating whether valid contents of this file are restricted based on file's uri.
public void
loadCompleteSource(IProject proj)
Loads all source files in the specified project as quickly as possible.
public ICompletionSet
mapCompletions(List completions)
Maps a list of completions of various types to an ICompletionSet that the source editor understands.
public void
refreshFile(ISourceDocument doc)
Initiates a full recompile of the specified document.
public void
refreshFile(URI path)
Initiates a full recompile of the specified URI.
public boolean
registerCompilerRequest(URI uri, Object compilationID)
If compilation tasks are initiated directly by code outside of the compiler service, the compiler service needs to be told about the initiation ant completion of these requests so that compiler projects will not be closed while they are underway.
public boolean
registerCompilerResponse(URI uri, Object compilationID)
If compilation tasks are initiated directly by code outside of the compiler service, the compiler service needs to be told about the initiation and completion of these requests so that compiler projects will not be closed while they are underway.
public void
registerDocument(ISourceDocument doc)
Associates the given source document with it's URI.
public boolean
registerExtension(String extNew, String extExisting)
Registers the given new extension to have the same language as the existing extension.
public boolean
sameLanguage(String ext1, String ext2)
Determines whether or not two extensions have the same default language
public void
setFileModified(ISourceDocument doc, ISourceModelEvent e, ISourceModelEvent.EventType type)
Called by various document change listeners to notify the compiler of changes to document content.
public boolean
synchronizeProject(URI uri)

Waits for the project containing the specified URI to synch up with the compiler.

public void
unregisterDocument(URI uri, ISourceDocument doc)
Remove the association between the given URI and the given document.

Method Detail

addFileStore(Object) Method

public boolean addFileStore(Object o)
Add a com.bea.compiler.IFileStore to the running Javelin compiler instance.

Parameters

o
the IFileStore object to add

Returns

Success or failure. This method will fail if the object was not of the correct type.

canCompileFile(URI) Method

public boolean canCompileFile(URI uri)
Checks to see if the URI points to a valid, compilable file.

Parameters

uri
the URI pointing to the file in question.

getCompileFilter() Method

public IFileFilter getCompileFilter()
get a file filter that only accepts compilable files

Returns

IFileFilter implementation that filters out files that cannot be compiled by the compiler svc.

getDefaultLanguageDriver(ISourceDocument, String) Method

public ILanguageDriver getDefaultLanguageDriver(ISourceDocument doc, 
                                                String languageName)
Returns a default language driver implementation appropriate to the language at the specified offset within the specified document. This method should only be called by ISourceViewDriver.getLanguageDriver implementations that do not want to customize language behavior. All other callers should obtain an ILanguageDriver by calling through their document's ISourceViewDriver.getLanguageDriver method. Note that a valid return from this method does not guarantee that the specified langauge exists within the document: getLanguageName and getLanguageStack should be used to determine which languages are present.

Parameters

doc
The document upon which to get the language driver
languageName
The language for which a driver is needed.

Returns

an ILanguageDriver implementation. Null if the language does not exist.

getDiagnostics(ISourceDocument, Range) Method

public List getDiagnostics(ISourceDocument doc, 
                           Range range)
Returns a list of the ICompilerDiagnostic objects found in the specified document in the specified range. Note that diagnostics overlapping the range will be returned as well as those that are completely contained.

Parameters

doc
the source document for which diagnostics are desired
range
the range in the document text that should be searched

Returns

A list of ICompilerDiagnostic objects.

getEditLockObject(ISourceDocument) Method

public CompilerSvc.ITwoWayEditLock getEditLockObject(ISourceDocument doc)
Used by the two-way edit mechanism to ensure that the AWT thread waits for two-way edits to complete before continuing application execution.


getFeature(ISourceDocument, Class) Method

public Object getFeature(ISourceDocument doc, 
                         Class featureClass)
Allows access to compiler features associated with a specific document. Note that the only allowable feature classes for a paticular document type are those explicitly returned from the document's ICompilerDriver's getAvailableFeatures call.

Parameters

doc
the document associated with the desired feature instance
featureClass
the class of the desired feature. For example, IStructureFeature.class

Returns

the requested IFeature, if valid and available. May return null.

getFeature(IProject, Class) Method

public Object getFeature(IProject proj, 
                         Class featureClass)
Allows access to compiler features associated with a specific IDE project.

Parameters

proj
the IDE project
featureClass
the class of the desired feature. For example, ITokenInfoFeature.class

Returns

the requested IFeature, if valid and available. May return null.

getFieldsForType(ISourceDocument, String, boolean) Method

DEPRECATED Use getRootElementForType, preferably the non-blocking one, instead.

public List getFieldsForType(ISourceDocument doc, 
                             String type, 
                             boolean includeSupers)
Get the fields on a given class/interface. Note: this will block until the compiler finishes it's current work.

Parameters

doc
The source document in whose context the type will be resolved.
type
The fully-qualified type whose fields you want to find.
includeSupers
If false, only methods directly on the given type are returned, otherwise all methods available on that type and it's supertypes are given.

Returns

A List of JavaVariables objects corresponding to the fields. These are somewhat raw JavaFields, and do not support editing. If you need full information, you'll need to open the appropriate document and get it's parse tree. This list may be empty, but is never null.

getIdentifierInfo(ISourceDocument, int) Method

public IIdentifierInfo getIdentifierInfo(ISourceDocument doc, 
                                         int offset)
Get identifier info for an offset in a source document.

Parameters

doc
The source document for which to get the identifier info.
offset
The offset at which the identifier is located.

getIEncoding(IProject, String) Method

public Object getIEncoding(IProject project, 
                           String ext)
Returns an instance of an encoding strategy for the given extension. Not commonly used.


getLanguageName(ISourceDocument, int) Method

public String getLanguageName(ISourceDocument doc, 
                              int offset)
Returns the name of the active language at the specified offset in the specified document.

Parameters

doc
The document. See also getLanguageStack.
offset
The position within the document.

Returns

The name of the language at the specified location. Null is the location is invalid.

getLanguages() Method

public Iterator getLanguages()

Returns

an iterator of com.bea.compiler.ILanguage objects currently loaded by the compiler.

getLanguageStack(ISourceDocument, int) Method

public String[] getLanguageStack(ISourceDocument doc, 
                               int offset)
Returns an array of language names corresponding to the stack of languages present in the specified document at the specified offset. See also getLanguageName.

Parameters

doc
The document
offset
The position within the document

Returns

An array of strings corresponding to the language stack. Index zero corresponds to the top-level language of the document, index length - 1 corresponds to the langauge active at the offset. Null is the offset is invlaid.

getLockManager(URI) Method

public CompilerSvc.ICompilerLockManager getLockManager(URI uri)
Retrieves a lock manager for the compiler project associated with the specified URI. Compiler locks are required when accessing compiler features at a time when compilation may take place.

Parameters

uri
The uri used to determine which project should be locked.

getLockManager(IProject) Method

public CompilerSvc.ICompilerLockManager getLockManager(IProject proj)
Retrieves a lock manager for the compiler project associated with the specified project. Compiler locks are required when accessing compiler features at a time when compilation may take place.

Parameters

proj
The IDE project used to determine which compiler project should be locked.

getMethodsForType(ISourceDocument, String, boolean) Method

DEPRECATED Use getRootElementForType, preferably the non-blocking one, instead.

public List getMethodsForType(ISourceDocument doc, 
                              String type, 
                              boolean includeSupers)
Get the methods on a given class/interface. Note: this will block until the compiler finishes it's current work.

Parameters

doc
The source document in whose context the type will be resolved.
type
The fully-qualified type whose methods you want to find.
includeSupers
If false, only methods directly on the given type are returned, otherwise all methods available on that type and it's supertypes are given.

Returns

A List of JavaMethod objects corresponding to the methods. These are somewhat raw JavaMethods, and do not support editing. If you need full information, you'll need to open the appropriate document and get it's parse tree. This list may be empty, but is never null.

getPackageCache() Method

public IPackageCache getPackageCache()
Gets the package cache: this object is used to get general package information, such as that used for generating auto-import suggestions and generating searchable package/class name lists.

Note that the package cache returned by this method may be currently initializing or reloading due to classpath or source directory changes. If this is an issue, check the status of the package cache returned, or use getPackageCache() with a wait flag to block on load.


getPackageCache(int) Method

public IPackageCache getPackageCache(int wait)
Gets the package cache: this object is used to get general package information, such as that used for generating auto-import suggestions and generating searchable package/class name lists.

Parameters

wait
Flag indicating whether this call should block until a certain load status has been reached. See IPackageCache.WAIT_NONE, IPackageCache.WAIT_CLASSPATH_ONLY, IPackageCache.WAIT_ALL.

getPathForType(ISourceDocument, String) Method

DEPRECATED Normally, this isn't needed, since getRootElementForType() provides information.

public URI getPathForType(ISourceDocument doc, 
                          String type)
Get the path to the definition of a type in the context of the given document. Note: this will block until the compiler finishes it's current work.

Parameters

doc
The source document in whose context the type will be resolved.
type
The fully-qualified type whose methods you want to find.

Returns

The URI to the definition of the type.

getProject(IProject) Method

public IProject getProject(IProject proj)

Parameters

proj
an IDE project in the current workspace

Returns

the compiler project associated with a specific IDE project

getProperty(String, Object) Method

public Object getProperty(String name, 
                          Object defValue)

Parameters

name
a property key

Returns

a global compiler property

getProperty(IProject, String, Object) Method

public Object getProperty(IProject proj, 
                          String name, 
                          Object defValue)

Parameters

proj
an IDE project in the current workspace
name
a property key

Returns

a project specific compiler property

getPropertyViewDriver(IDocument) Method

public IPropertyViewDriver getPropertyViewDriver(IDocument document)
Gets an IPropertyViewDriver for the given document.

Parameters

document
the document for which the driver should be created.

Returns

the driver to get properties for the given document, or null if no driver is available for this document.

getRootElementForType(URI, String) Method

public IElement getRootElementForType(URI projectURI, 
                                      String type)
Get an element tree that represents the given type. WARNING: this will block until the compiler finishes it's current work.

Parameters

projectURI
The URI of a project (or document in a project) in which the type will be resolved.
type
the fully-qualified type on which the class will be based.

Returns

an element (a JavaUnit normally) containing a class for the type specified, or null if the type cannot be resolved. The returned element tree may not be part of any document, so it is not suitable for getting change notifications or doing any document edits. Use IDocument.getRootElement() if you want a fully-functioning parse tree.

getRootElementForType(URI, String, IElementChangeListener) Method

public IElement getRootElementForType(URI projectURI, 
                                      String type, 
                                      IElementChangeListener listener)
Get an element tree that represents the given type, or register a listener that will fire when the type has been resolved by the compiler.

Parameters

projectURI
The URI of a project (or document in a project) in which the type will be resolved.
type
the fully-qualified type on which the class will be based.

Returns

an element (normally a JavaUnit) containing a class representing the type specified, or null if one cannot be resolved. This will also return null if the compiler has not yet resolved this type, in which case the listener will fire when the class is available. This tree may or may not be part of a document. Use IDocument.getRootElement(ElementChangeListener) if you need a fully-functioning parse tree

getSupersForType(ISourceDocument, String) Method

DEPRECATED Use getRootElementForType, preferably the non-blocking one, instead.

public List getSupersForType(ISourceDocument doc, 
                             String type)
Get the superclass and superinterfaces of a given class/interface. Note: this will block until the compiler finishes it's current work.

Parameters

doc
The source document in whose context the type will be resolved.
type
The fully-qualified type whose supers you want to find.

Returns

A List of Strings corresponding to the superclass (unless it's java.lang.Object) and all declared interfaces.

hasCompiler(IProject) Method

public boolean hasCompiler(IProject proj)
Determines whether a specific IDE project has an active compiler project.

Parameters

proj
and IDE project in the current workspace

Returns

true if there is an associated compiler project

hasLanguage(String) Method

public boolean hasLanguage(String ext)
Returns true if the given file extension has a default language registered with the compiler

Returns

true if the compiler has a language registered for the given extension

isFeatureAvailable(ISourceDocument, Class) Method

public boolean isFeatureAvailable(ISourceDocument doc, 
                                  Class featureClass)
Determines if a compiler feature is available for a given document.

Parameters

doc
the document associated with the desired feature instance
featureClass
the class of the desired feature. For example, IStructureFeature.class

Returns

true if the feature is valid for the document.

Related Topics

ICompilerDriver.getAvailableFeatures()


isFilenameRestricted(String) Method

public boolean isFilenameRestricted(String ext)
Returns true if files with this extension have a restricted namespace in the filesystem. It is assumed that this namespace is shared with all other extensions that are also restricted. This check is done by seeing if the language registered for this extension is a name restricted language.


isNameRestricted(URI) Method

public boolean isNameRestricted(URI uri)
Returns a boolean indicating whether valid contents of this file are restricted based on file's uri. For example, a .java file must have a package defined that matches its location in the source tree, and a main class name that matches its file name.


loadCompleteSource(IProject) Method

public void loadCompleteSource(IProject proj)
Loads all source files in the specified project as quickly as possible. Under normal circumstances, source files are loaded incrementally, so as to provide maximum responsiveness to the user. However, certain features, such as auto-correction, are not available until all source files have been loaded. Calling this method will load all source files, making these features available sooner, possibly at the expense of foreground task responsiveness.

Parameters

proj
The project for which to load all source files.

mapCompletions(List) Method

public ICompletionSet mapCompletions(List completions)
Maps a list of completions of various types to an ICompletionSet that the source editor understands. This is necessary for completion types like IAttributeValue where on completion set will wrap another.

Parameters

completions
a list of compiler supplied competion objects.

Returns

a completion set.

refreshFile(ISourceDocument) Method

public void refreshFile(ISourceDocument doc)
Initiates a full recompile of the specified document. This will cause a refresh of all compiler features, including the IStructureFeature (i.e., the IDE parse tree).

Parameters

doc
the file to be recompiled

refreshFile(URI) Method

public void refreshFile(URI path)
Initiates a full recompile of the specified URI. This will cause a refresh of all compiler features, including the IStructureFeature (i.e., the IDE parse tree).

Parameters

path
the file to be recompiled

registerCompilerRequest(URI, Object) Method

public boolean registerCompilerRequest(URI uri, 
                                       Object compilationID)
If compilation tasks are initiated directly by code outside of the compiler service, the compiler service needs to be told about the initiation ant completion of these requests so that compiler projects will not be closed while they are underway. Call this method before submitting a compilation request to the compiler, and call registerCompilerResponse when the compilation is complete. Note that this method will not instantiate a new compiler project if one does not exist. If changes are being applied externally, it is the caller's responsibility to ensure that the project has been correctly initialized, generally via (@link #getProject getProject}.

Parameters

uri
A uri within the project for which synchronization is desired. This URI is used only to find the correct project, so it does not have to be directly related to the compilation task.
compilationID
an object that uniquely identifies this compilation. This ID will only be used to notify the compiler service of task completion.

Returns

boolean indicating whether a project existed for the specified URI.

registerCompilerResponse(URI, Object) Method

public boolean registerCompilerResponse(URI uri, 
                                        Object compilationID)
If compilation tasks are initiated directly by code outside of the compiler service, the compiler service needs to be told about the initiation and completion of these requests so that compiler projects will not be closed while they are underway. Call this method when an externally submitted compilation request has completed. This call should have been preceded by a call to CompilerSvc.I.registerCompilerRequest(URI, Object) before the compilation was initiated.

Parameters

uri
A uri within the project for which synchronization is desired. This URI is used only to find the correct project, so it does not have to be directly related to the compilation task.
compilationID
an object that uniquely identifies this compilation. This ID must be the the same as an ID passed in previously via CompilerSvc.I.registerCompilerRequest(URI, Object).

Returns

boolean indicating whether the specified response was found in the request set for the specified project.

registerDocument(ISourceDocument) Method

public void registerDocument(ISourceDocument doc)
Associates the given source document with it's URI. The compiler service will rely on the source document to notify it of important changes and will defer to the file system listener on the file to keep it informed about things like whether or not the file has been deleted.


registerExtension(String, String) Method

public boolean registerExtension(String extNew, 
                                 String extExisting)
Registers the given new extension to have the same language as the existing extension. Note that if the existing extension does not have a language associated with it or if the new extension already has an existing language, this method will do nothing and return false.

Returns

true if the new extension now has the same language as the existing extension, false otherwise.

sameLanguage(String, String) Method

public boolean sameLanguage(String ext1, 
                            String ext2)
Determines whether or not two extensions have the same default language

Returns

true if the extensions have the same default language

setFileModified(ISourceDocument, ISourceModelEvent, ISourceModelEvent.EventType) Method

public void setFileModified(ISourceDocument doc, 
                            ISourceModelEvent e, 
                            ISourceModelEvent.EventType type)
Called by various document change listeners to notify the compiler of changes to document content. Generally, only actual content changes (those that would require a recompile) need to be passed to the compiler. Under normal circumstances, it should not be necessary to call this method explicitly.

Parameters

doc
the document that has been modified
e
the event associated with the modification
type
the type of modification

synchronizeProject(URI) Method

public boolean synchronizeProject(URI uri)

Waits for the project containing the specified URI to synch up with the compiler. This method will block until there are no outstanding compiler requests for the specified project. Note that if the user is continuously changing a document in the project, synchronization may not take place until all edits have been completed.

IMPORTANT: except in very rare circumstances, this method should NEVER be called on the AWT thread. It it possible that completion of outstanding compilation requests may take several seconds, or even minutes.

Parameters

uri
A uri within the project for which synchronization is desired.

Returns

boolean indicating success or failure, where success means that there are no outstanding compilations for the project. It does not mean that the project is necessarily active or in an accessible state.

unregisterDocument(URI, ISourceDocument) Method

public void unregisterDocument(URI uri, 
                               ISourceDocument doc)
Remove the association between the given URI and the given document. If no such association exists, this method does nothing. Document object should call this method in their finalizers to insure that any compiler data structures associated with the document are removed.