Editor Hints
Stable
Overview of Editor Hints module
EditorHintsSPI allows to show errors in the editor, with possible fixes.
What is New (see all changes)?
- Sep 11 '21 Added FileHintPreferences.openFilePreferences to open settings Added FileHintPreferences.openFilePreferences that opens hints settings.
- Jul 24 '17 Provide a way to have fixable annotation with default action For custom type of annotations will dynamically register this annotation type as fixable, so Fix action (click on the icon) will work for it
- Jul 17 '17 Support multiple ranges for ErrorDescriptor Added support for multiple ranges for error/warning. New field added to ErrorDescription as well as corresponding getter method and new constructor in order to be able to provide multiple ranges support for highlight particular hint. Added new factory method to ErrorDescriptionFactory which uses new ErrorDescription constructor.
- Aug 26 '15 Added customType field and constructor to ErrorDescription Added customType field to ErrorDescription as well as corresponding getter method and new constructor in order to be able to provide custom annotation type for particular hint. Added new factory method to ErrorDescriptionFactory which uses new ErrorDescription constructor.
- Apr 24 '13 Added a new overload for ErrorDescriptionFactory.createErrorDescription taking PositionBounds XXX
Use Cases
redunderline
Assume that you have a module using e.g. Parsing API to parse the source files and wants to mark the errors in the editor to be shown as red underlined in the editor. Here is the pseudo code that achieves this:
Document doc = ...;
ArrayList<ErrorDescription> errors = new ArrayList<ErrorDescription>();
for (<all errors from the parser that have parsed the doc>) {
errors.add(
ErrorDescriptionFactory.createErrorDescription(
Severity.ERROR,
d.getMessage(Locale.getDefault()),
doc,
doc.createPosition(start),
doc.createPosition(end)
)
);
}
HintsController.setErrors(doc, "myerrors", errors);
warningwithfix
Adding a warning with fixes:
static final class FixImpl implements Fix {
...
}
...
Document doc = ...;
List<Fix> fixes = Arrays.<Fix>asList(new FixImpl(...));
ArrayList<ErrorDescription> warnings = new ArrayList<ErrorDescription>();
for (<all places where the warning should be displayed>) {
warnings.add(
ErrorDescriptionFactory.createErrorDescription(
Severity.WARNING,
displayName,
fixes,
doc,
doc.createPosition(start),
doc.createPosition(end)
)
);
}
HintsController.setErrors(doc, "mywarnings", warnings);
Exported Interfaces
This table lists all of the module exported APIs with defined stability classifications. It is generated based on answers to questions about the architecture of the module. Read them all...Group of java interfaces
| Interface Name | In/Out | Stability | Specified in What Document? |
|---|---|---|---|
| EditorHintsSPI | Exported | Stable | .../spi/editor/hints/package-summary.html allows to show errors in the editor, with possible fixes. |
Implementation Details
Where are the sources for the module?
The sources for the module are in the Apache Git repositories or in the GitHub repositories
What do other modules need to do to declare a dependency on this one, in addition to or instead of a plain module dependency?
Normal module dependencies are used for this module.
Read more about the implementation in the answers to architecture questions.
Editor Hints