Fix broken links and cross reference more sample code

This commit is contained in:
Breandan Considine 2016-03-21 16:47:39 -04:00
parent 381687fcdb
commit 778cfa08a8
8 changed files with 17 additions and 89 deletions

View File

@ -69,7 +69,7 @@ A set of Rake tasks, a Make-like programs implemented in Ruby, provides short co
rake preview rake preview
``` ```
* Open the address * Open the address
[http://127.0.0.1:4000/](http://127.0.0.1:4000/) [http://localhost:4000/intellij/sdk/docs/](http://localhost:4000/intellij/sdk/docs/)
in your browser. in your browser.
**Note:** Make sure you haven't change default Jekyll port during installation. **Note:** Make sure you haven't change default Jekyll port during installation.

View File

@ -11,7 +11,7 @@ In this case the group will be available as a top-level menu item, action will b
#### 2.1.1. Creating simple action groups #### 2.1.1. Creating simple action groups
Grouping can be done by extending adding `<group>` attribute to `<actions>` Grouping can be done by extending adding `<group>` attribute to `<actions>`
[plugin.xml](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/register_actions/META-INF/plugin.xml) [plugin.xml](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/register_actions/resources/META-INF/plugin.xml)
file. file.
```xml ```xml
@ -101,7 +101,7 @@ public class CustomDefaultActionGroup extends DefaultActionGroup {
As in case with the simple action group, the inheritor of As in case with the simple action group, the inheritor of
[DefaultActionGroup.java](upsource:///platform/platform-api/src/com/intellij/openapi/actionSystem/DefaultActionGroup.java) [DefaultActionGroup.java](upsource:///platform/platform-api/src/com/intellij/openapi/actionSystem/DefaultActionGroup.java)
should be declared in should be declared in
[plugin.xml](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/register_actions/META-INF/plugin.xml) [plugin.xml](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/register_actions/resources/META-INF/plugin.xml)
file: file:
```xml ```xml
@ -119,18 +119,13 @@ file:
needs to be extended: needs to be extended:
```java ```java
public class CustomGroupedAction extends AnAction { {% include /code_samples/register_actions/src/org/jetbrains/tutorials/actions/CustomGroupedAction.java %}
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
//Does nothing
}
}
``` ```
#### 2.2.4. Adding actions to the group #### 2.2.4. Adding actions to the group
Action's class should be registered in Action's class should be registered in
[plugin.xml](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/register_actions/META-INF/plugin.xml) [plugin.xml](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/register_actions/resources/META-INF/plugin.xml)
: :
```xml ```xml
@ -185,7 +180,7 @@ public class BaseActionGroup extends ActionGroup {
#### 2.3.2. Registering variable action group #### 2.3.2. Registering variable action group
To register the group `<group>` attribute needs to be placed in the *`<actions>`* section of To register the group `<group>` attribute needs to be placed in the *`<actions>`* section of
[plugin.xml](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/register_actions/META-INF/plugin.xml): [plugin.xml](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/register_actions/resources/META-INF/plugin.xml):
```xml ```xml
<actions> <actions>
@ -196,7 +191,7 @@ To register the group `<group>` attribute needs to be placed in the *`<actions>`
</actions> </actions>
``` ```
**Note**: Since the set of actions is defined dynamically no action definitions should be placed in **Note**: Since the set of actions is defined dynamically no action definitions should be placed in
[plugin.xml](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/register_actions/META-INF/plugin.xml). [plugin.xml](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/register_actions/resources/META-INF/plugin.xml).
If `<group>` attribute contains any static action definition an exception will be thrown. If `<group>` attribute contains any static action definition an exception will be thrown.
For statically defined group of action use For statically defined group of action use
[DefaultActionGroup.java](upsource:///platform/platform-api/src/com/intellij/openapi/actionSystem/DefaultActionGroup.java) [DefaultActionGroup.java](upsource:///platform/platform-api/src/com/intellij/openapi/actionSystem/DefaultActionGroup.java)

View File

@ -42,7 +42,7 @@ public class SimpleAction extends AnAction {
### 1.3. Registering actions ### 1.3. Registering actions
To register a newly created action, `<action>` attribute should be added to the `<actions>` section of the plugin configuration file To register a newly created action, `<action>` attribute should be added to the `<actions>` section of the plugin configuration file
[plugin.xml](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/register_actions/META-INF/plugin.xml). [plugin.xml](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/register_actions/resources/META-INF/plugin.xml).
IntelliJ IDEA has an embedded inspection that spots unregistered actions. IntelliJ IDEA has an embedded inspection that spots unregistered actions.
!["Action never used" inspection](img/action_never_used.png) !["Action never used" inspection](img/action_never_used.png)
@ -55,7 +55,7 @@ In our case the action will be available in the **Tools Menu**, it will be place
!["Register action" quick fix](img/new_action.png) !["Register action" quick fix](img/new_action.png)
After filling the **New Action** form and applying the changes `<actions>` section of our After filling the **New Action** form and applying the changes `<actions>` section of our
[plugin.xml](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/register_actions/META-INF/plugin.xml) [plugin.xml](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/register_actions/resources/META-INF/plugin.xml)
file will look like this: file will look like this:
```xml ```xml
@ -71,7 +71,7 @@ file will look like this:
### 1.4. Setting attributes manually ### 1.4. Setting attributes manually
Full list of action's attributes can also be set manually in Full list of action's attributes can also be set manually in
[plugin.xml](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/register_actions/META-INF/plugin.xml) [plugin.xml](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/register_actions/resources/META-INF/plugin.xml)
configuration file like the following code sample shows: configuration file like the following code sample shows:
```xml ```xml

View File

@ -9,46 +9,8 @@ Annotator helps highlight and annotate any code based on specific rules.
In this tutorial we will annotate usages of our properties within Java code. In this tutorial we will annotate usages of our properties within Java code.
Let's consider a literal which starts with *"simple:"* as a usage of our property. Let's consider a literal which starts with *"simple:"* as a usage of our property.
```java ```
package com.simpleplugin; {% include /code_samples/simple_language_plugin/src/com/simpleplugin/SimpleAnnotator.java %}
import com.intellij.lang.annotation.Annotation;
import com.intellij.lang.annotation.AnnotationHolder;
import com.intellij.lang.annotation.Annotator;
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiLiteralExpression;
import com.simpleplugin.psi.SimpleProperty;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class SimpleAnnotator implements Annotator {
@Override
public void annotate(@NotNull final PsiElement element, @NotNull AnnotationHolder holder) {
if (element instanceof PsiLiteralExpression) {
PsiLiteralExpression literalExpression = (PsiLiteralExpression) element;
String value = (String) literalExpression.getValue();
if (value != null && value.startsWith("simple:")) {
Project project = element.getProject();
String key = value.substring(7);
List<SimpleProperty> properties = SimpleUtil.findProperties(project, key);
if (properties.size() == 1) {
TextRange range = new TextRange(element.getTextRange().getStartOffset() + 7,
element.getTextRange().getStartOffset() + 7);
Annotation annotation = holder.createInfoAnnotation(range, null);
annotation.setTextAttributes(DefaultLanguageHighlighterColors.LINE_COMMENT);
} else if (properties.size() == 0) {
TextRange range = new TextRange(element.getTextRange().getStartOffset() + 8,
element.getTextRange().getEndOffset());
holder.createErrorAnnotation(range, "Unresolved property");
}
}
}
}
}
``` ```
### 7.2. Register the annotator ### 7.2. Register the annotator

View File

@ -51,24 +51,7 @@ public static PsiElement getNameIdentifier(SimpleProperty element) {
### 10.3. Define an element factory ### 10.3. Define an element factory
```java ```java
package com.simpleplugin.psi; {% include /code_samples/simpleplugin/psi/impl/SimpleElementFactory.java %}
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFileFactory;
import com.simpleplugin.SimpleFileType;
public class SimpleElementFactory {
public static SimpleProperty createProperty(Project project, String name) {
final SimpleFile file = createFile(project, name);
return (SimpleProperty) file.getFirstChild();
}
public static SimpleFile createFile(Project project, String text) {
String name = "dummy.simple";
return (SimpleFile) PsiFileFactory.getInstance(project).
createFileFromText(name, SimpleFileType.INSTANCE, text);
}
}
``` ```
### 10.4. Update grammar and regenerate the parser ### 10.4. Update grammar and regenerate the parser

View File

@ -19,7 +19,7 @@ public class DemoFramework extends FrameworkTypeEx {
## 2. Registering framework ## 2. Registering framework
The newly created framework should be registered as an extension point by putting *framework.type* attribute into `<extensions>` section of The newly created framework should be registered as an extension point by putting *framework.type* attribute into `<extensions>` section of
[plugin.xml](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/framework/META-INF/plugin.xml) [plugin.xml](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/framework/resources/META-INF/plugin.xml)
configuration file: configuration file:

View File

@ -20,7 +20,7 @@ to know how to do it.
## 1. Register a New Configuration Type ## 1. Register a New Configuration Type
Add new *configurationType* extension to the Add new *configurationType* extension to the
[plugin.xml](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/run_configuration/META-INF/plugin.xml) [plugin.xml](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/run_configuration/resources/META-INF/plugin.xml)
```xml ```xml
<extensions defaultExtensionNs="com.intellij"> <extensions defaultExtensionNs="com.intellij">

View File

@ -20,7 +20,7 @@ to know how to do it.
## 1. Register Custom TreeStructureView Provider ## 1. Register Custom TreeStructureView Provider
Add new *treeStructureProvider* extension to the Add new *treeStructureProvider* extension to the
[plugin.xml](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/tree_structure_provider/META-INF/plugin.xml) [plugin.xml](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/tree_structure_provider/resources/META-INF/plugin.xml)
```java ```java
<extensions defaultExtensionNs="com.intellij"> <extensions defaultExtensionNs="com.intellij">
@ -54,19 +54,7 @@ To implement Tree Structure nodes filtering logic, override modify() method.
The example below shows how to filter out all the Project View nodes except those which correspond text files and directories. The example below shows how to filter out all the Project View nodes except those which correspond text files and directories.
```java ```java
public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings settings) { {% include /code_samples/tree_structure_provider/src/org/jetbrains/tutorials/tree/structure/TextOnlyTreeStructureProvider.java %}
ArrayList<AbstractTreeNode> nodes = new ArrayList<AbstractTreeNode>();
for (AbstractTreeNode child : children) {
if (child instanceof PsiFileNode) {
VirtualFile file = ((PsiFileNode) child).getVirtualFile();
if (file != null && !file.isDirectory() && !(file.getFileType() instanceof PlainTextFileType)) {
continue;
}
}
nodes.add(child);
}
return nodes;
}
``` ```
## 4. Compile and Run the Plugin ## 4. Compile and Run the Plugin