public interface SourceFile extends SourceElement, JavaFile
| Modifier and Type | Interface and Description | 
|---|---|
| static class  | SourceFile.ElementAtMask | 
CHILDREN_ALL, CHILDREN_BLANKLINES, CHILDREN_COMMENTS, CHILDREN_default, CHILDREN_none, CHILDREN_REGULAR, EMPTY_ARRAY, PRINT_ALL, REFORMAT_ALL, REFORMAT_INDENT| Modifier and Type | Method and Description | 
|---|---|
| void | addSourceFileListener(SourceFileListener listener)Registers the given observer to begin receiving notifications when
 changes are made on this SourceFile or when this SourceFile is
 invalidated. | 
| SourceTransaction | beginTransaction()Locks (and implicitly pins) the text buffer and indicates a new
 transaction. | 
| void | cancelCompile()Cancels the previously started compile() on this file. | 
| void | clearAllBindings(int key)Traverses the entire parse tree, calling clearBinding( key )
 on each element. | 
| void | clearCompiledInfo()Clears the entire source data model of compiled information. | 
| SourceFile | cloneSelf(TextBuffer textBuffer)Clones this SourceFile into the input TextBuffer. | 
| void | compile(java.util.List<FlowAnalysisListener> listeners)Do a full compile of this SourceFile and request flow analysis callbacks. | 
| void | doFullCompile()By default, a SourceFile.compile() does a full resolution of
 types and names, but does little error checking otherwise. | 
| void | expire()Mark this SourceFile as invalid. | 
| java.util.List<SourceError> | getCompileErrors()Gets the list of compile-time errors. | 
| SourceElement | getElementAt(int offset)If the offset is in a token, meaning there is a character at that
 offset, select the deepest nested SourceElement containing that token. | 
| SourceElement | getElementAt(int offset,
            java.util.EnumSet<SourceFile.ElementAtMask> mask)If the offset is in a token, meaning there is a character at that
 offset, return the deepest nested SourceElement that satisfies
 the mask and contains that token. | 
| SourceElement | getElementAt(int offset,
            int mask)Deprecated. 
 The mask argument is too limited.
 This method has been replaced by getElementAt( offset, ElementAtMask ) | 
| SourceElement | getElementContaining(int startOffset,
                    int endOffset)Gets the deepest nested SourceElement that includes the range
 [startOffset, endOffset]. | 
| SourceElement | getElementContaining(int startOffset,
                    int endOffset,
                    java.util.EnumSet<SourceFile.ElementAtMask> mask)Gets the deepest nested SourceElement that includes the range
 [startOffset, endOffset]. | 
| java.util.Collection<SourceError> | getErrors(int severity,
         int errorCategory)Gets all the errors in the indicated categories with the given
 severity or worse. | 
| SourceFactory | getFactory()Gets the SourceFactory tied to this SourceFile. | 
| int | getLanguageVersion()Deprecated. 
 Use getJdkVersion() instead | 
| java.lang.String | getPackageName()Gets the package name, empty if none. | 
| java.util.List<SourceError> | getParseErrors()Gets the list of parse-time errors. | 
| java.util.List<java.lang.String> | getPossibleTypes()Gets the list of possible type String's, collected during
 parse-time. | 
| SourcePreferences | getPreferences()Gets the saved JavaPreferences cookie. | 
| JavaProvider | getProvider()Gets the saved JavaProvider cookie. | 
| SourceClass | getSourceClass(java.lang.String name)Gets the matching top-level source class. | 
| java.util.List<SourceClass> | getSourceClasses()Gets the list of top-level source classes. | 
| java.util.Set<java.lang.String> | getSourceImportNames()Gets the set of import strings. | 
| java.util.List<SourceImport> | getSourceImports()Gets the list of import declarations. | 
| SourcePackage | getSourcePackage()Gets the package declaration. | 
| SourceClass | getSourcePrimaryClass()Gets the primary class. | 
| TextBuffer | getTextBuffer()Gets the associated TextBuffer. | 
| SourceToken | getTokenAt(int offset)Get the token with startOffset <= offset and endOffset >= offset. | 
| SourceTransaction | getTransaction()Gets the pending transaction, null if none. | 
| java.net.URL | getURL()Gets the saved URL cookie. | 
| boolean | hasCompileErrors()True if compiling generated any errors. | 
| boolean | hasErrors(int severity,
         int errorCategory)True if any error in the indicated categories exists with the
 given severity or worse. | 
