diff --git a/src/main/gen/com/feakin/intellij/lexer/FeakinTypes.java b/src/main/gen/com/feakin/intellij/lexer/FeakinTypes.java index 38e466f..57fe91a 100644 --- a/src/main/gen/com/feakin/intellij/lexer/FeakinTypes.java +++ b/src/main/gen/com/feakin/intellij/lexer/FeakinTypes.java @@ -9,24 +9,54 @@ public interface FeakinTypes { + IElementType AGGREGATION_DECLARATION = new FeakinElementType("AGGREGATION_DECLARATION"); + IElementType AGGREGATION_NAME = new FeakinElementType("AGGREGATION_NAME"); IElementType CONTEXT_DECLARATION = new FeakinElementType("CONTEXT_DECLARATION"); IElementType CONTEXT_MAP_DECLARATION = new FeakinElementType("CONTEXT_MAP_DECLARATION"); IElementType CONTEXT_MAP_NAME = new FeakinElementType("CONTEXT_MAP_NAME"); IElementType CONTEXT_NAME = new FeakinElementType("CONTEXT_NAME"); + IElementType CONTEXT_NODE_NAME = new FeakinElementType("CONTEXT_NODE_NAME"); IElementType DECLARATION = new FeakinElementType("DECLARATION"); + IElementType ENTITY_DECLARATION = new FeakinElementType("ENTITY_DECLARATION"); + IElementType ENTITY_NAME = new FeakinElementType("ENTITY_NAME"); IElementType NAME_COMPONENT = new FeakinElementType("NAME_COMPONENT"); + IElementType VALUE_OBJECT_DECLARATION = new FeakinElementType("VALUE_OBJECT_DECLARATION"); + IElementType VALUE_OBJECT_NAME = new FeakinElementType("VALUE_OBJECT_NAME"); + IElementType AGGREGATION_KEYWORD = new FeakinTokenType("Aggregate"); IElementType BLOCK_COMMENT = new FeakinTokenType("BLOCK_COMMENT"); + IElementType CLOSE_BRACE = new FeakinTokenType("}"); + IElementType COLON = new FeakinTokenType(":"); + IElementType COMMA = new FeakinTokenType(","); IElementType COMMENT = new FeakinTokenType("COMMENT"); IElementType CONTEXT_KEYWORD = new FeakinTokenType("Context"); IElementType CONTEXT_MAP_KEYWORD = new FeakinTokenType("ContextMap"); + IElementType DARROW = new FeakinTokenType("<->"); + IElementType DOUBLE_COLON = new FeakinTokenType("::"); + IElementType ENTITY_KEYWORD = new FeakinTokenType("Entity"); + IElementType EQUAL = new FeakinTokenType("="); IElementType IDENTIFIER = new FeakinTokenType("IDENTIFIER"); + IElementType LARROW = new FeakinTokenType("<-"); + IElementType LPAREN = new FeakinTokenType("("); + IElementType OPEN_BRACE = new FeakinTokenType("{"); + IElementType QUOTA = new FeakinTokenType("'"); + IElementType RARROW = new FeakinTokenType("->"); + IElementType RPAREN = new FeakinTokenType(")"); + IElementType SEMICOLON = new FeakinTokenType(";"); IElementType STRING_LITERAL = new FeakinTokenType("STRING_LITERAL"); + IElementType STRUCT_KEYWORD = new FeakinTokenType("Struct"); + IElementType VALUE_OBJECT_KEYWORD = new FeakinTokenType("ValueObject"); class Factory { public static PsiElement createElement(ASTNode node) { IElementType type = node.getElementType(); - if (type == CONTEXT_DECLARATION) { + if (type == AGGREGATION_DECLARATION) { + return new FeakinAggregationDeclarationImpl(node); + } + else if (type == AGGREGATION_NAME) { + return new FeakinAggregationNameImpl(node); + } + else if (type == CONTEXT_DECLARATION) { return new FeakinContextDeclarationImpl(node); } else if (type == CONTEXT_MAP_DECLARATION) { @@ -38,12 +68,27 @@ else if (type == CONTEXT_MAP_NAME) { else if (type == CONTEXT_NAME) { return new FeakinContextNameImpl(node); } + else if (type == CONTEXT_NODE_NAME) { + return new FeakinContextNodeNameImpl(node); + } else if (type == DECLARATION) { return new FeakinDeclarationImpl(node); } + else if (type == ENTITY_DECLARATION) { + return new FeakinEntityDeclarationImpl(node); + } + else if (type == ENTITY_NAME) { + return new FeakinEntityNameImpl(node); + } else if (type == NAME_COMPONENT) { return new FeakinNameComponentImpl(node); } + else if (type == VALUE_OBJECT_DECLARATION) { + return new FeakinValueObjectDeclarationImpl(node); + } + else if (type == VALUE_OBJECT_NAME) { + return new FeakinValueObjectNameImpl(node); + } throw new AssertionError("Unknown element type: " + type); } } diff --git a/src/main/gen/com/feakin/intellij/parser/FeakinParser.java b/src/main/gen/com/feakin/intellij/parser/FeakinParser.java index 900b523..febfe8f 100644 --- a/src/main/gen/com/feakin/intellij/parser/FeakinParser.java +++ b/src/main/gen/com/feakin/intellij/parser/FeakinParser.java @@ -35,6 +35,73 @@ static boolean parse_root_(IElementType t, PsiBuilder b, int l) { return compilationUnit(b, l + 1); } + /* ********************************************************** */ + // aggregationEntry* + static boolean aggregationBody(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "aggregationBody")) return false; + while (true) { + int c = current_position_(b); + if (!aggregationEntry(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "aggregationBody", c)) break; + } + return true; + } + + /* ********************************************************** */ + // AGGREGATION_KEYWORD aggregationName OPEN_BRACE aggregationBody CLOSE_BRACE + public static boolean aggregationDeclaration(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "aggregationDeclaration")) return false; + if (!nextTokenIs(b, AGGREGATION_KEYWORD)) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeToken(b, AGGREGATION_KEYWORD); + r = r && aggregationName(b, l + 1); + r = r && consumeToken(b, OPEN_BRACE); + r = r && aggregationBody(b, l + 1); + r = r && consumeToken(b, CLOSE_BRACE); + exit_section_(b, m, AGGREGATION_DECLARATION, r); + return r; + } + + /* ********************************************************** */ + // IDENTIFIER ':' IDENTIFIER ';' + // | IDENTIFIER ':' IDENTIFIER '[' IDENTIFIER ']' + static boolean aggregationEntry(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "aggregationEntry")) return false; + if (!nextTokenIs(b, IDENTIFIER)) return false; + boolean r; + Marker m = enter_section_(b); + r = parseTokens(b, 0, IDENTIFIER, COLON, IDENTIFIER, SEMICOLON); + if (!r) r = aggregationEntry_1(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + // IDENTIFIER ':' IDENTIFIER '[' IDENTIFIER ']' + private static boolean aggregationEntry_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "aggregationEntry_1")) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeTokens(b, 0, IDENTIFIER, COLON, IDENTIFIER); + r = r && consumeToken(b, "["); + r = r && consumeToken(b, IDENTIFIER); + r = r && consumeToken(b, "]"); + exit_section_(b, m, null, r); + return r; + } + + /* ********************************************************** */ + // name_component + public static boolean aggregationName(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "aggregationName")) return false; + if (!nextTokenIs(b, IDENTIFIER)) return false; + boolean r; + Marker m = enter_section_(b); + r = name_component(b, l + 1); + exit_section_(b, m, AGGREGATION_NAME, r); + return r; + } + /* ********************************************************** */ // declaration* static boolean compilationUnit(PsiBuilder b, int l) { @@ -60,7 +127,7 @@ static boolean contextBody(PsiBuilder b, int l) { } /* ********************************************************** */ - // CONTEXT_KEYWORD contextName '{' contextBody '}' + // CONTEXT_KEYWORD contextName OPEN_BRACE contextBody CLOSE_BRACE public static boolean contextDeclaration(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "contextDeclaration")) return false; if (!nextTokenIs(b, CONTEXT_KEYWORD)) return false; @@ -68,9 +135,9 @@ public static boolean contextDeclaration(PsiBuilder b, int l) { Marker m = enter_section_(b); r = consumeToken(b, CONTEXT_KEYWORD); r = r && contextName(b, l + 1); - r = r && consumeToken(b, "{"); + r = r && consumeToken(b, OPEN_BRACE); r = r && contextBody(b, l + 1); - r = r && consumeToken(b, "}"); + r = r && consumeToken(b, CLOSE_BRACE); exit_section_(b, m, CONTEXT_DECLARATION, r); return r; } @@ -82,16 +149,13 @@ static boolean contextEntry(PsiBuilder b, int l) { if (!nextTokenIs(b, IDENTIFIER)) return false; boolean r; Marker m = enter_section_(b); - r = consumeToken(b, IDENTIFIER); - r = r && consumeToken(b, ":"); - r = r && consumeToken(b, IDENTIFIER); - r = r && consumeToken(b, ";"); + r = consumeTokens(b, 0, IDENTIFIER, COLON, IDENTIFIER, SEMICOLON); exit_section_(b, m, null, r); return r; } /* ********************************************************** */ - // CONTEXT_MAP_KEYWORD contextMapName '{' contextMapEntry* '}' + // CONTEXT_MAP_KEYWORD contextMapName OPEN_BRACE (contextNodeDecl | contextNodeRel)* CLOSE_BRACE public static boolean contextMapDeclaration(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "contextMapDeclaration")) return false; if (!nextTokenIs(b, CONTEXT_MAP_KEYWORD)) return false; @@ -99,36 +163,30 @@ public static boolean contextMapDeclaration(PsiBuilder b, int l) { Marker m = enter_section_(b); r = consumeToken(b, CONTEXT_MAP_KEYWORD); r = r && contextMapName(b, l + 1); - r = r && consumeToken(b, "{"); + r = r && consumeToken(b, OPEN_BRACE); r = r && contextMapDeclaration_3(b, l + 1); - r = r && consumeToken(b, "}"); + r = r && consumeToken(b, CLOSE_BRACE); exit_section_(b, m, CONTEXT_MAP_DECLARATION, r); return r; } - // contextMapEntry* + // (contextNodeDecl | contextNodeRel)* private static boolean contextMapDeclaration_3(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "contextMapDeclaration_3")) return false; while (true) { int c = current_position_(b); - if (!contextMapEntry(b, l + 1)) break; + if (!contextMapDeclaration_3_0(b, l + 1)) break; if (!empty_element_parsed_guard_(b, "contextMapDeclaration_3", c)) break; } return true; } - /* ********************************************************** */ - // IDENTIFIER ':' IDENTIFIER ';' - static boolean contextMapEntry(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "contextMapEntry")) return false; - if (!nextTokenIs(b, IDENTIFIER)) return false; + // contextNodeDecl | contextNodeRel + private static boolean contextMapDeclaration_3_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "contextMapDeclaration_3_0")) return false; boolean r; - Marker m = enter_section_(b); - r = consumeToken(b, IDENTIFIER); - r = r && consumeToken(b, ":"); - r = r && consumeToken(b, IDENTIFIER); - r = r && consumeToken(b, ";"); - exit_section_(b, m, null, r); + r = contextNodeDecl(b, l + 1); + if (!r) r = contextNodeRel(b, l + 1); return r; } @@ -157,19 +215,149 @@ public static boolean contextName(PsiBuilder b, int l) { } /* ********************************************************** */ - // contextDeclaration - // | contextMapDeclaration + // CONTEXT_KEYWORD contextName (COMMA contextName)* + static boolean contextNodeDecl(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "contextNodeDecl")) return false; + if (!nextTokenIs(b, CONTEXT_KEYWORD)) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeToken(b, CONTEXT_KEYWORD); + r = r && contextName(b, l + 1); + r = r && contextNodeDecl_2(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + // (COMMA contextName)* + private static boolean contextNodeDecl_2(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "contextNodeDecl_2")) return false; + while (true) { + int c = current_position_(b); + if (!contextNodeDecl_2_0(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "contextNodeDecl_2", c)) break; + } + return true; + } + + // COMMA contextName + private static boolean contextNodeDecl_2_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "contextNodeDecl_2_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeToken(b, COMMA); + r = r && contextName(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + /* ********************************************************** */ + // name_component + public static boolean contextNodeName(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "contextNodeName")) return false; + if (!nextTokenIs(b, IDENTIFIER)) return false; + boolean r; + Marker m = enter_section_(b); + r = name_component(b, l + 1); + exit_section_(b, m, CONTEXT_NODE_NAME, r); + return r; + } + + /* ********************************************************** */ + // contextNodeName (DARROW | LARROW | RARROW) contextNodeName SEMICOLON + static boolean contextNodeRel(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "contextNodeRel")) return false; + if (!nextTokenIs(b, IDENTIFIER)) return false; + boolean r; + Marker m = enter_section_(b); + r = contextNodeName(b, l + 1); + r = r && contextNodeRel_1(b, l + 1); + r = r && contextNodeName(b, l + 1); + r = r && consumeToken(b, SEMICOLON); + exit_section_(b, m, null, r); + return r; + } + + // DARROW | LARROW | RARROW + private static boolean contextNodeRel_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "contextNodeRel_1")) return false; + boolean r; + r = consumeToken(b, DARROW); + if (!r) r = consumeToken(b, LARROW); + if (!r) r = consumeToken(b, RARROW); + return r; + } + + /* ********************************************************** */ + // contextMapDeclaration + // | contextDeclaration + // | aggregationDeclaration + // | entityDeclaration + // | valueObjectDeclaration public static boolean declaration(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "declaration")) return false; - if (!nextTokenIs(b, "", CONTEXT_KEYWORD, CONTEXT_MAP_KEYWORD)) return false; boolean r; Marker m = enter_section_(b, l, _NONE_, DECLARATION, ""); - r = contextDeclaration(b, l + 1); - if (!r) r = contextMapDeclaration(b, l + 1); + r = contextMapDeclaration(b, l + 1); + if (!r) r = contextDeclaration(b, l + 1); + if (!r) r = aggregationDeclaration(b, l + 1); + if (!r) r = entityDeclaration(b, l + 1); + if (!r) r = valueObjectDeclaration(b, l + 1); exit_section_(b, l, m, r, false, null); return r; } + /* ********************************************************** */ + // entityEntry* + static boolean entityBody(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "entityBody")) return false; + while (true) { + int c = current_position_(b); + if (!entityEntry(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "entityBody", c)) break; + } + return true; + } + + /* ********************************************************** */ + // ENTITY_KEYWORD entityName OPEN_BRACE entityBody CLOSE_BRACE + public static boolean entityDeclaration(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "entityDeclaration")) return false; + if (!nextTokenIs(b, ENTITY_KEYWORD)) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeToken(b, ENTITY_KEYWORD); + r = r && entityName(b, l + 1); + r = r && consumeToken(b, OPEN_BRACE); + r = r && entityBody(b, l + 1); + r = r && consumeToken(b, CLOSE_BRACE); + exit_section_(b, m, ENTITY_DECLARATION, r); + return r; + } + + /* ********************************************************** */ + // IDENTIFIER ':' IDENTIFIER ';' + static boolean entityEntry(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "entityEntry")) return false; + if (!nextTokenIs(b, IDENTIFIER)) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeTokens(b, 0, IDENTIFIER, COLON, IDENTIFIER, SEMICOLON); + exit_section_(b, m, null, r); + return r; + } + + /* ********************************************************** */ + // name_component + public static boolean entityName(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "entityName")) return false; + if (!nextTokenIs(b, IDENTIFIER)) return false; + boolean r; + Marker m = enter_section_(b); + r = name_component(b, l + 1); + exit_section_(b, m, ENTITY_NAME, r); + return r; + } + /* ********************************************************** */ // IDENTIFIER public static boolean name_component(PsiBuilder b, int l) { @@ -182,4 +370,56 @@ public static boolean name_component(PsiBuilder b, int l) { return r; } + /* ********************************************************** */ + // valueObjectEntry* + static boolean valueObjectBody(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "valueObjectBody")) return false; + while (true) { + int c = current_position_(b); + if (!valueObjectEntry(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "valueObjectBody", c)) break; + } + return true; + } + + /* ********************************************************** */ + // VALUE_OBJECT_KEYWORD valueObjectName OPEN_BRACE valueObjectBody CLOSE_BRACE + public static boolean valueObjectDeclaration(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "valueObjectDeclaration")) return false; + if (!nextTokenIs(b, VALUE_OBJECT_KEYWORD)) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeToken(b, VALUE_OBJECT_KEYWORD); + r = r && valueObjectName(b, l + 1); + r = r && consumeToken(b, OPEN_BRACE); + r = r && valueObjectBody(b, l + 1); + r = r && consumeToken(b, CLOSE_BRACE); + exit_section_(b, m, VALUE_OBJECT_DECLARATION, r); + return r; + } + + /* ********************************************************** */ + // IDENTIFIER ':' IDENTIFIER ';' + static boolean valueObjectEntry(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "valueObjectEntry")) return false; + if (!nextTokenIs(b, IDENTIFIER)) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeTokens(b, 0, IDENTIFIER, COLON, IDENTIFIER, SEMICOLON); + exit_section_(b, m, null, r); + return r; + } + + /* ********************************************************** */ + // name_component + public static boolean valueObjectName(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "valueObjectName")) return false; + if (!nextTokenIs(b, IDENTIFIER)) return false; + boolean r; + Marker m = enter_section_(b); + r = name_component(b, l + 1); + exit_section_(b, m, VALUE_OBJECT_NAME, r); + return r; + } + } diff --git a/src/main/gen/com/feakin/intellij/psi/FeakinAggregationDeclaration.java b/src/main/gen/com/feakin/intellij/psi/FeakinAggregationDeclaration.java new file mode 100644 index 0000000..7c5195c --- /dev/null +++ b/src/main/gen/com/feakin/intellij/psi/FeakinAggregationDeclaration.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package com.feakin.intellij.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface FeakinAggregationDeclaration extends FeakinPsiCompositeElement { + + @NotNull + FeakinAggregationName getAggregationName(); + +} diff --git a/src/main/gen/com/feakin/intellij/psi/FeakinAggregationName.java b/src/main/gen/com/feakin/intellij/psi/FeakinAggregationName.java new file mode 100644 index 0000000..835a11f --- /dev/null +++ b/src/main/gen/com/feakin/intellij/psi/FeakinAggregationName.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package com.feakin.intellij.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface FeakinAggregationName extends FeakinPsiCompositeElement { + + @NotNull + FeakinNameComponent getNameComponent(); + +} diff --git a/src/main/gen/com/feakin/intellij/psi/FeakinContextDeclaration.java b/src/main/gen/com/feakin/intellij/psi/FeakinContextDeclaration.java index 0a0a874..4904532 100644 --- a/src/main/gen/com/feakin/intellij/psi/FeakinContextDeclaration.java +++ b/src/main/gen/com/feakin/intellij/psi/FeakinContextDeclaration.java @@ -4,10 +4,17 @@ import java.util.List; import org.jetbrains.annotations.*; import com.intellij.psi.PsiElement; +import com.intellij.navigation.ItemPresentation; -public interface FeakinContextDeclaration extends FeakinPsiCompositeElement { +public interface FeakinContextDeclaration extends FeakinNamedElement { @NotNull FeakinContextName getContextName(); + @Nullable + String getName(); + + @Nullable + ItemPresentation getPresentation(); + } diff --git a/src/main/gen/com/feakin/intellij/psi/FeakinContextMapDeclaration.java b/src/main/gen/com/feakin/intellij/psi/FeakinContextMapDeclaration.java index 2398c71..84c9168 100644 --- a/src/main/gen/com/feakin/intellij/psi/FeakinContextMapDeclaration.java +++ b/src/main/gen/com/feakin/intellij/psi/FeakinContextMapDeclaration.java @@ -4,10 +4,23 @@ import java.util.List; import org.jetbrains.annotations.*; import com.intellij.psi.PsiElement; +import com.intellij.navigation.ItemPresentation; -public interface FeakinContextMapDeclaration extends FeakinPsiCompositeElement { +public interface FeakinContextMapDeclaration extends FeakinNamedElement { @NotNull FeakinContextMapName getContextMapName(); + @NotNull + List getContextNameList(); + + @NotNull + List getContextNodeNameList(); + + @Nullable + String getName(); + + @Nullable + ItemPresentation getPresentation(); + } diff --git a/src/main/gen/com/feakin/intellij/psi/FeakinContextNodeName.java b/src/main/gen/com/feakin/intellij/psi/FeakinContextNodeName.java new file mode 100644 index 0000000..d5b73b3 --- /dev/null +++ b/src/main/gen/com/feakin/intellij/psi/FeakinContextNodeName.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package com.feakin.intellij.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface FeakinContextNodeName extends FeakinPsiCompositeElement { + + @NotNull + FeakinNameComponent getNameComponent(); + +} diff --git a/src/main/gen/com/feakin/intellij/psi/FeakinDeclaration.java b/src/main/gen/com/feakin/intellij/psi/FeakinDeclaration.java index 5455aa3..71784e0 100644 --- a/src/main/gen/com/feakin/intellij/psi/FeakinDeclaration.java +++ b/src/main/gen/com/feakin/intellij/psi/FeakinDeclaration.java @@ -7,10 +7,19 @@ public interface FeakinDeclaration extends FeakinPsiCompositeElement { + @Nullable + FeakinAggregationDeclaration getAggregationDeclaration(); + @Nullable FeakinContextDeclaration getContextDeclaration(); @Nullable FeakinContextMapDeclaration getContextMapDeclaration(); + @Nullable + FeakinEntityDeclaration getEntityDeclaration(); + + @Nullable + FeakinValueObjectDeclaration getValueObjectDeclaration(); + } diff --git a/src/main/gen/com/feakin/intellij/psi/FeakinEntityDeclaration.java b/src/main/gen/com/feakin/intellij/psi/FeakinEntityDeclaration.java new file mode 100644 index 0000000..fe42f87 --- /dev/null +++ b/src/main/gen/com/feakin/intellij/psi/FeakinEntityDeclaration.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package com.feakin.intellij.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface FeakinEntityDeclaration extends FeakinPsiCompositeElement { + + @NotNull + FeakinEntityName getEntityName(); + +} diff --git a/src/main/gen/com/feakin/intellij/psi/FeakinEntityName.java b/src/main/gen/com/feakin/intellij/psi/FeakinEntityName.java new file mode 100644 index 0000000..86b69ea --- /dev/null +++ b/src/main/gen/com/feakin/intellij/psi/FeakinEntityName.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package com.feakin.intellij.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface FeakinEntityName extends FeakinPsiCompositeElement { + + @NotNull + FeakinNameComponent getNameComponent(); + +} diff --git a/src/main/gen/com/feakin/intellij/psi/FeakinNameComponent.java b/src/main/gen/com/feakin/intellij/psi/FeakinNameComponent.java index 113ab4a..858bea3 100644 --- a/src/main/gen/com/feakin/intellij/psi/FeakinNameComponent.java +++ b/src/main/gen/com/feakin/intellij/psi/FeakinNameComponent.java @@ -11,6 +11,7 @@ public interface FeakinNameComponent extends FeakinNamedElement { @NotNull PsiElement getIdentifier(); + @Nullable PsiReference getReference(); } diff --git a/src/main/gen/com/feakin/intellij/psi/FeakinValueObjectDeclaration.java b/src/main/gen/com/feakin/intellij/psi/FeakinValueObjectDeclaration.java new file mode 100644 index 0000000..144829c --- /dev/null +++ b/src/main/gen/com/feakin/intellij/psi/FeakinValueObjectDeclaration.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package com.feakin.intellij.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface FeakinValueObjectDeclaration extends FeakinPsiCompositeElement { + + @NotNull + FeakinValueObjectName getValueObjectName(); + +} diff --git a/src/main/gen/com/feakin/intellij/psi/FeakinValueObjectName.java b/src/main/gen/com/feakin/intellij/psi/FeakinValueObjectName.java new file mode 100644 index 0000000..4b8e533 --- /dev/null +++ b/src/main/gen/com/feakin/intellij/psi/FeakinValueObjectName.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package com.feakin.intellij.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface FeakinValueObjectName extends FeakinPsiCompositeElement { + + @NotNull + FeakinNameComponent getNameComponent(); + +} diff --git a/src/main/gen/com/feakin/intellij/psi/FeakinVisitor.java b/src/main/gen/com/feakin/intellij/psi/FeakinVisitor.java index 9ba8d84..9c71799 100644 --- a/src/main/gen/com/feakin/intellij/psi/FeakinVisitor.java +++ b/src/main/gen/com/feakin/intellij/psi/FeakinVisitor.java @@ -6,14 +6,22 @@ public class FeakinVisitor extends PsiElementVisitor { - public void visitContextDeclaration(@NotNull FeakinContextDeclaration o) { + public void visitAggregationDeclaration(@NotNull FeakinAggregationDeclaration o) { visitPsiCompositeElement(o); } - public void visitContextMapDeclaration(@NotNull FeakinContextMapDeclaration o) { + public void visitAggregationName(@NotNull FeakinAggregationName o) { visitPsiCompositeElement(o); } + public void visitContextDeclaration(@NotNull FeakinContextDeclaration o) { + visitNamedElement(o); + } + + public void visitContextMapDeclaration(@NotNull FeakinContextMapDeclaration o) { + visitNamedElement(o); + } + public void visitContextMapName(@NotNull FeakinContextMapName o) { visitPsiCompositeElement(o); } @@ -22,14 +30,34 @@ public void visitContextName(@NotNull FeakinContextName o) { visitPsiCompositeElement(o); } + public void visitContextNodeName(@NotNull FeakinContextNodeName o) { + visitPsiCompositeElement(o); + } + public void visitDeclaration(@NotNull FeakinDeclaration o) { visitPsiCompositeElement(o); } + public void visitEntityDeclaration(@NotNull FeakinEntityDeclaration o) { + visitPsiCompositeElement(o); + } + + public void visitEntityName(@NotNull FeakinEntityName o) { + visitPsiCompositeElement(o); + } + public void visitNameComponent(@NotNull FeakinNameComponent o) { visitNamedElement(o); } + public void visitValueObjectDeclaration(@NotNull FeakinValueObjectDeclaration o) { + visitPsiCompositeElement(o); + } + + public void visitValueObjectName(@NotNull FeakinValueObjectName o) { + visitPsiCompositeElement(o); + } + public void visitNamedElement(@NotNull FeakinNamedElement o) { visitPsiCompositeElement(o); } diff --git a/src/main/gen/com/feakin/intellij/psi/impl/FeakinAggregationDeclarationImpl.java b/src/main/gen/com/feakin/intellij/psi/impl/FeakinAggregationDeclarationImpl.java new file mode 100644 index 0000000..870ad48 --- /dev/null +++ b/src/main/gen/com/feakin/intellij/psi/impl/FeakinAggregationDeclarationImpl.java @@ -0,0 +1,36 @@ +// This is a generated file. Not intended for manual editing. +package com.feakin.intellij.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 com.feakin.intellij.lexer.FeakinTypes.*; +import com.feakin.intellij.psi.*; +import com.feakin.intellij.parser.FeakinPsiImplUtil; + +public class FeakinAggregationDeclarationImpl extends FeakinPsiCompositeElementImpl implements FeakinAggregationDeclaration { + + public FeakinAggregationDeclarationImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull FeakinVisitor visitor) { + visitor.visitAggregationDeclaration(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof FeakinVisitor) accept((FeakinVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public FeakinAggregationName getAggregationName() { + return findNotNullChildByClass(FeakinAggregationName.class); + } + +} diff --git a/src/main/gen/com/feakin/intellij/psi/impl/FeakinAggregationNameImpl.java b/src/main/gen/com/feakin/intellij/psi/impl/FeakinAggregationNameImpl.java new file mode 100644 index 0000000..84ea76d --- /dev/null +++ b/src/main/gen/com/feakin/intellij/psi/impl/FeakinAggregationNameImpl.java @@ -0,0 +1,36 @@ +// This is a generated file. Not intended for manual editing. +package com.feakin.intellij.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 com.feakin.intellij.lexer.FeakinTypes.*; +import com.feakin.intellij.psi.*; +import com.feakin.intellij.parser.FeakinPsiImplUtil; + +public class FeakinAggregationNameImpl extends FeakinPsiCompositeElementImpl implements FeakinAggregationName { + + public FeakinAggregationNameImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull FeakinVisitor visitor) { + visitor.visitAggregationName(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof FeakinVisitor) accept((FeakinVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public FeakinNameComponent getNameComponent() { + return findNotNullChildByClass(FeakinNameComponent.class); + } + +} diff --git a/src/main/gen/com/feakin/intellij/psi/impl/FeakinContextDeclarationImpl.java b/src/main/gen/com/feakin/intellij/psi/impl/FeakinContextDeclarationImpl.java index 32f9147..1396869 100644 --- a/src/main/gen/com/feakin/intellij/psi/impl/FeakinContextDeclarationImpl.java +++ b/src/main/gen/com/feakin/intellij/psi/impl/FeakinContextDeclarationImpl.java @@ -10,8 +10,9 @@ import static com.feakin.intellij.lexer.FeakinTypes.*; import com.feakin.intellij.psi.*; import com.feakin.intellij.parser.FeakinPsiImplUtil; +import com.intellij.navigation.ItemPresentation; -public class FeakinContextDeclarationImpl extends FeakinPsiCompositeElementImpl implements FeakinContextDeclaration { +public class FeakinContextDeclarationImpl extends FeakinNamedElementImpl implements FeakinContextDeclaration { public FeakinContextDeclarationImpl(@NotNull ASTNode node) { super(node); diff --git a/src/main/gen/com/feakin/intellij/psi/impl/FeakinContextMapDeclarationImpl.java b/src/main/gen/com/feakin/intellij/psi/impl/FeakinContextMapDeclarationImpl.java index c3f0fa9..207d949 100644 --- a/src/main/gen/com/feakin/intellij/psi/impl/FeakinContextMapDeclarationImpl.java +++ b/src/main/gen/com/feakin/intellij/psi/impl/FeakinContextMapDeclarationImpl.java @@ -10,8 +10,9 @@ import static com.feakin.intellij.lexer.FeakinTypes.*; import com.feakin.intellij.psi.*; import com.feakin.intellij.parser.FeakinPsiImplUtil; +import com.intellij.navigation.ItemPresentation; -public class FeakinContextMapDeclarationImpl extends FeakinPsiCompositeElementImpl implements FeakinContextMapDeclaration { +public class FeakinContextMapDeclarationImpl extends FeakinNamedElementImpl implements FeakinContextMapDeclaration { public FeakinContextMapDeclarationImpl(@NotNull ASTNode node) { super(node); @@ -33,4 +34,16 @@ public FeakinContextMapName getContextMapName() { return findNotNullChildByClass(FeakinContextMapName.class); } + @Override + @NotNull + public List getContextNameList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, FeakinContextName.class); + } + + @Override + @NotNull + public List getContextNodeNameList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, FeakinContextNodeName.class); + } + } diff --git a/src/main/gen/com/feakin/intellij/psi/impl/FeakinContextNodeNameImpl.java b/src/main/gen/com/feakin/intellij/psi/impl/FeakinContextNodeNameImpl.java new file mode 100644 index 0000000..ac0fe5c --- /dev/null +++ b/src/main/gen/com/feakin/intellij/psi/impl/FeakinContextNodeNameImpl.java @@ -0,0 +1,36 @@ +// This is a generated file. Not intended for manual editing. +package com.feakin.intellij.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 com.feakin.intellij.lexer.FeakinTypes.*; +import com.feakin.intellij.psi.*; +import com.feakin.intellij.parser.FeakinPsiImplUtil; + +public class FeakinContextNodeNameImpl extends FeakinPsiCompositeElementImpl implements FeakinContextNodeName { + + public FeakinContextNodeNameImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull FeakinVisitor visitor) { + visitor.visitContextNodeName(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof FeakinVisitor) accept((FeakinVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public FeakinNameComponent getNameComponent() { + return findNotNullChildByClass(FeakinNameComponent.class); + } + +} diff --git a/src/main/gen/com/feakin/intellij/psi/impl/FeakinDeclarationImpl.java b/src/main/gen/com/feakin/intellij/psi/impl/FeakinDeclarationImpl.java index b4ab2d6..68db584 100644 --- a/src/main/gen/com/feakin/intellij/psi/impl/FeakinDeclarationImpl.java +++ b/src/main/gen/com/feakin/intellij/psi/impl/FeakinDeclarationImpl.java @@ -27,6 +27,12 @@ public void accept(@NotNull PsiElementVisitor visitor) { else super.accept(visitor); } + @Override + @Nullable + public FeakinAggregationDeclaration getAggregationDeclaration() { + return findChildByClass(FeakinAggregationDeclaration.class); + } + @Override @Nullable public FeakinContextDeclaration getContextDeclaration() { @@ -39,4 +45,16 @@ public FeakinContextMapDeclaration getContextMapDeclaration() { return findChildByClass(FeakinContextMapDeclaration.class); } + @Override + @Nullable + public FeakinEntityDeclaration getEntityDeclaration() { + return findChildByClass(FeakinEntityDeclaration.class); + } + + @Override + @Nullable + public FeakinValueObjectDeclaration getValueObjectDeclaration() { + return findChildByClass(FeakinValueObjectDeclaration.class); + } + } diff --git a/src/main/gen/com/feakin/intellij/psi/impl/FeakinEntityDeclarationImpl.java b/src/main/gen/com/feakin/intellij/psi/impl/FeakinEntityDeclarationImpl.java new file mode 100644 index 0000000..3d0268e --- /dev/null +++ b/src/main/gen/com/feakin/intellij/psi/impl/FeakinEntityDeclarationImpl.java @@ -0,0 +1,36 @@ +// This is a generated file. Not intended for manual editing. +package com.feakin.intellij.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 com.feakin.intellij.lexer.FeakinTypes.*; +import com.feakin.intellij.psi.*; +import com.feakin.intellij.parser.FeakinPsiImplUtil; + +public class FeakinEntityDeclarationImpl extends FeakinPsiCompositeElementImpl implements FeakinEntityDeclaration { + + public FeakinEntityDeclarationImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull FeakinVisitor visitor) { + visitor.visitEntityDeclaration(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof FeakinVisitor) accept((FeakinVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public FeakinEntityName getEntityName() { + return findNotNullChildByClass(FeakinEntityName.class); + } + +} diff --git a/src/main/gen/com/feakin/intellij/psi/impl/FeakinEntityNameImpl.java b/src/main/gen/com/feakin/intellij/psi/impl/FeakinEntityNameImpl.java new file mode 100644 index 0000000..67648b6 --- /dev/null +++ b/src/main/gen/com/feakin/intellij/psi/impl/FeakinEntityNameImpl.java @@ -0,0 +1,36 @@ +// This is a generated file. Not intended for manual editing. +package com.feakin.intellij.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 com.feakin.intellij.lexer.FeakinTypes.*; +import com.feakin.intellij.psi.*; +import com.feakin.intellij.parser.FeakinPsiImplUtil; + +public class FeakinEntityNameImpl extends FeakinPsiCompositeElementImpl implements FeakinEntityName { + + public FeakinEntityNameImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull FeakinVisitor visitor) { + visitor.visitEntityName(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof FeakinVisitor) accept((FeakinVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public FeakinNameComponent getNameComponent() { + return findNotNullChildByClass(FeakinNameComponent.class); + } + +} diff --git a/src/main/gen/com/feakin/intellij/psi/impl/FeakinNameComponentImpl.java b/src/main/gen/com/feakin/intellij/psi/impl/FeakinNameComponentImpl.java index 337d5f1..ea020c9 100644 --- a/src/main/gen/com/feakin/intellij/psi/impl/FeakinNameComponentImpl.java +++ b/src/main/gen/com/feakin/intellij/psi/impl/FeakinNameComponentImpl.java @@ -35,6 +35,7 @@ public PsiElement getIdentifier() { } @Override + @Nullable public PsiReference getReference() { return FeakinPsiImplUtil.getReference(this); } diff --git a/src/main/gen/com/feakin/intellij/psi/impl/FeakinValueObjectDeclarationImpl.java b/src/main/gen/com/feakin/intellij/psi/impl/FeakinValueObjectDeclarationImpl.java new file mode 100644 index 0000000..a82f1b1 --- /dev/null +++ b/src/main/gen/com/feakin/intellij/psi/impl/FeakinValueObjectDeclarationImpl.java @@ -0,0 +1,36 @@ +// This is a generated file. Not intended for manual editing. +package com.feakin.intellij.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 com.feakin.intellij.lexer.FeakinTypes.*; +import com.feakin.intellij.psi.*; +import com.feakin.intellij.parser.FeakinPsiImplUtil; + +public class FeakinValueObjectDeclarationImpl extends FeakinPsiCompositeElementImpl implements FeakinValueObjectDeclaration { + + public FeakinValueObjectDeclarationImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull FeakinVisitor visitor) { + visitor.visitValueObjectDeclaration(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof FeakinVisitor) accept((FeakinVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public FeakinValueObjectName getValueObjectName() { + return findNotNullChildByClass(FeakinValueObjectName.class); + } + +} diff --git a/src/main/gen/com/feakin/intellij/psi/impl/FeakinValueObjectNameImpl.java b/src/main/gen/com/feakin/intellij/psi/impl/FeakinValueObjectNameImpl.java new file mode 100644 index 0000000..20c3a6d --- /dev/null +++ b/src/main/gen/com/feakin/intellij/psi/impl/FeakinValueObjectNameImpl.java @@ -0,0 +1,36 @@ +// This is a generated file. Not intended for manual editing. +package com.feakin.intellij.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 com.feakin.intellij.lexer.FeakinTypes.*; +import com.feakin.intellij.psi.*; +import com.feakin.intellij.parser.FeakinPsiImplUtil; + +public class FeakinValueObjectNameImpl extends FeakinPsiCompositeElementImpl implements FeakinValueObjectName { + + public FeakinValueObjectNameImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull FeakinVisitor visitor) { + visitor.visitValueObjectName(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof FeakinVisitor) accept((FeakinVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public FeakinNameComponent getNameComponent() { + return findNotNullChildByClass(FeakinNameComponent.class); + } + +} diff --git a/src/main/kotlin/com/feakin/intellij/grammar/feakin.bnf b/src/main/kotlin/com/feakin/intellij/grammar/feakin.bnf index c5a9fb5..9cdffbe 100644 --- a/src/main/kotlin/com/feakin/intellij/grammar/feakin.bnf +++ b/src/main/kotlin/com/feakin/intellij/grammar/feakin.bnf @@ -23,30 +23,95 @@ IDENTIFIER = 'regexp:[_a-zA-Z][_a-zA-Z0-9]*' STRING_LITERAL = "regexp:\"([^\\\"\r\n]|\\[^\r\n])*\"?" - CONTEXT_MAP_KEYWORD ='ContextMap' - CONTEXT_KEYWORD ='Context' + COMMA = ',' + COLON = ":" + DOUBLE_COLON = "::" + SEMICOLON = ";" + OPEN_BRACE = "{" + CLOSE_BRACE = "}" + EQUAL = "=" + QUOTA = "'" + LPAREN = '(' + RPAREN = ')' + + RARROW = "->" + LARROW = "<-" + DARROW = "<->" + + CONTEXT_MAP_KEYWORD = 'ContextMap' + CONTEXT_KEYWORD = 'Context' + AGGREGATION_KEYWORD = 'Aggregate' + ENTITY_KEYWORD = 'Entity' + VALUE_OBJECT_KEYWORD = 'ValueObject' + STRUCT_KEYWORD = 'Struct' ] } -compilationUnit ::= declaration* { pin = 1} +compilationUnit ::= declaration* -declaration ::= contextDeclaration - | contextMapDeclaration +declaration ::= contextMapDeclaration + | contextDeclaration + | aggregationDeclaration + | entityDeclaration + | valueObjectDeclaration -contextMapDeclaration ::= CONTEXT_MAP_KEYWORD contextMapName '{' contextMapEntry* '}' +contextMapDeclaration ::= CONTEXT_MAP_KEYWORD contextMapName OPEN_BRACE (contextNodeDecl | contextNodeRel)* CLOSE_BRACE +{ + mixin="com.feakin.intellij.psi.impl.FeakinNamedElementImpl" + implements="com.feakin.intellij.psi.FeakinNamedElement" + methods=[getName getPresentation] +} + +private contextNodeDecl ::= CONTEXT_KEYWORD contextName (COMMA contextName)* + +private contextNodeRel ::= contextNodeName (DARROW | LARROW | RARROW) contextNodeName SEMICOLON +{ + implements="com.feakin.intellij.psi.FeakinContextNodeRel" + methods=[getLeftNode getRightNode] +} -contextDeclaration ::= CONTEXT_KEYWORD contextName '{' contextBody '}' +contextDeclaration ::= CONTEXT_KEYWORD contextName OPEN_BRACE contextBody CLOSE_BRACE +{ + mixin="com.feakin.intellij.psi.impl.FeakinNamedElementImpl" + implements="com.feakin.intellij.psi.FeakinNamedElement" + methods=[getName getPresentation] +} -private contextMapEntry ::= IDENTIFIER ':' IDENTIFIER ';' +aggregationDeclaration ::= AGGREGATION_KEYWORD aggregationName OPEN_BRACE aggregationBody CLOSE_BRACE -private contextBody ::= contextEntry* { pin = 1} +entityDeclaration ::= ENTITY_KEYWORD entityName OPEN_BRACE entityBody CLOSE_BRACE + +valueObjectDeclaration ::= VALUE_OBJECT_KEYWORD valueObjectName OPEN_BRACE valueObjectBody CLOSE_BRACE + +private contextBody ::= contextEntry* private contextEntry ::= IDENTIFIER ':' IDENTIFIER ';' +private aggregationBody ::= aggregationEntry* + +private aggregationEntry ::= + IDENTIFIER ':' IDENTIFIER ';' + | IDENTIFIER ':' IDENTIFIER '[' IDENTIFIER ']'; + +private entityBody ::= entityEntry* +private entityEntry ::= IDENTIFIER ':' IDENTIFIER ';' + +private valueObjectBody ::= valueObjectEntry* +private valueObjectEntry ::= IDENTIFIER ':' IDENTIFIER ';' + + contextMapName ::= name_component contextName ::= name_component +aggregationName ::= name_component + +entityName ::= name_component + +valueObjectName ::= name_component + +contextNodeName ::= name_component + name_component ::= IDENTIFIER { mixin="com.feakin.intellij.psi.impl.FeakinNamedElementImpl" diff --git a/src/main/kotlin/com/feakin/intellij/highlight/FeakinSyntaxHighlighter.kt b/src/main/kotlin/com/feakin/intellij/highlight/FeakinSyntaxHighlighter.kt index 615484d..97d2862 100644 --- a/src/main/kotlin/com/feakin/intellij/highlight/FeakinSyntaxHighlighter.kt +++ b/src/main/kotlin/com/feakin/intellij/highlight/FeakinSyntaxHighlighter.kt @@ -23,6 +23,12 @@ class FeakinSyntaxHighlighter : SyntaxHighlighterBase() { init { fillMap(ATTRIBUTES, FeakinTokenTypeSets.KEY_WORDS, DefaultLanguageHighlighterColors.KEYWORD) ATTRIBUTES[FeakinTypes.IDENTIFIER] = DefaultLanguageHighlighterColors.IDENTIFIER + + ATTRIBUTES[FeakinTypes.COMMENT] = DefaultLanguageHighlighterColors.LINE_COMMENT; + ATTRIBUTES[FeakinTypes.CLOSE_BRACE] = DefaultLanguageHighlighterColors.BRACES; + ATTRIBUTES[FeakinTypes.OPEN_BRACE] = DefaultLanguageHighlighterColors.BRACES; + + ATTRIBUTES[FeakinTypes.STRING_LITERAL] = DefaultLanguageHighlighterColors.STRING; } } } \ No newline at end of file diff --git a/src/main/kotlin/com/feakin/intellij/highlight/FeakinTokenTypeSets.kt b/src/main/kotlin/com/feakin/intellij/highlight/FeakinTokenTypeSets.kt index 87df0b5..c25d839 100644 --- a/src/main/kotlin/com/feakin/intellij/highlight/FeakinTokenTypeSets.kt +++ b/src/main/kotlin/com/feakin/intellij/highlight/FeakinTokenTypeSets.kt @@ -4,9 +4,11 @@ import com.feakin.intellij.lexer.FeakinTypes import com.intellij.psi.tree.TokenSet object FeakinTokenTypeSets { - var KEY_WORDS = TokenSet - .create( - FeakinTypes.CONTEXT_KEYWORD, - FeakinTypes.CONTEXT_MAP_KEYWORD - ) + var KEY_WORDS = TokenSet.create( + FeakinTypes.CONTEXT_KEYWORD, + FeakinTypes.CONTEXT_MAP_KEYWORD, + FeakinTypes.ENTITY_KEYWORD, + FeakinTypes.AGGREGATION_KEYWORD, + FeakinTypes.VALUE_OBJECT_KEYWORD, + ) } \ No newline at end of file diff --git a/src/main/kotlin/com/feakin/intellij/highlight/FkSyntaxHighlighterColors.kt b/src/main/kotlin/com/feakin/intellij/highlight/FkSyntaxHighlighterColors.kt new file mode 100644 index 0000000..647e6d0 --- /dev/null +++ b/src/main/kotlin/com/feakin/intellij/highlight/FkSyntaxHighlighterColors.kt @@ -0,0 +1,11 @@ +package com.feakin.intellij.highlight + + +import com.intellij.openapi.editor.colors.TextAttributesKey +import com.intellij.openapi.util.NlsContexts.AttributeDescriptor +import java.util.function.Supplier + +@Suppress("UnstableApiUsage") +enum class FkSyntaxHighlighterColors(humanName: Supplier<@AttributeDescriptor String>, default: TextAttributesKey? = null) { +// todos +} \ No newline at end of file diff --git a/src/main/kotlin/com/feakin/intellij/lexer/_FeakinLexer.flex b/src/main/kotlin/com/feakin/intellij/lexer/_FeakinLexer.flex index eacd533..e2d5ad2 100644 --- a/src/main/kotlin/com/feakin/intellij/lexer/_FeakinLexer.flex +++ b/src/main/kotlin/com/feakin/intellij/lexer/_FeakinLexer.flex @@ -34,8 +34,25 @@ STRING_LITERAL=\"([^\\\"\r\n]|\\[^\r\n])*\"? { {WHITE_SPACE} { return WHITE_SPACE; } + "," { return COMMA; } + ":" { return COLON; } + "::" { return DOUBLE_COLON; } + ";" { return SEMICOLON; } + "{" { return OPEN_BRACE; } + "}" { return CLOSE_BRACE; } + "=" { return EQUAL; } + "'" { return QUOTA; } + "(" { return LPAREN; } + ")" { return RPAREN; } + "->" { return RARROW; } + "<-" { return LARROW; } + "<->" { return DARROW; } "ContextMap" { return CONTEXT_MAP_KEYWORD; } "Context" { return CONTEXT_KEYWORD; } + "Aggregate" { return AGGREGATION_KEYWORD; } + "Entity" { return ENTITY_KEYWORD; } + "ValueObject" { return VALUE_OBJECT_KEYWORD; } + "Struct" { return STRUCT_KEYWORD; } {COMMENT} { return COMMENT; } {BLOCK_COMMENT} { return BLOCK_COMMENT; } diff --git a/src/main/kotlin/com/feakin/intellij/structure/FeakinStructureViewFactory.kt b/src/main/kotlin/com/feakin/intellij/structure/FeakinStructureViewFactory.kt index 3cea483..438958e 100644 --- a/src/main/kotlin/com/feakin/intellij/structure/FeakinStructureViewFactory.kt +++ b/src/main/kotlin/com/feakin/intellij/structure/FeakinStructureViewFactory.kt @@ -8,7 +8,7 @@ import com.intellij.openapi.editor.Editor import com.intellij.psi.PsiFile class FeakinStructureViewFactory : PsiStructureViewFactory { - override fun getStructureViewBuilder(psiFile: PsiFile): StructureViewBuilder? { + override fun getStructureViewBuilder(psiFile: PsiFile): StructureViewBuilder { return object : TreeBasedStructureViewBuilder() { override fun createStructureViewModel(editor: Editor?): StructureViewModel { return FeakinStructureViewModel(psiFile) diff --git a/src/main/kotlin/com/feakin/intellij/structure/FeakinStructureViewModel.kt b/src/main/kotlin/com/feakin/intellij/structure/FeakinStructureViewModel.kt index c6dc54f..1d36af2 100644 --- a/src/main/kotlin/com/feakin/intellij/structure/FeakinStructureViewModel.kt +++ b/src/main/kotlin/com/feakin/intellij/structure/FeakinStructureViewModel.kt @@ -22,8 +22,8 @@ class FeakinStructureViewModel(psiFile: PsiFile) : StructureViewModelBase(psiFil override fun isAlwaysLeaf(element: StructureViewTreeElement): Boolean { when (element.value) { is FeakinContextDeclaration, - is FeakinContextMapDeclaration -> return false - else -> return true + is FeakinContextMapDeclaration -> return true + else -> return false } } } \ No newline at end of file