public abstract class JavaFix extends Object
Fix
by means of the JavaFix.toEditorFix()
method.for various predefined fixes.
Modifier and Type | Class and Description |
---|---|
static class |
JavaFix.TransformationContext
A context that contains a reference to a
WorkingCopy through which
modifications of Java source code can be made. |
Modifier | Constructor and Description |
---|---|
protected |
JavaFix(CompilationInfo info,
TreePath tp)
Create JavaFix with the given base
TreePath . |
protected |
JavaFix(CompilationInfo info,
TreePath tp,
String sortText)
Create JavaFix with the given base
TreePath . |
protected |
JavaFix(TreePathHandle handle)
Create JavaFix with the given base
TreePathHandle . |
protected |
JavaFix(TreePathHandle handle,
String sortText)
Create JavaFix with the given base
TreePathHandle . |
Modifier and Type | Method and Description |
---|---|
protected abstract String |
getText()
The display text of the fix.
|
protected abstract void |
performRewrite(JavaFix.TransformationContext ctx)
Do the transformations needed to implement the hint's function.
|
Fix |
toEditorFix()
|
protected JavaFix(@NonNull CompilationInfo info, @NonNull TreePath tp)
TreePath
. The base TreePath
will be passed back to the real implementation of the fix.info
- a CompilationInfo
from which the given TreePath
originatestp
- a TreePath
that will be passed back to the
JavaFix.performRewrite(org.netbeans.spi.java.hints.JavaFix.TransformationContext)
methodprotected JavaFix(@NonNull CompilationInfo info, @NonNull TreePath tp, @NullAllowed String sortText)
TreePath
. The base TreePath
will be passed back to the real implementation of the fix.info
- a CompilationInfo
from which the given TreePath
originatestp
- a TreePath
that will be passed back to the
JavaFix.performRewrite(org.netbeans.spi.java.hints.JavaFix.TransformationContext)
methodsortText
- if non-null, fix returned from JavaFix.toEditorFix()
will be an EnhancedFix
,
and the given sortText
will be returned from its EnhancedFix.getSortText()
.protected JavaFix(@NonNull TreePathHandle handle)
TreePathHandle
. The base TreePathHandle
will be resolved and passed back to the real implementation of the fix.handle
- a TreePathHandle
that will be resolved and passed back to the
JavaFix.performRewrite(org.netbeans.spi.java.hints.JavaFix.TransformationContext)
methodprotected JavaFix(@NonNull TreePathHandle handle, @NullAllowed String sortText)
TreePathHandle
. The base TreePathHandle
will be resolved and passed back to the real implementation of the fix.handle
- a TreePathHandle
that will be resolved and passed back to the
JavaFix.performRewrite(org.netbeans.spi.java.hints.JavaFix.TransformationContext)
methodsortText
- if non-null, fix returned from JavaFix.toEditorFix()
will be an EnhancedFix
,
and the given sortText
will be returned from its EnhancedFix.getSortText()
.@NonNull protected abstract String getText()
protected abstract void performRewrite(@NonNull JavaFix.TransformationContext ctx) throws Exception
ctx
- a context over which the fix should operateException
- if something goes wrong while performing the transformation
- will be logged by the infrastructurepublic final Fix toEditorFix()
Fix
, that when invoked, will invoke JavaFix.performRewrite(org.netbeans.spi.java.hints.JavaFix.TransformationContext)
method on this JavaFix
.