public final class Annotation extends java.lang.Object implements Segment
Annotator
,
AnnotationHolder
,
RangeHighlighter
Modifier and Type | Class and Description |
---|---|
static class |
Annotation.QuickFixInfo |
BY_START_OFFSET_THEN_END_OFFSET, EMPTY_ARRAY
Constructor and Description |
---|
Annotation(int startOffset,
int endOffset,
HighlightSeverity severity,
java.lang.String message,
java.lang.String tooltip)
Creates an instance of the annotation.
|
Modifier and Type | Method and Description |
---|---|
java.util.List<Annotation.QuickFixInfo> |
getBatchFixes() |
int |
getEndOffset()
Returns the end offset of the text range covered by the annotation.
|
TextAttributes |
getEnforcedTextAttributes() |
GutterIconRenderer |
getGutterIconRenderer()
Gets the renderer used to draw the gutter icon in the region covered by the annotation.
|
ProblemHighlightType |
getHighlightType()
If the annotation matches one of commonly encountered problem types, returns the ID of that
problem type so that an appropriate color can be used for highlighting the annotation.
|
java.lang.String |
getMessage()
Returns the description of the annotation (shown in the status bar or by "View | Error Description" action).
|
ProblemGroup |
getProblemGroup()
Gets the unique object, which is the same for all of the problems of this group
|
java.util.List<Annotation.QuickFixInfo> |
getQuickFixes()
Returns the list of quick fixes registered for the annotation.
|
HighlightSeverity |
getSeverity()
Returns the severity of the problem indicated by the annotation (highlight, warning or error).
|
int |
getStartOffset()
Returns the start offset of the text range covered by the annotation.
|
TextAttributesKey |
getTextAttributes()
Returns the text attribute key used for highlighting the annotation.
|
java.lang.String |
getTooltip()
Returns the tooltip for the annotation (shown when hovering the mouse in the gutter bar).
|
boolean |
isAfterEndOfLine()
Returns the flag indicating whether the annotation is shown after the end of line containing it.
|
boolean |
isFileLevelAnnotation()
File level annotations are visualized differently than lesser range annotations by showing a title bar on top of the
editor rather than applying text attributes to the text range.
|
boolean |
needsUpdateOnTyping()
Gets a flag indicating what happens with the annotation when the user starts typing.
|
<T extends IntentionAction & LocalQuickFix> |
registerBatchFix(T fix,
TextRange range,
HighlightDisplayKey key)
Registers a quickfix which would be available during batch mode only,
in particular during com.intellij.codeInspection.DefaultHighlightVisitorBasedInspection run
|
void |
registerFix(IntentionAction fix)
Registers a quick fix for the annotation.
|
void |
registerFix(IntentionAction fix,
TextRange range) |
void |
registerFix(IntentionAction fix,
TextRange range,
HighlightDisplayKey key)
Registers a quick fix for the annotation which is only available on a particular range of text
within the annotation.
|
void |
registerFix(LocalQuickFix fix,
TextRange range,
HighlightDisplayKey key,
ProblemDescriptor problemDescriptor) |
<T extends IntentionAction & LocalQuickFix> |
registerUniversalFix(T fix,
TextRange range,
HighlightDisplayKey key)
Register a quickfix which would be available onTheFly and in the batch mode.
|
void |
setAfterEndOfLine(boolean afterEndOfLine)
Sets the flag indicating whether the annotation is shown after the end of line containing it.
|
void |
setEnforcedTextAttributes(TextAttributes enforcedAttributes)
Sets the text attributes used for highlighting the annotation.
|
void |
setFileLevelAnnotation(boolean isFileLevelAnnotation)
File level annotations are visualized differently than lesser range annotations by showing a title bar on top of the
editor rather than applying text attributes to the text range.
|
void |
setGutterIconRenderer(GutterIconRenderer gutterIconRenderer)
Sets the renderer used to draw the gutter icon in the region covered by the annotation.
|
void |
setHighlightType(ProblemHighlightType highlightType)
If the annotation matches one of commonly encountered problem types, sets the ID of that
problem type so that an appropriate color can be used for highlighting the annotation.
|
void |
setNeedsUpdateOnTyping(boolean b)
Sets a flag indicating what happens with the annotation when the user starts typing.
|
void |
setProblemGroup(ProblemGroup problemGroup)
Sets the unique object, which is the same for all of the problems of this group
|
void |
setTextAttributes(TextAttributesKey enforcedAttributes)
Sets the text attributes key used for highlighting the annotation.
|
void |
setTooltip(java.lang.String tooltip)
Sets the tooltip for the annotation (shown when hovering the mouse in the gutter bar).
|
java.lang.String |
toString() |
public Annotation(int startOffset, int endOffset, HighlightSeverity severity, java.lang.String message, java.lang.String tooltip)
AnnotationHolder.newAnnotation(HighlightSeverity, String)
builder methods instead.startOffset
- the start offset of the text range covered by the annotation.endOffset
- the end offset of the text range covered by the annotation.severity
- the severity of the problem indicated by the annotation (highlight, warning or error).message
- the description of the annotation (shown in the status bar or by "View | Error Description" action)tooltip
- the tooltip for the annotation (shown when hovering the mouse in the gutter bar)AnnotationHolder.newAnnotation(com.intellij.lang.annotation.HighlightSeverity, java.lang.String)
public void registerFix(IntentionAction fix)
fix
- the quick fix implementation.public void registerFix(IntentionAction fix, TextRange range)
public void registerFix(LocalQuickFix fix, TextRange range, HighlightDisplayKey key, ProblemDescriptor problemDescriptor)
public void registerFix(IntentionAction fix, TextRange range, HighlightDisplayKey key)
fix
- the quick fix implementation.range
- the text range (relative to the document) where the quick fix is available.public <T extends IntentionAction & LocalQuickFix> void registerBatchFix(T fix, TextRange range, HighlightDisplayKey key)
public <T extends IntentionAction & LocalQuickFix> void registerUniversalFix(T fix, TextRange range, HighlightDisplayKey key)
public void setNeedsUpdateOnTyping(boolean b)
b
- whether the annotation needs to be removed on typing.needsUpdateOnTyping()
public boolean needsUpdateOnTyping()
setNeedsUpdateOnTyping(boolean)
public int getStartOffset()
getStartOffset
in interface Segment
public int getEndOffset()
getEndOffset
in interface Segment
public HighlightSeverity getSeverity()
public ProblemHighlightType getHighlightType()
public TextAttributesKey getTextAttributes()
public TextAttributes getEnforcedTextAttributes()
public void setEnforcedTextAttributes(TextAttributes enforcedAttributes)
enforcedAttributes
- the text attributes for highlighting,public java.util.List<Annotation.QuickFixInfo> getQuickFixes()
public java.util.List<Annotation.QuickFixInfo> getBatchFixes()
public java.lang.String getMessage()
public java.lang.String getTooltip()
public void setTooltip(java.lang.String tooltip)
tooltip
- the tooltip text.public void setHighlightType(ProblemHighlightType highlightType)
highlightType
- the ID of the problem type.public void setTextAttributes(TextAttributesKey enforcedAttributes)
enforcedAttributes
- the text attributes key for highlighting,public boolean isAfterEndOfLine()
public void setAfterEndOfLine(boolean afterEndOfLine)
afterEndOfLine
- true if the annotation should be shown after the end of line, false otherwise.public boolean isFileLevelAnnotation()
true
if this particular annotation have been defined as file level.public void setFileLevelAnnotation(boolean isFileLevelAnnotation)
isFileLevelAnnotation
- true
if this particular annotation should be visualized at file level.public GutterIconRenderer getGutterIconRenderer()
public void setGutterIconRenderer(GutterIconRenderer gutterIconRenderer)
gutterIconRenderer
- the gutter icon renderer instance.public ProblemGroup getProblemGroup()
public void setProblemGroup(ProblemGroup problemGroup)
problemGroup
- the problem grouppublic java.lang.String toString()
toString
in class java.lang.Object