mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-28 01:07:49 +08:00
Tidy up code samples and wrap at 80 chars #IJSDK-24
This commit is contained in:
parent
8aaf13b046
commit
f416f02ce2
@ -3,7 +3,6 @@ package com.intellij.codeInspection;
|
||||
import com.intellij.codeInsight.daemon.GroupNames;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
@ -14,8 +13,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
/**
|
||||
@ -26,8 +23,12 @@ public class ComparingReferencesInspection extends BaseJavaLocalInspectionTool {
|
||||
|
||||
private final LocalQuickFix myQuickFix = new MyQuickFix();
|
||||
|
||||
@SuppressWarnings({"WeakerAccess"}) @NonNls public String CHECKED_CLASSES = "java.lang.String;java.util.Date";
|
||||
@NonNls private static final String DESCRIPTION_TEMPLATE = InspectionsBundle.message("inspection.comparing.references.problem.descriptor");
|
||||
@SuppressWarnings({"WeakerAccess"})
|
||||
@NonNls
|
||||
public String CHECKED_CLASSES = "java.lang.String;java.util.Date";
|
||||
@NonNls
|
||||
private static final String DESCRIPTION_TEMPLATE =
|
||||
InspectionsBundle.message("inspection.comparing.references.problem.descriptor");
|
||||
|
||||
@NotNull
|
||||
public String getDisplayName() {
|
||||
@ -67,7 +68,8 @@ public class ComparingReferencesInspection extends BaseJavaLocalInspectionTool {
|
||||
}
|
||||
|
||||
|
||||
@Override public void visitBinaryExpression(PsiBinaryExpression expression) {
|
||||
@Override
|
||||
public void visitBinaryExpression(PsiBinaryExpression expression) {
|
||||
super.visitBinaryExpression(expression);
|
||||
IElementType opSign = expression.getOperationTokenType();
|
||||
if (opSign == JavaTokenType.EQEQ || opSign == JavaTokenType.NE) {
|
||||
@ -101,7 +103,7 @@ public class ComparingReferencesInspection extends BaseJavaLocalInspectionTool {
|
||||
|
||||
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
|
||||
try {
|
||||
PsiBinaryExpression binaryExpression = (PsiBinaryExpression)descriptor.getPsiElement();
|
||||
PsiBinaryExpression binaryExpression = (PsiBinaryExpression) descriptor.getPsiElement();
|
||||
IElementType opSign = binaryExpression.getOperationTokenType();
|
||||
PsiExpression lExpr = binaryExpression.getLOperand();
|
||||
PsiExpression rExpr = binaryExpression.getROperand();
|
||||
@ -109,20 +111,20 @@ public class ComparingReferencesInspection extends BaseJavaLocalInspectionTool {
|
||||
return;
|
||||
|
||||
PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory();
|
||||
PsiMethodCallExpression equalsCall = (PsiMethodCallExpression)factory.createExpressionFromText("a.equals(b)", null);
|
||||
PsiMethodCallExpression equalsCall =
|
||||
(PsiMethodCallExpression) factory.createExpressionFromText("a.equals(b)", null);
|
||||
|
||||
equalsCall.getMethodExpression().getQualifierExpression().replace(lExpr);
|
||||
equalsCall.getArgumentList().getExpressions()[0].replace(rExpr);
|
||||
|
||||
PsiExpression result = (PsiExpression)binaryExpression.replace(equalsCall);
|
||||
PsiExpression result = (PsiExpression) binaryExpression.replace(equalsCall);
|
||||
|
||||
if (opSign == JavaTokenType.NE) {
|
||||
PsiPrefixExpression negation = (PsiPrefixExpression)factory.createExpressionFromText("!a", null);
|
||||
PsiPrefixExpression negation = (PsiPrefixExpression) factory.createExpressionFromText("!a", null);
|
||||
negation.getOperand().replace(result);
|
||||
result.replace(negation);
|
||||
}
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
} catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,6 @@ package com.intellij.codeInspection;
|
||||
*/
|
||||
public class ComparingReferencesProvider implements InspectionToolProvider {
|
||||
public Class[] getInspectionClasses() {
|
||||
return new Class[] { ComparingReferencesInspection.class};
|
||||
return new Class[]{ComparingReferencesInspection.class};
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,8 @@ public class TestThisPlugin extends UsefulTestCase {
|
||||
public void setUp() throws Exception {
|
||||
|
||||
final IdeaTestFixtureFactory fixtureFactory = IdeaTestFixtureFactory.getFixtureFactory();
|
||||
final TestFixtureBuilder<IdeaProjectTestFixture> testFixtureBuilder = fixtureFactory.createFixtureBuilder(getName());
|
||||
final TestFixtureBuilder<IdeaProjectTestFixture> testFixtureBuilder =
|
||||
fixtureFactory.createFixtureBuilder(getName());
|
||||
myFixture = JavaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(testFixtureBuilder.getFixture());
|
||||
myFixture.setTestDataPath(dataPath);
|
||||
final JavaModuleFixtureBuilder builder = testFixtureBuilder.addModule(JavaModuleFixtureBuilder.class);
|
||||
|
@ -13,7 +13,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
/**
|
||||
* @author dsl
|
||||
*/
|
||||
@NonNls public class ConditionalOperatorConvertor extends PsiElementBaseIntentionAction implements IntentionAction {
|
||||
@NonNls
|
||||
public class ConditionalOperatorConvertor extends PsiElementBaseIntentionAction implements IntentionAction {
|
||||
|
||||
@NotNull
|
||||
public String getText() {
|
||||
@ -30,10 +31,10 @@ import org.jetbrains.annotations.Nullable;
|
||||
if (!element.isWritable()) return false;
|
||||
|
||||
if (element instanceof PsiJavaToken) {
|
||||
final PsiJavaToken token = (PsiJavaToken)element;
|
||||
final PsiJavaToken token = (PsiJavaToken) element;
|
||||
if (token.getTokenType() != JavaTokenType.QUEST) return false;
|
||||
if (token.getParent() instanceof PsiConditionalExpression) {
|
||||
final PsiConditionalExpression conditionalExpression = (PsiConditionalExpression)token.getParent();
|
||||
final PsiConditionalExpression conditionalExpression = (PsiConditionalExpression) token.getParent();
|
||||
if (conditionalExpression.getThenExpression() == null
|
||||
|| conditionalExpression.getElseExpression() == null) {
|
||||
return false;
|
||||
@ -63,12 +64,13 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
// Maintain declrations
|
||||
if (originalStatement instanceof PsiDeclarationStatement) {
|
||||
final PsiDeclarationStatement declaration = (PsiDeclarationStatement)originalStatement;
|
||||
final PsiDeclarationStatement declaration = (PsiDeclarationStatement) originalStatement;
|
||||
final PsiElement[] declaredElements = declaration.getDeclaredElements();
|
||||
PsiLocalVariable variable = null;
|
||||
for (PsiElement declaredElement : declaredElements) {
|
||||
if (declaredElement instanceof PsiLocalVariable && PsiTreeUtil.isAncestor(declaredElement, conditionalExpression, true)) {
|
||||
variable = (PsiLocalVariable)declaredElement;
|
||||
if (declaredElement instanceof PsiLocalVariable &&
|
||||
PsiTreeUtil.isAncestor(declaredElement, conditionalExpression, true)) {
|
||||
variable = (PsiLocalVariable) declaredElement;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -77,31 +79,31 @@ import org.jetbrains.annotations.Nullable;
|
||||
final Object marker = new Object();
|
||||
PsiTreeUtil.mark(conditionalExpression, marker);
|
||||
PsiExpressionStatement statement =
|
||||
(PsiExpressionStatement)factory.createStatementFromText(variable.getName() + " = 0;", null);
|
||||
statement = (PsiExpressionStatement)CodeStyleManager.getInstance(project).reformat(statement);
|
||||
((PsiAssignmentExpression)statement.getExpression()).getRExpression().replace(variable.getInitializer());
|
||||
(PsiExpressionStatement) factory.createStatementFromText(variable.getName() + " = 0;", null);
|
||||
statement = (PsiExpressionStatement) CodeStyleManager.getInstance(project).reformat(statement);
|
||||
((PsiAssignmentExpression) statement.getExpression()).getRExpression().replace(variable.getInitializer());
|
||||
variable.getInitializer().delete();
|
||||
final PsiElement variableParent = variable.getParent();
|
||||
originalStatement = variableParent.getParent().addAfter(statement, variableParent);
|
||||
conditionalExpression = (PsiConditionalExpression)PsiTreeUtil.releaseMark(originalStatement, marker);
|
||||
conditionalExpression = (PsiConditionalExpression) PsiTreeUtil.releaseMark(originalStatement, marker);
|
||||
}
|
||||
|
||||
// create then and else branches
|
||||
final PsiElement[] originalElements = new PsiElement[]{originalStatement, conditionalExpression};
|
||||
final PsiExpression condition = (PsiExpression)conditionalExpression.getCondition().copy();
|
||||
final PsiExpression condition = (PsiExpression) conditionalExpression.getCondition().copy();
|
||||
final PsiElement[] thenElements = PsiTreeUtil.copyElements(originalElements);
|
||||
final PsiElement[] elseElements = PsiTreeUtil.copyElements(originalElements);
|
||||
thenElements[1].replace(conditionalExpression.getThenExpression());
|
||||
elseElements[1].replace(conditionalExpression.getElseExpression());
|
||||
|
||||
PsiIfStatement statement = (PsiIfStatement)factory.createStatementFromText("if (true) { a = b } else { c = d }",
|
||||
PsiIfStatement statement = (PsiIfStatement) factory.createStatementFromText("if (true) { a = b } else { c = d }",
|
||||
null);
|
||||
statement = (PsiIfStatement)CodeStyleManager.getInstance(project).reformat(statement);
|
||||
statement = (PsiIfStatement) CodeStyleManager.getInstance(project).reformat(statement);
|
||||
statement.getCondition().replace(condition);
|
||||
statement = (PsiIfStatement)originalStatement.replace(statement);
|
||||
statement = (PsiIfStatement) originalStatement.replace(statement);
|
||||
|
||||
((PsiBlockStatement)statement.getThenBranch()).getCodeBlock().getStatements()[0].replace(thenElements[0]);
|
||||
((PsiBlockStatement)statement.getElseBranch()).getCodeBlock().getStatements()[0].replace(elseElements[0]);
|
||||
((PsiBlockStatement) statement.getThenBranch()).getCodeBlock().getStatements()[0].replace(thenElements[0]);
|
||||
((PsiBlockStatement) statement.getElseBranch()).getCodeBlock().getStatements()[0].replace(elseElements[0]);
|
||||
}
|
||||
|
||||
public boolean startInWriteAction() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
<html>
|
||||
<body>
|
||||
This intention converts a ternary operator to a corresponding if statement. <br>
|
||||
This intention converts a ternary operator to a corresponding if statement. <br>
|
||||
</body>
|
||||
</html>
|
@ -1,6 +1,6 @@
|
||||
public class X {
|
||||
void f(boolean isMale) {
|
||||
String title = isMale <caret>? "Mr." : "Ms.";
|
||||
String title = isMale < caret > ? "Mr." : "Ms.";
|
||||
System.out.println("title = " + title);
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package testPlugin;
|
||||
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
|
||||
import com.intellij.testFramework.builders.JavaModuleFixtureBuilder;
|
||||
import com.intellij.testFramework.fixtures.*;
|
||||
import junit.framework.Assert;
|
||||
@ -20,7 +19,8 @@ import org.junit.Test;
|
||||
public class YourTest {
|
||||
protected CodeInsightTestFixture myFixture;
|
||||
// Specify path to your test data
|
||||
// e.g. final String dataPath = "c:\\users\\john.doe\\idea\\community\\samples\\conditionalOperatorConvertor/testData";
|
||||
// e.g. final String dataPath = "c:\\users\\john
|
||||
// .doe\\idea\\community\\samples\\conditionalOperatorConvertor/testData";
|
||||
final String dataPath = "c:\\users\\John.Doe\\idea\\community\\samples\\conditionalOperatorConvertor/testData";
|
||||
|
||||
@Before
|
||||
|
@ -25,15 +25,21 @@
|
||||
</project-components>
|
||||
|
||||
<actions>
|
||||
<action id="EditorBasics.EditorIllustration" class="org.jetbrains.tutorials.editor.basics.EditorIllustration" text="Editor Basics"
|
||||
<action id="EditorBasics.EditorIllustration"
|
||||
class="org.jetbrains.tutorials.editor.basics.EditorIllustration"
|
||||
text="Editor Basics"
|
||||
description="Illustrates how to plug an action in">
|
||||
<add-to-group group-id="EditorPopupMenu" anchor="first"/>
|
||||
</action>
|
||||
<action id="EditorBasics.EditorHandlerIllustration" class="org.jetbrains.tutorials.editor.basics.EditorHandlerIllustration" text="Editor Handler"
|
||||
<action id="EditorBasics.EditorHandlerIllustration"
|
||||
class="org.jetbrains.tutorials.editor.basics.EditorHandlerIllustration"
|
||||
text="Editor Handler"
|
||||
description="Illustrates how to plug an action in">
|
||||
<add-to-group group-id="EditorPopupMenu" anchor="first"/>
|
||||
</action>
|
||||
<action id="EditorBasics.LogicalPositionIllustration" class="org.jetbrains.tutorials.editor.basics.EditorAreaIllustration" text="Caret Position"
|
||||
<action id="EditorBasics.LogicalPositionIllustration"
|
||||
class="org.jetbrains.tutorials.editor.basics.EditorAreaIllustration"
|
||||
text="Caret Position"
|
||||
description="Illustrates how editor area is organized">
|
||||
<add-to-group group-id="EditorPopupMenu" anchor="first"/>
|
||||
</action>
|
||||
|
@ -3,7 +3,10 @@ package org.jetbrains.tutorials.editor.basics;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.editor.*;
|
||||
import com.intellij.openapi.editor.CaretModel;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.LogicalPosition;
|
||||
import com.intellij.openapi.editor.VisualPosition;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
|
||||
|
@ -22,11 +22,13 @@ public class EditorHandlerIllustration extends AnAction {
|
||||
EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_CLONE_CARET_BELOW);
|
||||
actionHandler.execute(editor, editor.getCaretModel().getCurrentCaret(), anActionEvent.getDataContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(@NotNull final AnActionEvent anActionEvent) {
|
||||
//Set visible if at least one caret is available
|
||||
final Project project = anActionEvent.getData(CommonDataKeys.PROJECT);
|
||||
final Editor editor = anActionEvent.getData(CommonDataKeys.EDITOR);
|
||||
anActionEvent.getPresentation().setVisible((project != null && editor != null && !editor.getCaretModel().getAllCarets().isEmpty()));
|
||||
anActionEvent.getPresentation()
|
||||
.setVisible((project != null && editor != null && !editor.getCaretModel().getAllCarets().isEmpty()));
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ public class EditorIllustration extends AnAction {
|
||||
WriteCommandAction.runWriteCommandAction(project, runnable);
|
||||
selectionModel.removeSelection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(final AnActionEvent e) {
|
||||
//Get required data keys
|
||||
|
@ -10,7 +10,11 @@ import com.intellij.openapi.module.Module;
|
||||
public class DemoFacet extends Facet<DemoFacetConfiguration> {
|
||||
public static final String ID = "DEMO_FACET_ID";
|
||||
|
||||
public DemoFacet(FacetType facetType, Module module, String name, DemoFacetConfiguration configuration, Facet underlyingFacet) {
|
||||
public DemoFacet(FacetType facetType,
|
||||
Module module,
|
||||
String name,
|
||||
DemoFacetConfiguration configuration,
|
||||
Facet underlyingFacet) {
|
||||
super(facetType, module, name, configuration, underlyingFacet);
|
||||
}
|
||||
}
|
||||
|
@ -21,9 +21,10 @@ public class DemoFacetConfiguration implements FacetConfiguration {
|
||||
public static final String PATH_TO_SDK_ATTR_NAME = "pathToSdk";
|
||||
private String myPathToSdk = "";
|
||||
JTextField myPath = new JTextField(myPathToSdk);
|
||||
|
||||
@Override
|
||||
public FacetEditorTab[] createEditorTabs(FacetEditorContext context, FacetValidatorsManager manager) {
|
||||
return new FacetEditorTab[] {
|
||||
return new FacetEditorTab[]{
|
||||
new FacetEditorTab() {
|
||||
|
||||
@NotNull
|
||||
|
@ -16,6 +16,7 @@ import javax.swing.*;
|
||||
*/
|
||||
public class DemoFacetType extends FacetType<DemoFacet, DemoFacetConfiguration> {
|
||||
private static final FacetTypeId<DemoFacet> TYPE_ID = new FacetTypeId<DemoFacet>(DemoFacet.ID);
|
||||
|
||||
public DemoFacetType() {
|
||||
super(TYPE_ID, DemoFacet.ID, "Demo Facet");
|
||||
}
|
||||
@ -26,7 +27,10 @@ public class DemoFacetType extends FacetType<DemoFacet, DemoFacetConfiguration>
|
||||
}
|
||||
|
||||
@Override
|
||||
public DemoFacet createFacet(@NotNull Module module, String s, @NotNull DemoFacetConfiguration configuration, Facet facet) {
|
||||
public DemoFacet createFacet(@NotNull Module module,
|
||||
String s,
|
||||
@NotNull DemoFacetConfiguration configuration,
|
||||
Facet facet) {
|
||||
return new DemoFacet(this, module, s, configuration, facet);
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@ import javax.swing.*;
|
||||
*/
|
||||
public class DemoFramework extends FrameworkTypeEx {
|
||||
public static final String FRAMEWORK_ID = "Demo";
|
||||
|
||||
protected DemoFramework() {
|
||||
super(FRAMEWORK_ID);
|
||||
}
|
||||
@ -44,7 +45,9 @@ public class DemoFramework extends FrameworkTypeEx {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSupport(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ModifiableModelsProvider provider) {
|
||||
public void addSupport(@NotNull Module module,
|
||||
@NotNull ModifiableRootModel model,
|
||||
@NotNull ModifiableModelsProvider provider) {
|
||||
//do what you want here: setup a library, generate a specific file, etc
|
||||
}
|
||||
};
|
||||
|
@ -27,5 +27,5 @@ group 'org.jetbrains'
|
||||
version '0.0.1-SNAPSHOT'
|
||||
|
||||
repositories {
|
||||
mavenCentral ()
|
||||
mavenCentral()
|
||||
}
|
@ -33,8 +33,8 @@
|
||||
|
||||
<actions>
|
||||
<group id="MyPlugin.SampleMenu" text="Greeting" description="Greeting menu">
|
||||
<add-to-group group-id="MainMenu" anchor="last" />
|
||||
<action id="Myplugin.Textboxes" class="HelloAction" text="Hello" description="Says hello" />
|
||||
<add-to-group group-id="MainMenu" anchor="last"/>
|
||||
<action id="Myplugin.Textboxes" class="HelloAction" text="Hello" description="Says hello"/>
|
||||
</group>
|
||||
</actions>
|
||||
|
||||
|
@ -7,6 +7,6 @@ import com.intellij.codeInspection.InspectionToolProvider;
|
||||
*/
|
||||
public class DemoInspectionToolProvider implements InspectionToolProvider {
|
||||
public Class[] getInspectionClasses() {
|
||||
return new Class[] { DemoCodeInspection.class};
|
||||
return new Class[]{DemoCodeInspection.class};
|
||||
}
|
||||
}
|
||||
|
@ -30,8 +30,8 @@
|
||||
|
||||
<actions>
|
||||
<group id="MyPlugin.TestMeu" text="Greeting" description="Greeting menu">
|
||||
<add-to-group group-id="MainMenu" anchor="last" />
|
||||
<action id="Myplugin.Textboxes" class="HelloAction" text="Hello" description="Says hello" />
|
||||
<add-to-group group-id="MainMenu" anchor="last"/>
|
||||
<action id="Myplugin.Textboxes" class="HelloAction" text="Hello" description="Says hello"/>
|
||||
</group>
|
||||
</actions>
|
||||
|
||||
|
@ -1,9 +1,13 @@
|
||||
<templateSet group="Markdown">
|
||||
<template name="[" value="[$TEXT$]($LINK$)$END$" description="New link reference." toReformat="false" toShortenFQNames="false">
|
||||
<variable name="TEXT" expression="" defaultValue="" alwaysStopAt="true" />
|
||||
<variable name="LINK" expression="complete()" defaultValue="" alwaysStopAt="true" />
|
||||
<template name="["
|
||||
value="[$TEXT$]($LINK$)$END$"
|
||||
description="New link reference."
|
||||
toReformat="false"
|
||||
toShortenFQNames="false">
|
||||
<variable name="TEXT" expression="" defaultValue="" alwaysStopAt="true"/>
|
||||
<variable name="LINK" expression="complete()" defaultValue="" alwaysStopAt="true"/>
|
||||
<context>
|
||||
<option name="MARKDOWN" value="true" />
|
||||
<option name="MARKDOWN" value="true"/>
|
||||
</context>
|
||||
</template>
|
||||
</templateSet>
|
@ -1,9 +1,6 @@
|
||||
import com.intellij.codeInsight.template.EverywhereContextType;
|
||||
import com.intellij.codeInsight.template.TemplateContextType;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class MarkdownContext extends TemplateContextType {
|
||||
protected MarkdownContext() {
|
||||
|
@ -3,9 +3,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class MarkdownTemplateProvider implements DefaultLiveTemplatesProvider {
|
||||
@Override
|
||||
public String[] getDefaultLiveTemplateFiles()
|
||||
{
|
||||
return new String[] {"liveTemplates/Markdown"};
|
||||
public String[] getDefaultLiveTemplateFiles() {
|
||||
return new String[]{"liveTemplates/Markdown"};
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -36,11 +36,12 @@ public class MaxProject implements ProjectComponent {
|
||||
MyCounter CommandCounter = ServiceManager.getService(MyCounter.class);
|
||||
|
||||
if (CommandCounter.IncreaseCounter() == -1) {
|
||||
Messages.showMessageDialog("The maximum number of opened projects exceeds " + String.valueOf(CommandCounter.MaxCount) +
|
||||
Messages.showMessageDialog(
|
||||
"The maximum number of opened projects exceeds " + String.valueOf(CommandCounter.MaxCount) +
|
||||
" projects!", "Error", Messages.getErrorIcon());
|
||||
ProjectManager PM=ProjectManager.getInstance();
|
||||
ProjectManager PM = ProjectManager.getInstance();
|
||||
Project[] AllProjects = PM.getOpenProjects();
|
||||
Project project = AllProjects[AllProjects.length-1];
|
||||
Project project = AllProjects[AllProjects.length - 1];
|
||||
PM.closeProject(project);
|
||||
}
|
||||
}
|
||||
|
@ -11,19 +11,20 @@ public class MyCounter {
|
||||
private int Count = 0;
|
||||
// Sets the maximum allowed number of opened projects.
|
||||
public final int MaxCount = 3;
|
||||
public MyCounter(){
|
||||
|
||||
public MyCounter() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public int IncreaseCounter() {
|
||||
Count++;
|
||||
return (Count > MaxCount) ? -1:Count;
|
||||
return (Count > MaxCount) ? -1 : Count;
|
||||
}
|
||||
|
||||
public int DecreaseCounter() {
|
||||
Count--;
|
||||
return (Count > MaxCount) ? -1:Count;
|
||||
return (Count > MaxCount) ? -1 : Count;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -54,7 +54,9 @@ public class DemoModuleType extends ModuleType<DemoModuleBuilder> {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ModuleWizardStep[] createWizardSteps(@NotNull WizardContext wizardContext, @NotNull DemoModuleBuilder moduleBuilder, @NotNull ModulesProvider modulesProvider) {
|
||||
public ModuleWizardStep[] createWizardSteps(@NotNull WizardContext wizardContext,
|
||||
@NotNull DemoModuleBuilder moduleBuilder,
|
||||
@NotNull ModulesProvider modulesProvider) {
|
||||
return super.createWizardSteps(wizardContext, moduleBuilder, modulesProvider);
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,9 @@
|
||||
The optional "use-shortcut-of" attribute specifies the ID of the action whose keyboard shortcut this action will use.
|
||||
The optional "description" attribute specifies the text which is displayed in the status bar when the action is focused.
|
||||
The optional "icon" attribute specifies the icon which is displayed on the toolbar button or next to the menu item. -->
|
||||
<action id="PluginSample.DummyAction" class="org.jetbrains.tutorials.sample.actions.SimpleAction" text="Dummy Action"
|
||||
<action id="PluginSample.DummyAction"
|
||||
class="org.jetbrains.tutorials.sample.actions.SimpleAction"
|
||||
text="Dummy Action"
|
||||
description="Illustrates how to plug an action in">
|
||||
<!-- The <keyboard-shortcut> node specifies the keyboard shortcut for the action. An action can have several keyboard shortcuts.
|
||||
The mandatory "first-keystroke" attribute specifies the first keystroke of the action. The key strokes are specified according to the regular Swing rules.
|
||||
@ -107,7 +109,8 @@
|
||||
The optional "popup" attribute specifies how the group is presented in the menu. If a group has popup="true", actions in it
|
||||
are placed in a submenu; for popup="false", actions are displayed as a section of the same menu delimited by separators. -->
|
||||
<group id="DummyDefaultActionGroup" text="Default action group">
|
||||
<action class="org.jetbrains.tutorials.sample.actions.GroupedToDefaultAction" id="PluginSample.GroupedToDefaultAction"/>
|
||||
<action class="org.jetbrains.tutorials.sample.actions.GroupedToDefaultAction"
|
||||
id="PluginSample.GroupedToDefaultAction"/>
|
||||
</group>
|
||||
<group class="org.jetbrains.tutorials.sample.actions.DummyActionGroup" id="DummyActionGroup" text="Action Group"
|
||||
description="Illustration of an action group"
|
||||
@ -131,7 +134,7 @@
|
||||
<!--</extensionPoints>-->
|
||||
|
||||
<!-- Extensions which the plugin adds to extension points defined by the IDEA core or by other plugins. The "defaultExtensionNs " attribute must be set to the ID of the plugin defining the extension point,
|
||||
or to "com.intellij" if the extension point is defined by the IDEA core. The name of the
|
||||
or to "com.intellij" if the extension point is defined by the IDEA core. The name of the
|
||||
tag within the <extensions> tag matches the name of the extension point, and the "implementation" class specifies the name of the
|
||||
class added to the extension point. -->
|
||||
<extensions>
|
||||
|
@ -5,5 +5,5 @@ import com.intellij.openapi.components.ApplicationComponent;
|
||||
/**
|
||||
* @author Anna Bulenkova
|
||||
*/
|
||||
interface DummyApplicationComponent extends ApplicationComponent{
|
||||
interface DummyApplicationComponent extends ApplicationComponent {
|
||||
}
|
||||
|
@ -5,5 +5,5 @@ import com.intellij.openapi.module.ModuleComponent;
|
||||
/**
|
||||
* @author Anna Bulenkova
|
||||
*/
|
||||
public interface DummyModuleComponent extends ModuleComponent{
|
||||
public interface DummyModuleComponent extends ModuleComponent {
|
||||
}
|
||||
|
@ -5,5 +5,5 @@ import com.intellij.openapi.components.ProjectComponent;
|
||||
/**
|
||||
* @author Anna Bulenkova
|
||||
*/
|
||||
public interface DummyProjectComponent extends ProjectComponent{
|
||||
public interface DummyProjectComponent extends ProjectComponent {
|
||||
}
|
||||
|
@ -56,7 +56,8 @@ public class LibrariesAction extends AnAction {
|
||||
}
|
||||
}
|
||||
if (jars.length() > 0) {
|
||||
Messages.showInfoMessage("Libraries for file " + virtualFile.getName() + ": " + jars.toString(), "Libraries Info");
|
||||
Messages.showInfoMessage("Libraries for file " + virtualFile.getName() + ": " + jars.toString(),
|
||||
"Libraries Info");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,8 @@ public class ShowSourceRootsActions extends AnAction {
|
||||
for (VirtualFile file : vFiles) {
|
||||
sourceRootsList.append(file.getUrl()).append("\n");
|
||||
}
|
||||
Messages.showInfoMessage("Source roots for the " + projectName + " plugin:\n" + sourceRootsList, "Project Properties");
|
||||
Messages.showInfoMessage("Source roots for the " + projectName + " plugin:\n" + sourceRootsList,
|
||||
"Project Properties");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -158,7 +158,9 @@ public class ImagesProjectNode extends AbstractTreeNode<VirtualFile> {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ProjectView.getInstance(myProject).getProjectViewPaneById(ImagesProjectViewPane.ID).updateFromRoot(true);
|
||||
ProjectView.getInstance(myProject)
|
||||
.getProjectViewPaneById(ImagesProjectViewPane.ID)
|
||||
.updateFromRoot(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -14,7 +14,9 @@
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<!-- Add your extensions here -->
|
||||
<moduleBuilder builderClass="org.jetbrains.tutorials.project.wizard.DemoModuleWizardStep" id="DEMO_STEP" order="first"/>
|
||||
<moduleBuilder builderClass="org.jetbrains.tutorials.project.wizard.DemoModuleWizardStep"
|
||||
id="DEMO_STEP"
|
||||
order="first"/>
|
||||
</extensions>
|
||||
|
||||
<application-components>
|
||||
|
@ -24,7 +24,8 @@ public class DemoModuleWizardStep extends ModuleBuilder {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModuleWizardStep[] createWizardSteps(@NotNull WizardContext wizardContext, @NotNull ModulesProvider modulesProvider) {
|
||||
public ModuleWizardStep[] createWizardSteps(@NotNull WizardContext wizardContext,
|
||||
@NotNull ModulesProvider modulesProvider) {
|
||||
return new ModuleWizardStep[]{new ModuleWizardStep() {
|
||||
@Override
|
||||
public JComponent getComponent() {
|
||||
|
@ -14,10 +14,12 @@ public class BaseActionGroup extends ActionGroup {
|
||||
public AnAction[] getChildren(AnActionEvent anActionEvent) {
|
||||
return new AnAction[]{new MyAction()};
|
||||
}
|
||||
|
||||
class MyAction extends AnAction {
|
||||
public MyAction() {
|
||||
super("Dynamically Added Action");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(@NotNull AnActionEvent anActionEvent) {
|
||||
//does nothing
|
||||
|
@ -30,7 +30,8 @@ public class DemoRunConfiguration extends RunConfigurationBase {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment executionEnvironment) throws ExecutionException {
|
||||
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment executionEnvironment) throws
|
||||
ExecutionException {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
// This is a generated file. Not intended for manual editing.
|
||||
package com.simpleplugin.parser;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.LightPsiParser;
|
||||
import com.intellij.lang.PsiBuilder;
|
||||
import com.intellij.lang.PsiBuilder.Marker;
|
||||
import static com.simpleplugin.psi.SimpleTypes.*;
|
||||
import static com.intellij.lang.parser.GeneratedParserUtilBase.*;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.lang.PsiParser;
|
||||
import com.intellij.lang.LightPsiParser;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
|
||||
import static com.intellij.lang.parser.GeneratedParserUtilBase.*;
|
||||
import static com.simpleplugin.psi.SimpleTypes.*;
|
||||
|
||||
@SuppressWarnings({"SimplifiableIfStatement", "UnusedAssignment"})
|
||||
public class SimpleParser implements PsiParser, LightPsiParser {
|
||||
@ -25,8 +25,7 @@ public class SimpleParser implements PsiParser, LightPsiParser {
|
||||
Marker m = enter_section_(b, 0, _COLLAPSE_, null);
|
||||
if (t == PROPERTY) {
|
||||
r = property(b, 0);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
r = parse_root_(t, b, 0);
|
||||
}
|
||||
exit_section_(b, 0, m, t, r, true, TRUE_CONDITION);
|
||||
|
@ -1,10 +1,8 @@
|
||||
// This is a generated file. Not intended for manual editing.
|
||||
package com.simpleplugin.psi;
|
||||
|
||||
import java.util.List;
|
||||
import org.jetbrains.annotations.*;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import com.intellij.psi.PsiElement;
|
||||
|
||||
public interface SimpleProperty extends SimpleNamedElement {
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
// This is a generated file. Not intended for manual editing.
|
||||
package com.simpleplugin.psi;
|
||||
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.simpleplugin.psi.impl.*;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.simpleplugin.psi.impl.SimplePropertyImpl;
|
||||
|
||||
public interface SimpleTypes {
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
// This is a generated file. Not intended for manual editing.
|
||||
package com.simpleplugin.psi;
|
||||
|
||||
import org.jetbrains.annotations.*;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SimpleVisitor extends PsiElementVisitor {
|
||||
|
||||
|
@ -1,15 +1,13 @@
|
||||
// This is a generated file. Not intended for manual editing.
|
||||
package com.simpleplugin.psi.impl;
|
||||
|
||||
import java.util.List;
|
||||
import org.jetbrains.annotations.*;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import static com.simpleplugin.psi.SimpleTypes.*;
|
||||
import com.simpleplugin.psi.*;
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import com.simpleplugin.psi.SimpleProperty;
|
||||
import com.simpleplugin.psi.SimpleVisitor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SimplePropertyImpl extends SimpleNamedElementImpl implements SimpleProperty {
|
||||
|
||||
@ -18,7 +16,7 @@ public class SimplePropertyImpl extends SimpleNamedElementImpl implements Simple
|
||||
}
|
||||
|
||||
public void accept(@NotNull PsiElementVisitor visitor) {
|
||||
if (visitor instanceof SimpleVisitor) ((SimpleVisitor)visitor).visitProperty(this);
|
||||
if (visitor instanceof SimpleVisitor) ((SimpleVisitor) visitor).visitProperty(this);
|
||||
else super.accept(visitor);
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,9 @@
|
||||
<!-- Add your extensions here -->
|
||||
<fileTypeFactory implementation="com.simpleplugin.SimpleFileTypeFactory"/>
|
||||
<lang.parserDefinition language="Simple" implementationClass="com.simpleplugin.SimpleParserDefinition"/>
|
||||
<lang.syntaxHighlighterFactory key="Simple" language="Simple" implementationClass="com.simpleplugin.SimpleSyntaxHighlighterFactory"/>
|
||||
<lang.syntaxHighlighterFactory key="Simple"
|
||||
language="Simple"
|
||||
implementationClass="com.simpleplugin.SimpleSyntaxHighlighterFactory"/>
|
||||
<colorSettingsPage implementation="com.simpleplugin.SimpleColorSettingsPage"/>
|
||||
<annotator language="JAVA" implementationClass="com.simpleplugin.SimpleAnnotator"/>
|
||||
<codeInsight.lineMarkerProvider language="JAVA" implementationClass="com.simpleplugin.SimpleLineMarkerProvider"/>
|
||||
|
@ -4,7 +4,7 @@ import com.intellij.codeInsight.intention.impl.BaseIntentionAction;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.editor.*;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.fileChooser.FileChooser;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
|
||||
@ -51,16 +51,19 @@ class CreatePropertyQuickFix extends BaseIntentionAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull final Project project, final Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||
public void invoke(@NotNull final Project project, final Editor editor, PsiFile file) throws
|
||||
IncorrectOperationException {
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, SimpleFileType.INSTANCE,
|
||||
Collection<VirtualFile> virtualFiles =
|
||||
FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, SimpleFileType.INSTANCE,
|
||||
GlobalSearchScope.allScope(project));
|
||||
if (virtualFiles.size() == 1) {
|
||||
createProperty(project, virtualFiles.iterator().next());
|
||||
} else {
|
||||
final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileDescriptor(SimpleFileType.INSTANCE);
|
||||
final FileChooserDescriptor descriptor =
|
||||
FileChooserDescriptorFactory.createSingleFileDescriptor(SimpleFileType.INSTANCE);
|
||||
descriptor.setRoots(project.getBaseDir());
|
||||
final VirtualFile file = FileChooser.chooseFile(descriptor, project, null);
|
||||
if (file != null) {
|
||||
|
@ -18,9 +18,9 @@ public class SimpleAnnotator implements Annotator {
|
||||
public void annotate(@NotNull final PsiElement element, @NotNull AnnotationHolder holder) {
|
||||
if (element instanceof PsiLiteralExpression) {
|
||||
PsiLiteralExpression literalExpression = (PsiLiteralExpression) element;
|
||||
String value = literalExpression.getValue() instanceof String ? (String)literalExpression.getValue() : null;
|
||||
String value = literalExpression.getValue() instanceof String ? (String) literalExpression.getValue() : null;
|
||||
|
||||
if (value != null && value.startsWith("simple"+":")) {
|
||||
if (value != null && value.startsWith("simple" + ":")) {
|
||||
Project project = element.getProject();
|
||||
String key = value.substring(7);
|
||||
List<SimpleProperty> properties = SimpleUtil.findProperties(project, key);
|
||||
|
@ -4,7 +4,7 @@ import com.intellij.openapi.fileTypes.FileTypeConsumer;
|
||||
import com.intellij.openapi.fileTypes.FileTypeFactory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SimpleFileTypeFactory extends FileTypeFactory{
|
||||
public class SimpleFileTypeFactory extends FileTypeFactory {
|
||||
@Override
|
||||
public void createFileTypes(@NotNull FileTypeConsumer fileTypeConsumer) {
|
||||
fileTypeConsumer.consume(SimpleFileType.INSTANCE, "simple");
|
||||
|
@ -16,7 +16,9 @@ public class SimpleFindUsagesProvider implements FindUsagesProvider {
|
||||
@Override
|
||||
public WordsScanner getWordsScanner() {
|
||||
return new DefaultWordsScanner(new SimpleLexerAdapter(),
|
||||
TokenSet.create(SimpleTypes.KEY), TokenSet.create(SimpleTypes.COMMENT), TokenSet.EMPTY);
|
||||
TokenSet.create(SimpleTypes.KEY),
|
||||
TokenSet.create(SimpleTypes.COMMENT),
|
||||
TokenSet.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -25,9 +25,10 @@ public class SimpleFoldingBuilder extends FoldingBuilderEx {
|
||||
FoldingGroup group = FoldingGroup.newGroup("simple");
|
||||
|
||||
List<FoldingDescriptor> descriptors = new ArrayList<FoldingDescriptor>();
|
||||
Collection<PsiLiteralExpression> literalExpressions = PsiTreeUtil.findChildrenOfType(root, PsiLiteralExpression.class);
|
||||
Collection<PsiLiteralExpression> literalExpressions =
|
||||
PsiTreeUtil.findChildrenOfType(root, PsiLiteralExpression.class);
|
||||
for (final PsiLiteralExpression literalExpression : literalExpressions) {
|
||||
String value = literalExpression.getValue() instanceof String ? (String)literalExpression.getValue() : null;
|
||||
String value = literalExpression.getValue() instanceof String ? (String) literalExpression.getValue() : null;
|
||||
|
||||
if (value != null && value.startsWith("simple:")) {
|
||||
Project project = literalExpression.getProject();
|
||||
@ -36,14 +37,16 @@ public class SimpleFoldingBuilder extends FoldingBuilderEx {
|
||||
if (properties.size() == 1) {
|
||||
descriptors.add(new FoldingDescriptor(literalExpression.getNode(),
|
||||
new TextRange(literalExpression.getTextRange().getStartOffset() + 1,
|
||||
literalExpression.getTextRange().getEndOffset() - 1), group) {
|
||||
literalExpression.getTextRange().getEndOffset() - 1),
|
||||
group) {
|
||||
@Nullable
|
||||
@Override
|
||||
public String getPlaceholderText() {
|
||||
// IMPORTANT: keys can come with no values, so a test for null is needed
|
||||
// IMPORTANT: Convert embedded \n to backslash n, so that the string will look like it has LF embedded in it and embedded " to escaped "
|
||||
// IMPORTANT: Convert embedded \n to backslash n, so that the string will look like it has LF embedded
|
||||
// in it and embedded " to escaped "
|
||||
String valueOf = properties.get(0).getValue();
|
||||
return valueOf == null ? "" : valueOf.replaceAll("\n","\\n").replaceAll("\"","\\\\\"");
|
||||
return valueOf == null ? "" : valueOf.replaceAll("\n", "\\n").replaceAll("\"", "\\\\\"");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -15,14 +15,21 @@ public class SimpleFormattingModelBuilder implements FormattingModelBuilder {
|
||||
@Override
|
||||
public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) {
|
||||
return FormattingModelProvider.createFormattingModelForPsiFile(element.getContainingFile(),
|
||||
new SimpleBlock(element.getNode(), Wrap.createWrap(WrapType.NONE, false),
|
||||
Alignment.createAlignment(), createSpaceBuilder(settings)), settings);
|
||||
new SimpleBlock(element.getNode(),
|
||||
Wrap.createWrap(WrapType.NONE,
|
||||
false),
|
||||
Alignment.createAlignment(),
|
||||
createSpaceBuilder(settings)),
|
||||
settings);
|
||||
}
|
||||
|
||||
private static SpacingBuilder createSpaceBuilder(CodeStyleSettings settings) {
|
||||
return new SpacingBuilder(settings, SimpleLanguage.INSTANCE).
|
||||
around(SimpleTypes.SEPARATOR).spaceIf(settings.SPACE_AROUND_ASSIGNMENT_OPERATORS).
|
||||
before(SimpleTypes.PROPERTY).none();
|
||||
around(SimpleTypes.SEPARATOR)
|
||||
.spaceIf(settings.SPACE_AROUND_ASSIGNMENT_OPERATORS)
|
||||
.
|
||||
before(SimpleTypes.PROPERTY)
|
||||
.none();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -3,9 +3,9 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.lexer.FlexLexer;
|
||||
import com.intellij.psi.TokenType;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.simpleplugin.psi.SimpleTypes;
|
||||
import com.intellij.psi.TokenType;
|
||||
|
||||
|
||||
/**
|
||||
@ -15,10 +15,14 @@ import com.intellij.psi.TokenType;
|
||||
* <tt>/Users/vlad/src/SimplePlugin/src/com/simpleplugin/Simple.flex</tt>
|
||||
*/
|
||||
class SimpleLexer implements FlexLexer {
|
||||
/** initial size of the lookahead buffer */
|
||||
/**
|
||||
* initial size of the lookahead buffer
|
||||
*/
|
||||
private static final int ZZ_BUFFERSIZE = 16384;
|
||||
|
||||
/** lexical states */
|
||||
/**
|
||||
* lexical states
|
||||
*/
|
||||
public static final int WAITING_VALUE = 2;
|
||||
public static final int YYINITIAL = 0;
|
||||
|
||||
@ -36,31 +40,31 @@ class SimpleLexer implements FlexLexer {
|
||||
* Translates characters to character classes
|
||||
*/
|
||||
private static final String ZZ_CMAP_PACKED =
|
||||
"\11\0\1\3\1\1\1\0\1\6\1\2\22\0\1\5\1\7\1\0"+
|
||||
"\11\0\1\3\1\1\1\0\1\6\1\2\22\0\1\5\1\7\1\0" +
|
||||
"\1\7\26\0\1\10\2\0\1\10\36\0\1\4\uffa3\0";
|
||||
|
||||
/**
|
||||
* Translates characters to character classes
|
||||
*/
|
||||
private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
|
||||
private static final char[] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
|
||||
|
||||
/**
|
||||
* Translates DFA states to action switch labels.
|
||||
*/
|
||||
private static final int [] ZZ_ACTION = zzUnpackAction();
|
||||
private static final int[] ZZ_ACTION = zzUnpackAction();
|
||||
|
||||
private static final String ZZ_ACTION_PACKED_0 =
|
||||
"\2\0\1\1\1\2\1\3\1\4\1\5\1\6\1\7"+
|
||||
"\2\0\1\1\1\2\1\3\1\4\1\5\1\6\1\7" +
|
||||
"\1\3\1\7\2\0\1\6";
|
||||
|
||||
private static int [] zzUnpackAction() {
|
||||
int [] result = new int[14];
|
||||
private static int[] zzUnpackAction() {
|
||||
int[] result = new int[14];
|
||||
int offset = 0;
|
||||
offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static int zzUnpackAction(String packed, int offset, int [] result) {
|
||||
private static int zzUnpackAction(String packed, int offset, int[] result) {
|
||||
int i = 0; /* index in packed string */
|
||||
int j = offset; /* index in unpacked array */
|
||||
int l = packed.length();
|
||||
@ -76,20 +80,20 @@ class SimpleLexer implements FlexLexer {
|
||||
/**
|
||||
* Translates a state to a row index in the transition table
|
||||
*/
|
||||
private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
|
||||
private static final int[] ZZ_ROWMAP = zzUnpackRowMap();
|
||||
|
||||
private static final String ZZ_ROWMAP_PACKED_0 =
|
||||
"\0\0\0\11\0\22\0\33\0\44\0\55\0\66\0\77"+
|
||||
"\0\0\0\11\0\22\0\33\0\44\0\55\0\66\0\77" +
|
||||
"\0\110\0\121\0\132\0\44\0\121\0\143";
|
||||
|
||||
private static int [] zzUnpackRowMap() {
|
||||
int [] result = new int[14];
|
||||
private static int[] zzUnpackRowMap() {
|
||||
int[] result = new int[14];
|
||||
int offset = 0;
|
||||
offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static int zzUnpackRowMap(String packed, int offset, int [] result) {
|
||||
private static int zzUnpackRowMap(String packed, int offset, int[] result) {
|
||||
int i = 0; /* index in packed string */
|
||||
int j = offset; /* index in unpacked array */
|
||||
int l = packed.length();
|
||||
@ -103,25 +107,25 @@ class SimpleLexer implements FlexLexer {
|
||||
/**
|
||||
* The transition table of the DFA
|
||||
*/
|
||||
private static final int [] ZZ_TRANS = zzUnpackTrans();
|
||||
private static final int[] ZZ_TRANS = zzUnpackTrans();
|
||||
|
||||
private static final String ZZ_TRANS_PACKED_0 =
|
||||
"\1\3\3\4\1\5\2\4\1\6\1\7\1\10\2\4"+
|
||||
"\1\11\1\12\2\13\2\10\1\3\3\0\1\14\2\0"+
|
||||
"\1\3\2\0\3\4\1\0\2\4\7\0\1\3\3\0"+
|
||||
"\1\6\2\0\6\6\11\0\1\10\2\0\1\10\1\15"+
|
||||
"\1\10\1\0\3\10\2\4\1\11\1\15\1\11\1\13"+
|
||||
"\4\10\1\16\6\10\1\0\2\4\1\13\1\0\2\13"+
|
||||
"\1\3\3\4\1\5\2\4\1\6\1\7\1\10\2\4" +
|
||||
"\1\11\1\12\2\13\2\10\1\3\3\0\1\14\2\0" +
|
||||
"\1\3\2\0\3\4\1\0\2\4\7\0\1\3\3\0" +
|
||||
"\1\6\2\0\6\6\11\0\1\10\2\0\1\10\1\15" +
|
||||
"\1\10\1\0\3\10\2\4\1\11\1\15\1\11\1\13" +
|
||||
"\4\10\1\16\6\10\1\0\2\4\1\13\1\0\2\13" +
|
||||
"\2\0\2\10\1\0\1\10\1\15\1\10\1\0\2\10";
|
||||
|
||||
private static int [] zzUnpackTrans() {
|
||||
int [] result = new int[108];
|
||||
private static int[] zzUnpackTrans() {
|
||||
int[] result = new int[108];
|
||||
int offset = 0;
|
||||
offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static int zzUnpackTrans(String packed, int offset, int [] result) {
|
||||
private static int zzUnpackTrans(String packed, int offset, int[] result) {
|
||||
int i = 0; /* index in packed string */
|
||||
int j = offset; /* index in unpacked array */
|
||||
int l = packed.length();
|
||||
@ -153,19 +157,19 @@ class SimpleLexer implements FlexLexer {
|
||||
/**
|
||||
* ZZ_ATTRIBUTE[aState] contains the attributes of state <code>aState</code>
|
||||
*/
|
||||
private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
|
||||
private static final int[] ZZ_ATTRIBUTE = zzUnpackAttribute();
|
||||
|
||||
private static final String ZZ_ATTRIBUTE_PACKED_0 =
|
||||
"\2\0\4\1\1\11\4\1\2\0\1\1";
|
||||
|
||||
private static int [] zzUnpackAttribute() {
|
||||
int [] result = new int[14];
|
||||
private static int[] zzUnpackAttribute() {
|
||||
int[] result = new int[14];
|
||||
int offset = 0;
|
||||
offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static int zzUnpackAttribute(String packed, int offset, int [] result) {
|
||||
private static int zzUnpackAttribute(String packed, int offset, int[] result) {
|
||||
int i = 0; /* index in packed string */
|
||||
int j = offset; /* index in unpacked array */
|
||||
int l = packed.length();
|
||||
@ -177,33 +181,51 @@ class SimpleLexer implements FlexLexer {
|
||||
return j;
|
||||
}
|
||||
|
||||
/** the current state of the DFA */
|
||||
/**
|
||||
* the current state of the DFA
|
||||
*/
|
||||
private int zzState;
|
||||
|
||||
/** the current lexical state */
|
||||
/**
|
||||
* the current lexical state
|
||||
*/
|
||||
private int zzLexicalState = YYINITIAL;
|
||||
|
||||
/** this buffer contains the current text to be matched and is
|
||||
the source of the yytext() string */
|
||||
/**
|
||||
* this buffer contains the current text to be matched and is
|
||||
* the source of the yytext() string
|
||||
*/
|
||||
private CharSequence zzBuffer = "";
|
||||
|
||||
/** this buffer may contains the current text array to be matched when it is cheap to acquire it */
|
||||
/**
|
||||
* this buffer may contains the current text array to be matched when it is cheap to acquire it
|
||||
*/
|
||||
private char[] zzBufferArray;
|
||||
|
||||
/** the textposition at the last accepting state */
|
||||
/**
|
||||
* the textposition at the last accepting state
|
||||
*/
|
||||
private int zzMarkedPos;
|
||||
|
||||
/** the textposition at the last state to be included in yytext */
|
||||
/**
|
||||
* the textposition at the last state to be included in yytext
|
||||
*/
|
||||
private int zzPushbackPos;
|
||||
|
||||
/** the current text position in the buffer */
|
||||
/**
|
||||
* the current text position in the buffer
|
||||
*/
|
||||
private int zzCurrentPos;
|
||||
|
||||
/** startRead marks the beginning of the yytext() string in the buffer */
|
||||
/**
|
||||
* startRead marks the beginning of the yytext() string in the buffer
|
||||
*/
|
||||
private int zzStartRead;
|
||||
|
||||
/** endRead marks the last character in the buffer, that has been read
|
||||
from input */
|
||||
/**
|
||||
* endRead marks the last character in the buffer, that has been read
|
||||
* from input
|
||||
*/
|
||||
private int zzEndRead;
|
||||
|
||||
/**
|
||||
@ -211,10 +233,14 @@ class SimpleLexer implements FlexLexer {
|
||||
*/
|
||||
private boolean zzAtBOL = true;
|
||||
|
||||
/** zzAtEOF == true <=> the scanner is at the EOF */
|
||||
/**
|
||||
* zzAtEOF == true <=> the scanner is at the EOF
|
||||
*/
|
||||
private boolean zzAtEOF;
|
||||
|
||||
/** denotes if the user-EOF-code has already been executed */
|
||||
/**
|
||||
* denotes if the user-EOF-code has already been executed
|
||||
*/
|
||||
private boolean zzEOFDone;
|
||||
|
||||
|
||||
@ -238,8 +264,8 @@ class SimpleLexer implements FlexLexer {
|
||||
* @param packed the packed character translation table
|
||||
* @return the unpacked character translation table
|
||||
*/
|
||||
private static char [] zzUnpackCMap(String packed) {
|
||||
char [] map = new char[0x10000];
|
||||
private static char[] zzUnpackCMap(String packed) {
|
||||
char[] map = new char[0x10000];
|
||||
int i = 0; /* index in packed string */
|
||||
int j = 0; /* index in unpacked array */
|
||||
while (i < 36) {
|
||||
@ -250,15 +276,15 @@ class SimpleLexer implements FlexLexer {
|
||||
return map;
|
||||
}
|
||||
|
||||
public final int getTokenStart(){
|
||||
public final int getTokenStart() {
|
||||
return zzStartRead;
|
||||
}
|
||||
|
||||
public final int getTokenEnd(){
|
||||
public final int getTokenEnd() {
|
||||
return getTokenStart() + yylength();
|
||||
}
|
||||
|
||||
public void reset(CharSequence buffer, int start, int end,int initialState){
|
||||
public void reset(CharSequence buffer, int start, int end, int initialState) {
|
||||
zzBuffer = buffer;
|
||||
zzBufferArray = com.intellij.util.text.CharArrayUtil.fromSequenceWithoutCopying(buffer);
|
||||
zzCurrentPos = zzMarkedPos = zzStartRead = start;
|
||||
@ -273,8 +299,7 @@ class SimpleLexer implements FlexLexer {
|
||||
* Refills the input buffer.
|
||||
*
|
||||
* @return <code>false</code>, iff there was new input.
|
||||
*
|
||||
* @exception java.io.IOException if any I/O-Error occurs
|
||||
* @throws java.io.IOException if any I/O-Error occurs
|
||||
*/
|
||||
private boolean zzRefill() throws java.io.IOException {
|
||||
return true;
|
||||
@ -310,16 +335,15 @@ class SimpleLexer implements FlexLexer {
|
||||
/**
|
||||
* Returns the character at position <tt>pos</tt> from the
|
||||
* matched text.
|
||||
*
|
||||
* <p>
|
||||
* It is equivalent to yytext().charAt(pos), but faster
|
||||
*
|
||||
* @param pos the position of the character to fetch.
|
||||
* A value from 0 to yylength()-1.
|
||||
*
|
||||
* @return the character at position pos
|
||||
*/
|
||||
public final char yycharat(int pos) {
|
||||
return zzBufferArray != null ? zzBufferArray[zzStartRead+pos]:zzBuffer.charAt(zzStartRead+pos);
|
||||
return zzBufferArray != null ? zzBufferArray[zzStartRead + pos] : zzBuffer.charAt(zzStartRead + pos);
|
||||
}
|
||||
|
||||
|
||||
@ -327,19 +351,19 @@ class SimpleLexer implements FlexLexer {
|
||||
* Returns the length of the matched text region.
|
||||
*/
|
||||
public final int yylength() {
|
||||
return zzMarkedPos-zzStartRead;
|
||||
return zzMarkedPos - zzStartRead;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reports an error that occured while scanning.
|
||||
*
|
||||
* <p>
|
||||
* In a wellformed scanner (no or only correct usage of
|
||||
* yypushback(int) and a match-all fallback rule) this method
|
||||
* will only be called with things that "Can't Possibly Happen".
|
||||
* If this method is called, something is seriously wrong
|
||||
* (e.g. a JFlex bug producing a faulty scanner etc.).
|
||||
*
|
||||
* <p>
|
||||
* Usual syntax/scanner level error handling should be done
|
||||
* in error fallback rules.
|
||||
*
|
||||
@ -349,8 +373,7 @@ class SimpleLexer implements FlexLexer {
|
||||
String message;
|
||||
try {
|
||||
message = ZZ_ERROR_MSG[errorCode];
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException e) {
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
|
||||
}
|
||||
|
||||
@ -360,14 +383,14 @@ class SimpleLexer implements FlexLexer {
|
||||
|
||||
/**
|
||||
* Pushes the specified amount of characters back into the input stream.
|
||||
*
|
||||
* <p>
|
||||
* They will be read again by then next call of the scanning method
|
||||
*
|
||||
* @param number the number of characters to be read again.
|
||||
* This number must not be greater than yylength()!
|
||||
*/
|
||||
public void yypushback(int number) {
|
||||
if ( number > yylength() )
|
||||
if (number > yylength())
|
||||
zzScanError(ZZ_PUSHBACK_2BIG);
|
||||
|
||||
zzMarkedPos -= number;
|
||||
@ -391,7 +414,7 @@ class SimpleLexer implements FlexLexer {
|
||||
* the end of input is encountered or an I/O-Error occurs.
|
||||
*
|
||||
* @return the next token
|
||||
* @exception java.io.IOException if any I/O-Error occurs
|
||||
* @throws java.io.IOException if any I/O-Error occurs
|
||||
*/
|
||||
public IElementType advance() throws java.io.IOException {
|
||||
int zzInput;
|
||||
@ -403,11 +426,11 @@ class SimpleLexer implements FlexLexer {
|
||||
int zzEndReadL = zzEndRead;
|
||||
CharSequence zzBufferL = zzBuffer;
|
||||
char[] zzBufferArrayL = zzBufferArray;
|
||||
char [] zzCMapL = ZZ_CMAP;
|
||||
char[] zzCMapL = ZZ_CMAP;
|
||||
|
||||
int [] zzTransL = ZZ_TRANS;
|
||||
int [] zzRowMapL = ZZ_ROWMAP;
|
||||
int [] zzAttrL = ZZ_ATTRIBUTE;
|
||||
int[] zzTransL = ZZ_TRANS;
|
||||
int[] zzRowMapL = ZZ_ROWMAP;
|
||||
int[] zzAttrL = ZZ_ATTRIBUTE;
|
||||
|
||||
while (true) {
|
||||
zzMarkedPosL = zzMarkedPos;
|
||||
@ -419,7 +442,8 @@ class SimpleLexer implements FlexLexer {
|
||||
zzState = ZZ_LEXSTATE[zzLexicalState];
|
||||
|
||||
|
||||
zzForAction: {
|
||||
zzForAction:
|
||||
{
|
||||
while (true) {
|
||||
|
||||
if (zzCurrentPosL < zzEndReadL)
|
||||
@ -427,8 +451,7 @@ class SimpleLexer implements FlexLexer {
|
||||
else if (zzAtEOF) {
|
||||
zzInput = YYEOF;
|
||||
break zzForAction;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// store back cached positions
|
||||
zzCurrentPos = zzCurrentPosL;
|
||||
zzMarkedPos = zzMarkedPosL;
|
||||
@ -441,20 +464,19 @@ class SimpleLexer implements FlexLexer {
|
||||
if (eof) {
|
||||
zzInput = YYEOF;
|
||||
break zzForAction;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
zzInput = (zzBufferArrayL != null ? zzBufferArrayL[zzCurrentPosL++] : zzBufferL.charAt(zzCurrentPosL++));
|
||||
}
|
||||
}
|
||||
int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ];
|
||||
int zzNext = zzTransL[zzRowMapL[zzState] + zzCMapL[zzInput]];
|
||||
if (zzNext == -1) break zzForAction;
|
||||
zzState = zzNext;
|
||||
|
||||
int zzAttributes = zzAttrL[zzState];
|
||||
if ( (zzAttributes & 1) == 1 ) {
|
||||
if ((zzAttributes & 1) == 1) {
|
||||
zzAction = zzState;
|
||||
zzMarkedPosL = zzCurrentPosL;
|
||||
if ( (zzAttributes & 8) == 8 ) break zzForAction;
|
||||
if ((zzAttributes & 8) == 8) break zzForAction;
|
||||
}
|
||||
|
||||
}
|
||||
@ -464,41 +486,53 @@ class SimpleLexer implements FlexLexer {
|
||||
zzMarkedPos = zzMarkedPosL;
|
||||
|
||||
switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
|
||||
case 6:
|
||||
{ yybegin(YYINITIAL); return SimpleTypes.VALUE;
|
||||
case 6: {
|
||||
yybegin(YYINITIAL);
|
||||
return SimpleTypes.VALUE;
|
||||
}
|
||||
case 8: break;
|
||||
case 5:
|
||||
{ yybegin(WAITING_VALUE); return SimpleTypes.SEPARATOR;
|
||||
case 8:
|
||||
break;
|
||||
case 5: {
|
||||
yybegin(WAITING_VALUE);
|
||||
return SimpleTypes.SEPARATOR;
|
||||
}
|
||||
case 9: break;
|
||||
case 4:
|
||||
{ yybegin(YYINITIAL); return SimpleTypes.COMMENT;
|
||||
case 9:
|
||||
break;
|
||||
case 4: {
|
||||
yybegin(YYINITIAL);
|
||||
return SimpleTypes.COMMENT;
|
||||
}
|
||||
case 10: break;
|
||||
case 3:
|
||||
{ return TokenType.BAD_CHARACTER;
|
||||
case 10:
|
||||
break;
|
||||
case 3: {
|
||||
return TokenType.BAD_CHARACTER;
|
||||
}
|
||||
case 11: break;
|
||||
case 2:
|
||||
{ yybegin(YYINITIAL); return TokenType.WHITE_SPACE;
|
||||
case 11:
|
||||
break;
|
||||
case 2: {
|
||||
yybegin(YYINITIAL);
|
||||
return TokenType.WHITE_SPACE;
|
||||
}
|
||||
case 12: break;
|
||||
case 7:
|
||||
{ yybegin(WAITING_VALUE); return TokenType.WHITE_SPACE;
|
||||
case 12:
|
||||
break;
|
||||
case 7: {
|
||||
yybegin(WAITING_VALUE);
|
||||
return TokenType.WHITE_SPACE;
|
||||
}
|
||||
case 13: break;
|
||||
case 1:
|
||||
{ yybegin(YYINITIAL); return SimpleTypes.KEY;
|
||||
case 13:
|
||||
break;
|
||||
case 1: {
|
||||
yybegin(YYINITIAL);
|
||||
return SimpleTypes.KEY;
|
||||
}
|
||||
case 14: break;
|
||||
case 14:
|
||||
break;
|
||||
default:
|
||||
if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
|
||||
zzAtEOF = true;
|
||||
zzDoEOF();
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
zzScanError(ZZ_NO_MATCH);
|
||||
}
|
||||
}
|
||||
|
@ -14,11 +14,12 @@ import java.util.List;
|
||||
|
||||
public class SimpleLineMarkerProvider extends RelatedItemLineMarkerProvider {
|
||||
@Override
|
||||
protected void collectNavigationMarkers(@NotNull PsiElement element, Collection<? super RelatedItemLineMarkerInfo> result) {
|
||||
protected void collectNavigationMarkers(@NotNull PsiElement element,
|
||||
Collection<? super RelatedItemLineMarkerInfo> result) {
|
||||
if (element instanceof PsiLiteralExpression) {
|
||||
PsiLiteralExpression literalExpression = (PsiLiteralExpression) element;
|
||||
String value = literalExpression.getValue() instanceof String ? (String)literalExpression.getValue() : null;
|
||||
if (value != null && value.startsWith("simple"+":")) {
|
||||
String value = literalExpression.getValue() instanceof String ? (String) literalExpression.getValue() : null;
|
||||
if (value != null && value.startsWith("simple" + ":")) {
|
||||
Project project = element.getProject();
|
||||
final List<SimpleProperty> properties = SimpleUtil.findProperties(project, value.substring(7));
|
||||
if (properties.size() > 0) {
|
||||
|
@ -17,11 +17,12 @@ import com.simpleplugin.psi.SimpleFile;
|
||||
import com.simpleplugin.psi.SimpleTypes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SimpleParserDefinition implements ParserDefinition{
|
||||
public class SimpleParserDefinition implements ParserDefinition {
|
||||
public static final TokenSet WHITE_SPACES = TokenSet.create(TokenType.WHITE_SPACE);
|
||||
public static final TokenSet COMMENTS = TokenSet.create(SimpleTypes.COMMENT);
|
||||
|
||||
public static final IFileElementType FILE = new IFileElementType(Language.<SimpleLanguage>findInstance(SimpleLanguage.class));
|
||||
public static final IFileElementType FILE =
|
||||
new IFileElementType(Language.<SimpleLanguage>findInstance(SimpleLanguage.class));
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
|
@ -13,11 +13,15 @@ public class SimpleReferenceContributor extends PsiReferenceContributor {
|
||||
new PsiReferenceProvider() {
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
|
||||
public PsiReference[] getReferencesByElement(@NotNull PsiElement element,
|
||||
@NotNull ProcessingContext
|
||||
context) {
|
||||
PsiLiteralExpression literalExpression = (PsiLiteralExpression) element;
|
||||
String value = literalExpression.getValue() instanceof String ? (String)literalExpression.getValue() : null;
|
||||
if (value != null && value.startsWith("simple"+":")) {
|
||||
return new PsiReference[]{new SimpleReference(element, new TextRange(8, value.length() + 1))};
|
||||
String value = literalExpression.getValue() instanceof String ?
|
||||
(String) literalExpression.getValue() : null;
|
||||
if (value != null && value.startsWith("simple" + ":")) {
|
||||
return new PsiReference[]{
|
||||
new SimpleReference(element, new TextRange(8, value.length() + 1))};
|
||||
}
|
||||
return PsiReference.EMPTY_ARRAY;
|
||||
}
|
||||
|
@ -36,13 +36,13 @@ public class SimpleStructureViewElement implements StructureViewTreeElement, Sor
|
||||
@Override
|
||||
public boolean canNavigate() {
|
||||
return element instanceof NavigationItem &&
|
||||
((NavigationItem)element).canNavigate();
|
||||
((NavigationItem) element).canNavigate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canNavigateToSource() {
|
||||
return element instanceof NavigationItem &&
|
||||
((NavigationItem)element).canNavigateToSource();
|
||||
((NavigationItem) element).canNavigateToSource();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -16,7 +16,7 @@ public class SimpleStructureViewModel extends StructureViewModelBase implements
|
||||
|
||||
@NotNull
|
||||
public Sorter[] getSorters() {
|
||||
return new Sorter[] {Sorter.ALPHA_SORTER};
|
||||
return new Sorter[]{Sorter.ALPHA_SORTER};
|
||||
}
|
||||
|
||||
|
||||
|
@ -13,11 +13,16 @@ import org.jetbrains.annotations.NotNull;
|
||||
import static com.intellij.openapi.editor.colors.TextAttributesKey.createTextAttributesKey;
|
||||
|
||||
public class SimpleSyntaxHighlighter extends SyntaxHighlighterBase {
|
||||
public static final TextAttributesKey SEPARATOR = createTextAttributesKey("SIMPLE_SEPARATOR", DefaultLanguageHighlighterColors.OPERATION_SIGN);
|
||||
public static final TextAttributesKey KEY = createTextAttributesKey("SIMPLE_KEY", DefaultLanguageHighlighterColors.KEYWORD);
|
||||
public static final TextAttributesKey VALUE = createTextAttributesKey("SIMPLE_VALUE", DefaultLanguageHighlighterColors.STRING);
|
||||
public static final TextAttributesKey COMMENT = createTextAttributesKey("SIMPLE_COMMENT", DefaultLanguageHighlighterColors.LINE_COMMENT);
|
||||
public static final TextAttributesKey BAD_CHARACTER = createTextAttributesKey("SIMPLE_BAD_CHARACTER", HighlighterColors.BAD_CHARACTER);
|
||||
public static final TextAttributesKey SEPARATOR =
|
||||
createTextAttributesKey("SIMPLE_SEPARATOR", DefaultLanguageHighlighterColors.OPERATION_SIGN);
|
||||
public static final TextAttributesKey KEY =
|
||||
createTextAttributesKey("SIMPLE_KEY", DefaultLanguageHighlighterColors.KEYWORD);
|
||||
public static final TextAttributesKey VALUE =
|
||||
createTextAttributesKey("SIMPLE_VALUE", DefaultLanguageHighlighterColors.STRING);
|
||||
public static final TextAttributesKey COMMENT =
|
||||
createTextAttributesKey("SIMPLE_COMMENT", DefaultLanguageHighlighterColors.LINE_COMMENT);
|
||||
public static final TextAttributesKey BAD_CHARACTER =
|
||||
createTextAttributesKey("SIMPLE_BAD_CHARACTER", HighlighterColors.BAD_CHARACTER);
|
||||
|
||||
private static final TextAttributesKey[] BAD_CHAR_KEYS = new TextAttributesKey[]{BAD_CHARACTER};
|
||||
private static final TextAttributesKey[] SEPARATOR_KEYS = new TextAttributesKey[]{SEPARATOR};
|
||||
|
@ -18,7 +18,8 @@ import java.util.List;
|
||||
public class SimpleUtil {
|
||||
public static List<SimpleProperty> findProperties(Project project, String key) {
|
||||
List<SimpleProperty> result = null;
|
||||
Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, SimpleFileType.INSTANCE,
|
||||
Collection<VirtualFile> virtualFiles =
|
||||
FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, SimpleFileType.INSTANCE,
|
||||
GlobalSearchScope.allScope(project));
|
||||
for (VirtualFile virtualFile : virtualFiles) {
|
||||
SimpleFile simpleFile = (SimpleFile) PsiManager.getInstance(project).findFile(virtualFile);
|
||||
@ -41,7 +42,8 @@ public class SimpleUtil {
|
||||
|
||||
public static List<SimpleProperty> findProperties(Project project) {
|
||||
List<SimpleProperty> result = new ArrayList<SimpleProperty>();
|
||||
Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, SimpleFileType.INSTANCE,
|
||||
Collection<VirtualFile> virtualFiles =
|
||||
FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, SimpleFileType.INSTANCE,
|
||||
GlobalSearchScope.allScope(project));
|
||||
for (VirtualFile virtualFile : virtualFiles) {
|
||||
SimpleFile simpleFile = (SimpleFile) PsiManager.getInstance(project).findFile(virtualFile);
|
||||
|
@ -9,7 +9,6 @@ import com.simpleplugin.psi.SimpleElementFactory;
|
||||
import com.simpleplugin.psi.SimpleProperty;
|
||||
import com.simpleplugin.psi.SimpleTypes;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import java.lang.String;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@ -18,7 +17,7 @@ public class SimplePsiImplUtil {
|
||||
ASTNode keyNode = element.getNode().findChildByType(SimpleTypes.KEY);
|
||||
if (keyNode != null) {
|
||||
// IMPORTANT: Convert embedded escaped spaces to simple spaces
|
||||
return keyNode.getText().replaceAll("\\\\ "," ");
|
||||
return keyNode.getText().replaceAll("\\\\ ", " ");
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -2,6 +2,6 @@ public class Test {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("simple:website");
|
||||
System.out.println("simple:key with spaces");
|
||||
System.out.println("simple:<error descr="Unresolved property">websit"</error>);
|
||||
System.out.println("simple:<error descr="Unresolved property">websit" < / error >);
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,35 @@
|
||||
public class Test {
|
||||
public static void main(String[] args)<fold text=' { '> {
|
||||
</fold>System.out.println("<fold text='http://en.wikipedia.org/'>simple:website</fold>");<fold text=' }'>
|
||||
}</fold>
|
||||
public static void main1(String[] args)<fold text=' { '> {
|
||||
</fold>System.out.println("<fold text='This is the value that could be looked up with the key \"key with spaces\".'>simple:key with spaces</fold>");<fold text=' }'>
|
||||
}</fold>
|
||||
public static void main2(String[] args)<fold text=' { '> {
|
||||
</fold>System.out.println("<fold text='Welcome to \n Wikipedia!'>simple:message</fold>");<fold text=' }'>
|
||||
}</fold>
|
||||
public static void main(String[] args)
|
||||
|
||||
<fold text=' { '>
|
||||
|
||||
{
|
||||
</fold > System.out.println("<fold text='http://en.wikipedia.org/'>simple:website</fold>");<fold text = ' }' >
|
||||
}
|
||||
|
||||
</fold>
|
||||
|
||||
public static void main1(String[] args)
|
||||
|
||||
<fold text=' { '>
|
||||
|
||||
{
|
||||
</fold > System.out.println(
|
||||
"<fold text='This is the value that could be looked up with the key \"key with spaces\".'>simple:key with " +
|
||||
"spaces</fold>");<
|
||||
fold text = ' }' >
|
||||
}
|
||||
|
||||
</fold>
|
||||
|
||||
public static void main2(String[] args)
|
||||
|
||||
<fold text=' { '>
|
||||
|
||||
{
|
||||
</fold > System.out.println("<fold text='Welcome to \n Wikipedia!'>simple:message</fold>");<
|
||||
fold text = ' }' >
|
||||
}
|
||||
|
||||
</fold>
|
||||
}
|
||||
|
@ -55,7 +55,8 @@ public class MyToolWindowFactory implements ToolWindowFactory {
|
||||
// Get current date and time
|
||||
Calendar instance = Calendar.getInstance();
|
||||
currentDate.setText(String.valueOf(instance.get(Calendar.DAY_OF_MONTH)) + "/"
|
||||
+ String.valueOf(instance.get(Calendar.MONTH) + 1) + "/" + String.valueOf(instance.get(Calendar.YEAR)));
|
||||
+ String.valueOf(instance.get(Calendar.MONTH) + 1) + "/" +
|
||||
String.valueOf(instance.get(Calendar.YEAR)));
|
||||
currentDate.setIcon(new ImageIcon(getClass().getResource("/myToolWindow/Calendar-icon.png")));
|
||||
int min = instance.get(Calendar.MINUTE);
|
||||
String strMin;
|
||||
|
@ -18,7 +18,9 @@ import java.util.Collection;
|
||||
public class TextOnlyTreeStructureProvider implements TreeStructureProvider {
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings settings) {
|
||||
public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent,
|
||||
@NotNull Collection<AbstractTreeNode> children,
|
||||
ViewSettings settings) {
|
||||
ArrayList<AbstractTreeNode> nodes = new ArrayList<AbstractTreeNode>();
|
||||
for (AbstractTreeNode child : children) {
|
||||
if (child instanceof PsiFileNode) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user