Jakub Chrzanowski 4e802980f2
Webhelp migration (#347)
* [webhelp] Fixes for TXP00152, TXP00002, test build 27 Jul 22:26

* [webhelp] Fixes for Part #4 TXP00010, EXCEPT decimal numbers in section titles

* [webhelp] Fixes for Part #5 TXP00017

* [webhelp] Fixes for Part #4 TXP00010 - removed numbers from page section titles in "Custom Language Support Tutorial" and "Testing a Custom Language Plugin".

* [webhelp] Removed numbers from page section titles in rest of project *.md files.

* [new webhelp] Build #44 changes

* [new webhelp] Maintenance merge from master

* [new webhelp] Add placeholder file for webhelp import.

* [webhelp] Correct redirects for file name changes

* [webhelp] TOC not needed in webhelp

* [format] {:toc} not needed for webhelp

* add {:disable-links} to ensure demo links are not interpreted as real links.

* Put all badges on the same line to simplify composition.

* formatter.md: fix upsource link

* fix some links

* api_changes_list.md: remove note

* migrate to webhelp - initial

* fix GH edit URL

* remove sdkdocs-template setup in VCS config

* remove recently_updated.md

* restore COC/CONTRIBUTING.md

* api_changes_list.md: remove note

* useful_links.md: IPE

Co-authored-by: JohnHake <john.hake@jetbrains.com>
Co-authored-by: Yann Cébron <yann.cebron@jetbrains.com>
2021-01-14 16:07:39 +01:00

2.7 KiB

A quick fix for a custom language supports the IntelliJ Platform-based IDE feature Intention Actions. For the Simple Language, this tutorial adds a quick fix that helps to define an unresolved property from its usage.

Reference: Code Inspections and Intentions

Update the Element Factory

The SimpleElementFactory is updated to include two new methods to support the user choice of creating a new property for the Simple Language quick fix. The new createCRLF() method supports adding a newline to the end of the test.simple file before adding a new property. A new overload of createProperty() creates a new key-value pair for Simple Language.

{src="simple_language_plugin/src/main/java/org/intellij/sdk/language/psi/SimpleElementFactory.java"}

Define an Intention Action

The SimpleCreatePropertyQuickFix creates a property in the file chosen by the user - in this case, a Java file containing a prefix:key - and navigate to this property after creation. Under the hood, SimpleCreatePropertyQuickFix is an Intention Action. For a more in-depth example of an Intention Action, see conditional_operator_intention.

{src="simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleCreatePropertyQuickFix.java"}

Update the Annotator

When a badProperty annotation is created, the badProperty.registerFix() method is called. This method call registers the SimpleCreatePropertyQuickFix as the Intention Action for the Intellij Platform to use to correct the problem.

{src="simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleAnnotator.java"}

Run the Project

Open the test Java file in an IDE Development Instance running the simple_language_plugin.

To test SimpleCreatePropertyQuickFix, change simple:website to simple:website.url. The key website.url is highlighted by SimpleAnnotator as an invalid key, as shown below. Choose "Create Property".

Quick Fix{width="800"}

The IDE opens the test.simple file and adds website.url as a new key. Add the new value jetbrains.com for the new website.url key.

New Property

Now switch back to the Java file; the new key is highlighted as valid.