mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-28 01:07:49 +08:00
language tutorial: link to "Run plugin"
This commit is contained in:
parent
2af2cdb04a
commit
89fa711c18
@ -180,12 +180,10 @@ See the [Creating Actions](working_with_custom_actions.md) tutorial for step-by-
|
||||
|
||||
### Executing the Plugin
|
||||
Open the Gradle tool window and search for the `runIde` task:
|
||||
* If it’s not in the list, hit the [Refresh](https://www.jetbrains.com/help/idea/jetgradle-tool-window.html#1eeec055) button at the top of the Gradle window.
|
||||
* If it’s not in the list, hit the [Refresh](https://www.jetbrains.com/help/idea/jetgradle-tool-window.html#1eeec055) button at the top of the Gradle tool window.
|
||||
* Or [Create a new Gradle Run Configuration](https://www.jetbrains.com/help/idea/create-run-debug-configuration-gradle-tasks.html).
|
||||
|
||||
{width="398"}
|
||||
|
||||
Double-click on the _runIde_ task to execute it.
|
||||
See the IntelliJ IDEA help for more information about [Working with Gradle tasks](https://www.jetbrains.com/help/idea/gradle.html#96bba6c3).
|
||||
|
||||
Finally, when `my_gradle_plugin` launches in the IDE development instance, there should be a new menu under the **Tools** menu.
|
||||
|
@ -1,6 +1,6 @@
|
||||
[//]: # (title: 7. Annotator)
|
||||
|
||||
<!-- Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
<!-- Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
|
||||
An `Annotator` helps highlight and annotate any code based on specific rules.
|
||||
This section adds annotation functionality to support the Simple Language in the context of Java code.
|
||||
@ -60,6 +60,9 @@ Using the `com.intellij.annotator` extension point in the plugin configuration f
|
||||
```
|
||||
|
||||
## Run the Project
|
||||
|
||||
Run the plugin by using the Gradle [runIde task](gradle_prerequisites.md#running-a-simple-gradle-based-intellij-platform-plugin).
|
||||
|
||||
As a test, define the following Java file containing a Simple Language `prefix:value` pair:
|
||||
|
||||
```java
|
||||
|
@ -1,6 +1,6 @@
|
||||
[//]: # (title: 16. Code Style Settings)
|
||||
|
||||
<!-- Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
<!-- Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
|
||||
Code style settings enable defining formatting options.
|
||||
A code style settings provider creates an instance of the settings and also creates an options page in settings/preferences.
|
||||
@ -50,6 +50,8 @@ The `SimpleLanguageCodeStyleSettingsProvider` implementation is registered with
|
||||
```
|
||||
|
||||
## Run the Project
|
||||
Run the plugin by using the Gradle [runIde task](gradle_prerequisites.md#running-a-simple-gradle-based-intellij-platform-plugin).
|
||||
|
||||
In the IDE Development Instance, open the Simple Language code formatting page: **Preferences/Settings \| Editor \| Code Style \| Simple**.
|
||||
|
||||

|
@ -1,6 +1,6 @@
|
||||
[//]: # (title: 17. Commenter)
|
||||
|
||||
<!-- Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
<!-- Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
|
||||
A commenter enables the user to comment-out a line of code at the cursor or selected code automatically.
|
||||
The [`Commenter`](upsource:///platform/core-api/src/com/intellij/lang/Commenter.java) defines support for **Code \| Comment with Line Comment** and **Code \| Comment with Block Comment** actions.
|
||||
@ -22,6 +22,8 @@ The `SimpleCommenter` implementation is registered in the plugin configuration f
|
||||
```
|
||||
|
||||
## Run the Project
|
||||
Run the plugin by using the Gradle [runIde task](gradle_prerequisites.md#running-a-simple-gradle-based-intellij-platform-plugin).
|
||||
|
||||
Open the example Simple Language [properties file ](lexer_and_parser_definition.md#run-the-project) in the IDE Development Instance.
|
||||
Place the cursor at the `website` line.
|
||||
Select **Code \| Comment with Line Comment**.
|
||||
|
@ -26,7 +26,9 @@ The `SimpleCompletionContributor` implementation is registered in the plugin con
|
||||
```
|
||||
|
||||
## Run the Project
|
||||
Run the `simple_language_plugin` in a Development Instance and open the [`test.simple`](lexer_and_parser_definition.md#run-the-project) file.
|
||||
Run the plugin by using the Gradle [runIde task](gradle_prerequisites.md#running-a-simple-gradle-based-intellij-platform-plugin).
|
||||
|
||||
Open the [`test.simple`](lexer_and_parser_definition.md#run-the-project) file.
|
||||
Erase the property "English" and invoke [Basic Code Completion](https://www.jetbrains.com/help/idea/auto-completing-code.html#invoke-basic-completion).
|
||||
The choice "Hello" is shown:
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
[//]: # (title: 11. Find Usages Provider)
|
||||
|
||||
<!-- Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
<!-- Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
|
||||
A `FindUsagesProvider` uses a word scanner to build an index of words in every file.
|
||||
A scanner breaks the text into words and defines the context for each word.
|
||||
@ -27,7 +27,8 @@ The `SimpleFindUsagesProvider` implementation is registered with the IntelliJ Pl
|
||||
```
|
||||
|
||||
## Run the Project
|
||||
Rebuild the project, and run `simple_language_plugin` in a Development Instance.
|
||||
Run the plugin by using the Gradle [runIde task](gradle_prerequisites.md#running-a-simple-gradle-based-intellij-platform-plugin).
|
||||
|
||||
The IDE now supports [Find Usages](https://www.jetbrains.com/help/idea/find-highlight-usages.html) for any property with a reference:
|
||||
|
||||

|
@ -1,6 +1,6 @@
|
||||
[//]: # (title: 12. Folding Builder)
|
||||
|
||||
<!-- Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
<!-- Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
|
||||
A folding builder identifies the folding regions in the code.
|
||||
In this step of the tutorial, the folding builder is used to identify folding regions and replace the regions with specific text.
|
||||
@ -37,8 +37,9 @@ The `SimpleFoldingBuilder` implementation is registered with the IntelliJ Platfo
|
||||
```
|
||||
|
||||
## Run the Project
|
||||
Rebuild the project, and run `simple_language_plugin` in a Development Instance.
|
||||
Now when a Java file is opened in the Editor, it shows the property's value instead of the key.
|
||||
Run the plugin by using the Gradle [runIde task](gradle_prerequisites.md#running-a-simple-gradle-based-intellij-platform-plugin).
|
||||
|
||||
Now when a Java file is opened in the editor, it shows the property's value instead of the key.
|
||||
This is because `SimpleFoldingBuilder.isCollapsedByDefault()` always returns `true`.
|
||||
Try using **Code \| Folding \| Expand All** to show the key rather than the value.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
[//]: # (title: 15. Formatter)
|
||||
|
||||
<!-- Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
<!-- Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
|
||||
The IntelliJ Platform includes a powerful framework for implementing formatting for custom languages.
|
||||
A formatter enables reformatting code automatically based on code style settings.
|
||||
@ -39,6 +39,9 @@ The `SimpleFormattingModelBuilder` implementation is registered with the Intelli
|
||||
```
|
||||
|
||||
## Run the Project
|
||||
Run the plugin by using the Gradle [runIde task](gradle_prerequisites.md#running-a-simple-gradle-based-intellij-platform-plugin).
|
||||
|
||||
Open the example Simple Language [properties file ](lexer_and_parser_definition.md#run-the-project) in the IDE Development Instance.
|
||||
Add some extra spaces around the `=` separator between `language` and `English`.
|
||||
Reformat the code by selecting **Code \| Show Reformat File Dialog** and choose **Run**.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
[//]: # (title: 13. Go To Symbol Contributor)
|
||||
|
||||
<!-- Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
<!-- Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
|
||||
A _Go to Symbol Contributor_ helps the user to navigate to any PSI element by its name.
|
||||
|
||||
@ -66,7 +66,8 @@ The `SimpleChooseByNameContributor` implementation is registered with the Intell
|
||||
```
|
||||
|
||||
## Run the Project
|
||||
Rebuild the project, and run `simple_language_plugin` in a Development Instance.
|
||||
Run the plugin by using the Gradle [runIde task](gradle_prerequisites.md#running-a-simple-gradle-based-intellij-platform-plugin).
|
||||
|
||||
The IDE now supports navigating to a property definition by name pattern via **Navigate \| Symbol** action.
|
||||
|
||||
{width="800"}
|
@ -1,6 +1,6 @@
|
||||
[//]: # (title: 2. Language and File Type)
|
||||
|
||||
<!-- Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
<!-- Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
|
||||
The IntelliJ Platform determines file type by examining the name of a file.
|
||||
Each language has [Language](upsource:///platform/core-api/src/com/intellij/lang/Language.java) and [LanguageFileType](upsource:///platform/core-api/src/com/intellij/openapi/fileTypes/LanguageFileType.java) objects defining the language.
|
||||
@ -67,7 +67,7 @@ The `SimpleFileTypeFactory` is registered using the `com.intellij.openapi.fileTy
|
||||
|
||||
## Run the Project
|
||||
|
||||
Run your project by using the [runIde task](gradle_prerequisites.md#running-a-simple-gradle-based-intellij-platform-plugin) in Gradle-based projects or [using the Plugin Run/Debug configuration](running_and_debugging_a_plugin.md) in DevKit-based projects.
|
||||
Run the plugin by using the Gradle [runIde task](gradle_prerequisites.md#running-a-simple-gradle-based-intellij-platform-plugin).
|
||||
|
||||
Create an empty file with the extension `*.simple`, and IntelliJ IDEA automatically associates it with our language.
|
||||
Note the appearance of the Simple Language file icon next to the `test.simple` file in the **Project Tool Window**, and the editor tab for the file.
|
||||
|
@ -1,6 +1,6 @@
|
||||
[//]: # (title: 4. Lexer and Parser Definition)
|
||||
|
||||
<!-- Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
<!-- Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
|
||||
The lexical analyzer defines how the contents of a file are broken into tokens, which is the basis for supporting custom language features.
|
||||
The easiest way to create a lexer is to use [JFlex](https://jflex.de/).
|
||||
@ -79,7 +79,10 @@ For example, see `simple_language_plugin/src/main/resources/META-INF/plugin.xml`
|
||||
```
|
||||
|
||||
## Run the Project
|
||||
With the `simple_language_plugin` loaded in a Development Instance, create a `test.simple` properties file with the following content:
|
||||
|
||||
Run the plugin by using the Gradle [runIde task](gradle_prerequisites.md#running-a-simple-gradle-based-intellij-platform-plugin).
|
||||
|
||||
Create a `test.simple` properties file with the following content:
|
||||
|
||||
```text
|
||||
# You are reading the ".properties" entry.
|
||||
|
@ -76,7 +76,9 @@ The `SimpleLineMarkerProvider` implementation is registered with the IntelliJ Pl
|
||||
```
|
||||
|
||||
## Run the Project
|
||||
Run the `simple_language_plugin` in a Development Instance and open the [Test file](annotator.md#run-the-project).
|
||||
Run the plugin by using the Gradle [runIde task](gradle_prerequisites.md#running-a-simple-gradle-based-intellij-platform-plugin).
|
||||
|
||||
Open the Java [Test file](annotator.md#run-the-project).
|
||||
Now the icon appears next to line 3 on the gutter.
|
||||
A user can click on the icon to navigate to the property definition.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
[//]: # (title: 18. Quick Fix)
|
||||
|
||||
<!-- Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
<!-- Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
|
||||
A quick fix for a custom language supports the IntelliJ Platform-based IDE feature [Intention Actions](https://www.jetbrains.com/help/idea/intention-actions.html#apply-intention-actions).
|
||||
For the Simple Language, this tutorial adds a quick fix that helps to define an unresolved property from its usage.
|
||||
@ -34,7 +34,8 @@ This method call registers the `SimpleCreatePropertyQuickFix` as the Intention A
|
||||
{src="simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleAnnotator.java"}
|
||||
|
||||
## Run the Project
|
||||
Open the test [Java file](annotator.md#run-the-project) in an IDE Development Instance running the `simple_language_plugin`.
|
||||
Run the project by using the Gradle [runIde task](gradle_prerequisites.md#running-a-simple-gradle-based-intellij-platform-plugin).
|
||||
Open the test [Java file](annotator.md#run-the-project).
|
||||
|
||||
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.
|
||||
|
@ -1,6 +1,6 @@
|
||||
[//]: # (title: 10. Reference Contributor)
|
||||
|
||||
<!-- Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
<!-- Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
|
||||
The references functionality is one of the most important parts in the implementation of custom language support.
|
||||
Resolving references means the ability to go from the usage of an element to its declaration, completion, rename refactoring, find usages, etc.
|
||||
@ -128,7 +128,8 @@ The `SimpleReferenceContributor` implementation is registered with the IntelliJ
|
||||
```
|
||||
|
||||
## Run the Project with the Reference Contributor
|
||||
Rebuild the project, and run `simple_language_plugin` in a Development Instance.
|
||||
Run the project by using the Gradle [runIde task](gradle_prerequisites.md#running-a-simple-gradle-based-intellij-platform-plugin).
|
||||
|
||||
The IDE now resolves the property and provides [completion](https://www.jetbrains.com/help/idea/auto-completing-code.html#basic_completion) suggestions:
|
||||
|
||||
{width="800"}
|
||||
@ -157,7 +158,8 @@ The `SimpleRefactoringSupportProvider` implementation is registered with the Int
|
||||
```
|
||||
|
||||
## Run the Project
|
||||
Rebuild the project, and run `simple_language_plugin` in a Development Instance.
|
||||
Run the project by using the Gradle [runIde task](gradle_prerequisites.md#running-a-simple-gradle-based-intellij-platform-plugin).
|
||||
|
||||
The IDE now supports [refactoring](https://www.jetbrains.com/help/idea/rename-refactorings.html) suggestions:
|
||||
|
||||
{width="800"}
|
@ -1,6 +1,6 @@
|
||||
[//]: # (title: 14. Structure View Factory)
|
||||
|
||||
<!-- Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
<!-- Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
|
||||
The structure view can be customized for a specific file type.
|
||||
Creating a structure view factory allows showing the structure of any file in a _Structure_ Tool Window for easy navigation between items in the current editor.
|
||||
@ -44,7 +44,8 @@ The `SimpleStructureViewFactory` implementation is registered with the IntelliJ
|
||||
```
|
||||
|
||||
## Run the Project
|
||||
Rebuild the project, and run `simple_language_plugin` in a Development Instance.
|
||||
Run the project by using the Gradle [runIde task](gradle_prerequisites.md#running-a-simple-gradle-based-intellij-platform-plugin).
|
||||
|
||||
Open the `test.simple` file and choose **View \| Tool Windows \| Structure**.
|
||||
The IDE now supports a structure view of the Simple Language:
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
[//]: # (title: 5. Syntax Highlighter and Color Settings Page)
|
||||
|
||||
<!-- Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
<!-- Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
|
||||
The first level of syntax highlighting is based on the lexer output, and is provided by `SyntaxHighlighter`.
|
||||
A plugin can also define color settings based on `ColorSettingPage` so the user can configure highlight colors.
|
||||
@ -59,6 +59,8 @@ Register the Simple Language color settings page with the IntelliJ Platform in t
|
||||
```
|
||||
|
||||
### Run the Project
|
||||
Run the project by using the Gradle [runIde task](gradle_prerequisites.md#running-a-simple-gradle-based-intellij-platform-plugin).
|
||||
|
||||
In the IDE Development Instance, open the Simple Language highlight settings page: **Preferences/Settings \| Editor \| Color Scheme \| Simple**.
|
||||
Each color initially inherits from a _Language Defaults_ value.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user