public interface SourceElement extends Element
| Modifier and Type | Field and Description | 
|---|---|
static int | 
CHILDREN_ALL
Includes every type of child currently supported. 
 | 
static int | 
CHILDREN_BLANKLINES
(SourceLexicalBlankline). 
 | 
static int | 
CHILDREN_COMMENTS
(SourceLexicalComment). 
 | 
static int | 
CHILDREN_default
The same as CHILDREN_REGULAR. 
 | 
static int | 
CHILDREN_none
Masks for getChildren(I), getSiblings(I), and getElementAt(I). 
 | 
static int | 
CHILDREN_REGULAR
(extends SourceElement, does not extend SourceLexicalElement). 
 | 
static SourceElement[] | 
EMPTY_ARRAY  | 
static int | 
PRINT_ALL
Constant that can be used as the format argument in calls to
 SourceElement.print(int) or SourceElement.print(PrintWriter, int). 
 | 
static int | 
REFORMAT_ALL
Redoes formatting on this subtree. 
 | 
static int | 
REFORMAT_INDENT
Redoes indentation on this subtree. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
addSelf(SourceElement parent)
Performs an add (usually append) of this element to the parent. 
 | 
void | 
addSelf(SourceElement sibling,
       boolean before)
Performs an add of this element to the parent of the input
 sibling. 
 | 
void | 
addSelfAfter(SourceElement sibling)
Performs an add of this element after the sibling to the
 parent of sibling. 
 | 
void | 
addSelfBefore(SourceElement sibling)
Performs an add of this element before the sibling to the
 parent of sibling. 
 | 
boolean | 
adjustTextIndentation(int delta,
                     int tabSize,
                     boolean useTabs)
Most SourceElements that were removed from their parent, such as by the removeSelf
 or replaceSelf methods, save their textual representation as returned by getText(). 
 | 
void | 
clearBinding(int key)
Clears the NodeBinding instance that returns the same
 binding type key as the incoming key. 
 | 
SourceElement | 
cloneSelf(SourceFile targetFile)
Performs a deep-copy of this SourceElement but attached to the
 input SourceFile. 
 | 
void | 
compile()
Recursively compiles the sub-tree rooted at this element. 
 | 
CallerContext | 
createContext(boolean forgiving)
Creates a CallerContext with this SourceElement as
 the scope. 
 | 
NodeBinding | 
getBinding(int key)
Gets the NodeBinding instance stored under the same
 key as the incoming key. 
 | 
java.util.List<SourceElement> | 
getChildren()
Gets the list of children SourceElement. 
 | 
java.util.List<SourceElement> | 
getChildren(int mask)
Gets the list of children SourceElement. 
 | 
JavaElement | 
getCompiledObject()
Call resolve() implicitly and gets the compiled object
 associated with this element. 
 | 
SourceElement[] | 
getContainedElements()
This method is equivalent to getChildren() except that it returns an
 array. 
 | 
CallerContext | 
getContext()
Gets the compiler context. 
 | 
int | 
getEndOffset()
Gets the (exclusive) end offset into the TextBuffer. 
 | 
SourceToken | 
getFirstToken(short tokenValue)
Get the first token of this SourceElement that has a particular token value,
 e.g. 
 | 
JdkVersion | 
getJdkVersion()
Gets the JDK version used to validate syntax for this SourceElement. 
 | 
SourceToken | 
getLastToken(short tokenValue)
Get the last token of this SourceElement that has a particular token value,
 e.g. 
 | 
SourceFile | 
getOwningFile()
Deprecated. 
 
Use getOwningSourceFile(). 
 | 
SourceFile | 
getOwningSourceFile()
Gets the owning SourceFile. 
 | 
SourceElement | 
getParent()
Gets the parent SourceElement to this. 
 | 
SourceElement | 
getSiblingAfter()
Gets the sibling after this SourceElement. 
 | 
SourceElement | 
getSiblingAfter(int mask)
Gets the sibling after this SourceElement. 
 | 
SourceElement | 
getSiblingBefore()
Gets the sibling before this SourceElement. 
 | 
SourceElement | 
getSiblingBefore(int mask)
Gets the sibling before this SourceElement. 
 | 
java.util.ListIterator<SourceElement> | 
getSiblings()
Gets a ListIterator for this SourceElement's siblings. 
 | 
java.util.ListIterator<SourceElement> | 
getSiblings(int mask)
Gets a ListIterator for this SourceElement's siblings. 
 | 
int | 
getStartOffset()
Gets the (inclusive) start offset into the TextBuffer. 
 | 
int | 
getSymbolKind()
Identifies what kind of SourceElement this is. 
 | 
java.lang.String | 
getText()
Gets the raw text for this SourceElement. 
 | 
java.util.List<SourceToken> | 
getTokens()
Get the tokens of this SourceElement. 
 | 
java.util.List<SourceToken> | 
getTokens(short tokenValue)
Get the tokens of this SourceElement that have a particular token value,
 e.g. 
 | 
boolean | 
hasErrors()
Determine if this SourceElement, or any SourceElement it contains,
 caused an error that will prevent a successful compilation. 
 | 
java.lang.String | 
print()
Returns a formatted representation of this SourceElement. 
 | 
java.lang.String | 
print(int format)
Returns a formatted, potentially adjusted representation of this SourceElement. 
 | 
void | 
print(java.io.PrintWriter out)
Prints a formatted representation of this SourceElement to the PrintWriter
 instance. 
 | 
void | 
print(java.io.PrintWriter out,
     int format)
Prints a formatted, potentially adjusted representation of this SourceElement
 to the PrintWriter. 
 | 
boolean | 
reformatSelf(int mask)
Attempts to format this subtree based on the mask argument. 
 | 
