diff --git a/.run/Run Plugin.run.xml b/.run/Run Plugin.run.xml new file mode 100644 index 0000000..f53aed2 --- /dev/null +++ b/.run/Run Plugin.run.xml @@ -0,0 +1,37 @@ + + + + + + + + true + true + + + + + false + false + + + \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 173c115..886e4e2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,7 @@ plugins { id("java") id("org.jetbrains.kotlin.jvm") version "1.9.21" - id("org.jetbrains.intellij") version "1.16.1" + id("org.jetbrains.intellij") version "1.17.3" } group = "ru.crabs" @@ -14,7 +14,9 @@ repositories { // Include the generated files in the source set sourceSets { main { - kotlin.srcDirs("src/main/gen") + java { + srcDirs("src/main/gen") + } } } @@ -24,17 +26,17 @@ intellij { version.set("2023.1.5") type.set("IC") // Target IDE Platform - plugins.set(listOf(/* Plugin Dependencies */)) + plugins.set(listOf("com.intellij.java")) } tasks { // Set the JVM compatibility versions withType { - sourceCompatibility = "17" - targetCompatibility = "17" + sourceCompatibility = "11" + targetCompatibility = "11" } withType { - kotlinOptions.jvmTarget = "17" + kotlinOptions.jvmTarget = "11" } patchPluginXml { @@ -42,12 +44,6 @@ tasks { untilBuild.set("241.*") } - signPlugin { - certificateChain.set(System.getenv("CERTIFICATE_CHAIN")) - privateKey.set(System.getenv("PRIVATE_KEY")) - password.set(System.getenv("PRIVATE_KEY_PASSWORD")) - } - publishPlugin { token.set(System.getenv("PUBLISH_TOKEN")) } diff --git a/gen/ru/crabs/sdk/language/parser/SJsonParser.java b/gen/ru/crabs/sdk/language/parser/SJsonParser.java new file mode 100644 index 0000000..731fb7c --- /dev/null +++ b/gen/ru/crabs/sdk/language/parser/SJsonParser.java @@ -0,0 +1,185 @@ +// This is a generated file. Not intended for manual editing. +package ru.crabs.sdk.language.parser; + +import com.intellij.lang.PsiBuilder; +import com.intellij.lang.PsiBuilder.Marker; +import static ru.crabs.sdk.language.psi.SJsonTypes.*; +import static com.intellij.lang.parser.GeneratedParserUtilBase.*; +import com.intellij.psi.tree.IElementType; +import com.intellij.lang.ASTNode; +import com.intellij.psi.tree.TokenSet; +import com.intellij.lang.PsiParser; +import com.intellij.lang.LightPsiParser; + +@SuppressWarnings({"SimplifiableIfStatement", "UnusedAssignment"}) +public class SJsonParser implements PsiParser, LightPsiParser { + + public ASTNode parse(IElementType t, PsiBuilder b) { + parseLight(t, b); + return b.getTreeBuilt(); + } + + public void parseLight(IElementType t, PsiBuilder b) { + boolean r; + b = adapt_builder_(t, b, this, null); + Marker m = enter_section_(b, 0, _COLLAPSE_, null); + r = parse_root_(t, b); + exit_section_(b, 0, m, t, r, true, TRUE_CONDITION); + } + + protected boolean parse_root_(IElementType t, PsiBuilder b) { + return parse_root_(t, b, 0); + } + + static boolean parse_root_(IElementType t, PsiBuilder b, int l) { + return root(b, l + 1); + } + + /* ********************************************************** */ + // "[" (item ",")* item "]" + public static boolean array(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "array")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, ARRAY, ""); + r = consumeToken(b, "["); + r = r && array_1(b, l + 1); + r = r && item(b, l + 1); + r = r && consumeToken(b, "]"); + exit_section_(b, l, m, r, false, null); + return r; + } + + // (item ",")* + private static boolean array_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "array_1")) return false; + while (true) { + int c = current_position_(b); + if (!array_1_0(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "array_1", c)) break; + } + return true; + } + + // item "," + private static boolean array_1_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "array_1_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = item(b, l + 1); + r = r && consumeToken(b, ","); + exit_section_(b, m, null, r); + return r; + } + + /* ********************************************************** */ + // object | array | var | string | number + public static boolean item(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "item")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, ITEM, ""); + r = object(b, l + 1); + if (!r) r = array(b, l + 1); + if (!r) r = var(b, l + 1); + if (!r) r = consumeToken(b, STRING); + if (!r) r = consumeToken(b, NUMBER); + exit_section_(b, l, m, r, false, null); + return r; + } + + /* ********************************************************** */ + // var ":" item + public static boolean mixin(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "mixin")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, MIXIN, ""); + r = var(b, l + 1); + r = r && consumeToken(b, ":"); + r = r && item(b, l + 1); + exit_section_(b, l, m, r, false, null); + return r; + } + + /* ********************************************************** */ + // "{" (prop ",")* prop "}" + public static boolean object(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "object")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, OBJECT, ""); + r = consumeToken(b, "{"); + r = r && object_1(b, l + 1); + r = r && prop(b, l + 1); + r = r && consumeToken(b, "}"); + exit_section_(b, l, m, r, false, null); + return r; + } + + // (prop ",")* + private static boolean object_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "object_1")) return false; + while (true) { + int c = current_position_(b); + if (!object_1_0(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "object_1", c)) break; + } + return true; + } + + // prop "," + private static boolean object_1_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "object_1_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = prop(b, l + 1); + r = r && consumeToken(b, ","); + exit_section_(b, m, null, r); + return r; + } + + /* ********************************************************** */ + // string ":" item + public static boolean pair(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "pair")) return false; + if (!nextTokenIs(b, STRING)) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeToken(b, STRING); + r = r && consumeToken(b, ":"); + r = r && item(b, l + 1); + exit_section_(b, m, PAIR, r); + return r; + } + + /* ********************************************************** */ + // pair | mixin + public static boolean prop(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "prop")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, PROP, ""); + r = pair(b, l + 1); + if (!r) r = mixin(b, l + 1); + exit_section_(b, l, m, r, false, null); + return r; + } + + /* ********************************************************** */ + // object | COMMENT + static boolean root(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "root")) return false; + boolean r; + r = object(b, l + 1); + if (!r) r = consumeToken(b, COMMENT); + return r; + } + + /* ********************************************************** */ + // "regexp:\"$[^\"]*\"" + public static boolean var(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "var")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, VAR, ""); + r = consumeToken(b, "regexp:\"$[^\"]*\""); + exit_section_(b, l, m, r, false, null); + return r; + } + +} diff --git a/gen/ru/crabs/sdk/language/psi/SJsonArray.java b/gen/ru/crabs/sdk/language/psi/SJsonArray.java new file mode 100644 index 0000000..71924e3 --- /dev/null +++ b/gen/ru/crabs/sdk/language/psi/SJsonArray.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package ru.crabs.sdk.language.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface SJsonArray extends PsiElement { + + @NotNull + List getItemList(); + +} diff --git a/gen/ru/crabs/sdk/language/psi/SJsonItem.java b/gen/ru/crabs/sdk/language/psi/SJsonItem.java new file mode 100644 index 0000000..b7e90c3 --- /dev/null +++ b/gen/ru/crabs/sdk/language/psi/SJsonItem.java @@ -0,0 +1,25 @@ +// This is a generated file. Not intended for manual editing. +package ru.crabs.sdk.language.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface SJsonItem extends PsiElement { + + @Nullable + SJsonArray getArray(); + + @Nullable + SJsonObject getObject(); + + @Nullable + SJsonVar getVar(); + + @Nullable + PsiElement getNumber(); + + @Nullable + PsiElement getString(); + +} diff --git a/gen/ru/crabs/sdk/language/psi/SJsonMixin.java b/gen/ru/crabs/sdk/language/psi/SJsonMixin.java new file mode 100644 index 0000000..be09d29 --- /dev/null +++ b/gen/ru/crabs/sdk/language/psi/SJsonMixin.java @@ -0,0 +1,16 @@ +// This is a generated file. Not intended for manual editing. +package ru.crabs.sdk.language.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface SJsonMixin extends PsiElement { + + @NotNull + SJsonItem getItem(); + + @NotNull + SJsonVar getVar(); + +} diff --git a/gen/ru/crabs/sdk/language/psi/SJsonObject.java b/gen/ru/crabs/sdk/language/psi/SJsonObject.java new file mode 100644 index 0000000..eea3899 --- /dev/null +++ b/gen/ru/crabs/sdk/language/psi/SJsonObject.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package ru.crabs.sdk.language.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface SJsonObject extends PsiElement { + + @NotNull + List getPropList(); + +} diff --git a/gen/ru/crabs/sdk/language/psi/SJsonPair.java b/gen/ru/crabs/sdk/language/psi/SJsonPair.java new file mode 100644 index 0000000..8a3bb6d --- /dev/null +++ b/gen/ru/crabs/sdk/language/psi/SJsonPair.java @@ -0,0 +1,16 @@ +// This is a generated file. Not intended for manual editing. +package ru.crabs.sdk.language.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface SJsonPair extends PsiElement { + + @NotNull + SJsonItem getItem(); + + @NotNull + PsiElement getString(); + +} diff --git a/gen/ru/crabs/sdk/language/psi/SJsonProp.java b/gen/ru/crabs/sdk/language/psi/SJsonProp.java new file mode 100644 index 0000000..ad3f578 --- /dev/null +++ b/gen/ru/crabs/sdk/language/psi/SJsonProp.java @@ -0,0 +1,16 @@ +// This is a generated file. Not intended for manual editing. +package ru.crabs.sdk.language.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface SJsonProp extends PsiElement { + + @Nullable + SJsonMixin getMixin(); + + @Nullable + SJsonPair getPair(); + +} diff --git a/gen/ru/crabs/sdk/language/psi/SJsonTypes.java b/gen/ru/crabs/sdk/language/psi/SJsonTypes.java new file mode 100644 index 0000000..1047f45 --- /dev/null +++ b/gen/ru/crabs/sdk/language/psi/SJsonTypes.java @@ -0,0 +1,51 @@ +// This is a generated file. Not intended for manual editing. +package ru.crabs.sdk.language.psi; + +import com.intellij.psi.tree.IElementType; +import com.intellij.psi.PsiElement; +import com.intellij.lang.ASTNode; +import ru.crabs.sdk.language.psi.impl.*; + +public interface SJsonTypes { + + IElementType ARRAY = new SJsonElementType("ARRAY"); + IElementType ITEM = new SJsonElementType("ITEM"); + IElementType MIXIN = new SJsonElementType("MIXIN"); + IElementType OBJECT = new SJsonElementType("OBJECT"); + IElementType PAIR = new SJsonElementType("PAIR"); + IElementType PROP = new SJsonElementType("PROP"); + IElementType VAR = new SJsonElementType("VAR"); + + IElementType COMMENT = new SJsonTokenType("COMMENT"); + IElementType NUMBER = new SJsonTokenType("number"); + IElementType STRING = new SJsonTokenType("string"); + IElementType VARS_WORD = new SJsonTokenType("@vars"); + + class Factory { + public static PsiElement createElement(ASTNode node) { + IElementType type = node.getElementType(); + if (type == ARRAY) { + return new SJsonArrayImpl(node); + } + else if (type == ITEM) { + return new SJsonItemImpl(node); + } + else if (type == MIXIN) { + return new SJsonMixinImpl(node); + } + else if (type == OBJECT) { + return new SJsonObjectImpl(node); + } + else if (type == PAIR) { + return new SJsonPairImpl(node); + } + else if (type == PROP) { + return new SJsonPropImpl(node); + } + else if (type == VAR) { + return new SJsonVarImpl(node); + } + throw new AssertionError("Unknown element type: " + type); + } + } +} diff --git a/gen/ru/crabs/sdk/language/psi/SJsonVar.java b/gen/ru/crabs/sdk/language/psi/SJsonVar.java new file mode 100644 index 0000000..c716fb3 --- /dev/null +++ b/gen/ru/crabs/sdk/language/psi/SJsonVar.java @@ -0,0 +1,10 @@ +// This is a generated file. Not intended for manual editing. +package ru.crabs.sdk.language.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface SJsonVar extends PsiElement { + +} diff --git a/gen/ru/crabs/sdk/language/psi/SJsonVisitor.java b/gen/ru/crabs/sdk/language/psi/SJsonVisitor.java new file mode 100644 index 0000000..77ccef1 --- /dev/null +++ b/gen/ru/crabs/sdk/language/psi/SJsonVisitor.java @@ -0,0 +1,42 @@ +// This is a generated file. Not intended for manual editing. +package ru.crabs.sdk.language.psi; + +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElementVisitor; +import com.intellij.psi.PsiElement; + +public class SJsonVisitor extends PsiElementVisitor { + + public void visitArray(@NotNull SJsonArray o) { + visitPsiElement(o); + } + + public void visitItem(@NotNull SJsonItem o) { + visitPsiElement(o); + } + + public void visitMixin(@NotNull SJsonMixin o) { + visitPsiElement(o); + } + + public void visitObject(@NotNull SJsonObject o) { + visitPsiElement(o); + } + + public void visitPair(@NotNull SJsonPair o) { + visitPsiElement(o); + } + + public void visitProp(@NotNull SJsonProp o) { + visitPsiElement(o); + } + + public void visitVar(@NotNull SJsonVar o) { + visitPsiElement(o); + } + + public void visitPsiElement(@NotNull PsiElement o) { + visitElement(o); + } + +} diff --git a/gen/ru/crabs/sdk/language/psi/impl/SJsonArrayImpl.java b/gen/ru/crabs/sdk/language/psi/impl/SJsonArrayImpl.java new file mode 100644 index 0000000..564474a --- /dev/null +++ b/gen/ru/crabs/sdk/language/psi/impl/SJsonArrayImpl.java @@ -0,0 +1,36 @@ +// This is a generated file. Not intended for manual editing. +package ru.crabs.sdk.language.psi.impl; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiElementVisitor; +import com.intellij.psi.util.PsiTreeUtil; +import static ru.crabs.sdk.language.psi.SJsonTypes.*; +import com.intellij.extapi.psi.ASTWrapperPsiElement; +import ru.crabs.sdk.language.psi.*; + +public class SJsonArrayImpl extends ASTWrapperPsiElement implements SJsonArray { + + public SJsonArrayImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull SJsonVisitor visitor) { + visitor.visitArray(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof SJsonVisitor) accept((SJsonVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public List getItemList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, SJsonItem.class); + } + +} diff --git a/gen/ru/crabs/sdk/language/psi/impl/SJsonItemImpl.java b/gen/ru/crabs/sdk/language/psi/impl/SJsonItemImpl.java new file mode 100644 index 0000000..0bcef12 --- /dev/null +++ b/gen/ru/crabs/sdk/language/psi/impl/SJsonItemImpl.java @@ -0,0 +1,60 @@ +// This is a generated file. Not intended for manual editing. +package ru.crabs.sdk.language.psi.impl; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiElementVisitor; +import com.intellij.psi.util.PsiTreeUtil; +import static ru.crabs.sdk.language.psi.SJsonTypes.*; +import com.intellij.extapi.psi.ASTWrapperPsiElement; +import ru.crabs.sdk.language.psi.*; + +public class SJsonItemImpl extends ASTWrapperPsiElement implements SJsonItem { + + public SJsonItemImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull SJsonVisitor visitor) { + visitor.visitItem(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof SJsonVisitor) accept((SJsonVisitor)visitor); + else super.accept(visitor); + } + + @Override + @Nullable + public SJsonArray getArray() { + return findChildByClass(SJsonArray.class); + } + + @Override + @Nullable + public SJsonObject getObject() { + return findChildByClass(SJsonObject.class); + } + + @Override + @Nullable + public SJsonVar getVar() { + return findChildByClass(SJsonVar.class); + } + + @Override + @Nullable + public PsiElement getNumber() { + return findChildByType(NUMBER); + } + + @Override + @Nullable + public PsiElement getString() { + return findChildByType(STRING); + } + +} diff --git a/gen/ru/crabs/sdk/language/psi/impl/SJsonMixinImpl.java b/gen/ru/crabs/sdk/language/psi/impl/SJsonMixinImpl.java new file mode 100644 index 0000000..df173e1 --- /dev/null +++ b/gen/ru/crabs/sdk/language/psi/impl/SJsonMixinImpl.java @@ -0,0 +1,42 @@ +// This is a generated file. Not intended for manual editing. +package ru.crabs.sdk.language.psi.impl; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiElementVisitor; +import com.intellij.psi.util.PsiTreeUtil; +import static ru.crabs.sdk.language.psi.SJsonTypes.*; +import com.intellij.extapi.psi.ASTWrapperPsiElement; +import ru.crabs.sdk.language.psi.*; + +public class SJsonMixinImpl extends ASTWrapperPsiElement implements SJsonMixin { + + public SJsonMixinImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull SJsonVisitor visitor) { + visitor.visitMixin(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof SJsonVisitor) accept((SJsonVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public SJsonItem getItem() { + return findNotNullChildByClass(SJsonItem.class); + } + + @Override + @NotNull + public SJsonVar getVar() { + return findNotNullChildByClass(SJsonVar.class); + } + +} diff --git a/gen/ru/crabs/sdk/language/psi/impl/SJsonObjectImpl.java b/gen/ru/crabs/sdk/language/psi/impl/SJsonObjectImpl.java new file mode 100644 index 0000000..79ff7ca --- /dev/null +++ b/gen/ru/crabs/sdk/language/psi/impl/SJsonObjectImpl.java @@ -0,0 +1,36 @@ +// This is a generated file. Not intended for manual editing. +package ru.crabs.sdk.language.psi.impl; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiElementVisitor; +import com.intellij.psi.util.PsiTreeUtil; +import static ru.crabs.sdk.language.psi.SJsonTypes.*; +import com.intellij.extapi.psi.ASTWrapperPsiElement; +import ru.crabs.sdk.language.psi.*; + +public class SJsonObjectImpl extends ASTWrapperPsiElement implements SJsonObject { + + public SJsonObjectImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull SJsonVisitor visitor) { + visitor.visitObject(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof SJsonVisitor) accept((SJsonVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public List getPropList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, SJsonProp.class); + } + +} diff --git a/gen/ru/crabs/sdk/language/psi/impl/SJsonPairImpl.java b/gen/ru/crabs/sdk/language/psi/impl/SJsonPairImpl.java new file mode 100644 index 0000000..a0543c8 --- /dev/null +++ b/gen/ru/crabs/sdk/language/psi/impl/SJsonPairImpl.java @@ -0,0 +1,42 @@ +// This is a generated file. Not intended for manual editing. +package ru.crabs.sdk.language.psi.impl; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiElementVisitor; +import com.intellij.psi.util.PsiTreeUtil; +import static ru.crabs.sdk.language.psi.SJsonTypes.*; +import com.intellij.extapi.psi.ASTWrapperPsiElement; +import ru.crabs.sdk.language.psi.*; + +public class SJsonPairImpl extends ASTWrapperPsiElement implements SJsonPair { + + public SJsonPairImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull SJsonVisitor visitor) { + visitor.visitPair(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof SJsonVisitor) accept((SJsonVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public SJsonItem getItem() { + return findNotNullChildByClass(SJsonItem.class); + } + + @Override + @NotNull + public PsiElement getString() { + return findNotNullChildByType(STRING); + } + +} diff --git a/gen/ru/crabs/sdk/language/psi/impl/SJsonPropImpl.java b/gen/ru/crabs/sdk/language/psi/impl/SJsonPropImpl.java new file mode 100644 index 0000000..ebfd3ef --- /dev/null +++ b/gen/ru/crabs/sdk/language/psi/impl/SJsonPropImpl.java @@ -0,0 +1,42 @@ +// This is a generated file. Not intended for manual editing. +package ru.crabs.sdk.language.psi.impl; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiElementVisitor; +import com.intellij.psi.util.PsiTreeUtil; +import static ru.crabs.sdk.language.psi.SJsonTypes.*; +import com.intellij.extapi.psi.ASTWrapperPsiElement; +import ru.crabs.sdk.language.psi.*; + +public class SJsonPropImpl extends ASTWrapperPsiElement implements SJsonProp { + + public SJsonPropImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull SJsonVisitor visitor) { + visitor.visitProp(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof SJsonVisitor) accept((SJsonVisitor)visitor); + else super.accept(visitor); + } + + @Override + @Nullable + public SJsonMixin getMixin() { + return findChildByClass(SJsonMixin.class); + } + + @Override + @Nullable + public SJsonPair getPair() { + return findChildByClass(SJsonPair.class); + } + +} diff --git a/gen/ru/crabs/sdk/language/psi/impl/SJsonVarImpl.java b/gen/ru/crabs/sdk/language/psi/impl/SJsonVarImpl.java new file mode 100644 index 0000000..efdafe0 --- /dev/null +++ b/gen/ru/crabs/sdk/language/psi/impl/SJsonVarImpl.java @@ -0,0 +1,30 @@ +// This is a generated file. Not intended for manual editing. +package ru.crabs.sdk.language.psi.impl; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiElementVisitor; +import com.intellij.psi.util.PsiTreeUtil; +import static ru.crabs.sdk.language.psi.SJsonTypes.*; +import com.intellij.extapi.psi.ASTWrapperPsiElement; +import ru.crabs.sdk.language.psi.*; + +public class SJsonVarImpl extends ASTWrapperPsiElement implements SJsonVar { + + public SJsonVarImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull SJsonVisitor visitor) { + visitor.visitVar(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof SJsonVisitor) accept((SJsonVisitor)visitor); + else super.accept(visitor); + } + +} diff --git a/src/main/kotlin/ru/crabs/sjson/SJsonTokenType.kt b/src/main/kotlin/ru/crabs/sdk/language/psi/SJsonTokenType.kt similarity index 82% rename from src/main/kotlin/ru/crabs/sjson/SJsonTokenType.kt rename to src/main/kotlin/ru/crabs/sdk/language/psi/SJsonTokenType.kt index fb2d9a7..7a768d4 100644 --- a/src/main/kotlin/ru/crabs/sjson/SJsonTokenType.kt +++ b/src/main/kotlin/ru/crabs/sdk/language/psi/SJsonTokenType.kt @@ -1,6 +1,7 @@ -package ru.crabs.sjson +package ru.crabs.sdk.language.psi import com.intellij.psi.tree.IElementType +import ru.crabs.sjson.SJsonLanguage class SJsonTokenType(debugName: String) : IElementType(debugName, SJsonLanguage.INSTANCE) { diff --git a/src/main/kotlin/ru/crabs/sjson/SJson.bnf b/src/main/kotlin/ru/crabs/sjson/SJson.bnf index 06a6c50..5399909 100644 --- a/src/main/kotlin/ru/crabs/sjson/SJson.bnf +++ b/src/main/kotlin/ru/crabs/sjson/SJson.bnf @@ -1,16 +1,19 @@ { - parserClass="ru.crabs.sjson.parser.SJsonParser" + parserClass="ru.crabs.sdk.language.parser.SJsonParser" +// parserUtilClass="com.intellij.lang.parser.GeneratedParserUtilBase" extends="com.intellij.extapi.psi.ASTWrapperPsiElement" psiClassPrefix="SJson" psiImplClassSuffix="Impl" - psiPackage="ru.crabs.sjson" - psiImplPackage="ru.crabs.sjson.impl" + psiPackage="ru.crabs.sdk.language.psi" + psiImplPackage="ru.crabs.sdk.language.psi.impl" - elementTypeHolderClass="ru.crabs.sjson.SJsonTypes" - elementTypeClass="ru.crabs.sjson.SJsonElementType" - tokenTypeClass="ru.crabs.sjson.SJsonTokenType" + elementTypeHolderClass="ru.crabs.sdk.language.psi.SJsonTypes" + elementTypeClass="ru.crabs.sdk.language.psi.SJsonElementType" + tokenTypeClass="ru.crabs.sdk.language.psi.SJsonTokenType" + + psiImplUtilClass="ru.crabs.sdk.language.psi.impl.SJsonPsiImplUtil" tokens = [ space = 'regexp:\s+' @@ -21,7 +24,7 @@ ] } -root ::= object +root ::= object | COMMENT // COMMENT = какой-то костыль и тут не нужен object ::= "{" (prop ",")* prop "}" array ::= "[" (item ",")* item "]" @@ -31,4 +34,4 @@ pair ::= string ":" item mixin ::= var ":" item item ::= (object | array | var | string | number) -var ::= "regexp:\"\$[^\"]*\"" +var ::= "regexp:\"$[^\"]*\"" diff --git a/src/main/kotlin/ru/crabs/sjson/SJson.flex b/src/main/kotlin/ru/crabs/sjson/SJson.flex index a4e0f56..85045ea 100644 --- a/src/main/kotlin/ru/crabs/sjson/SJson.flex +++ b/src/main/kotlin/ru/crabs/sjson/SJson.flex @@ -2,7 +2,7 @@ package ru.crabs.sjson.language; import com.intellij.lexer.FlexLexer; import com.intellij.psi.tree.IElementType; -import ru.crabs.sjson.SJsonTypes; +import ru.crabs.sdk.language.psi.SJsonTypes; import com.intellij.psi.TokenType; %% diff --git a/src/main/kotlin/ru/crabs/sjson/language/SJsonParserDefinition.kt b/src/main/kotlin/ru/crabs/sjson/language/SJsonParserDefinition.kt new file mode 100644 index 0000000..d3e6180 --- /dev/null +++ b/src/main/kotlin/ru/crabs/sjson/language/SJsonParserDefinition.kt @@ -0,0 +1,78 @@ +package ru.crabs.sjson.language + +import com.intellij.extapi.psi.PsiFileBase +import com.intellij.lang.ASTNode +import com.intellij.lang.ParserDefinition +import com.intellij.lang.PsiParser +import com.intellij.lexer.FlexAdapter +import com.intellij.lexer.Lexer +import com.intellij.openapi.fileTypes.FileType +import com.intellij.openapi.project.Project +import com.intellij.psi.FileViewProvider +import com.intellij.psi.PsiElement +import com.intellij.psi.PsiFile +import com.intellij.psi.tree.IFileElementType +import com.intellij.psi.tree.TokenSet +import ru.crabs.sdk.language.parser.SJsonParser +import ru.crabs.sdk.language.psi.SJsonTypes +import ru.crabs.sjson.SJsonFileType +import ru.crabs.sjson.SJsonLanguage + + +class SJsonLexerAdapter : FlexAdapter(SJsonLexer(null)) + +class SJsonFile(viewProvider: FileViewProvider) : + + PsiFileBase(viewProvider, SJsonLanguage.INSTANCE) { + + override fun getFileType(): FileType { + return SJsonFileType.INSTANCE + } + + override fun toString(): String { + return "SJson File" + } +} + +interface SJsonTokenSets { + companion object { + val VARS_WORD: TokenSet = TokenSet.create(SJsonTypes.VARS_WORD) + + var COMMENTS: TokenSet = TokenSet.create(SJsonTypes.COMMENT) + } +} + +internal class SJsonParserDefinition : ParserDefinition { + + override fun createLexer(project: Project?): Lexer { + return SJsonLexerAdapter() + } + + override fun getCommentTokens(): TokenSet { + return SJsonTokenSets.COMMENTS + } + + override fun getStringLiteralElements(): TokenSet { + return TokenSet.EMPTY + } + + override fun createParser(project: Project?): PsiParser { + return SJsonParser() + } + + override fun getFileNodeType(): IFileElementType { + return FILE + } + + override fun createFile(viewProvider: FileViewProvider): PsiFile { + return SJsonFile(viewProvider) + } + + override fun createElement(node: ASTNode?): PsiElement { + return SJsonTypes.Factory.createElement(node) + } + + companion object { + val FILE: IFileElementType = IFileElementType(SJsonLanguage.INSTANCE) + } +} diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 0afd48b..4fb01e0 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -29,5 +29,8 @@ fieldName="INSTANCE" language="SJson" extensions="sjson"/> +