public class TransformContext
extends java.lang.Object
Transform
can be applied to a Violation
.
Contexts are created by the Audit framework when it needs to invoke
transform methods, and discarded immediately after use. A context has
properties derived from the violation: in particular, rule, location, and
parameters. The location can be set differently than the location of the
violation, though typically it will at least be a related location of the
violation.
In support of transforms used in interactive circumstances (e.g., a code
editor), contexts allow a transform to specify the caret and selection to
leave the user with after the transform is applied.Constructor and Description |
---|
TransformContext(TransformAdapter adapter,
Transform transform,
Violation violation,
Location location)
Creates a transform context for a transform to be applied to a violation.
|
Modifier and Type | Method and Description |
---|---|
void |
addHighlight(java.lang.Object construct)
Adds a highlight region for a construct in the model for this context.
|
void |
addRemovedHighlight(java.lang.Object construct)
Adds a highlight region for an about-to-be-removed construct in the model
for this context.
|
TransformAdapter |
getAdapter()
Gets the transform adapter for the transform of this context.
|
java.lang.Object |
getAttribute(java.lang.String name)
Gets the value of an attribute.
|
Transform |
getDefaultTransform()
Gets the default transform of this violation, or null if none.
|
Location |
getFocusLocation()
Gets the focus location of the violation, or null if none.
|
Context |
getIdeContext()
Gets an IDE context in which this transform is being applied.
|
Location |
getLocation()
Gets the location to be transformed.
|
ModelAdapter |
getModel()
Gets the model to be transformed.
|
ModelAdapter |
getModelAdapter()
Deprecated.
use
getModel() |
Node |
getNode()
Gets the node to be transformed.
|
java.lang.Object |
getParameter(java.lang.String name)
Gets the value of a parameter added to the violation or a property of the
transform, or null if none.
|
int |
getParameterCount()
Gets the number of parameters of the violation.
|
java.lang.String |
getParameterName(int index)
Gets the name of a parameter of the violation.
|
java.lang.Object |
getParameterValue(int index)
Gets the value of a parameter of this violation.
|
java.lang.Object |
getParameterValue(java.lang.String name)
Gets the value of a parameter of the violation by name.
|
java.lang.Object |
getPredecessorApplyData()
Gets the data that was returned by the apply method of the immediate
predecessor in a multiple context transform.
|
Project |
getProject()
Gets the project containing the model to be transformed.
|
Rule |
getRule() |
int |
getSerialNumber()
Gets the serial number of the violation.
|
Transform |
getTransform()
Gets the transform of this context.
|
Transform |
getTransform(int index)
Gets a transform of the violation.
|
int |
getTransformCount()
Gets the number of transforms of the violation.
|
java.lang.String |
getVariation()
Gets the variation in the rule violated, or null if the default.
|
Violation |
getViolation()
Gets the violation associated with the transform.
|
Workspace |
getWorkspace()
Gets the workspace containing the model to be transformed.
|
void |
invokeLater(Command command)
Invokes a command after the command currently being executed by the
Audit framework completes.
|
void |
setAttribute(java.lang.String name,
java.lang.Object value)
Sets the value of an attribute.
|
protected void |
setPredecessorApplyData(java.lang.Object applyData)
Sets the data that was returned by the apply method of the immediate
predecessor in a multiple context transform.
|
void |
setSelection(ModelAdapter model,
java.lang.Object construct,
boolean before,
boolean after)
Deprecated.
Use {@link #setSelection(ModelAdapter, Object, int, int)
|
void |
setSelection(ModelAdapter model,
java.lang.Object construct,
int margin,
int endMargin)
Sets the post-application caret and selection relative to a construct in a
specified model.
|
void |
setSelection(java.lang.Object construct,
boolean before,
boolean after)
Deprecated.
Use {@link #setSelection(Object, int, int)
|
void |
setSelection(java.lang.Object construct,
int margin,
int endMargin)
Sets the post-application caret and selection relative to a construct in
the model for this context.
|
java.lang.String |
toString() |
public TransformContext(TransformAdapter adapter, Transform transform, Violation violation, Location location)
adapter
- transform
- violation
- location
- public TransformAdapter getAdapter()
public Transform getTransform()
public Violation getViolation()
public Location getLocation()
public ModelAdapter getModel()
public ModelAdapter getModelAdapter()
getModel()
public Node getNode()
public Project getProject()
public Workspace getWorkspace()
public Context getIdeContext()
public Rule getRule()
public java.lang.String getVariation()
public java.lang.Object getParameter(java.lang.String name)
name
- The name given to the parameter.IssueReport.addParameter(java.lang.String, java.lang.Object)
public Location getFocusLocation()
public int getParameterCount()
public java.lang.String getParameterName(int index)
index
- The index of the parameter.public java.lang.Object getParameterValue(int index)
index
- The index of the parameter.public java.lang.Object getParameterValue(java.lang.String name)
public int getTransformCount()
public Transform getTransform(int index)
index
- The index of the transform.public Transform getDefaultTransform()
public int getSerialNumber()
public void setAttribute(java.lang.String name, java.lang.Object value)
public java.lang.Object getAttribute(java.lang.String name)
public java.lang.Object getPredecessorApplyData()
public void setSelection(java.lang.Object construct, int margin, int endMargin)
construct
- The construct at which to place the caret.margin
- Margin from start of construct to start of selection.endMargin
- Margin from end of construct to end of selection.public void setSelection(ModelAdapter model, java.lang.Object construct, int margin, int endMargin)
model
- The model containing the construct to select.construct
- The construct at which to place the caret.margin
- Margin from start of construct to start of selection.endMargin
- Margin from end of construct to end of selection.public void addHighlight(java.lang.Object construct)
construct
- The construct to highlight.public void addRemovedHighlight(java.lang.Object construct)
construct
- The construct to be removed.public void invokeLater(Command command)
protected void setPredecessorApplyData(java.lang.Object applyData)
public java.lang.String toString()
toString
in class java.lang.Object
public void setSelection(java.lang.Object construct, boolean before, boolean after)
before
is true, the caret is
positioned at the beginning of the construct; otherwise at the end of the
construct.construct
- The construct at which to place the caret.before
- Whether to place the caret at the beginning of the construct.after
- Whether to place the caret at the end of the construct.public void setSelection(ModelAdapter model, java.lang.Object construct, boolean before, boolean after)
before
is true, the caret is positioned
at the beginning of the construct; otherwise at the end of the construct.model
- The model containing the construct to select.construct
- The construct at which to place the caret.before
- Whether to place the caret at the beginning of the construct.after
- Whether to place the caret at the end of the construct.