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