mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-28 01:07:49 +08:00
simplify links
This commit is contained in:
parent
857f7a60c7
commit
276955ed78
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
<!-- 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. -->
|
<!-- 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. -->
|
||||||
|
|
||||||
Custom languages provide code completion using one of two approaches: Contributor and Reference-based (see [10. Reference Contributor](reference_contributor.md)) completion.
|
Custom languages provide code completion using one of two approaches: Contributor and Reference-based (see [](reference_contributor.md)) completion.
|
||||||
|
|
||||||
**Reference**: [Code Completion](code_completion.md)
|
**Reference**: [](code_completion.md)
|
||||||
|
|
||||||
## Define a Completion Contributor
|
## Define a Completion Contributor
|
||||||
For this tutorial, the `simple_language_plugin` provides custom completion for values in Simple Language property files.
|
For this tutorial, the `simple_language_plugin` provides custom completion for values in Simple Language property files.
|
||||||
@ -32,4 +32,4 @@ 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).
|
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:
|
The choice "Hello" is shown:
|
||||||
|
|
||||||

|

|
||||||
|
@ -7,12 +7,12 @@ helps users by showing documentation for symbols like method calls inside the ed
|
|||||||
For the custom language tutorial, we’re implementing a version of this EP for the Simple Language that shows the key/value,
|
For the custom language tutorial, we’re implementing a version of this EP for the Simple Language that shows the key/value,
|
||||||
the file where it is defined, and any related documentation comment.
|
the file where it is defined, and any related documentation comment.
|
||||||
|
|
||||||
**Reference:** [Documentation](documentation.md)
|
**Reference:** [](documentation.md)
|
||||||
|
|
||||||
|
|
||||||
## Implement DocumentationProvider and Register the EP
|
## Implement DocumentationProvider and Register the EP
|
||||||
|
|
||||||
In the first step, we create an empty class that extends
|
In the first step, we create an empty class that extends
|
||||||
[`AbstractDocumentationProvider`](upsource:///platform/analysis-api/src/com/intellij/lang/documentation/AbstractDocumentationProvider.java)
|
[`AbstractDocumentationProvider`](upsource:///platform/analysis-api/src/com/intellij/lang/documentation/AbstractDocumentationProvider.java)
|
||||||
and registers it in the <path>plugin.xml</path>.
|
and registers it in the <path>plugin.xml</path>.
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ Make sure the class is registered in the <path>plugin.xml</path> between the `ex
|
|||||||
|
|
||||||
For the Simple Language, we consider two use-cases:
|
For the Simple Language, we consider two use-cases:
|
||||||
|
|
||||||
1. A Simple key is [used inside a Java string literal](reference_contributor.md),
|
1. A Simple key is [used inside a Java string literal](reference_contributor.md),
|
||||||
and we would like to show documentation for the key/value right from the reference inside the Java file.
|
and we would like to show documentation for the key/value right from the reference inside the Java file.
|
||||||
2. The cursor is already over a key/value definition inside a Simple file, in which case we would also like to show its documentation.
|
2. The cursor is already over a key/value definition inside a Simple file, in which case we would also like to show its documentation.
|
||||||
|
|
||||||
@ -194,7 +194,7 @@ In other circumstances, you can override `getDocumentationElementForLookupItem()
|
|||||||
|
|
||||||
To be able to call <menupath>View | Quick Documentation</menupath> for Simple properties in all places of a Java string literal, two steps are required:
|
To be able to call <menupath>View | Quick Documentation</menupath> for Simple properties in all places of a Java string literal, two steps are required:
|
||||||
|
|
||||||
1. The extension point needs to be changed from `lang.documentationProvider` to `documentationProvider` because only then
|
1. The extension point needs to be changed from `lang.documentationProvider` to `documentationProvider` because only then
|
||||||
the Simple DocumentationProvider is called for PSI elements with a different language.
|
the Simple DocumentationProvider is called for PSI elements with a different language.
|
||||||
2. The `getCustomDocumentationElement()` method needs to be implemented to find the correct target PSI element for creating the documentation.
|
2. The `getCustomDocumentationElement()` method needs to be implemented to find the correct target PSI element for creating the documentation.
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
A `FindUsagesProvider` uses a word scanner to build an index of words in every 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.
|
A scanner breaks the text into words and defines the context for each word.
|
||||||
|
|
||||||
**Reference**: [Find Usages](find_usages.md)
|
**Reference**: [](find_usages.md)
|
||||||
|
|
||||||
## Define a Find Usages Provider
|
## Define a Find Usages Provider
|
||||||
The `SimpleFindUsagesProvider` implements [`FindUsagesProvider`](upsource:///platform/indexing-api/src/com/intellij/lang/findUsages/FindUsagesProvider.java).
|
The `SimpleFindUsagesProvider` implements [`FindUsagesProvider`](upsource:///platform/indexing-api/src/com/intellij/lang/findUsages/FindUsagesProvider.java).
|
||||||
@ -31,4 +31,4 @@ Run the plugin by using the Gradle [runIde task](gradle_prerequisites.md#running
|
|||||||
|
|
||||||
The IDE now supports [Find Usages](https://www.jetbrains.com/help/idea/find-highlight-usages.html) for any property with a reference:
|
The IDE now supports [Find Usages](https://www.jetbrains.com/help/idea/find-highlight-usages.html) for any property with a reference:
|
||||||
|
|
||||||

|

|
||||||
|
@ -6,7 +6,7 @@ The IntelliJ Platform includes a powerful framework for implementing formatting
|
|||||||
A formatter enables reformatting code automatically based on code style settings.
|
A formatter enables reformatting code automatically based on code style settings.
|
||||||
The formatter controls spaces, indents, wrap, and alignment.
|
The formatter controls spaces, indents, wrap, and alignment.
|
||||||
|
|
||||||
**Reference**: [Code Formatter](code_formatting.md)
|
**Reference**: [](code_formatting.md)
|
||||||
|
|
||||||
## Define a Block
|
## Define a Block
|
||||||
The formatting model represents the formatting structure of a file as a tree of [`Block`](upsource:///platform/code-style-api/src/com/intellij/formatting/Block.java) objects, with associated indent, wrap, alignment and spacing settings.
|
The formatting model represents the formatting structure of a file as a tree of [`Block`](upsource:///platform/code-style-api/src/com/intellij/formatting/Block.java) objects, with associated indent, wrap, alignment and spacing settings.
|
||||||
@ -45,4 +45,4 @@ Open the example Simple Language [properties file ](lexer_and_parser_definition.
|
|||||||
Add some extra spaces around the `=` separator between `language` and `English`.
|
Add some extra spaces around the `=` separator between `language` and `English`.
|
||||||
Reformat the code by selecting **Code \| Show Reformat File Dialog** and choose **Run**.
|
Reformat the code by selecting **Code \| Show Reformat File Dialog** and choose **Run**.
|
||||||
|
|
||||||

|

|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
A _Go to Symbol Contributor_ helps the user to navigate to any PSI element by its name.
|
A _Go to Symbol Contributor_ helps the user to navigate to any PSI element by its name.
|
||||||
|
|
||||||
**Reference**: [Go to Class and Go to Symbol](go_to_class_and_go_to_symbol.md)
|
**Reference**: [](go_to_class_and_go_to_symbol.md)
|
||||||
|
|
||||||
## Define a Helper Method for Generated PSI Elements
|
## Define a Helper Method for Generated PSI Elements
|
||||||
To specify how a PSI element looks like in the <menupath>Navigate | Symbol</menupath> popup window, <control>Structure</control> tool window, or other components, it should implement `getPresentation()`.
|
To specify how a PSI element looks like in the <menupath>Navigate | Symbol</menupath> popup window, <control>Structure</control> tool window, or other components, it should implement `getPresentation()`.
|
||||||
@ -50,4 +50,4 @@ Run the plugin by using the Gradle [runIde task](gradle_prerequisites.md#running
|
|||||||
|
|
||||||
The IDE now supports navigating to a property definition by name pattern via <menupath>Navigate | Symbol</menupath> action.
|
The IDE now supports navigating to a property definition by name pattern via <menupath>Navigate | Symbol</menupath> action.
|
||||||
|
|
||||||
{width="800"}
|
{width="800"}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
In order for the IntelliJ Platform to parse a Simple Language file, tokens and elements must be defined based on [`IElementType`](upsource:///platform/core-api/src/com/intellij/psi/tree/IElementType.java).
|
In order for the IntelliJ Platform to parse a Simple Language file, tokens and elements must be defined based on [`IElementType`](upsource:///platform/core-api/src/com/intellij/psi/tree/IElementType.java).
|
||||||
The Simple Language grammar must also be defined to generate a parser.
|
The Simple Language grammar must also be defined to generate a parser.
|
||||||
|
|
||||||
**Reference**: [Implementing a Parser and PSI](implementing_parser_and_psi.md)
|
**Reference**: [](implementing_parser_and_psi.md)
|
||||||
|
|
||||||
## Define a Token Type
|
## Define a Token Type
|
||||||
Create `SimpleTokenType` in the `org.intellij.sdk.language.psi` package (see the `simple_language_plugin` code sample) by subclassing `IElementType`.
|
Create `SimpleTokenType` in the `org.intellij.sdk.language.psi` package (see the `simple_language_plugin` code sample) by subclassing `IElementType`.
|
||||||
@ -66,4 +66,4 @@ Mark this folder as *Generated Sources Root* and make sure everything compiles w
|
|||||||
>
|
>
|
||||||
{type="tip"}
|
{type="tip"}
|
||||||
|
|
||||||
{width="800"}
|
{width="800"}
|
||||||
|
@ -6,7 +6,7 @@ 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.
|
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.
|
||||||
Register the `LanguageFileType` with the IntelliJ Platform in the plugin configuration file.
|
Register the `LanguageFileType` with the IntelliJ Platform in the plugin configuration file.
|
||||||
|
|
||||||
**Reference**: [Registering a File Type](registering_file_type.md)
|
**Reference**: [](registering_file_type.md)
|
||||||
|
|
||||||
## Define the Language
|
## Define the Language
|
||||||
The language implemented in this tutorial is named "Simple" - note the case of the name.
|
The language implemented in this tutorial is named "Simple" - note the case of the name.
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
The lexical analyzer defines how the contents of a file are broken into tokens, which is the basis for supporting custom language features.
|
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/).
|
The easiest way to create a lexer is to use [JFlex](https://jflex.de/).
|
||||||
|
|
||||||
**Reference**: [Implementing Lexer](implementing_lexer.md)
|
**Reference**: [](implementing_lexer.md)
|
||||||
|
|
||||||
## Required Project Configuration Change
|
## Required Project Configuration Change
|
||||||
The previous tutorial step [Grammar and Parser](grammar_and_parser.md), and this page, generate source files in the directory `src/main/gen`.
|
The previous tutorial step [Grammar and Parser](grammar_and_parser.md), and this page, generate source files in the directory `src/main/gen`.
|
||||||
@ -20,7 +20,7 @@ Or the following line in the project's `build.gradle.kts` file:
|
|||||||
sourceSets["main"].java.srcDirs("src/main/gen")
|
sourceSets["main"].java.srcDirs("src/main/gen")
|
||||||
```
|
```
|
||||||
|
|
||||||
Reload the Gradle project for changes to take effect.
|
Reload the Gradle project for changes to take effect.
|
||||||
|
|
||||||
## Define a Lexer
|
## Define a Lexer
|
||||||
Define a `Simple.flex` file with rules for the Simple Language lexer, as demonstrated in `org.intellij.sdk.language.Simple.flex`.
|
Define a `Simple.flex` file with rules for the Simple Language lexer, as demonstrated in `org.intellij.sdk.language.Simple.flex`.
|
||||||
@ -101,4 +101,4 @@ tab : \u0009
|
|||||||
|
|
||||||
Now open the *PsiViewer* tool window and check how the lexer breaks the content of the file into tokens, and the parser parsed the tokens into PSI elements.
|
Now open the *PsiViewer* tool window and check how the lexer breaks the content of the file into tokens, and the parser parsed the tokens into PSI elements.
|
||||||
|
|
||||||

|

|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
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).
|
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.
|
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](code_inspections_and_intentions.md)
|
**Reference**: [](code_inspections_and_intentions.md)
|
||||||
|
|
||||||
## Update the Element Factory
|
## 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 `SimpleElementFactory` is updated to include two new methods to support the user choice of creating a new property for the Simple Language quick fix.
|
||||||
|
@ -9,7 +9,7 @@ Resolving references means the ability to go from the usage of an element to its
|
|||||||
>
|
>
|
||||||
{type="note"}
|
{type="note"}
|
||||||
|
|
||||||
**Reference**: [References and Resolve](references_and_resolve.md), [PSI References](psi_references.md)
|
**Reference**: [](references_and_resolve.md), [](psi_references.md)
|
||||||
|
|
||||||
## Define a Named Element Class
|
## Define a Named Element Class
|
||||||
The classes below show how the Simple Language fulfills the need to implement `PsiNamedElement`.
|
The classes below show how the Simple Language fulfills the need to implement `PsiNamedElement`.
|
||||||
@ -162,4 +162,4 @@ Run the project by using the Gradle [runIde task](gradle_prerequisites.md#runnin
|
|||||||
|
|
||||||
The IDE now supports [refactoring](https://www.jetbrains.com/help/idea/rename-refactorings.html) suggestions:
|
The IDE now supports [refactoring](https://www.jetbrains.com/help/idea/rename-refactorings.html) suggestions:
|
||||||
|
|
||||||
{width="800"}
|
{width="800"}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
The structure view can be customized for a specific file type.
|
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.
|
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.
|
||||||
|
|
||||||
**Reference**: [Structure View](structure_view.md)
|
**Reference**: [](structure_view.md)
|
||||||
|
|
||||||
## Define a Structure View Factory
|
## Define a Structure View Factory
|
||||||
The structure view factory implements [`PsiStructureViewFactory`](upsource:///platform/editor-ui-api/src/com/intellij/lang/PsiStructureViewFactory.java).
|
The structure view factory implements [`PsiStructureViewFactory`](upsource:///platform/editor-ui-api/src/com/intellij/lang/PsiStructureViewFactory.java).
|
||||||
@ -49,4 +49,4 @@ Run the project by using the Gradle [runIde task](gradle_prerequisites.md#runnin
|
|||||||
Open the `test.simple` file and choose **View \| Tool Windows \| Structure**.
|
Open the `test.simple` file and choose **View \| Tool Windows \| Structure**.
|
||||||
The IDE now supports a structure view of the Simple Language:
|
The IDE now supports a structure view of the Simple Language:
|
||||||
|
|
||||||

|

|
||||||
|
@ -6,7 +6,7 @@ The first level of syntax highlighting is based on the lexer output, and is prov
|
|||||||
A plugin can also define color settings based on `ColorSettingPage` so the user can configure highlight colors.
|
A plugin can also define color settings based on `ColorSettingPage` so the user can configure highlight colors.
|
||||||
The `SimpleSyntaxHighlighter`, `SimpleSyntaxHighlighterFactory`, and `SimpleColorSettingsPage` discussed on this page are demonstrated in the `simple_language_plugin` code sample.
|
The `SimpleSyntaxHighlighter`, `SimpleSyntaxHighlighterFactory`, and `SimpleColorSettingsPage` discussed on this page are demonstrated in the `simple_language_plugin` code sample.
|
||||||
|
|
||||||
**Reference**: [Syntax Highlighting and Error Highlighting](syntax_highlighting_and_error_highlighting.md)
|
**Reference**: [](syntax_highlighting_and_error_highlighting.md)
|
||||||
|
|
||||||
## Define a Syntax Highlighter
|
## Define a Syntax Highlighter
|
||||||
The Simple Language syntax highlighter class extends [`SyntaxHighlighterBase`](upsource:///platform/editor-ui-api/src/com/intellij/openapi/fileTypes/SyntaxHighlighterBase.java).
|
The Simple Language syntax highlighter class extends [`SyntaxHighlighterBase`](upsource:///platform/editor-ui-api/src/com/intellij/openapi/fileTypes/SyntaxHighlighterBase.java).
|
||||||
@ -64,4 +64,4 @@ Run the project by using the Gradle [runIde task](gradle_prerequisites.md#runnin
|
|||||||
In the IDE Development Instance, open the Simple Language highlight settings page: <menupath>Settings/Preferences | Editor | Color Scheme | Simple</menupath>.
|
In the IDE Development Instance, open the Simple Language highlight settings page: <menupath>Settings/Preferences | Editor | Color Scheme | Simple</menupath>.
|
||||||
Each color initially inherits from a <control>Language Defaults</control> value.
|
Each color initially inherits from a <control>Language Defaults</control> value.
|
||||||
|
|
||||||

|

|
||||||
|
Loading…
x
Reference in New Issue
Block a user