| boolean | hasParseErrors()True if parsing generated any errors. | 
| void | installImportCache()Installs a cache which helps speed up lookups of imported names and types
 when a lot of SourceElements are resolved and compiled, for instance
 during a SourceVisitor that traverses a substantial part of a SourceFile. | 
| boolean | isCompiled()Note: This does not consider whether or not the file is
 out-of-date and needs to be recompiled. | 
| boolean | isExpired()True if this has been expired. | 
| boolean | isFullyCompiled()Note: This does not consider whether or not the file is
 out-of-date and needs to be recompiled. | 
| boolean | isPackageInfoFile()Determine if this is a package-info.java SourceFile. | 
| void | pinTextBuffer(TextBuffer textBuffer)Sets the text buffer cookie and pins it. | 
| void | releaseImportCache()Releases the import cache. | 
| void | removeSourceFileListener(SourceFileListener listener)Unregisters the given observer. | 
| javax.swing.undo.UndoableEdit | runInTransaction(java.util.function.Function<SourceTransaction,java.lang.Boolean> function)Runs the function as part of a SourceTransaction on this SourceFile. | 
| void | setCompileErrors(java.util.List<SourceError> errors)Sets the compile errors for this SourceFile. | 
| void | setPackageName(java.lang.String packageName)Attempts to set the name of the package declaration. | 
| void | setParseErrors(java.util.List<SourceError> errors)Sets the parse errors for this SourceFile. | 
| void | setPreferences(SourcePreferences preferences)Sets the preferences to be used with this source file. | 
| void | setProvider(JavaProvider provider)Sets the provider cookie that will provide class information
 needed for compilation. | 
| void | setSourcePackage(SourcePackage packageD)Attempts to set the package declaration. | 
| void | setTextBuffer(TextBuffer textBuffer)Sets the text buffer but leaves it unpinned. | 
| void | setURL(java.net.URL url)Set the URL cookie that is saved with this SourceFile. | 
| void | unpinTextBuffer()Unpins the saved text buffer from this parse tree. | 
addSelf, addSelf, addSelfAfter, addSelfBefore, adjustTextIndentation, clearBinding, cloneSelf, compile, createContext, getBinding, getChildren, getChildren, getCompiledObject, getContainedElements, getContext, getEndOffset, getFirstToken, getJdkVersion, getLastToken, getOwningFile, getOwningSourceFile, getParent, getSiblingAfter, getSiblingAfter, getSiblingBefore, getSiblingBefore, getSiblings, getSiblings, getStartOffset, getSymbolKind, getText, getTokens, getTokens, hasErrors, print, print, reformatSelf, removeSelf, replaceSelf, resolve, setBinding, setContext, visitSelfgetClass, getClasses, getPackage, getPrimaryClass, getSourceElementgetElementKind, getFile, getModifiers, getOwner, isDeprecated, isFinal, isHidden, isSourceElement, isSynthetic, printCompiledInfo@Deprecated int getLanguageVersion()
JavaTokens
 .J2SE_* constant, e.g. J2SE_16SourcePackage getSourcePackage()
java.lang.String getPackageName()
getPackageName in interface JavaFilevoid setSourcePackage(SourcePackage packageD)
void setPackageName(java.lang.String packageName)
packageName - Must be non-null. If empty, this will attempt to
                    remove the package declaration.java.util.List<SourceImport> getSourceImports()
java.util.Set<java.lang.String> getSourceImportNames()
java.util.List<SourceClass> getSourceClasses()
SourceClass getSourceClass(java.lang.String name)
SourceClass getSourcePrimaryClass()
SourceFile cloneSelf(TextBuffer textBuffer)
textBuffer - If null, an array text buffer is created for use.java.lang.UnsupportedOperationException - if this SourceFile has no
 TextBuffer associated with it, or if this SourceFile has an
 open transaction with outstanding changes. To clone a SourceFile
 with an open transaction, perform a savepoint() on the
 transaction.SourceFactory getFactory()
void clearAllBindings(int key)
java.util.List<java.lang.String> getPossibleTypes()
boolean isCompiled()
void compile(java.util.List<FlowAnalysisListener> listeners)
listeners - The listeners that want to get flow analysis
 call backsjava.util.concurrent.CancellationException - if SourceFile.cancelCompile() is
 called or the thread doing the compile is interrupted.doFullCompile()boolean isFullyCompiled()
void doFullCompile()
void cancelCompile()
void clearCompiledInfo()
void expire()
boolean isExpired()
boolean isPackageInfoFile()
boolean hasParseErrors()
java.util.List<SourceError> getParseErrors()
boolean hasCompileErrors()
java.util.List<SourceError> getCompileErrors()
boolean hasErrors(int severity,
                  int errorCategory)
