add jflex
This commit is contained in:
parent
29232018e5
commit
df7b96b39d
|
@ -0,0 +1,37 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Run Plugin" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<log_file alias="idea.log" path="$PROJECT_DIR$/build/idea-sandbox/system/log/idea.log" />
|
||||
<ExternalSystemSettings>
|
||||
<option name="executionName" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="externalSystemIdString" value="GRADLE" />
|
||||
<option name="scriptParameters" value="" />
|
||||
<option name="taskDescriptions">
|
||||
<list />
|
||||
</option>
|
||||
<option name="taskNames">
|
||||
<list>
|
||||
<option value="runIde" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="vmOptions" value="" />
|
||||
</ExternalSystemSettings>
|
||||
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
|
||||
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
|
||||
<EXTENSION ID="com.intellij.execution.ExternalSystemRunConfigurationJavaExtension">
|
||||
<extension name="net.ashald.envfile">
|
||||
<option name="IS_ENABLED" value="false" />
|
||||
<option name="IS_SUBST" value="false" />
|
||||
<option name="IS_PATH_MACRO_SUPPORTED" value="false" />
|
||||
<option name="IS_IGNORE_MISSING_FILES" value="false" />
|
||||
<option name="IS_ENABLE_EXPERIMENTAL_INTEGRATIONS" value="false" />
|
||||
<ENTRIES>
|
||||
<ENTRY IS_ENABLED="true" PARSER="runconfig" IS_EXECUTABLE="false" />
|
||||
</ENTRIES>
|
||||
</extension>
|
||||
</EXTENSION>
|
||||
<DebugAllEnabled>false</DebugAllEnabled>
|
||||
<RunAsTest>false</RunAsTest>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
|
@ -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<JavaCompile> {
|
||||
sourceCompatibility = "17"
|
||||
targetCompatibility = "17"
|
||||
sourceCompatibility = "11"
|
||||
targetCompatibility = "11"
|
||||
}
|
||||
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
|
||||
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"))
|
||||
}
|
||||
|
|
|
@ -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, "<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, "<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, "<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, "<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, "<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, "<var>");
|
||||
r = consumeToken(b, "regexp:\"$[^\"]*\"");
|
||||
exit_section_(b, l, m, r, false, null);
|
||||
return r;
|
||||
}
|
||||
|
||||
}
|
|
@ -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<SJsonItem> getItemList();
|
||||
|
||||
}
|
|
@ -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();
|
||||
|
||||
}
|
|
@ -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();
|
||||
|
||||
}
|
|
@ -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<SJsonProp> getPropList();
|
||||
|
||||
}
|
|
@ -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();
|
||||
|
||||
}
|
|
@ -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();
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 {
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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<SJsonItem> getItemList() {
|
||||
return PsiTreeUtil.getChildrenOfTypeAsList(this, SJsonItem.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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<SJsonProp> getPropList() {
|
||||
return PsiTreeUtil.getChildrenOfTypeAsList(this, SJsonProp.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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) {
|
|
@ -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:\"$[^\"]*\""
|
||||
|
|
|
@ -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;
|
||||
|
||||
%%
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
|
@ -29,5 +29,8 @@
|
|||
fieldName="INSTANCE"
|
||||
language="SJson"
|
||||
extensions="sjson"/>
|
||||
<lang.parserDefinition
|
||||
language="SJson"
|
||||
implementationClass="ru.crabs.sjson.language.SJsonParserDefinition"/>
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
|
|
Loading…
Reference in New Issue