blank lines around code blocks

This commit is contained in:
Yann Cébron 2020-04-22 12:54:06 +02:00
parent 29668e4086
commit 8a65dfe12a
61 changed files with 178 additions and 8 deletions

View File

@ -29,6 +29,7 @@ To create a file type that has multiple interspersing trees for different langua
Implement [`FileViewProviderFactory`](upsource:///platform/core-api/src/com/intellij/psi/FileViewProviderFactory.java) and return your `FileViewProvider` implementation from `createFileViewProvider()` method.
Register as follows in `plugin.xml`:
```xml
<extensions defaultExtensionNs="com.intellij">
<fileType.fileViewProviderFactory filetype="%file_type%" implementationClass="com.plugin.MyFileViewProviderFactory" />

View File

@ -48,6 +48,7 @@ project.getMessageBus().connect().subscribe(VirtualFileManager.VFS_CHANGES, new
}
});
```
See [Message Infrastructure](/reference_guide/messaging_infrastructure.md) and [Plugin Listeners](/basics/plugin_structure/plugin_listeners.md) for more details.
For a non-blocking alternative, starting with version 2019.2 of the platform, see [`AsyncFileListener`](upsource:///platform/core-api/src/com/intellij/openapi/vfs/AsyncFileListener.java)

View File

@ -52,6 +52,7 @@ The format of an `updatePlugins.xml` file is simply a list of sequential element
</plugin>
</plugins>
```
<br>
**Note:**
* An `updatePlugins.xml` file must contain at least one set of `<plugin></plugin>` elements.

View File

@ -9,6 +9,7 @@ The Credentials Store API allows you to securely store sensitive user data, like
Use [`PasswordSafe`](upsource:///platform/platform-api/src/com/intellij/ide/passwordSafe/PasswordSafe.kt) to work with credentials.
### Retrieve stored credentials
```java
String key = null; // e.g. serverURL, accountID
CredentialAttributes credentialAttributes = createCredentialAttributes(key);
@ -33,6 +34,7 @@ Use [`PasswordSafe`](upsource:///platform/platform-api/src/com/intellij/ide/pass
Credentials credentials = new Credentials(username, password);
PasswordSafe.getInstance().set(credentialAttributes, credentials);
```
To remove stored credentials, pass `null` for `credentials` parameter.
## Storage

View File

@ -60,6 +60,7 @@ To display a list of available IntelliJ Platform modules, invoke the [code compl
### 3.1 Configuring plugin.xml
In the `plugin.xml`, add a `<depends>` tag with the ID of the dependency plugin as its content.
Continuing with the example from [Section 2](#2-project-setup) above, the dependency declaration in `plugin.xml` would be:
```xml
<depends>org.jetbrains.kotlin</depends>
```
@ -72,6 +73,7 @@ add `optional="true" config-file="otherconfig.xml"` to the `<depends>` tag.
For example, if a plugin project adds additional highlighting for Java and Kotlin files, use the following setup.
The main `plugin.xml` will define an annotator for Java and specify an optional dependency on the Kotlin plugin:
```xml
<idea-plugin>
...
@ -84,6 +86,7 @@ The main `plugin.xml` will define an annotator for Java and specify an optional
```
Then create a file called `withKotlin.xml`, in the same directory as the main `plugin.xml` file. In that file, define an annotator for Kotlin:
```xml
<idea-plugin>
<extensions defaultExtensionNs="com.intellij">

View File

@ -21,6 +21,7 @@ You can declare extensions and extension points in the plugin configuration file
To declare extension points in your plugin, add an `<extensionPoints>` section to your `plugin.xml`. Then insert a child element `<extensionPoint>` that defines the extension point name and the name of a bean class or an interface that is allowed to extend the plugin functionality in the `name`, `beanClass` and `interface` attributes, respectively.
_myPlugin/META-INF/plugin.xml_
```xml
<idea-plugin>
<id>my.plugin</id>
@ -46,6 +47,7 @@ The plugin that contributes to the extension point will read those properties fr
To clarify this, consider the following sample `MyBeanClass` bean class used in the above `plugin.xml` file:
_myPlugin/src/com/myplugin/MyBeanClass.java_
```java
public class MyBeanClass extends AbstractExtensionPointBean {
@Attribute("key")
@ -69,6 +71,7 @@ public class MyBeanClass extends AbstractExtensionPointBean {
For above extension points usage in _anotherPlugin_ would look like this (see also [Declaring Extensions](plugin_extensions.md#declaring-extensions)):
_anotherPlugin/META-INF/plugin.xml_
```xml
<idea-plugin>
<id>another.plugin</id>
@ -90,6 +93,7 @@ _anotherPlugin/META-INF/plugin.xml_
To refer to all registered extension instances at runtime, declare an [`ExtensionPointName`](upsource:///platform/extensions/src/com/intellij/openapi/extensions/ExtensionPointName.java) passing in the fully-qualified name matching its [declaration in `plugin.xml`](#how-to-declare-extension-points).
_myPlugin/src/com/myplugin/MyExtensionUsingService.java_
```java
public class MyExtensionUsingService {
@ -104,6 +108,7 @@ public class MyExtensionUsingService {
}
}
```
A gutter icon for the `ExtensionPointName` declaration allows navigating to the corresponding `<extensionPoint>` declaration in `plugin.xml`.
## Dynamic extension points
@ -113,6 +118,7 @@ To support [Dynamic Plugins](dynamic_plugins.md) (2020.1 and later), an extensio
- alternatively, an `ExtensionPointChangeListener` can perform necessary updates of data structures (register via `ExtensionPointName.addExtensionPointListener()`)
Extension points matching these conditions can then be marked as _dynamic_ by adding `dynamic="true"` in their declaration:
```xml
<extensionPoints>
<extensionPoint name="myDynamicExtensionPoint" beanClass="com.myplugin.MyBeanClass" dynamic="true" />

View File

@ -51,6 +51,7 @@ To clarify this procedure, consider the following sample section of the `plugin.
<myExtensionPoint key="keyValue" implementationClass="com.myplugin.MyExtensionPointImpl" />
</extensions>
```
### Extension default properties
The following properties are available always:
@ -71,6 +72,7 @@ Property names matching the following list will resolve to FQN:
- ending with `Class` (case-sensitive)
A required parent type can be specified in the extension point declaration via nested `<with>`:
```xml
<extensionPoint name="myExtension" beanClass="MyExtensionBean">
<with attribute="psiElementClass" implements="com.intellij.psi.PsiElement"/>

View File

@ -90,6 +90,7 @@ MyProjectService projectService = project.service<MyProjectService>()
This minimal sample shows [light](#light-services) `ProjectService` interacting with another project level service `AnotherService` (not shown here).
_ProjectService.java_
```java
@Service
public final class ProjectService {

View File

@ -47,6 +47,7 @@ This page gives a list of recipes for the most common operations for working wit
PsiJavaFile javaFile = (PsiJavaFile) psiClass.getContainingFile();
PsiPackage pkg = JavaPsiFacade.getInstance(project).findPackage(javaFile.getPackageName());
```
or
`com.intellij.psi.util.PsiUtil.getPackageName()`

View File

@ -35,6 +35,7 @@ Each roadmap should contain:
## Plugin Copyright Statements
Use the standard intellij-community copyright notice in all sample plugins authored by JetBrains:
```text
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."
```
@ -88,6 +89,7 @@ Standardized structure not only makes the samples simpler to navigate and unders
Note that directories below the plugin root folder should not have underscore characters, and should use camelCase if needed.
The following is an example directory structure for a `foo_basics` plugin.
```text
code_samples/
foo_basics/

View File

@ -42,6 +42,7 @@ Here are the steps to configure the `build.gradle` file for developing a plugin
Set the Development Instance to the (user-specific) absolute path to the target Android Studio application.
The snippet below is an example of configuring the Setup and Running DSLs in a `build.gradle` specific to developing a plugin targeted at Android Studio.
```groovy
intellij {
// Define IntelliJ Platform against which to build the plugin project.
@ -62,6 +63,7 @@ The snippet below is an example of configuring the Setup and Running DSLs in a `
As discussed in the [Plugin Dependencies](/basics/getting_started/plugin_compatibility.md#declaring-plugin-dependencies) section of this guide, a plugin's dependency on [Modules Specific to Functionality](/basics/getting_started/plugin_compatibility.md#modules-specific-to-functionality) must be declared in `plugin.xml`.
When using Android Studio-specific features (APIs), a dependency on `com.intellij.modules.androidstudio` must be declared as shown in the code snippet below.
Otherwise, if only general IntelliJ Platform features (APIs) are used, then a dependency on `com.intellij.modules.platform` must be declared as discussed in [Plugin Compatibility with IntelliJ Platform Products](/basics/getting_started/plugin_compatibility.md).
```xml
<depends>com.intellij.modules.androidstudio</depends>
```

View File

@ -22,6 +22,7 @@ The table below summarizes the `gradle-intellij-plugin` attributes to set in the
The dependency on the CLion APIs must be declared in the `plugin.xml` file.
As described in [Modules Specific to Functionality](/basics/getting_started/plugin_compatibility.md#modules-specific-to-functionality) table, the `<depends>` elements should contain the CLion module, as illustrated in the `plugin.xml` snippet below:
```xml
<!-- Required for core CLion functionality -->
<depends>com.intellij.modules.clion</depends>

View File

@ -42,6 +42,7 @@ Specifying the target as a product-specific `intellij.type` attribute has two ad
A `build.gradle` snippet setting a plugin project to target PyCharm is shown below.
The `gradle-intellij-plugin` will fetch the matching build of PyCharm Professional to define the APIs available, and use that build of PyCharm (and associated JetBrains runtime) as the Development Instance.
No additional product-specific configuration needs to be set in `build.gradle`:
```groovy
intellij {
version '2019.2.3'
@ -104,6 +105,7 @@ Set the `runIde.ideDirectory` attribute to the (user-specific) absolute path of
The exact path format varies by operating system.
This snippet is an example for configuring the Setup and Running DSLs in a `build.gradle` specific to developing a plugin for _targetIDE_.
```groovy
intellij {
// Define IntelliJ Platform against which to build the plugin project.
@ -130,6 +132,7 @@ Otherwise, if only general IntelliJ Platform features (APIs) are used, then a de
> **NOTE** In the special case of a plugin project declaring dependencies only on other plugins, it must also declare a dependency on `com.intellij.modules.platform`. Otherwise, the plugin project is considered to be legacy and will only load in IntelliJ IDEA.
Continuing with the example of developing a plugin for PhpStorm:
```xml
<!-- Targeting PhpStorm, so is dependent on the PHP plugin -->
<depends>com.jetbrains.php</depends>

View File

@ -26,12 +26,14 @@ The dependency on the Go plugin APIs must be declared in the `plugin.xml` file.
As described in [Modules Specific to Functionality](/basics/getting_started/plugin_compatibility.md#modules-specific-to-functionality) table, the `<depends>` tags must declare `com.intellij.modules.go`.
The `plugin.xml` file must also declare a dependency on `com.intellij.modules.platform` as explained in [Configuring the plugin.xml File](dev_alternate_products.md#configuring-pluginxml).
The dependency declaration is illustrated in the `plugin.xml` snippet below:
```xml
<!-- Requires the Go plugin -->
<depends>org.jetbrains.plugins.go</depends>
<!-- Requires the platform module to distinguish it from a legacy plugin -->
<depends>com.intellij.modules.platform</depends>
```
## Available GoLand APIs
Use the [Exploring APIs as a Consumer](/basics/getting_started/plugin_compatibility.md#exploring-apis-as-a-consumer) process to identify the library `intellij-go-<version>.jar`, where `<version>` corresponds to the version of the Go plugin.
Test your plugin with any version of GoLand you intend to support.

View File

@ -61,8 +61,6 @@ public interface PhpTypeProvider2 {
Our implementation: includes a Completion contributor for the parameter values too.
```java
/**
*/
public class PhpStaticFactoryTypeProvider extends CompletionContributor implements PhpTypeProvider2 {
private static final Key<CachedValue<Map<String, Map<String, String>>>> STATIC_FACTORY_TYPE_MAP =

View File

@ -27,6 +27,7 @@ The correct Ruby plugin version is also determined from the Ruby plugin version
The dependency on the Ruby plugin APIs must be declared in the `plugin.xml` file.
As described in [Modules Specific to Functionality](/basics/getting_started/plugin_compatibility.md#modules-specific-to-functionality) table, the `<depends>` elements must contain `com.intellij.modules.ruby`.
The dependency declaration is illustrated in the `plugin.xml` snippet below:
```xml
<!-- Requires the Ruby plugin -->
<depends>com.intellij.modules.ruby</depends>

View File

@ -143,6 +143,7 @@ Images module functionality (package `org.intellij.images.*`) extracted to plugi
: The dependency [must be declared](/basics/plugin_structure/plugin_dependencies.md) explicitly now:
* Add `<depends>com.intellij.platform.images</depends>` in `plugin.xml`
* Add to `build.gradle`:
```groovy
intellij {
plugins = ['platform-images']

View File

@ -33,6 +33,7 @@ It's _not_ correct to create chained calls like
file.getDocument().getRootTag().findFirstSubTag("foo").
findSubTags("bar")[1].getValue().getTrimmedText()
```
because each call here may return `null`.
So the code would probably look like this:
@ -223,6 +224,7 @@ One more common case in DTD and Schemas is when children have the same tag name
```java
List<Entity> getEntities();
```
There's also an annotation `@SubTagList` where you can explicitly specify the tag name.
Returned collections cannot be modified directly. To delete an element from collection, just call `undefine()` on this element. The tag will then be removed, and element will become invalid (`DomElement.isValid() == false`). Note that this behavior differs from that of fixed-number children and attributes: they are always valid, even after `undefine()`. Again, unlike those children types, collection children always have valid underlying XML tags.
@ -238,6 +240,7 @@ which adds an element to wherever you want, or
```java
Entity addEntity();
```
which adds a new DOM element to the end of the collection. Please note the singular tense of the word "Entity". That's because here we deal with one `Entity` object, while in the collection getter we dealt with potentially many entities.
Now, you can do anything you want with the returned value: modify, define the tag's value, children, etc.
@ -255,6 +258,7 @@ List<Bar> getBars();
@SubTagsList({"foo", "bar"})
List<FooBar> getMergedListOfFoosAndBars();
```
The annotation here is mandatory - we cannot guess several tag names from one method name.
To add elements to such mixed collections, you should create "add" methods for each possible tag name:
@ -263,6 +267,7 @@ To add elements to such mixed collections, you should create "add" methods for e
@SubTagsList(value={"foo","bar"}, tagName="foo") Fubar addFoo();
@SubTagsList(value={"foo","bar"}, tagName="bar") Fubar addBar(int index);
```
The index parameter in the last example means the index in the merged collection, not in the collection of tags named "bar".
### Dynamic Definition
@ -405,6 +410,7 @@ GenericDomValue<String> getVeryLongName()
@PropertyAccessor("very-long-name")
GenericDomValue<String> getName()
```
In this case, the second method will return just the same as the first one. If there were "foo.bar.name" instead of "very-long-name" in the annotation, the system would actually call `getFoo().getBar().getName()` and return the result to you. Such annotations are useful when you're extending some interface that is inconsistent with your model, or you try to extract a common super-interface from two model interfaces with differently named children that have the same sense (see `<ejb-ref>` and `<ejb-local-ref>`).
The case just described is simple, but rare. More often, you really have to incorporate some logic into your model. Then nothing except Java code helps you. And it will. Add the desired methods to your interface, then create an abstract class implementing the interface, and implement there only methods that you added manually and that are not directly connected to your XML model. Note that the class should have a constructor with no arguments.
@ -523,6 +529,7 @@ public class ConverterComponent extends BasicDomElementComponent<Converter> {
}
}
```
All the fields here are now bound to controls in a GUI form.
Very often you'll have to create your own file editor. Then, to use all the binding and undo functionality, it's suggested to inherit your [`FileEditorProvider`](upsource:///platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorProvider.java) from [`PerspectiveFileEditorProvider`](upsource:///xml/dom-openapi/src/com/intellij/util/xml/ui/PerspectiveFileEditorProvider.java), create an instance of [`DomFileEditor`](upsource:///xml/dom-openapi/src/com/intellij/util/xml/ui/DomFileEditor.java) there, and pass a [`BasicDomElementComponent`](upsource:///xml/dom-openapi/src/com/intellij/util/xml/ui/BasicDomElementComponent.java). To easily create an editor with a caption at the top, like in our EJB and JSF, you may use the static method `DomFileEditor.createDomFileEditor()`. `DomFileEditor` automatically listens to all changes in the document corresponding to the given DOM element, and therefore refreshes your component on undo. If you want to listen to changes in additional documents, use the methods `addWatchedDocument()`, `removeWatchedDocument()`, `addWatchedElement()`, `removeWatchedElement()` in `DomFileEditor`.

View File

@ -90,6 +90,7 @@ There are two parts to the example: the repository and the dependency sections.
### Repositories Section
This code snippet selects the release repository with the first URL, and repository of IntelliJ Platform dependencies with the second URL.
The second URL is needed because this example selects individual modules.
```groovy
repositories {
maven { url "https://www.jetbrains.com/intellij-repository/releases" }
@ -99,12 +100,14 @@ repositories {
### Dependencies Section
This code snippet specifies the desired module artifacts.
```groovy
dependencies {
compile "com.jetbrains.intellij.platform:jps-model-serialization:182.2949.4"
compile "com.jetbrains.intellij.platform:jps-model-impl:182.2949.4"
}
```
Note:
* The artifact version (`182.2949.4`) must match in both statements.
* In this example `jps-model-serialization` declares the APIs and `jps-model-impl` provides the implementation, so both

View File

@ -12,7 +12,8 @@ There are multiple ways to enable internal mode, but the simplest is within Inte
This selection opens IntelliJ IDEA's `idea.properties` file.
If it does not exist, IntelliJ IDEA will prompt to create one.
* Add the line shown below to the `idea.properties` file:
```
```properties
idea.is.internal=true
```
* Save the `idea.properties` file and restart IntelliJ IDEA.

View File

@ -76,6 +76,7 @@ For executing JS code and callbacks (see below), use the wrapped `CefBrowser` in
By default, `JBCefBrowser` is created with implicit `JBCefClient` (disposed automatically). It is possible to pass your own `JBCefClient` (disposed by the developer).
For accessing:
```java
JBCefClient getJBCefClient();
```

View File

@ -23,6 +23,7 @@ Package [`libraries`](upsource:///platform/projectModel-api/src/com/intellij/ope
### Getting a List of Libraries a Module Depends On
To get the list of libraries that a module depends on, use `OrderEnumerator.forEachLibrary` as follows.
```java
final List<String> libraryNames = new ArrayList<String>();
ModuleRootManager.getInstance(module).orderEntries().forEachLibrary(library -> {
@ -41,6 +42,7 @@ whereas the list of project-level library tables is accessed through `LibraryTab
Once you have a `LibraryTable`, you can get the libraries in it by calling `LibraryTable.getLibraries()`.
To get the list of all module libraries defined in a given module, use the following API:
```java
OrderEntryUtil.getModuleLibraries(ModuleRootManager.getInstance(module));
```
@ -48,6 +50,7 @@ OrderEntryUtil.getModuleLibraries(ModuleRootManager.getInstance(module));
### Getting the Library Content
[`Library`](upsource:///platform/projectModel-api/src/com/intellij/openapi/roots/libraries/Library.java) provides the `getUrls()` method you can use to get a list of source roots and classes the library includes.
To clarify, consider the following code snippet:
```java
StringBuilder roots = new StringBuilder("The " + lib.getName() + " library includes:\n");
roots.append("Sources:\n");

View File

@ -45,6 +45,7 @@ Messages.showInfoMessage("Source roots for the " + projectName + " plugin:\n" +
### Checking if a File Belongs to a Project
Use [`ProjectFileIndex`](upsource:///platform/projectModel-api/src/com/intellij/openapi/roots/ProjectFileIndex.java) to get this information:
```java
ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
```
@ -52,6 +53,7 @@ ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getF
### Getting the Content or Source Root to Which the a File or Directory Belongs
Use the `ProjectFileIndex.getContentRootForFile()` and `ProjectFileIndex.getSourceRootForFile()` methods.
For example:
```java
VirtualFile moduleContentRoot = ProjectRootManager.getInstance(project).getFileIndex().getContentRootForFile(virtualFileOrDirectory);
VirtualFile moduleSourceRoot = ProjectRootManager.getInstance(project).getFileIndex().getSourceRootForFile(virtualFileOrDirectory);

View File

@ -34,6 +34,7 @@ To create a new module type and an extension
```xml
<moduleType id="MY_MODULE" implementationClass="st.redline.smalltalk.module.MyModuleType"/>
```
to the
[`plugin.xml`](https://github.com/bulenkov/RedlineSmalltalk/blob/master/resources/META-INF/plugin.xml).
A custom module type should extend the
@ -95,6 +96,7 @@ Method
```java
public void moduleCreated(@NotNull final Module module);
```
executed tasks right after a module has been created,
these may include configuring roots looking up for an SDK and setting it up, adding a specific facet if required and others.
For more details please see the following
@ -108,6 +110,7 @@ Adding new steps to the module wizard can be done by overriding the
```java
public ModuleWizardStep[] createWizardSteps(WizardContext wizardContext, ModulesProvider modulesProvider);
```
method in a custom
[module builder](https://github.com/bulenkov/RedlineSmalltalk/blob/master/src/st/redline/smalltalk/module/RsModuleBuilder.java).
If this method returns a non-empty array of ModuleWizardStep objects, new steps will be shown in their indexing order while creating a new module.

View File

@ -65,6 +65,7 @@ For the SDK code sample `theme_basics` the box is _unchecked_.
Clicking the _OK_ button creates a default Theme description file named `[themeName].theme.json` in the plugin project's `resources` folder.
In this example, the file is named `theme_basics.theme.json`.
The content of the default file is a short set of keyvalue pairs:
```json
{
"name": "theme_basics",
@ -84,11 +85,13 @@ The `ui` section will be addressed in [Customizing UI Control Colors](themes_cus
The Wizard also creates a `themeProvider` declaration in the `<extensions>` section of the plugin's `plugin.xml` file.
This declaration binds the Theme description file to a theme provider extension using a generated unique `id`.
```xml
<extensions defaultExtensionNs="com.intellij">
<themeProvider id="eb9b7461-397b-4b98-a422-224fc0a74564" path="/theme_basics.theme.json"/>
</extensions>
```
> **WARNING** Do not modify or re-use an existing value of the generated `id` attribute.
At this point, the UI Theme `theme_basics` is a valid UI Theme.

View File

@ -37,6 +37,7 @@ Maintaining a Theme is more manageable if _Named Colors_ are globally defined in
After that, the Named Color can be used instead of a hexadecimal description of the color.
For example, defining the Named Color `basicBackground` and then using it to set the background color for panels.
(Don't be concerned with the `"ui"` syntax in the example below, it will be discussed in [Custom UI Control Colors](#custom-ui-control-colors).)
```json
{
"name": "theme_basics",
@ -62,6 +63,7 @@ Default global icon colors are customized by adding key-value pairs to a `"Color
The `ColorPalette` must be inserted in the `icons` section.
In the following example the `key` - the default red color (#DB5860) used for `Action` icons in the _Light_ Theme - is overridden to the `value` of a different color (#D61A26):
```json
{
"icons": {
@ -71,6 +73,7 @@ In the following example the `key` - the default red color (#DB5860) used for `A
}
}
```
This color substitution is applied throughout the IDE UI.
### Custom Icon Palette Colors
@ -92,6 +95,7 @@ The list of available icon `Actions` and `Objects` keys are provided by the comp
![Color Palette Popup](img/theme_colorpalette_popup.png){:width="600px"}
For example, the following key-value pair changes the color for all blue-colored icons on toolbars to the color #5BC0DE:
```json
{
"icons": {
@ -101,6 +105,7 @@ For example, the following key-value pair changes the color for all blue-colore
}
}
```
This more specific change to the `Actions.Blue` color overrides the default definition.
It will also, in the narrower context of blue `Actions` icons, supersede any global color overrides of the default blue icon color.
@ -118,6 +123,7 @@ This path is derived from the `AllIcons.[Group].[IconName]` path in icon section
For example, the _Build_ (hammer) icon in the toolbar has the path `Allcons.Actions.Compile` as reported by the UI Inspector.
Therefore the `key` for the _Build_ icon is `/actions/compile.svg`.
The `value` is the file name of the replacement icon, located in the `resources` folder of the UI Theme plugin project:
```json
{
"icons": {
@ -125,6 +131,7 @@ The `value` is the file name of the replacement icon, located in the `resources`
}
}
```
The color of a replaced icon takes precedence over any `ColorPalette` overrides.
## Customizing UI Controls
@ -151,6 +158,7 @@ A key-value pair is inserted in this section, but only the `property` portion of
The `value` is the custom color.
The following example would change the default background color to #AED7E3 for all UI controls:
```json
{
"ui": {
@ -160,6 +168,7 @@ The following example would change the default background color to #AED7E3 for a
}
}
```
Note that the wildcard `"*": {}` section must be within the `"ui": {}` section.
#### Customizing the Color of Specific UI Control Types
@ -167,6 +176,7 @@ The color of a specific UI control types are changed by adding a key-value pair
The `key` is the full `element.property` format and the `value` is the custom color.
The following example sets the background color for all labels to the color #F6E9C9
```json
{
"ui": {
@ -177,6 +187,7 @@ The following example sets the background color for all labels to the color #F6E
}
}
```
The `Label.background` entry supersedes, in the narrower context of label backgrounds, any default color as well as any wildcard color assigned to backgrounds.
#### Customizing the Color of UI Tabs
@ -243,6 +254,7 @@ Methods for identifying UI control keys are in the [Finding Attribute Keys for U
The appearance of borders for specific UI control types are customized by adding a key-value pair to the `"ui": {}` section of a Theme description file.
The following example sets a new border width and color for all windows:
```json
{
"ui": {
@ -250,6 +262,7 @@ The following example sets a new border width and color for all windows:
}
}
```
In this example the customized border supersedes the default definition and
any global color override.

View File

@ -30,6 +30,7 @@ The next step is to add the color scheme to the UI Theme plugin project:
The `value` is the name of the editor color scheme file.
The example below adds an editor scheme named "Lightning" to the _Theme Basics_ custom UI Theme:
```json
{
"name": "Theme Basics",
@ -45,11 +46,13 @@ The example below adds an editor scheme named "Lightning" to the _Theme Basics_
When an editor color scheme is exported as a file, the color options appear as `name`-`value` attributes of `option` elements.
The `name` is the aspect of the editor to be changed, and the `value` is the new color in six-digit RGB or eight-digit RGBA hexadecimal notation.
For example, the snippet below sets the color of the line numbers displayed in the editor:
```xml
<colors>
<option name="LINE_NUMBERS_COLOR" value="999999" />
</colors>
```
For additional examples of `name` and `value` attributes, review the editor color scheme XML file for the [High Contrast editor scheme](upsource:///platform/platform-resources/src/themes/highContrastScheme.xml).
### Customizing Version Control File Status Colors
@ -57,6 +60,7 @@ As [described above](#creating-a-custom-editor-scheme-using-settingspreferences)
No other procedure is necessary to customize these colors.
In the exported color scheme file the `name` is the VCS file status, and the `value` is the new color corresponding to that status.
For example, customized VCS colors for a subset of file statuses will appear in the editor scheme file as:
```xml
<colors>
<option name="FILESTATUS_ADDED" value="62cc47" />
@ -65,6 +69,7 @@ For example, customized VCS colors for a subset of file statuses will appear in
</colors>
```
For additional examples of `FILESTATUS` color `name` attributes, see the editor color scheme XML file for the [High Contrast editor scheme](upsource:///platform/platform-resources/src/themes/highContrastScheme.xml).
### Customizing Editor Scroll Bar Colors
@ -82,6 +87,7 @@ In some cases `usage` itself can be compound such as `ScrollBar.Mac.Transparent.
In these compound cases, the last portion of the compound `usage` still describes where the color is to be applied.
Note that the following example snippet uses an eight-digit hexadecimal color `value` to give `ScrollBar.Mac.thumbColor` transparency:
```xml
<color>
<option name="ScrollBar.Mac.trackColor" value="000000"/>
@ -142,6 +148,7 @@ A `value` of 100 is opaque.
The following example adds an image of the Austrian countryside to the _Theme Basics_
Theme description file:
```json
{
"name": "Theme Basics",

View File

@ -19,6 +19,7 @@ All available UI Customization Keys that can be used in [Custom Themes](themes_c
The following minimal sample demonstrates all details required when exposing UI customization keys of your plugin's UI.
`/resources/META-INF/plugin.xml`:
```xml
<idea-plugin>
[...]
@ -27,10 +28,10 @@ The following minimal sample demonstrates all details required when exposing UI
</extensions>
[...]
</idea-plugin>
```
`/resources/META-INF/MyPlugin.themeMetadata.json`:
```json
{
"name": "My Plugin",
@ -47,7 +48,6 @@ The following minimal sample demonstrates all details required when exposing UI
}
]
}
```
### Attributes
@ -69,6 +69,7 @@ The following minimal sample demonstrates all details required when exposing UI
> **TIP** Do not remove existing keys, but deprecate them instead to help Theme authors upgrade their existing themes.
Color keys can be used via `JBColor.namedColor()` providing defaults for Light and Dark theme:
```java
private static final Color SECTION_HEADER_FOREGROUND =
JBColor.namedColor("Plugins.SectionHeader.foreground", new JBColor(0x787878, 0x999999));

View File

@ -59,6 +59,7 @@ As SVG icons can be scaled arbitrarily, they provide better results on HiDPI env
A base size denoting the size (in the user space) of the rendered image in 1x scale should be provided. The size is set via the `width` and `height` attributes omitting the size units. If unspecified, it defaults to 16x16 pixels.
A minimal SVG icon file:
```xml
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">
<rect width="100%" height="100%" fill="green"/>

View File

@ -162,6 +162,7 @@ public class DynamicActionGroup extends ActionGroup {
### Registering a Variable Action Group
To register the dynamic menu group, a `<group>` attribute needs to be placed in the `<actions>` section of [`plugin`.xml](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/action_basics/src/main/resources/META-INF/plugin.xml).
When enabled, this group appears at the entry just below the [Static Grouped Actions](#binding-action-groups-to-ui-components) in the **Tools** menu:
```xml
<group id="org.intellij.sdk.action.DynamicActionGroup" class="org.intellij.sdk.action.DynamicActionGroup" popup="true"
text="Dynamically Grouped Actions" description="SDK dynamically grouped action example" icon="SdkIcons.Sdk_default_icon">

View File

@ -20,6 +20,7 @@ Classes that extend it should override `AnAction.update()`, and must override `A
* The `actionPerformed()` method implements the code that executes when an action is invoked by the user.
As an example, [`PopupDialogAction`](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/action_basics/src/main/java/org/intellij/sdk/action/PopupDialogAction.java) overrides `AnAction` for the `action_basics` code sample.
```java
public class PopupDialogAction extends AnAction {
@ -78,6 +79,7 @@ In this case, `PopupDialogAction` would be available in the **Tools** menu, it w
After finishing the **New Action** form and applying the changes, the `<actions>` section of the plugin's `plugins.xml` file
would contain:
```xml
<actions>
<action id="org.intellij.sdk.action.PopupDialogAction" class="org.intellij.sdk.action.PopupDialogAction"
@ -101,6 +103,7 @@ The `<action>` declaration for `PopupDialogAction` in the `action_basics` [plugi
It also contains an attribute for an [`Icon`](/reference_guide/work_with_icons_and_images.md) and encloses elements declaring text overrides, keyboard and mouse shortcuts, and to which menu group the action should be added.
The full declaration is:
```xml
<action id="org.intellij.sdk.action.PopupDialogAction" class="org.intellij.sdk.action.PopupDialogAction"
text="Action Basics Plugin: Pop Dialog Action" description="SDK action example" icon="SdkIcons.Sdk_default_icon">

View File

@ -30,6 +30,7 @@ You can store the Hub Token in [Gradle properties](https://docs.gradle.org/curre
If you place a `gradle.properties` file containing your Hub Permanent Token in your project's root directory, please ensure your version control tool ignores this file.
For example in Git, you can add the following line to your `.gitignore` file:
```
gradle.properties
```
@ -43,6 +44,7 @@ intellijPublishToken=YOUR_HUB_TOKEN_HERE
```
Then refer to these values in `publishPlugin` task in your `build.gradle` file:
```groovy
publishPlugin {
token intellijPublishToken
@ -52,6 +54,7 @@ publishPlugin {
### Using Environment Variables
Alternatively, and possibly slightly safer because you cannot accidentally commit your token to version control, you can provide your token via an environment variable.
For example, start by defining an environment variable such as:
```bash
export ORG_GRADLE_PROJECT_intellijPublishToken='YOUR_HUB_TOKEN_HERE'
```
@ -61,6 +64,7 @@ Environment variables visible to all processes need to be defined in [Environmen
Now provide the environment variable in the run configuration with which you run the `publishPlugin` task locally.
To do so, create a Gradle run configuration (if not already done), choose your Gradle project, specify the `publishPlugin` task, and then add the environment variable.
```groovy
publishPlugin {
token = System.getenv("ORG_GRADLE_PROJECT_intellijPublishToken")
@ -83,6 +87,7 @@ You may wish to verify this by [installing your plugin from disk](https://www.je
### Publishing a Plugin
Once you are confident the plugin works as intended, make sure the plugin version is updated, as the JetBrains Plugin repository won't accept multiple artifacts with the same version.
To deploy a new version of your plugin to the JetBrains plugin repository, execute the following Gradle command:
```bash
gradle publishPlugin
```
@ -93,6 +98,7 @@ If successfully deployed, any users who currently have your plugin installed on
### Specifying a Release Channel
You may also deploy plugins to a release channel of your choosing, by configuring the `publishPlugin.channels` property.
For example:
```groovy
publishPlugin {
channels 'beta'

View File

@ -14,12 +14,14 @@ The `SimpleAnnotator` subclasses [`Annotator`](upsource:///platform/analysis-api
Consider a literal string that starts with "simple:" as a prefix of a Simple Language key.
It isn't part of the Simple Language, but it is a useful convention for detecting Simple Language keys embedded as string literals in other languages, like Java.
Annotate the `simple:key` literal expression, and differentiate between a well-formed vs. an unresolved property:
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleAnnotator.java %}
```
## 7.2. Register the Annotator
Using the `com.intellij.annotator` extension point in the plugin configuration file, register the Simple Language annotator class with the IntelliJ Platform:
```xml
<extensions defaultExtensionNs="com.intellij">
<annotator language="JAVA" implementationClass="org.intellij.sdk.language.SimpleAnnotator"/>
@ -28,6 +30,7 @@ Using the `com.intellij.annotator` extension point in the plugin configuration f
## 7.3. Run the Project
As a test, define the following Java file containing a Simple Language `prefix:value` pair:
```java
public class Test {
public static void main(String[] args) {

View File

@ -12,6 +12,7 @@ This example creates a settings/preferences page that uses the default language
## 16.1. Define Code Style Settings
Define a code style settings for Simple Language by subclassing [`CustomCodeStyleSettings`](upsource:///platform/lang-api/src/com/intellij/psi/codeStyle/CustomCodeStyleSettings.java).
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleCodeStyleSettings.java %}
```
@ -19,12 +20,14 @@ Define a code style settings for Simple Language by subclassing [`CustomCodeStyl
## 16.2. Define Code Style Settings Provider
The code style settings provider gives the IntelliJ Platform a standard way to instantiate `CustomCodeStyleSettings` for the Simple Language.
Define a code style settings provider for Simple Language by subclassing [`CodeStyleSettingsProvider`](upsource:///platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettingsProvider.java).
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleCodeStyleSettingsProvider.java %}
```
## 16.3. Register the Code Style Settings Provider
The `SimpleCodeStyleSettingsProvider` implementation is registered with the IntelliJ Platform in the plugin configuration file using the `com.intellij.codeStyleSettingsProvider` extension point.
```xml
<extensions defaultExtensionNs="com.intellij">
<codeStyleSettingsProvider implementation="org.intellij.sdk.language.SimpleCodeStyleSettingsProvider"/>
@ -33,12 +36,14 @@ The `SimpleCodeStyleSettingsProvider` implementation is registered with the Inte
## 16.4. Define the Language Code Style Settings Provider
Define a code style settings provider for Simple Language by subclassing [`LanguageCodeStyleSettingsProvider`](upsource:///platform/lang-api/src/com/intellij/psi/codeStyle/LanguageCodeStyleSettingsProvider.java), which provides common code style settings for a specific language.
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleLanguageCodeStyleSettingsProvider.java %}
```
## 16.5. Register the Language Code Style Settings Provider
The `SimpleLanguageCodeStyleSettingsProvider` implementation is registered with the IntelliJ Platform in the plugin configuration file using the `com.intellij.langCodeStyleSettingsProvider` extension point.
```xml
<extensions defaultExtensionNs="com.intellij">
<langCodeStyleSettingsProvider

View File

@ -12,12 +12,14 @@ The [`Commenter`](upsource:///platform/core-api/src/com/intellij/lang/Commenter.
## 17.1. Define a Commenter
The Simple Language commenter subclasses `Commenter`.
This commenter defines the line comment prefix as "#".
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleCommenter.java %}
```
## 17.2. Register the Commenter
The `SimpleCommenter` implementation is registered with the IntelliJ Platform in the plugin configuration file using the `com.intellij.lang.commenter` extension point.
```xml
<extensions defaultExtensionNs="com.intellij">
<lang.commenter language="Simple" implementationClass="org.intellij.sdk.language.SimpleCommenter"/>

View File

@ -13,12 +13,14 @@ The Simple Language plugin implements the less complex of the two methods, refer
For this tutorial, the `simple_language_plugin` provides custom completion for values in Simple Language property files.
Create a completion contributor by subclassing [`CompletionContributor`](upsource:///platform/analysis-api/src/com/intellij/codeInsight/completion/CompletionContributor.java).
This rudimentary completion contributor always adds "Hello" to the results set, regardless of context:
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleCompletionContributor.java %}
```
## 9.2. Register the Completion Contributor
The `SimpleCompletionContributor` implementation is registered in the plugin configuration file with the IntelliJ Platform using the `com.intellij.completion.contributor` extension point.
```xml
<extensions defaultExtensionNs="com.intellij">
<completion.contributor language="Simple"

View File

@ -13,12 +13,14 @@ A scanner breaks the text into words and defines the context for each word.
The `SimpleFindUsagesProvider` implements [`FindUsagesProvider`](upsource:///platform/indexing-api/src/com/intellij/lang/findUsages/FindUsagesProvider.java).
Using the [`DefaultWordsScanner`](upsource:///platform/indexing-api/src/com/intellij/lang/cacheBuilder/DefaultWordsScanner.java) ensures the scanner implementation is thread-safe.
See the comments in `FindUsagesProvider` for more information.
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleFindUsagesProvider.java %}
```
## 11.2. Register the Find Usages Provider
The `SimpleFindUsagesProvider` implementation is registered with the IntelliJ Platform in the plugin configuration file using the `com.intellij.lang.findUsagesProvider` extension point.
```xml
<extensions defaultExtensionNs="com.intellij">
<lang.findUsagesProvider language="Simple"

View File

@ -30,6 +30,7 @@ The IntelliJ Platform uses the value to substitute for the key when the code get
## 12.2. Register the Folding Builder
The `SimpleFoldingBuilder` implementation is registered with the IntelliJ Platform in the plugin configuration file using the `com.intellij.lang.foldingBuilder` extension point.
```xml
<extensions defaultExtensionNs="com.intellij">
<lang.foldingBuilder language="JAVA"

View File

@ -15,6 +15,7 @@ The formatting model represents the formatting structure of a file as a tree of
The goal is to cover each PSI element with such a block.
Since each block builds its children's blocks, it can generate extra blocks or skip any PSI elements.
Define `SimpleBlock` based on [`AbstractBlock`](upsource:///platform/lang-impl/src/com/intellij/psi/formatter/common/AbstractBlock.java)
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleBlock.java %}
```
@ -23,12 +24,14 @@ Define `SimpleBlock` based on [`AbstractBlock`](upsource:///platform/lang-impl/s
Define a formatter that removes extra spaces except for the single spaces around the property separator.
For example, reformat "foo = &nbsp;&nbsp;&nbsp;&nbsp;bar" to `foo = bar`.
Create `SimpleFormattingModelBuilder` by subclassing [`FormattingModelBuilder`](upsource:///platform/lang-api/src/com/intellij/formatting/FormattingModelBuilder.java).
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleFormattingModelBuilder.java %}
```
## 15.3. Register the Formatter
The `SimpleFormattingModelBuilder` implementation is registered with the IntelliJ Platform in the plugin configuration file using the `com.intellij.lang.formatter` extension point.
```xml
<extensions defaultExtensionNs="com.intellij">
<lang.formatter language="Simple"

View File

@ -12,6 +12,7 @@ A _Go to Symbol Contributor_ helps the user to navigate to any PSI element by it
To specify how a PSI element looks like in the **Go To Symbol** popup window, **Structure** tool window, or other components, it should implement `getPresentation()`.
This method gets defined in the utility class `SimplePsiImplUtil`, and the parser and PSI classes must be regenerated.
Add the following method to `SimplePsiImplUtil`:
```java
public static ItemPresentation getPresentation(final SimpleProperty element) {
return new ItemPresentation() {
@ -40,6 +41,7 @@ public static ItemPresentation getPresentation(final SimpleProperty element) {
Now add the `SimplePsiImplUtil.getPresentation()` to the `property` methods definition in the `Simple.bnf` grammar file by replacing the `property` definition with the lines below.
Don't forget to regenerate the parser after updating the file!
Right-click on the `Simple.bnf` file and select **Generate Parser Code**.
```java
property ::= (KEY? SEPARATOR VALUE?) | KEY {
mixin="org.intellij.sdk.language.psi.impl.SimpleNamedElementImpl"
@ -50,12 +52,14 @@ property ::= (KEY? SEPARATOR VALUE?) | KEY {
## 13.3. Define a Go to Symbol Contributor
To enable the `simple_language_plugin` to contribute items to **Navigate \| Class..., File..., Symbol...** lists, subclass [`ChooseByNameContributor`](upsource:///platform/lang-api/src/com/intellij/navigation/ChooseByNameContributor.java) to create `SimpleChooseByNameContributor`:
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleChooseByNameContributor.java %}
```
## 13.4. Register the Go To Symbol Contributor
The `SimpleChooseByNameContributor` implementation is registered with the IntelliJ Platform in the plugin configuration file using the `com.intellij.gotoSymbolContributor` extension point.
```xml
<extensions defaultExtensionNs="com.intellij">
<gotoSymbolContributor

View File

@ -11,18 +11,21 @@ The Simple Language grammar must also be defined to generate a parser.
## 3.1. Define a Token Type
Create `SimpleTokenType` in the `org.intellij.sdk.language.psi` package (see the `simple_language_plugin` code sample) by subclassing `IElementType`.
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/psi/SimpleTokenType.java %}
```
## 3.2. Define an Element Type
Create the `SimpleElementType` in the `org.intellij.sdk.language.psi` package by subclassing `IElementType`.
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/psi/SimpleElementType.java %}
```
## 3.3. Define the Grammar
Define a grammar for the Simple Language in the `com/intellij/sdk/language/Simple.bnf` file.
```java
{
parserClass="org.intellij.sdk.language.parser.SimpleParser"

View File

@ -13,6 +13,7 @@ Register the `LanguageFileType` with the IntelliJ Platform in the plugin configu
## 2.1. Define the Language
The language implemented in this tutorial is named "Simple" - note the case of the name.
The `SimpleLanguage` class is defined in the `org.intellij.sdk.language` package of the `simple_language_plugin` code sample:
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleLanguage.java %}
```
@ -21,12 +22,14 @@ The `SimpleLanguage` class is defined in the `org.intellij.sdk.language` package
The [icon](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/simple_language_plugin/src/main/resources/icons/jar-gray.png) for the Simple Language is defined by the `SimpleIcons` class.
There is nothing uniquely Simple Language-specific about [defining the icon](/reference_guide/work_with_icons_and_images.md) itself.
The definition follows a pattern similar to defining, e.g., `SdkIcons`.
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleIcons.java %}
```
## 2.3. Define a FileType
The Simple Language file type is defined by subclassing [`LanguageFileType`](upsource:///platform/core-api/src/com/intellij/openapi/fileTypes/LanguageFileType.java):
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleFileType.java %}
```
@ -35,6 +38,7 @@ The Simple Language file type is defined by subclassing [`LanguageFileType`](ups
Direct registration is necessary when targeting version 2019.2 (and later) of the IntelliJ Platform.
No `FileTypeFactory` is required.
Instead, the file type is registered of file type is done via the `com.intellij.fileType` extension point in `plugin.xml`:
```xml
<extensions defaultExtensionNs="com.intellij">
<fileType name="Simple file" implementationClass="org.intellij.sdk.language.SimpleFileType"
@ -49,12 +53,14 @@ This pattern is necessary when targeting versions of the IntelliJ Platform prior
### 2.5.1 Define a FileType Factory
First, define `SimpleFileTypeFactory` as a subclass of [`FileTypeFactory`](upsource:///platform/platform-api/src/com/intellij/openapi/fileTypes/FileTypeFactory.java).
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleFileTypeFactory.java %}
```
### 2.5.2 Register the FileType Factory
The `SimpleFileTypeFactory` is registered with the IntelliJ Platform using the `com.intellij.openapi.fileTypes.FileTypeFactory` extension point in `plugin.xml`.
```xml
<extensions defaultExtensionNs="com.intellij">
<fileTypeFactory implementation="org.intellij.sdk.language.SimpleFileTypeFactory"/>

View File

@ -11,6 +11,7 @@ The easiest way to create a lexer is to use [JFlex](https://jflex.de/).
## 4.1. Define a Lexer
Define a `Simple.flex` file with rules for the Simple Language lexer, as demonstrated in `org.intellij.sdk.language.Simple.flex`.
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/Simple.flex %}
```
@ -29,18 +30,21 @@ See [Implementing Lexer](/reference_guide/custom_language_support/implementing_l
## 4.3. Define a Lexer Adapter
The JFlex lexer needs to be adapted to the IntelliJ Platform Lexer API.
This is done by subclassing [`FlexAdapter`](upsource:///platform/core-api/src/com/intellij/lexer/FlexAdapter.java).
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleLexerAdapter.java %}
```
## 4.4. Define a Root File
The `SimpleFile` implementation is the top-level node of the [tree of `PsiElements`](/reference_guide/custom_language_support/implementing_parser_and_psi.md) for a Simple Language file.
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/psi/SimpleFile.java %}
```
## 4.5. Define a Parser
The Simple Language parser is defined by subclassing [`ParserDefinition`](upsource:///platform/core-api/src/com/intellij/lang/ParserDefinition.java).
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleParserDefinition.java %}
```
@ -49,6 +53,7 @@ The Simple Language parser is defined by subclassing [`ParserDefinition`](upsour
Registering the parser definition in the `plugin.xml` file makes it available to the IntelliJ Platform.
Use the `com.intellij.lang.parserDefinition` extension point for registration.
For example, see `simple_language_plugin/src/main/resources/META-INF/plugin.xml`.
```xml
<extensions defaultExtensionNs="com.intellij">
<lang.parserDefinition language="Simple"
@ -58,6 +63,7 @@ For example, see `simple_language_plugin/src/main/resources/META-INF/plugin.xml`
## 4.7. Run the Project
With the `simple_language_plugin` loaded in a Development Instance, create a `test.simple` properties file with the following content:
```text
# You are reading the ".properties" entry.
! The exclamation mark can also mark text as comments.

View File

@ -15,6 +15,7 @@ The visual marker is a Simple Language icon in the gutter of the Editor window.
The Simple Language marker provider subclasses [`RelatedItemLineMarkerProvider`](upsource:///platform/lang-api/src/com/intellij/codeInsight/daemon/RelatedItemLineMarkerProvider.java).
For this example, override the `collectNavigationMarkers()` method to collect usage of a Simple Language [key and separators](/tutorials/custom_language_support/language_and_filetype.md#define-the-language):
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleLineMarkerProvider.java %}
```
@ -32,6 +33,7 @@ The `collectNavigationMarkers()` method should:
What happens when a `LineMarkerProvider` returns marker information for a `PsiElement` that is a higher node in the PSI tree?
For example, if `MyWrongLineMarkerProvider()` erroneously returns a `PsiMethod` instead of a `PsiIdentifier` element:
```java
public class MyWrongLineMarkerProvider implements LineMarkerProvider {
public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element) {
@ -53,6 +55,7 @@ However, if a method like `actionPerformed()` is not completely visible in the E
As a result, _the line marker icon would blink annoyingly_.
To fix this problem, rewrite `MyWrongLineMarkerProvider` to return info for `PsiIdentifier` instead of `PsiMethod` as shown below:
```java
public class MyCorrectLineMarkerProvider implements LineMarkerProvider {
public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element) {
@ -64,6 +67,7 @@ public class MyCorrectLineMarkerProvider implements LineMarkerProvider {
## 8.3. Register the Line Marker Provider
The `SimpleLineMarkerProvider` implementation is registered with the IntelliJ Platform in the plugin configuration file using the `com.intellij.codeInsight.lineMarkerProvider` extension point.
```xml
<extensions defaultExtensionNs="com.intellij">
<codeInsight.lineMarkerProvider language="JAVA"

View File

@ -11,6 +11,7 @@ Helper classes and utilities can be embedded in the code generated by Grammar-Ki
## 6.1. Define Helper Methods for Generated PSI Elements
Custom methods in PSI classes are defined separately, and Grammar-Kit embeds them into generated code.
Define a utility class with these helper methods:
```java
package org.intellij.sdk.language.psi.impl;
@ -75,6 +76,7 @@ After making changes to the grammar, regenerate the parser and PSI classes.
## 6.3. Define a Utility to Search Properties
Create a utility class to search PSI elements for defined properties over the project.
This utility will be used later when implementing [code completion](https://www.jetbrains.com/help/idea/auto-completing-code.html).
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleUtil.java %}
```

View File

@ -13,6 +13,7 @@ For the Simple Language, this tutorial adds a quick fix that helps to define an
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`](/tutorials/custom_language_support/lexer_and_parser_definition.md#run-the-project) file before adding a new property.
A new overload of `createProperty()` creates a new `key`-`value` pair for Simple Language.
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/psi/SimpleElementFactory.java %}
```
@ -21,6 +22,7 @@ A new overload of `createProperty()` creates a new `key`-`value` pair for Simple
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`](https://github.com/JetBrains/intellij-sdk-docs/tree/master/code_samples/conditional_operator_intention).
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleCreatePropertyQuickFix.java %}
```
@ -28,6 +30,7 @@ For a more in-depth example of an Intention Action, see [`conditional_operator_i
## 18.3. 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.
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleAnnotator.java %}
```

View File

@ -15,11 +15,13 @@ Resolving references means the ability to go from the usage of an element to its
The classes below show how the Simple Language fulfills the need to implement `PsiNamedElement`.
The `SimpleNamedElement` interface is subclassed from [`PsiNameIdentifierOwner`](upsource:///platform/core-api/src/com/intellij/psi/PsiNameIdentifierOwner.java).
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/psi/SimpleNamedElement.java %}
```
The `SimpleNamedElementImpl` class implements the `SimpleNamedElement` interface and extends [`ASTWrapperPsiElement`](upsource:///platform/core-impl/src/com/intellij/extapi/psi/ASTWrapperPsiElement.java).
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/psi/impl/SimpleNamedElementImpl.java %}
```
@ -63,6 +65,7 @@ public class SimplePsiImplUtil {
## 10.3. Define an Element Factory
The `SimpleElementFactory` provides methods for creating `SimpleFile`.
```java
package org.intellij.sdk.language.psi;
@ -88,6 +91,7 @@ public class SimpleElementFactory {
Now make corresponding changes to the `Simple.bnf` grammar file by replacing the `property` definition with the lines below.
Don't forget to regenerate the parser after updating the file!
Right-click on the `Simple.bnf` file and select **Generate Parser Code**.
```java
property ::= (KEY? SEPARATOR VALUE?) | KEY {
mixin="org.intellij.sdk.language.psi.impl.SimpleNamedElementImpl"
@ -100,6 +104,7 @@ property ::= (KEY? SEPARATOR VALUE?) | KEY {
Now define a reference class to resolve a property from its usage.
This requires extending [`PsiReferenceBase`](upsource:///platform/core-api/src/com/intellij/psi/PsiReferenceBase.java) and implementing [`PsiPolyVariantReference`](upsource:///platform/core-api/src/com/intellij/psi/PsiPolyVariantReference.java).
The latter enables the reference to resolve to more than one element or to resolve result(s) for a superset of valid resolve cases.
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleReference.java %}
```
@ -108,12 +113,14 @@ The latter enables the reference to resolve to more than one element or to resol
A reference contributor allows the `simple_language_plugin` to provide references to Simple Language from elements in other languages such as Java.
Create `SimpleReferenceContributor` by subclassing [`PsiReferenceContributor`](upsource:///platform/core-api/src/com/intellij/psi/PsiReferenceContributor.java).
Contribute a reference to each usage of a property:
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleReferenceContributor.java %}
```
## 10.7. Register the Reference Contributor
The `SimpleReferenceContributor` implementation is registered with the IntelliJ Platform using the `com.intellij.psi.referenceContributor` extension point.
```xml
<extensions defaultExtensionNs="com.intellij">
<psi.referenceContributor implementation="org.intellij.sdk.language.SimpleReferenceContributor"/>
@ -134,12 +141,14 @@ The [Rename refactoring](https://www.jetbrains.com/help/idea/rename-refactorings
Support for in-place refactoring is specified explicitly in a refactoring support provider.
Create `SimpleRefactoringSupportProvider` by subclassing [`RefactoringSupportProvider`](upsource:///platform/lang-api/src/com/intellij/lang/refactoring/RefactoringSupportProvider.java)
As long as an element is a `SimpleProperty` it is allowed to be refactored:
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleRefactoringSupportProvider.java %}
```
## 10.10. Register the Refactoring Support Provider
The `SimpleRefactoringSupportProvider` implementation is registered with the IntelliJ Platform in the plugin configuration file using the `com.intellij.lang.refactoringSupport` extension point.
```xml
<extensions defaultExtensionNs="com.intellij">
<lang.refactoringSupport language="Simple"

View File

@ -13,6 +13,7 @@ Creating a structure view factory allows showing the structure of any file in a
The structure view factory implements [`PsiStructureViewFactory`](upsource:///platform/editor-ui-api/src/com/intellij/lang/PsiStructureViewFactory.java).
The `getStructureViewBuilder()` implementation reuses the IntelliJ Platform class [`TreeBasedStructureViewBuilder`](upsource:///platform/editor-ui-api/src/com/intellij/ide/structureView/TreeBasedStructureViewBuilder.java).
At this point the project will not compile until `SimpleStructureViewModel` is [implemented below](#define-a-structure-view-model).
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleStructureViewFactory.java %}
```
@ -20,6 +21,7 @@ At this point the project will not compile until `SimpleStructureViewModel` is [
## 14.2. Define a Structure View Model
The `SimpleStructureViewModel` is created by implementing [`StructureViewModel`](upsource:///platform/editor-ui-api/src/com/intellij/ide/structureView/StructureViewModel.java), which defines the model for data displayed in the standard structure view.
It also extends [`StructureViewModelBase`](upsource:///platform/editor-ui-api/src/com/intellij/ide/structureView/StructureViewModelBase.java), an implementation that links the model to a text editor.
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleStructureViewModel.java %}
```
@ -28,12 +30,14 @@ It also extends [`StructureViewModelBase`](upsource:///platform/editor-ui-api/sr
The `SimpleStructureViewElement` implements [`StructureViewTreeElement`](upsource:///platform/editor-ui-api/src/com/intellij/ide/structureView/StructureViewTreeElement.java) and [`SortableTreeElement`](upsource:///platform/editor-ui-api/src/com/intellij/ide/util/treeView/smartTree/SortableTreeElement.java).
The `StructureViewTreeElement` represents an element in the Structure View tree model.
The `SortableTreeElement` represents an item in a smart tree that allows using text other than the presentable text as a key for alphabetic sorting.
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleStructureViewElement.java %}
```
## 14.4. Register the Structure View Factory
The `SimpleStructureViewFactory` implementation is registered with the IntelliJ Platform in the plugin configuration file using the `com.intellij.lang.psiStructureViewFactory` extension point.
```xml
<extensions defaultExtensionNs="com.intellij">
<lang.psiStructureViewFactory language="Simple"

View File

@ -14,6 +14,7 @@ The `SimpleSyntaxHighlighter`, `SimpleSyntaxHighlighterFactory`, and `SimpleColo
The Simple Language syntax highlighter class extends [`SyntaxHighlighterBase`](upsource:///platform/editor-ui-api/src/com/intellij/openapi/fileTypes/SyntaxHighlighterBase.java).
As recommended in [Color Scheme Management](/reference_guide/color_scheme_management.md#text-attribute-key-dependency), the Simple Language highlighting text attributes are specified as a dependency on one of standard Intellij Platform keys.
For the Simple Language, define only one scheme.
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleSyntaxHighlighter.java %}
```
@ -21,12 +22,14 @@ For the Simple Language, define only one scheme.
### 5.2. Define a Syntax Highlighter Factory
The factory provides a standard way for the IntelliJ Platform to instantiate the syntax highlighter for Simple Language files.
Here, `SimpleSyntaxHighlighterFactory` subclasses [`SyntaxHighlighterFactory`](upsource:///platform/editor-ui-api/src/com/intellij/openapi/fileTypes/SyntaxHighlighterFactory.java).
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleSyntaxHighlighterFactory.java %}
```
### 5.3. Register the Syntax Highlighter Factory
Register the factory with the IntelliJ Platform in the plugin configuration file using the `com.intellij.lang.syntaxHighlighterFactory` extension point.
```xml
<extensions defaultExtensionNs="com.intellij">
<lang.syntaxHighlighterFactory language="Simple"
@ -43,12 +46,14 @@ The colors for Simple Language Key, Separator, and Value highlighting default to
## 5.5. Define a Color Settings Page
The color settings page adds the ability for users to customize color settings for the highlighting in Simple Language files.
The `SimpleColorSettingsPage` implements [`ColorSettingsPage`](upsource:///platform/platform-api/src/com/intellij/openapi/options/colors/ColorSettingsPage.java).
```java
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleColorSettingsPage.java %}
```
### 5.6. Register the Color Settings Page
Register the Simple Language color settings page with the IntelliJ Platform in the plugin configuration file using the `com.intellij.colorSettingsPage` extension point.
```xml
<extensions defaultExtensionNs="com.intellij">
<colorSettingsPage implementation="org.intellij.sdk.language.SimpleColorSettingsPage"/>

View File

@ -166,6 +166,7 @@ Starting on the left end of the line, and using the arrow key to advance a line-
System.out.println( str );
}
```
The apparent discontinuity in Logical Position is because the RTL portion of the string is treated (or counted) in the logical character order in which it would be written.
The apparent continuity in Visual Position is because the RTL portion of the string is counted in the visual order in which it is displayed in the code.

View File

@ -12,7 +12,7 @@ In addition to [null safety](https://kotlinlang.org/docs/reference/null-safety.h
Likewise, it is easy to customize the behavior of internal classes in IntelliJ IDEA, with [extensions](https://kotlinlang.org/docs/reference/extensions.html). For example, it is common practice to [guard logging statements](https://www.slf4j.org/faq.html#logging_performance) to avoid the cost of parameter construction, leading to the following ceremony when using the log:
```java
if(logger.isDebugEnabled()) {
if (logger.isDebugEnabled()) {
logger.debug("...");
}
```

View File

@ -8,6 +8,7 @@ When a user types the designated abbreviation followed by a configurable *expans
For example, consider a `for` loop. Typically, the end user would need to type `for(int i = 0; i < 10; i++) {<Enter><Tab><Enter><Enter>}<Up>`.
This pattern may be shortened to `fori<Tab>` and the remaining contents will be expanded, leaving the following structure:
```
for(int i = [|]; i < []; i++) {
[]

View File

@ -34,6 +34,7 @@ The XML representation of an example Live Template using the new `titleCase` fun
There is only one variable, `TITLE`.
The expression for `TITLE` evaluates to the `titleCase` function provided by the plugin.
The argument to the `titleCase` function is `SELECTION`, which tells the IntelliJ Platform to operate on the current selection.
```xml
<template name="mc"
value="$TITLE$"
@ -49,6 +50,7 @@ The argument to the `titleCase` function is `SELECTION`, which tells the Intelli
## Register Extension Point
Using the `com.intellij.liveTemplateMacro` extension point, register the implementation with the IntelliJ Platform.
```xml
<extensions defaultExtensionNs="com.intellij">
<liveTemplateMacro implementation="org.intellij.sdk.liveTemplates.TitleCaseMacro"/>

View File

@ -18,6 +18,7 @@ Get started by [creating a new Live Template](https://www.jetbrains.com/idea/hel
* Assign the template the abbreviation "**{**".
* Assign the description "**SDK: New link reference**".
* Paste the following snippet into the *Template text* field:
```text
[$TEXT$]($LINK$)$END$
```
@ -61,6 +62,7 @@ Ultimately, a file's extension determines the applicable Markdown context.
> **Note** Once the `MarkdownContext` is defined, be sure to add the new context type to the previously created Live Template settings file.
Within the `<template>...</template>` elements in the `Markdown.xml` [Live Template definition file](#export-the-live-template), add the following context elements:
```xml
<variable.../>
<context>
@ -81,12 +83,14 @@ For 2020.1 and later, follow this section to register the extension points and t
#### Register Extension Points
Using the `com.intellij.defaultLiveTemplates` and `com.intellij.liveTemplateContext` extension points, register the implementations with the IntelliJ Platform.
The `file` attribute in the `defaultLiveTemplates` element specifies `path/filename` under the `src/main/resources` folder.
```xml
<extensions defaultExtensionNs="com.intellij">
<defaultLiveTemplates file="/liveTemplates/Markdown.xml"/>
<liveTemplateContext implementation="org.intellij.sdk.liveTemplates.MarkdownContext"/>
</extensions>
```
Now go to the [Check Plugin](#check-plugin) section to test the template.
### Versions 2019.3 and Earlier
@ -96,6 +100,7 @@ Then proceed to the [Check Plugin](#check-plugin) section.
#### Implement DefaultLiveTemplatesProvider
The `MarkdownTemplateProvider` tells the Platform where to find the Live Template settings file.
Make sure to include the full path to the file, relative to the `src/main/resources` directory, excluding the file extension.
```java
package org.intellij.sdk.liveTemplates;
@ -118,6 +123,7 @@ public class MarkdownTemplateProvider implements DefaultLiveTemplatesProvider {
#### Register Extension Points
Using the `com.intellij.defaultLiveTemplatesProvider` and `com.intellij.liveTemplateContext` extension points, register the implementations with the IntelliJ Platform.
```xml
<extensions defaultExtensionNs="com.intellij">
<defaultLiveTemplatesProvider implementation="org.intellij.sdk.liveTemplates.MarkdownTemplateProvider"/>

View File

@ -23,12 +23,14 @@ Add a new `com.intellij.moduleType` implementation with the IntelliJ Platform in
## 2. Implement ModuleType Interface
Create the `DemoModuleType` implementation based on [`ModuleType`](upsource:///platform/lang-api/src/com/intellij/openapi/module/ModuleType.java).
```java
{% include /code_samples/module/src/main/java/org/intellij/sdk/module/DemoModuleType.java %}
```
## 3. Implement Custom Module Builder
Create `DemoModuleBuilder` based on [`ModuleBuilder`](upsource:///platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleBuilder.java).
```java
{% include /code_samples/module/src/main/java/org/intellij/sdk/module/DemoModuleBuilder.java %}
```
@ -36,6 +38,7 @@ Create `DemoModuleBuilder` based on [`ModuleBuilder`](upsource:///platform/lang-
## 4. Provide Custom Wizard Steps
Provide a straightforward implementation of UI components for the project creating stage.
Create a generic `DemoModuleWizardStep` based on [ModuleWizardStep](upsource:///platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleWizardStep.java)
```java
{% include /code_samples/module/src/main/java/org/intellij/sdk/module/DemoModuleWizardStep.java %}
```

View File

@ -12,6 +12,7 @@ Create an input test file `AnnotatorTestData.java` in the `testData` directory.
This file contains two instances of Simple Language embedded in the Java code.
The first instance is a valid use of the `simple:` prefix followed by the Simple Language key `website`.
The second is a valid prefix but an invalid key, as noted by the test `<error>` [highlighting](/basics/testing_plugins/testing_highlighting.md).
```java
public class Test {
public static void main(String[] args) {
@ -25,6 +26,7 @@ public class Test {
Add the `testAnnotator()` method to the `SimpleCodeInsightTest` class [previously defined](completion_test.md#define-a-test).
Again, this method configures the test fixture by using the test files.
It then calls the `checkHighlighting()` method to verify weak warnings.
```java
public void testAnnotator() {
myFixture.configureByFiles("AnnotatorTestData.java", "DefaultTestData.simple");

View File

@ -14,6 +14,7 @@ Create the `DefaultTestData.simple` properties file in the `testData` directory.
Create a test input Java file `CompleteTestData.java` in the `testData` directory.
This file contains a Simple Language snippet within the Java.
```java
{% include /code_samples/simple_language_plugin/src/test/testData/CompleteTestData.java %}
```

View File

@ -10,6 +10,7 @@ This test verifies the Simple Language folding builder, implemented in the [Fold
## 7.1. Define Test Data
Create a file `FoldingTestData.java` in the `testData` directory.
This java file contains markup instructions for three different cases of code folding.
```java
{% include /code_samples/simple_language_plugin/src/test/testData/FoldingTestData.java %}
```
@ -17,6 +18,7 @@ This java file contains markup instructions for three different cases of code fo
## 7.2. Define a Test
Add the `testFolding()` method to the `SimpleCodeInsightTest` class [previously defined](completion_test.md#define-a-test).
This test method reuses the `DefaultTestData.simple` properties file.
```java
public void testFolding() {
myFixture.configureByFile("DefaultTestData.simple");

View File

@ -27,6 +27,7 @@ private recover_property ::= !(KEY|SEPARATOR|COMMENT)
## 2.2. Define Input Test Data
Create the *ParsingTestData.simple* properties file in the *testData* folder.
Note the last few lines define a purposely incorrect key.
```bash
{% include /code_samples/simple_language_plugin/src/test/testData/ParsingTestData.simple %}
```
@ -49,6 +50,7 @@ Create a file *ParsingTestData.txt* with the copied PSI tree.
## 2.4. Define a Parsing Test
Subclass [`ParsingTestCase`](upsource:///platform/testFramework/src/com/intellij/testFramework/ParsingTestCase.java) to create `SimpleParsingTest`:
Override `getTestDataPath()`, and return the path from the root of this plugin module to the `testData` directory.
```java
{% include /code_samples/simple_language_plugin/src/test/java/org/intellij/sdk/language/SimpleParsingTest.java %}
```

View File

@ -26,6 +26,7 @@ IntelliJ IDEA does everything automatically when the utility class [`LightJavaCo
The system properties are defined in the `build.gradle` file using the snippet shown below.
The `/path/to/community/` is set to the absolute path to the root directory of the local intellij-community source on the machine running the tests.
For example, on macOS the `path/to/community/` might be `/Users/<user name>/Documents/<IJ community source root>/`
```groovy
test {
systemProperty "idea.home.path", "/path/to/community/"

View File

@ -76,6 +76,7 @@ There are two ways to add child components. The recommended way is to use factor
```
These methods also support **property bindings**, allowing you to automatically load the value displayed in the component from a property and to store it back. The easiest way to do that is to pass a reference to a Kotlin bound property:
```kotlin
checkBox("Show tabs in single row", uiSettings::scrollTabLayoutInEditor)
```
@ -92,13 +93,14 @@ Alternatively, many factory methods support specifying a getter/setter pair for
```
If you want to add a component for which there are no factory methods, you can simply invoke an instance of your component, using the `()` overloaded operator:
```kotlin
```kotlin
val userField = JTextField(credentials?.userName)
panel() {
row { userField(grow, wrap) }
}
// use userField variable somehow
```
```
## Supported Components