void | 
removeSelf()
Performs a remove of this element from its parent. 
 | 
void | 
replaceSelf(SourceElement newElement)
Performs a set of this element with the newElement. 
 | 
JavaElement | 
resolve()
Performs name and type resolution on this element. 
 | 
void | 
setBinding(NodeBinding data)
Stores the data under the key returned by the NodeBinding
 instance. 
 | 
void | 
setContext(CallerContext context)
Sets the compiler context. 
 | 
void | 
visitSelf(SourceVisitor visitor)
Traverses the subtree rooted at this element with the given visitor. 
 | 
static final SourceElement[] EMPTY_ARRAY
static final int CHILDREN_none
static final int CHILDREN_REGULAR
static final int CHILDREN_COMMENTS
static final int CHILDREN_BLANKLINES
static final int CHILDREN_ALL
static final int CHILDREN_default
static final int REFORMAT_ALL
static final int REFORMAT_INDENT
static final int PRINT_ALL
int getStartOffset()
int getEndOffset()
int getSymbolKind()
java.lang.String getText()
ExpiredTextBufferException - if the SourceFile that contains
 this SourceElement has expired@Deprecated SourceFile getOwningFile()
SourceFile getOwningSourceFile()
SourceElement getParent()
CallerContext createContext(boolean forgiving)
forgiving - If true, the context will attempt to ignore
 compiler errors as much as possible in order to give non-null
 results. If false, the context will return null results if
 compiler errors are encounteredjava.lang.IllegalStateException - if this SourceElement has no
 owning SourceFile OR if that SourceFile has no JavaProviderCallerContext getContext()
void setContext(CallerContext context)
java.lang.IllegalStateException - if this element already has a parent.java.util.List<SourceElement> getChildren()
java.util.List<SourceElement> getChildren(int mask)
mask - A bit mask determining what input to use.
  Use one or more of the CHILDREN_XXX mask variables
  defined in this filejava.util.ListIterator<SourceElement> getSiblings()
java.util.ListIterator<SourceElement> getSiblings(int mask)
mask - A bit mask determining what input to use.
  Use one or more of the CHILDREN_XXX mask variables
  defined in this filejava.lang.IllegalArgumentException - if this element does not match
 the input bit mask.SourceElement getSiblingBefore()
SourceElement getSiblingBefore(int mask)
mask - A bit mask determining what input to use.
  Use one or more of the CHILDREN_XXX mask variables
  defined in this fileSourceElement getSiblingAfter()
SourceElement getSiblingAfter(int mask)
mask - A bit mask determining what input to use.
  Use one or more of the CHILDREN_XXX mask variables
  defined in this filevoid visitSelf(SourceVisitor visitor)
SourceElement cloneSelf(SourceFile targetFile)
java.lang.UnsupportedOperationException - if this is a SourceFile.
 If you want to clone a SourceFile, you should use
 SourceFile.cloneSelf( TextBuffer ).void addSelf(SourceElement parent)
java.lang.UnsupportedOperationException - if this element may not
 be added.java.lang.IllegalStateException - if this element already has a
 parent.void addSelf(SourceElement sibling, boolean before)
before - If true, this element will be added before the
 sibling. If false, this element will be added after the sibling.java.lang.UnsupportedOperationException - if this element cannot be addedjava.lang.IllegalStateException - if sibling does not have a parentvoid addSelfBefore(SourceElement sibling)
java.lang.UnsupportedOperationException - if this element cannot be addedjava.lang.IllegalStateException - if sibling does not have a parentvoid addSelfAfter(SourceElement sibling)
java.lang.UnsupportedOperationException - if this element cannot be addedjava.lang.IllegalStateException - if sibling does not have a parentvoid replaceSelf(SourceElement newElement)
java.lang.UnsupportedOperationException - if this element may not
 be removed or the new element may not be added.java.lang.IllegalStateException - if this element does not have a
 parent or if the new element already has a parent.void removeSelf()
java.lang.UnsupportedOperationException - if this element may not
 be removed.java.lang.IllegalStateException - if the element does not have a
 parent.JavaElement getCompiledObject()
JavaElement resolve()
getCompiledObject()void compile()
java.util.concurrent.CancellationException - if SourceFile.cancelCompile() is
 called or the thread doing the compile is interrupted.NodeBinding getBinding(int key)
key - A key as defined by the BindingRegistryvoid setBinding(NodeBinding data)
data - The data to store under the key defined
 by the NodeBinding instancevoid clearBinding(int key)
key - A key as defined in the BindingRegistryboolean reformatSelf(int mask)
mask - Valid values are REFORMAT_*void print(java.io.PrintWriter out,
           int format)
format - SourceClass, SourceMethod, SourceVariable and SourceTypeParameter
 allow for limited formatting when printing. See those interfaces for more detailsvoid print(java.io.PrintWriter out)
java.lang.String print(int format)
format - SourceClass, SourceMethod, SourceVariable and SourceTypeParameter
 allow for limited formatting when printing. See those interfaces for more detailsjava.lang.String print()
SourceElement[] getContainedElements()
boolean hasErrors()
boolean adjustTextIndentation(int delta,
                              int tabSize,
                              boolean useTabs)
delta - The number of spaces to (un)indent, use negative for unindenttabSize - The number of spaces per tabuseTabs - If true, convert added spaces to tabs if possibleJdkVersion getJdkVersion()
java.util.List<SourceToken> getTokens()
java.util.List<SourceToken> getTokens(short tokenValue)
tokenValue - The token value all the returned tokens should haveSourceToken getFirstToken(short tokenValue)
tokenValue - The token value the returned token should haveSourceToken getLastToken(short tokenValue)
tokenValue - The token value the returned token should have