org.netbeans.api.java.source
public class WorkingCopy extends CompilationController
Modifier and Type | Method and Description |
---|---|
static WorkingCopy |
get(org.netbeans.modules.parsing.spi.Parser.Result result)
Returns an instance of the
WorkingCopy for
given Parser.Result if it is a result
of a java parser. |
TreeMaker |
getTreeMaker() |
void |
rewrite(Tree oldTree,
Tree newTree)
Replaces the original tree
oldTree with the new one -
newTree . |
void |
rewriteInComment(int start,
int length,
String newText)
Replace a part of a comment token with the given text.
|
void |
tag(Tree t,
Object tag)
Tags a tree.
|
JavaSource.Phase |
toPhase(JavaSource.Phase phase)
Moves the state to required phase.
|
doInvalidate
getChangedTree, getClasspathInfo, getCompilationUnit, getDiagnostics, getDocument, getElements, getElementUtilities, getFileObject, getJavaSource, getPhase, getPositionConverter, getSnapshot, getSourceVersion, getText, getTokenHierarchy, getTopLevelElements, getTrees, getTreeUtilities, getTypes, getTypeUtilities
@NullUnknown public static WorkingCopy get(@NonNull org.netbeans.modules.parsing.spi.Parser.Result result)
WorkingCopy
for
given Parser.Result
if it is a result
of a java parser.result
- for which the WorkingCopy
should be
returned.WorkingCopy
or null when the given result
is not a result of java parsing.@NonNull public JavaSource.Phase toPhase(@NonNull JavaSource.Phase phase) throws IOException
CompilationController
org.netbeans.api.java.source.JavaSource.Phase.PARSED
org.netbeans.api.java.source.JavaSource.Phase.ELEMENTS_RESOLVED
org.netbeans.api.java.source.JavaSource.Phase.RESOLVED
org.netbeans.api.java.source.JavaSource.Phase.UP_TO_DATE
toPhase
in class CompilationController
phase
- The required phaseIOException
- when the file cannot be red@NonNull public TreeMaker getTreeMaker() throws IllegalStateException
IllegalStateException
public void rewrite(@NullAllowed Tree oldTree, @NonNull Tree newTree)
oldTree
with the new one -
newTree
. null
values are not allowed.
Use methods in TreeMaker
for tree element removal.oldTree
- tree to be replaced, use tree already represented in
source code.newTree
- new tree, either created by TreeMaker
or obtained from different place.IllegalStateException
- if toPhase()
method was not
called before.IllegalArgumentException
- when null
was passed to the
method.TreeMaker
public void rewriteInComment(int start, int length, @NonNull String newText) throws IllegalArgumentException
rewrite(Tree,Tree)
.start
- absolute offset in the original text to start the replacementlength
- how many characters should be deleted from the original textnewText
- new text to be inserted at the specified offsetIllegalArgumentException
- when an attempt is made to replace non-comment textBuilt on March 18 2014. | Portions Copyright 1997-2014 Sun Microsystems, Inc. All rights reserved.