mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-30 10:17:50 +08:00
[md] code inspections and intentions
This commit is contained in:
parent
512752509b
commit
c80c25c61f
@ -57,6 +57,7 @@
|
||||
* [Rename Refactoring](rename_refactoring.html)
|
||||
* [Safe Delete Refactoring](safe_delete_refactoring.html)
|
||||
* [Code Formatter](code_formatting.html)
|
||||
* [Code Inspections and Intentions](code_inspections_and_intentions.html)
|
||||
* [XML DOM API](xml_dom_api.html)
|
||||
* [Spring API](spring_api.html)
|
||||
* [VCS Integration Plugins](vcs_integration_for_plugins.html)
|
||||
|
36
code_inspections_and_intentions.md
Normal file
36
code_inspections_and_intentions.md
Normal file
@ -0,0 +1,36 @@
|
||||
---
|
||||
layout: editable
|
||||
title: Code Inspections and Intentions
|
||||
---
|
||||
|
||||
The code inspections for custom languages use the same API as all other code inspections, based on the
|
||||
[LocalInspectionTool](https://github.com/JetBrains/intellij-community/blob/master/platform/analysis-api/src/com/intellij/codeInspection/LocalInspectionTool.java)
|
||||
class.
|
||||
|
||||
The functionality of
|
||||
[LocalInspectionTool](https://github.com/JetBrains/intellij-community/blob/master/platform/analysis-api/src/com/intellij/codeInspection/LocalInspectionTool.java)
|
||||
partially duplicates that of
|
||||
[Annotator](https://github.com/JetBrains/intellij-community/blob/master/platform/analysis-api/src/com/intellij/lang/annotation/Annotator.java).
|
||||
The main differences are that
|
||||
[LocalInspectionTool](https://github.com/JetBrains/intellij-community/blob/master/platform/analysis-api/src/com/intellij/codeInspection/LocalInspectionTool.java)
|
||||
supports batch analysis of code (through the **Analyze \| Inspect Code...** action), the possibility to turn off the inspection (globally or by suppressing them on various levels) and to configure the inspection options.
|
||||
If none of that is required and the analysis only needs to run in the active editor,
|
||||
[Annotator](https://github.com/JetBrains/intellij-community/blob/master/platform/analysis-api/src/com/intellij/lang/annotation/Annotator.java)
|
||||
provides better performance (because of its support for incremental analysis) and more flexibility for highlighting errors.
|
||||
|
||||
**Example**:
|
||||
A
|
||||
[simple inspection](https://github.com/JetBrains/intellij-community/blob/master/plugins/properties/properties-psi-impl/src/com/intellij/codeInspection/TrailingSpacesInPropertyInspection.java)
|
||||
for
|
||||
[Properties language plugin](https://github.com/JetBrains/intellij-community/blob/master/plugins/properties/)
|
||||
|
||||
|
||||
The code intentions for custom languages also use the regular API for intentions.
|
||||
The intention classes need to implement the
|
||||
[IntentionAction](https://github.com/JetBrains/intellij-community/blob/master/platform/analysis-api/src/com/intellij/codeInsight/intention/IntentionAction.java)
|
||||
interface and to be registered using the `<intentionAction>` bean in your *plugin.xml*.
|
||||
|
||||
**Example:**
|
||||
A
|
||||
[simple intention action](https://github.com/JetBrains/intellij-community/blob/master/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/control/SplitIfIntention.java)
|
||||
for Groovy
|
@ -29,43 +29,7 @@ Providing custom language support includes the following major steps:
|
||||
* [Rename Refactoring](rename_refactoring.html)
|
||||
* [Safe Delete Refactoring](safe_delete_refactoring.html)
|
||||
* [Code Formatter](code_formatting.html)
|
||||
|
||||
|
||||
## Code Inspections and Intentions
|
||||
|
||||
The code inspections for custom languages use the same API as all other code inspections, based on the
|
||||
[LocalInspectionTool](https://github.com/JetBrains/intellij-community/blob/master/platform/analysis-api/src/com/intellij/codeInspection/LocalInspectionTool.java)
|
||||
class.
|
||||
|
||||
The functionality of
|
||||
[LocalInspectionTool](https://github.com/JetBrains/intellij-community/blob/master/platform/analysis-api/src/com/intellij/codeInspection/LocalInspectionTool.java)
|
||||
partially duplicates that of
|
||||
[Annotator](https://github.com/JetBrains/intellij-community/blob/master/platform/analysis-api/src/com/intellij/lang/annotation/Annotator.java).
|
||||
The main differences are that
|
||||
[LocalInspectionTool](https://github.com/JetBrains/intellij-community/blob/master/platform/analysis-api/src/com/intellij/codeInspection/LocalInspectionTool.java)
|
||||
supports batch analysis of code (through the **Analyze \| Inspect Code...** action), the possibility to turn off the inspection (globally or by suppressing them on various levels) and to configure the inspection options.
|
||||
If none of that is required and the analysis only needs to run in the active editor,
|
||||
[Annotator](https://github.com/JetBrains/intellij-community/blob/master/platform/analysis-api/src/com/intellij/lang/annotation/Annotator.java)
|
||||
provides better performance (because of its support for incremental analysis) and more flexibility for highlighting errors.
|
||||
|
||||
**Example**:
|
||||
A
|
||||
[simple inspection](https://github.com/JetBrains/intellij-community/blob/master/plugins/properties/properties-psi-impl/src/com/intellij/codeInspection/TrailingSpacesInPropertyInspection.java)
|
||||
for
|
||||
[Properties language plugin](https://github.com/JetBrains/intellij-community/blob/master/plugins/properties/)
|
||||
|
||||
|
||||
The code intentions for custom languages also use the regular API for intentions.
|
||||
The intention classes need to implement the
|
||||
[IntentionAction](https://github.com/JetBrains/intellij-community/blob/master/platform/analysis-api/src/com/intellij/codeInsight/intention/IntentionAction.java)
|
||||
interface and to be registered using the `<intentionAction>` bean in your *plugin.xml*.
|
||||
|
||||
**Example:**
|
||||
A
|
||||
[simple intention action](https://github.com/JetBrains/intellij-community/blob/master/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/control/SplitIfIntention.java)
|
||||
for Groovy
|
||||
|
||||
|
||||
* [Code Inspections and Intentions](code_inspections_and_intentions.html)
|
||||
|
||||
|
||||
## Structure View
|
||||
|
Loading…
x
Reference in New Issue
Block a user