severity - Valid values are JavaErrors.SEVERITY_*.errorCategory - Valid values are JavaErrors.ERROR_CATEGORY_*.
                      If no error categories are included, the
                      error set is trivially empty.
                      If ERROR_CATEGORY_COMPILE is included, this
                      SourceFile will be implicitly compiled if
                      if not already so.java.util.Collection<SourceError> getErrors(int severity, int errorCategory)
severity - Valid values are JavaErrors.SEVERITY_*.errorCategory - Valid values are JavaErrors.ERROR_CATEGORY_*.
                      If no error categories are included, the
                      error set is trivially empty.
                      If ERROR_CATEGORY_COMPILE is included, this
                      SourceFile will be implicitly compiled if
                      if not already so.java.net.URL getURL()
void setURL(java.net.URL url)
JavaProvider getProvider()
ExpiredTextBufferException - if this SourceFile is out-of-date because the underlying
         TextBuffer was modifiedvoid setProvider(JavaProvider provider)
SourcePreferences getPreferences()
void setPreferences(SourcePreferences preferences)
TextBuffer getTextBuffer()
ExpiredTextBufferException - if this SourceFile is out-of-date because the underlying
         TextBuffer was modifiedvoid setTextBuffer(TextBuffer textBuffer)
java.lang.IllegalStateException - if there is already a pinned text
 buffer.void pinTextBuffer(TextBuffer textBuffer)
java.lang.IllegalStateException - if there is already a pinned text
 buffer.void unpinTextBuffer()
javax.swing.undo.UndoableEdit runInTransaction(java.util.function.Function<SourceTransaction,java.lang.Boolean> function)
function - A Function that executes code that modifies this SourceFile.
 Return true from this Function if all went well and the changes should be
 committed, return false if the transaction should be abortedjava.lang.UnsupportedOperationException - if there is no text buffer to edit.java.lang.IllegalStateException - if there is already a transaction in progress.ExpiredTextBufferException - if this SourceFile is out-of-date because the underlying
         TextBuffer was modifiedSourceTransaction beginTransaction()
java.lang.UnsupportedOperationException - if there is no text buffer to
                                       edit.java.lang.IllegalStateException - if there is already a transaction
                               in progress.ExpiredTextBufferException - if this SourceFile is out-of-date because the underlying
         TextBuffer was modifiedSourceTransaction getTransaction()
void addSourceFileListener(SourceFileListener listener)
listener - The listener to be added.void removeSourceFileListener(SourceFileListener listener)
listener - The listener to be removed.SourceElement getElementAt(int offset)
offset - The offset in the buffer of the SourceFileSourceElement getElementAt(int offset, java.util.EnumSet<SourceFile.ElementAtMask> mask)
offset - The offset in the buffer of the SourceFilemask - A set of ElementAtMask. DEFAULT is implicitly added if
 mask is null or empty or does not contain NONE or ALL. In case several
 flags might conflict, the order of application is:
   NONE, COMMENTS, BLANKLINES, SAME_LINE, STRUCTURAL,
   NEAREST, BEFORE, AFTER, ALL, DEFAULT@Deprecated SourceElement getElementAt(int offset, int mask)
0. Whitespace. 1. Comments. 2. All others.If there are two elements at the insertion point (one before and one after), then:
 1. If they have different precedence, the one with the higher
    precedence is returned. For example, suppose one element is
    a whitespace element (0) and the other is a structural
    element (2), then the structural element is returned.
 2. The element occurring after the insertion point is returned.
 offset - The insertion point.mask - Same as the mask in getChildren(I) or getSiblings(I).SourceElement.getChildren(int), 
SourceElement.getSiblings(int)SourceElement getElementContaining(int startOffset, int endOffset)
startOffset - The start offset, inclusiveendOffset - The end offset, inclusiveSourceElement getElementContaining(int startOffset, int endOffset, java.util.EnumSet<SourceFile.ElementAtMask> mask)
startOffset - The startOffset, inclusiveendOffset - The endOffset, inclusivemask - The mask to use for filtering elements. Only NONE, COMMENTS,
 BLANKLINES, ALL, DEFAULT are honored, applied in that order.SourceToken getTokenAt(int offset)
offset - An offsetvoid installImportCache()
void releaseImportCache()
void setParseErrors(java.util.List<SourceError> errors)
errors - A list of errorsvoid setCompileErrors(java.util.List<SourceError> errors)
errors - A list of errors