Move the "Find by UI text" API exploring strategy from code_inspections.md to explore_api.md

This commit is contained in:
Karol Lewandowski 2023-02-22 10:33:39 +01:00
parent b7e6d166fc
commit 754ddff0d0
2 changed files with 20 additions and 17 deletions

View File

@ -126,7 +126,23 @@ You can either use
[Search Everything or Go to Symbol](https://www.jetbrains.com/help/idea/reference-keymap-win-default.html#find_everything). [Search Everything or Go to Symbol](https://www.jetbrains.com/help/idea/reference-keymap-win-default.html#find_everything).
Note that you need to change the search scope to <control>All Places</control> in the search window to find all occurrences of symbols. Note that you need to change the search scope to <control>All Places</control> in the search window to find all occurrences of symbols.
### 2.5 Refrain from Using Internal Classes ### 2.5 Search by UI Text
If you want to implement a functionality that is similar to an existing IDE feature, but you can't guess the name of the extension point or implementation class, the underlying implementation can be found by the texts displayed in the UI.
* Use the displayed text or its part as the [target for a search](https://www.jetbrains.com/help/idea/finding-and-replacing-text-in-project.html) within the IntelliJ Community project.
* If the text is localized, this will identify a bundle file there the text is defined. Copy the key from the bundle file identified by the search.
* Use the key text as the target for a search within the IntelliJ Community project.
This search locates the implementation or related class, or [plugin configuration file](plugin_configuration_file.md) that uses the text key in an [extension](plugin_extensions.md) declaration.
* If the key is found in the extension declaration in <path>plugin.xml</path> file, find the implementing class attribute value (in most cases it is `implementationClass`) and
[navigate to a declaration](https://www.jetbrains.com/help/rider/Navigation_and_Search__Go_to_Declaration.html#74fa64b7),
or use attribute value as the
[target of a class search](https://www.jetbrains.com/help/idea/searching-everywhere.html#Searching_Everywhere.xml)
in the IntelliJ Community codebase to find the implementation.
* If the text is not localized, the search will most probably find the desired implementation or related class.
In this case, search for the found method/class usages, and repeat this until the actual implementation class is found.
### 2.6 Refrain from Using Internal Classes
As a general remark, the use of internal classes is strongly discouraged (i.e. classes ending with `Impl` in their name, As a general remark, the use of internal classes is strongly discouraged (i.e. classes ending with `Impl` in their name,
located under `impl` package, or included in <path>*-impl.jar</path>). located under `impl` package, or included in <path>*-impl.jar</path>).

View File

@ -31,22 +31,9 @@ It illustrates the components for a custom inspection plugin:
* Writing an HTML [description](#inspection-description) of the inspection for display in the inspection preferences panel. * Writing an HTML [description](#inspection-description) of the inspection for display in the inspection preferences panel.
* Optionally, create a [unit test](#inspection-unit-test) for the plugin. * Optionally, create a [unit test](#inspection-unit-test) for the plugin.
Although the IntelliJ Platform SDK code samples illustrate implementations of these components, it is often useful to see examples of inspections implemented in the [IntelliJ Community](https://github.com/JetBrains/intellij-community) code base. Although the code sample illustrates implementations of these components, it is often useful to see examples of inspections implemented in the [IntelliJ Community](https://github.com/JetBrains/intellij-community) code base.
This process can help find inspection descriptions and implementations based on what is visible in the IDE UI. To identify a given inspection's implementation classes, try to find an inspection [by name](explore_api.md#24-search-for-symbol-names) or [by UI texts](explore_api.md#25-search-by-ui-text).
The overall approach works for inspections aimed at other languages as well. Consider also searching for existing implementations in [IntelliJ Platform Explorer](https://jb.gg/ipe?extensions=com.intellij.localInspection).
* Find an existing inspection that is similar to the one you want to implement in the <ui-path>Settings | Editor | Inspections</ui-path> panel.
Note the display name of the inspection.
For example, the Java/Probable Bugs inspection <control>Object comparison using '==', instead of 'equals()'</control> is very similar to `comparing_references_inspection`.
* Use the display name text as the [target for a search](https://www.jetbrains.com/help/idea/finding-and-replacing-text-in-project.html) within the IntelliJ Community project.
This will identify a bundle file if the display name is localized.
If it is not localized, the search finds either the <path>[plugin.xml](plugin_configuration_file.md)</path> file where it is an attribute in the inspection description, or the implementation where it is provided by an overridden method.
* In the case of localization, copy the key from the bundle file identified by the search.
* Use the key text as the target for a search within the IntelliJ Community project.
This search locates the plugin configuration file that describes the inspection.
* From the inspection description entry, find the `implementationClass` attribute value.
* Use the `implementationClass` text as the [target of a class search](https://www.jetbrains.com/help/idea/searching-everywhere.html#Searching_Everywhere.xml) in the IntelliJ Community codebase to find the implementation.
See also [](explore_api.md) for more information and strategies.
## Creating an Inspection ## Creating an Inspection