diff --git a/README.md b/README.md index b0644dd75..c6556164c 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ A set of Rake tasks, a Make-like programs implemented in Ruby, provides short co rake preview ``` * 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. **Note:** Make sure you haven't change default Jekyll port during installation. diff --git a/tutorials/action_system/grouping_action.md b/tutorials/action_system/grouping_action.md index 2ab441941..995e512c6 100644 --- a/tutorials/action_system/grouping_action.md +++ b/tutorials/action_system/grouping_action.md @@ -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 Grouping can be done by extending adding `` attribute to `` -[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. ```xml @@ -101,7 +101,7 @@ public class CustomDefaultActionGroup extends DefaultActionGroup { As in case with the simple action group, the inheritor of [DefaultActionGroup.java](upsource:///platform/platform-api/src/com/intellij/openapi/actionSystem/DefaultActionGroup.java) 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: ```xml @@ -119,18 +119,13 @@ file: needs to be extended: ```java -public class CustomGroupedAction extends AnAction { - @Override - public void actionPerformed(AnActionEvent anActionEvent) { - //Does nothing - } -} +{% include /code_samples/register_actions/src/org/jetbrains/tutorials/actions/CustomGroupedAction.java %} ``` #### 2.2.4. Adding actions to the group 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 @@ -185,7 +180,7 @@ public class BaseActionGroup extends ActionGroup { #### 2.3.2. Registering variable action group To register the group `` attribute needs to be placed in the *``* 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 @@ -196,7 +191,7 @@ To register the group `` attribute needs to be placed in the *`` ``` **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 `` attribute contains any static action definition an exception will be thrown. For statically defined group of action use [DefaultActionGroup.java](upsource:///platform/platform-api/src/com/intellij/openapi/actionSystem/DefaultActionGroup.java) diff --git a/tutorials/action_system/working_with_custom_actions.md b/tutorials/action_system/working_with_custom_actions.md index 441a372f7..a7f40b1a4 100644 --- a/tutorials/action_system/working_with_custom_actions.md +++ b/tutorials/action_system/working_with_custom_actions.md @@ -42,7 +42,7 @@ public class SimpleAction extends AnAction { ### 1.3. Registering actions To register a newly created action, `` attribute should be added to the `` 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. !["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) After filling the **New Action** form and applying the changes `` 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: ```xml @@ -71,7 +71,7 @@ file will look like this: ### 1.4. Setting attributes manually 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: ```xml diff --git a/tutorials/custom_language_support/annotator.md b/tutorials/custom_language_support/annotator.md index 623945fb7..36f18ec9b 100644 --- a/tutorials/custom_language_support/annotator.md +++ b/tutorials/custom_language_support/annotator.md @@ -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. Let's consider a literal which starts with *"simple:"* as a usage of our property. -```java -package com.simpleplugin; - -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 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"); - } - } - } - } -} +``` +{% include /code_samples/simple_language_plugin/src/com/simpleplugin/SimpleAnnotator.java %} ``` ### 7.2. Register the annotator diff --git a/tutorials/custom_language_support/reference_contributor.md b/tutorials/custom_language_support/reference_contributor.md index d9ff460c0..08761d8e8 100644 --- a/tutorials/custom_language_support/reference_contributor.md +++ b/tutorials/custom_language_support/reference_contributor.md @@ -51,24 +51,7 @@ public static PsiElement getNameIdentifier(SimpleProperty element) { ### 10.3. Define an element factory ```java -package com.simpleplugin.psi; - -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); - } -} +{% include /code_samples/simpleplugin/psi/impl/SimpleElementFactory.java %} ``` ### 10.4. Update grammar and regenerate the parser diff --git a/tutorials/framework.md b/tutorials/framework.md index 031413956..34f866d52 100644 --- a/tutorials/framework.md +++ b/tutorials/framework.md @@ -19,7 +19,7 @@ public class DemoFramework extends FrameworkTypeEx { ## 2. Registering framework The newly created framework should be registered as an extension point by putting *framework.type* attribute into `` 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: diff --git a/tutorials/run_configurations.md b/tutorials/run_configurations.md index cf400baa0..ea488f6cc 100644 --- a/tutorials/run_configurations.md +++ b/tutorials/run_configurations.md @@ -20,7 +20,7 @@ to know how to do it. ## 1. Register a New Configuration Type 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 diff --git a/tutorials/tree_structure_view.md b/tutorials/tree_structure_view.md index 4fb111a0a..42b14a704 100644 --- a/tutorials/tree_structure_view.md +++ b/tutorials/tree_structure_view.md @@ -20,7 +20,7 @@ to know how to do it. ## 1. Register Custom TreeStructureView Provider 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 @@ -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. ```java -public Collection modify(@NotNull AbstractTreeNode parent, @NotNull Collection children, ViewSettings settings) { - ArrayList nodes = new ArrayList(); - 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; -} +{% include /code_samples/tree_structure_provider/src/org/jetbrains/tutorials/tree/structure/TextOnlyTreeStructureProvider.java %} ``` ## 4. Compile and Run the Plugin