diff --git a/build.gradle.kts b/build.gradle.kts index f4454ea..3ac69df 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -25,6 +25,8 @@ dependencies { } } +sourceSets["main"].java.srcDirs("gen") + tasks { withType { sourceCompatibility = "21" diff --git a/flex/idea-flex.skeleton b/flex/idea-flex.skeleton new file mode 100644 index 0000000..f100c0d --- /dev/null +++ b/flex/idea-flex.skeleton @@ -0,0 +1,240 @@ + + /** This character denotes the end of file */ + public static final int YYEOF = -1; + + /** initial size of the lookahead buffer */ +--- private static final int ZZ_BUFFERSIZE = ...; + + /** lexical states */ +--- lexical states, charmap + + /* error codes */ + private static final int ZZ_UNKNOWN_ERROR = 0; + private static final int ZZ_NO_MATCH = 1; + private static final int ZZ_PUSHBACK_2BIG = 2; + + /* error messages for the codes above */ + private static final String[] ZZ_ERROR_MSG = { + "Unknown internal scanner error", + "Error: could not match input", + "Error: pushback value was too large" + }; + +--- isFinal list + /** the input device */ + private java.io.Reader zzReader; + + /** the current state of the DFA */ + private int zzState; + + /** the current lexical state */ + private int zzLexicalState = YYINITIAL; + + /** this buffer contains the current text to be matched and is + the source of the yytext() string */ + private CharSequence zzBuffer = ""; + + /** the textposition at the last accepting state */ + private int zzMarkedPos; + + /** the current text position in the buffer */ + private int zzCurrentPos; + + /** startRead marks the beginning of the yytext() string in the buffer */ + private int zzStartRead; + + /** endRead marks the last character in the buffer, that has been read + from input */ + private int zzEndRead; + + /** zzAtEOF == true <=> the scanner is at the EOF */ + private boolean zzAtEOF; + +--- user class code + +--- constructor declaration + + public final int getTokenStart() { + return zzStartRead; + } + + public final int getTokenEnd() { + return getTokenStart() + yylength(); + } + + public void reset(CharSequence buffer, int start, int end, int initialState) { + zzBuffer = buffer; + zzCurrentPos = zzMarkedPos = zzStartRead = start; + zzAtEOF = false; + zzAtBOL = true; + zzEndRead = end; + yybegin(initialState); + } + + /** + * Refills the input buffer. + * + * @return {@code false}, iff there was new input. + * + * @exception java.io.IOException if any I/O-Error occurs + */ + private boolean zzRefill() throws java.io.IOException { + return true; + } + + + /** + * Returns the current lexical state. + */ + public final int yystate() { + return zzLexicalState; + } + + + /** + * Enters a new lexical state + * + * @param newState the new lexical state + */ + public final void yybegin(int newState) { + zzLexicalState = newState; + } + + + /** + * Returns the text matched by the current regular expression. + */ + public final CharSequence yytext() { + return zzBuffer.subSequence(zzStartRead, zzMarkedPos); + } + + + /** + * Returns the character at position {@code pos} from the + * matched text. + * + * It is equivalent to yytext().charAt(pos), but faster + * + * @param pos the position of the character to fetch. + * A value from 0 to yylength()-1. + * + * @return the character at position pos + */ + public final char yycharat(int pos) { + return zzBuffer.charAt(zzStartRead+pos); + } + + + /** + * Returns the length of the matched text region. + */ + public final int yylength() { + return zzMarkedPos-zzStartRead; + } + + + /** + * Reports an error that occurred while scanning. + * + * In a wellformed scanner (no or only correct usage of + * yypushback(int) and a match-all fallback rule) this method + * will only be called with things that "Can't Possibly Happen". + * If this method is called, something is seriously wrong + * (e.g. a JFlex bug producing a faulty scanner etc.). + * + * Usual syntax/scanner level error handling should be done + * in error fallback rules. + * + * @param errorCode the code of the errormessage to display + */ +--- zzScanError declaration + String message; + try { + message = ZZ_ERROR_MSG[errorCode]; + } + catch (ArrayIndexOutOfBoundsException e) { + message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; + } + +--- throws clause + } + + + /** + * Pushes the specified amount of characters back into the input stream. + * + * They will be read again by then next call of the scanning method + * + * @param number the number of characters to be read again. + * This number must not be greater than yylength()! + */ +--- yypushback decl (contains zzScanError exception) + if ( number > yylength() ) + zzScanError(ZZ_PUSHBACK_2BIG); + + zzMarkedPos -= number; + } + + +--- zzDoEOF + /** + * Resumes scanning until the next regular expression is matched, + * the end of input is encountered or an I/O-Error occurs. + * + * @return the next token + * @exception java.io.IOException if any I/O-Error occurs + */ +--- yylex declaration + int zzInput; + int zzAction; + + // cached fields: + int zzCurrentPosL; + int zzMarkedPosL; + int zzEndReadL = zzEndRead; + CharSequence zzBufferL = zzBuffer; + +--- local declarations + + while (true) { + zzMarkedPosL = zzMarkedPos; + +--- start admin (line, char, col count) + zzAction = -1; + + zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; + +--- start admin (lexstate etc) + + zzForAction: { + while (true) { + +--- next input, line, col, char count, next transition, isFinal action + zzAction = zzState; + zzMarkedPosL = zzCurrentPosL; +--- line count update + } + + } + } + + // store back cached position + zzMarkedPos = zzMarkedPosL; +--- char count update + + if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { + zzAtEOF = true; +--- eofvalue + } + else { +--- actions + default: +--- no match + } + } + } + } + +--- main + +} diff --git a/flex/jflex-1.9.1.jar b/flex/jflex-1.9.1.jar new file mode 100644 index 0000000..544ae1a Binary files /dev/null and b/flex/jflex-1.9.1.jar differ diff --git a/gen/jp/s6n/idea/typespec/lang/parser/TypeSpecParser.java b/gen/jp/s6n/idea/typespec/lang/parser/TypeSpecParser.java new file mode 100644 index 0000000..a80d95f --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/parser/TypeSpecParser.java @@ -0,0 +1,741 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.parser; + +import com.intellij.lang.PsiBuilder; +import com.intellij.lang.PsiBuilder.Marker; +import static jp.s6n.idea.typespec.lang.psi.TypeSpecElementTypes.*; +import static jp.s6n.idea.typespec.lang.parser.TypeSpecParserUtil.*; +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 TypeSpecParser 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, EXTENDS_SETS_); + 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 File(b, l + 1); + } + + public static final TokenSet[] EXTENDS_SETS_ = new TokenSet[] { + create_token_set_(EXPRESSION, LITERAL_EXPRESSION, OBJECT_EXPRESSION, PATH_EXPRESSION), + create_token_set_(ARRAY_TYPE, LITERAL_TYPE, PATH_TYPE, TYPE, + UNION_TYPE), + }; + + /* ********************************************************** */ + // LPAREN [Expression (COMMA Expression)*] RPAREN + public static boolean ArgumentsList(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ArgumentsList")) return false; + if (!nextTokenIs(b, LPAREN)) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeToken(b, LPAREN); + r = r && ArgumentsList_1(b, l + 1); + r = r && consumeToken(b, RPAREN); + exit_section_(b, m, ARGUMENTS_LIST, r); + return r; + } + + // [Expression (COMMA Expression)*] + private static boolean ArgumentsList_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ArgumentsList_1")) return false; + ArgumentsList_1_0(b, l + 1); + return true; + } + + // Expression (COMMA Expression)* + private static boolean ArgumentsList_1_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ArgumentsList_1_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = Expression(b, l + 1); + r = r && ArgumentsList_1_0_1(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + // (COMMA Expression)* + private static boolean ArgumentsList_1_0_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ArgumentsList_1_0_1")) return false; + while (true) { + int c = current_position_(b); + if (!ArgumentsList_1_0_1_0(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "ArgumentsList_1_0_1", c)) break; + } + return true; + } + + // COMMA Expression + private static boolean ArgumentsList_1_0_1_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ArgumentsList_1_0_1_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeToken(b, COMMA); + r = r && Expression(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + /* ********************************************************** */ + // AT PathExpression ArgumentsList? + public static boolean Decorator(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Decorator")) return false; + if (!nextTokenIs(b, AT)) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeToken(b, AT); + r = r && PathExpression(b, l + 1); + r = r && Decorator_2(b, l + 1); + exit_section_(b, m, DECORATOR, r); + return r; + } + + // ArgumentsList? + private static boolean Decorator_2(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Decorator_2")) return false; + ArgumentsList(b, l + 1); + return true; + } + + /* ********************************************************** */ + // ObjectExpression + // | PathExpression + // | LiteralExpression + public static boolean Expression(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Expression")) return false; + boolean r; + Marker m = enter_section_(b, l, _COLLAPSE_, EXPRESSION, ""); + r = ObjectExpression(b, l + 1); + if (!r) r = PathExpression(b, l + 1); + if (!r) r = LiteralExpression(b, l + 1); + exit_section_(b, l, m, r, false, null); + return r; + } + + /* ********************************************************** */ + // Statement* + static boolean File(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "File")) return false; + while (true) { + int c = current_position_(b); + if (!Statement(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "File", c)) break; + } + return true; + } + + /* ********************************************************** */ + // IDENTIFIER + static boolean Identifier(PsiBuilder b, int l) { + return consumeToken(b, IDENTIFIER); + } + + /* ********************************************************** */ + // IMPORT STRING_LITERAL SEMICOLON + public static boolean ImportStatement(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ImportStatement")) return false; + if (!nextTokenIs(b, IMPORT)) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeTokens(b, 0, IMPORT, STRING_LITERAL, SEMICOLON); + exit_section_(b, m, IMPORT_STATEMENT, r); + return r; + } + + /* ********************************************************** */ + // Decorator* Operation SEMICOLON + public static boolean InterfaceOperation(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "InterfaceOperation")) return false; + if (!nextTokenIs(b, "", AT, IDENTIFIER)) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, INTERFACE_OPERATION, ""); + r = InterfaceOperation_0(b, l + 1); + r = r && Operation(b, l + 1); + r = r && consumeToken(b, SEMICOLON); + exit_section_(b, l, m, r, false, null); + return r; + } + + // Decorator* + private static boolean InterfaceOperation_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "InterfaceOperation_0")) return false; + while (true) { + int c = current_position_(b); + if (!Decorator(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "InterfaceOperation_0", c)) break; + } + return true; + } + + /* ********************************************************** */ + // LBRACE InterfaceOperation* RBRACE + static boolean InterfaceOperationsBlock(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "InterfaceOperationsBlock")) return false; + if (!nextTokenIs(b, LBRACE)) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeToken(b, LBRACE); + r = r && InterfaceOperationsBlock_1(b, l + 1); + r = r && consumeToken(b, RBRACE); + exit_section_(b, m, null, r); + return r; + } + + // InterfaceOperation* + private static boolean InterfaceOperationsBlock_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "InterfaceOperationsBlock_1")) return false; + while (true) { + int c = current_position_(b); + if (!InterfaceOperation(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "InterfaceOperationsBlock_1", c)) break; + } + return true; + } + + /* ********************************************************** */ + // Decorator* INTERFACE Identifier InterfaceOperationsBlock + public static boolean InterfaceStatement(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "InterfaceStatement")) return false; + if (!nextTokenIs(b, "", AT, INTERFACE)) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, INTERFACE_STATEMENT, ""); + r = InterfaceStatement_0(b, l + 1); + r = r && consumeToken(b, INTERFACE); + r = r && Identifier(b, l + 1); + r = r && InterfaceOperationsBlock(b, l + 1); + exit_section_(b, l, m, r, false, null); + return r; + } + + // Decorator* + private static boolean InterfaceStatement_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "InterfaceStatement_0")) return false; + while (true) { + int c = current_position_(b); + if (!Decorator(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "InterfaceStatement_0", c)) break; + } + return true; + } + + /* ********************************************************** */ + // STRING_LITERAL | NUMERIC_LITERAL + public static boolean LiteralExpression(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "LiteralExpression")) return false; + if (!nextTokenIs(b, "", NUMERIC_LITERAL, STRING_LITERAL)) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, LITERAL_EXPRESSION, ""); + r = consumeToken(b, STRING_LITERAL); + if (!r) r = consumeToken(b, NUMERIC_LITERAL); + exit_section_(b, l, m, r, false, null); + return r; + } + + /* ********************************************************** */ + // LBRACE ModelProperty* RBRACE + static boolean ModelPropertiesBlock(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ModelPropertiesBlock")) return false; + if (!nextTokenIs(b, LBRACE)) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeToken(b, LBRACE); + r = r && ModelPropertiesBlock_1(b, l + 1); + r = r && consumeToken(b, RBRACE); + exit_section_(b, m, null, r); + return r; + } + + // ModelProperty* + private static boolean ModelPropertiesBlock_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ModelPropertiesBlock_1")) return false; + while (true) { + int c = current_position_(b); + if (!ModelProperty(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "ModelPropertiesBlock_1", c)) break; + } + return true; + } + + /* ********************************************************** */ + // Decorator* Identifier QUEST? COLON Type SEMICOLON + public static boolean ModelProperty(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ModelProperty")) return false; + if (!nextTokenIs(b, "", AT, IDENTIFIER)) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, MODEL_PROPERTY, ""); + r = ModelProperty_0(b, l + 1); + r = r && Identifier(b, l + 1); + r = r && ModelProperty_2(b, l + 1); + r = r && consumeToken(b, COLON); + r = r && Type(b, l + 1, -1); + r = r && consumeToken(b, SEMICOLON); + exit_section_(b, l, m, r, false, null); + return r; + } + + // Decorator* + private static boolean ModelProperty_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ModelProperty_0")) return false; + while (true) { + int c = current_position_(b); + if (!Decorator(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "ModelProperty_0", c)) break; + } + return true; + } + + // QUEST? + private static boolean ModelProperty_2(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ModelProperty_2")) return false; + consumeToken(b, QUEST); + return true; + } + + /* ********************************************************** */ + // Decorator* MODEL Identifier ModelPropertiesBlock + public static boolean ModelStatement(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ModelStatement")) return false; + if (!nextTokenIs(b, "", AT, MODEL)) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, MODEL_STATEMENT, ""); + r = ModelStatement_0(b, l + 1); + r = r && consumeToken(b, MODEL); + r = r && Identifier(b, l + 1); + r = r && ModelPropertiesBlock(b, l + 1); + exit_section_(b, l, m, r, false, null); + return r; + } + + // Decorator* + private static boolean ModelStatement_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ModelStatement_0")) return false; + while (true) { + int c = current_position_(b); + if (!Decorator(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "ModelStatement_0", c)) break; + } + return true; + } + + /* ********************************************************** */ + // Decorator* Identifier COLON Type + public static boolean NamedArgument(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "NamedArgument")) return false; + if (!nextTokenIs(b, "", AT, IDENTIFIER)) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, NAMED_ARGUMENT, ""); + r = NamedArgument_0(b, l + 1); + r = r && Identifier(b, l + 1); + r = r && consumeToken(b, COLON); + r = r && Type(b, l + 1, -1); + exit_section_(b, l, m, r, false, null); + return r; + } + + // Decorator* + private static boolean NamedArgument_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "NamedArgument_0")) return false; + while (true) { + int c = current_position_(b); + if (!Decorator(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "NamedArgument_0", c)) break; + } + return true; + } + + /* ********************************************************** */ + // Decorator* NAMESPACE Path (SEMICOLON | LBRACE Statement* RBRACE) + public static boolean NamespaceStatement(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "NamespaceStatement")) return false; + if (!nextTokenIs(b, "", AT, NAMESPACE)) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, NAMESPACE_STATEMENT, ""); + r = NamespaceStatement_0(b, l + 1); + r = r && consumeToken(b, NAMESPACE); + r = r && Path(b, l + 1); + r = r && NamespaceStatement_3(b, l + 1); + exit_section_(b, l, m, r, false, null); + return r; + } + + // Decorator* + private static boolean NamespaceStatement_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "NamespaceStatement_0")) return false; + while (true) { + int c = current_position_(b); + if (!Decorator(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "NamespaceStatement_0", c)) break; + } + return true; + } + + // SEMICOLON | LBRACE Statement* RBRACE + private static boolean NamespaceStatement_3(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "NamespaceStatement_3")) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeToken(b, SEMICOLON); + if (!r) r = NamespaceStatement_3_1(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + // LBRACE Statement* RBRACE + private static boolean NamespaceStatement_3_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "NamespaceStatement_3_1")) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeToken(b, LBRACE); + r = r && NamespaceStatement_3_1_1(b, l + 1); + r = r && consumeToken(b, RBRACE); + exit_section_(b, m, null, r); + return r; + } + + // Statement* + private static boolean NamespaceStatement_3_1_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "NamespaceStatement_3_1_1")) return false; + while (true) { + int c = current_position_(b); + if (!Statement(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "NamespaceStatement_3_1_1", c)) break; + } + return true; + } + + /* ********************************************************** */ + // LBRACE [ObjectExpressionProperty (COMMA ObjectExpressionProperty)* COMMA?] RBRACE + public static boolean ObjectExpression(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ObjectExpression")) return false; + if (!nextTokenIs(b, LBRACE)) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeToken(b, LBRACE); + r = r && ObjectExpression_1(b, l + 1); + r = r && consumeToken(b, RBRACE); + exit_section_(b, m, OBJECT_EXPRESSION, r); + return r; + } + + // [ObjectExpressionProperty (COMMA ObjectExpressionProperty)* COMMA?] + private static boolean ObjectExpression_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ObjectExpression_1")) return false; + ObjectExpression_1_0(b, l + 1); + return true; + } + + // ObjectExpressionProperty (COMMA ObjectExpressionProperty)* COMMA? + private static boolean ObjectExpression_1_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ObjectExpression_1_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = ObjectExpressionProperty(b, l + 1); + r = r && ObjectExpression_1_0_1(b, l + 1); + r = r && ObjectExpression_1_0_2(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + // (COMMA ObjectExpressionProperty)* + private static boolean ObjectExpression_1_0_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ObjectExpression_1_0_1")) return false; + while (true) { + int c = current_position_(b); + if (!ObjectExpression_1_0_1_0(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "ObjectExpression_1_0_1", c)) break; + } + return true; + } + + // COMMA ObjectExpressionProperty + private static boolean ObjectExpression_1_0_1_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ObjectExpression_1_0_1_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeToken(b, COMMA); + r = r && ObjectExpressionProperty(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + // COMMA? + private static boolean ObjectExpression_1_0_2(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ObjectExpression_1_0_2")) return false; + consumeToken(b, COMMA); + return true; + } + + /* ********************************************************** */ + // Identifier COLON Expression + public static boolean ObjectExpressionProperty(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ObjectExpressionProperty")) return false; + if (!nextTokenIs(b, IDENTIFIER)) return false; + boolean r; + Marker m = enter_section_(b); + r = Identifier(b, l + 1); + r = r && consumeToken(b, COLON); + r = r && Expression(b, l + 1); + exit_section_(b, m, OBJECT_EXPRESSION_PROPERTY, r); + return r; + } + + /* ********************************************************** */ + // Identifier OperationArgumentList COLON Type + public static boolean Operation(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Operation")) return false; + if (!nextTokenIs(b, IDENTIFIER)) return false; + boolean r; + Marker m = enter_section_(b); + r = Identifier(b, l + 1); + r = r && OperationArgumentList(b, l + 1); + r = r && consumeToken(b, COLON); + r = r && Type(b, l + 1, -1); + exit_section_(b, m, OPERATION, r); + return r; + } + + /* ********************************************************** */ + // NamedArgument + // | VariadicArgument + public static boolean OperationArgument(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "OperationArgument")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, OPERATION_ARGUMENT, ""); + r = NamedArgument(b, l + 1); + if (!r) r = VariadicArgument(b, l + 1); + exit_section_(b, l, m, r, false, null); + return r; + } + + /* ********************************************************** */ + // LPAREN [OperationArgument (COMMA OperationArgument)*] RPAREN + public static boolean OperationArgumentList(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "OperationArgumentList")) return false; + if (!nextTokenIs(b, LPAREN)) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeToken(b, LPAREN); + r = r && OperationArgumentList_1(b, l + 1); + r = r && consumeToken(b, RPAREN); + exit_section_(b, m, OPERATION_ARGUMENT_LIST, r); + return r; + } + + // [OperationArgument (COMMA OperationArgument)*] + private static boolean OperationArgumentList_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "OperationArgumentList_1")) return false; + OperationArgumentList_1_0(b, l + 1); + return true; + } + + // OperationArgument (COMMA OperationArgument)* + private static boolean OperationArgumentList_1_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "OperationArgumentList_1_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = OperationArgument(b, l + 1); + r = r && OperationArgumentList_1_0_1(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + // (COMMA OperationArgument)* + private static boolean OperationArgumentList_1_0_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "OperationArgumentList_1_0_1")) return false; + while (true) { + int c = current_position_(b); + if (!OperationArgumentList_1_0_1_0(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "OperationArgumentList_1_0_1", c)) break; + } + return true; + } + + // COMMA OperationArgument + private static boolean OperationArgumentList_1_0_1_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "OperationArgumentList_1_0_1_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeToken(b, COMMA); + r = r && OperationArgument(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + /* ********************************************************** */ + // Identifier (DOT Identifier)* + public static boolean Path(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Path")) return false; + if (!nextTokenIs(b, IDENTIFIER)) return false; + boolean r; + Marker m = enter_section_(b); + r = Identifier(b, l + 1); + r = r && Path_1(b, l + 1); + exit_section_(b, m, PATH, r); + return r; + } + + // (DOT Identifier)* + private static boolean Path_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Path_1")) return false; + while (true) { + int c = current_position_(b); + if (!Path_1_0(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "Path_1", c)) break; + } + return true; + } + + // DOT Identifier + private static boolean Path_1_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Path_1_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeToken(b, DOT); + r = r && Identifier(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + /* ********************************************************** */ + // Path + public static boolean PathExpression(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "PathExpression")) return false; + if (!nextTokenIs(b, IDENTIFIER)) return false; + boolean r; + Marker m = enter_section_(b); + r = Path(b, l + 1); + exit_section_(b, m, PATH_EXPRESSION, r); + return r; + } + + /* ********************************************************** */ + // ImportStatement + // | UsingStatement + // | NamespaceStatement + // | ModelStatement + // | InterfaceStatement + static boolean Statement(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Statement")) return false; + boolean r; + r = ImportStatement(b, l + 1); + if (!r) r = UsingStatement(b, l + 1); + if (!r) r = NamespaceStatement(b, l + 1); + if (!r) r = ModelStatement(b, l + 1); + if (!r) r = InterfaceStatement(b, l + 1); + return r; + } + + /* ********************************************************** */ + // USING Path SEMICOLON + public static boolean UsingStatement(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "UsingStatement")) return false; + if (!nextTokenIs(b, USING)) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeToken(b, USING); + r = r && Path(b, l + 1); + r = r && consumeToken(b, SEMICOLON); + exit_section_(b, m, USING_STATEMENT, r); + return r; + } + + /* ********************************************************** */ + // DOTDOTDOT Identifier + public static boolean VariadicArgument(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "VariadicArgument")) return false; + if (!nextTokenIs(b, DOTDOTDOT)) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeToken(b, DOTDOTDOT); + r = r && Identifier(b, l + 1); + exit_section_(b, m, VARIADIC_ARGUMENT, r); + return r; + } + + /* ********************************************************** */ + // Expression root: Type + // Operator priority table: + // 0: N_ARY(UnionType) + // 1: POSTFIX(ArrayType) + // 2: ATOM(PathType) + // 3: ATOM(LiteralType) + public static boolean Type(PsiBuilder b, int l, int g) { + if (!recursion_guard_(b, l, "Type")) return false; + addVariant(b, ""); + boolean r, p; + Marker m = enter_section_(b, l, _NONE_, ""); + r = PathType(b, l + 1); + if (!r) r = LiteralType(b, l + 1); + p = r; + r = r && Type_0(b, l + 1, g); + exit_section_(b, l, m, null, r, p, null); + return r || p; + } + + public static boolean Type_0(PsiBuilder b, int l, int g) { + if (!recursion_guard_(b, l, "Type_0")) return false; + boolean r = true; + while (true) { + Marker m = enter_section_(b, l, _LEFT_, null); + if (g < 0 && consumeTokenSmart(b, PIPE)) { + while (true) { + r = report_error_(b, Type(b, l, 0)); + if (!consumeTokenSmart(b, PIPE)) break; + } + exit_section_(b, l, m, UNION_TYPE, r, true, null); + } + else if (g < 1 && parseTokensSmart(b, 0, LBRACKET, RBRACKET)) { + r = true; + exit_section_(b, l, m, ARRAY_TYPE, r, true, null); + } + else { + exit_section_(b, l, m, null, false, false, null); + break; + } + } + return r; + } + + // Path + public static boolean PathType(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "PathType")) return false; + if (!nextTokenIsSmart(b, IDENTIFIER)) return false; + boolean r; + Marker m = enter_section_(b); + r = Path(b, l + 1); + exit_section_(b, m, PATH_TYPE, r); + return r; + } + + // STRING_LITERAL | NUMERIC_LITERAL + public static boolean LiteralType(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "LiteralType")) return false; + if (!nextTokenIsSmart(b, NUMERIC_LITERAL, STRING_LITERAL)) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, LITERAL_TYPE, ""); + r = consumeTokenSmart(b, STRING_LITERAL); + if (!r) r = consumeTokenSmart(b, NUMERIC_LITERAL); + exit_section_(b, l, m, r, false, null); + return r; + } + +} diff --git a/gen/jp/s6n/idea/typespec/lang/parser/_TypeSpecLexer.java b/gen/jp/s6n/idea/typespec/lang/parser/_TypeSpecLexer.java new file mode 100644 index 0000000..a342209 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/parser/_TypeSpecLexer.java @@ -0,0 +1,742 @@ +// Generated by JFlex 1.9.1 http://jflex.de/ (tweaked for IntelliJ platform) +// source: _TypeSpecLexer.flex + +package jp.s6n.idea.typespec.lang.parser; + +import com.intellij.lexer.FlexLexer; +import com.intellij.psi.tree.IElementType; + +import static com.intellij.psi.TokenType.BAD_CHARACTER; +import static com.intellij.psi.TokenType.WHITE_SPACE; +import static jp.s6n.idea.typespec.lang.psi.TypeSpecElementTypes.*; + + +public class _TypeSpecLexer implements FlexLexer { + + /** This character denotes the end of file */ + public static final int YYEOF = -1; + + /** initial size of the lookahead buffer */ + private static final int ZZ_BUFFERSIZE = 16384; + + /** lexical states */ + public static final int YYINITIAL = 0; + + /** + * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l + * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l + * at the beginning of a line + * l is of the form l = 2*k, k a non negative integer + */ + private static final int ZZ_LEXSTATE[] = { + 0, 0 + }; + + /** + * Top-level table for translating characters to character classes + */ + private static final int [] ZZ_CMAP_TOP = zzUnpackcmap_top(); + + private static final String ZZ_CMAP_TOP_PACKED_0 = + "\1\0\37\u0100\1\u0200\267\u0100\10\u0300\u1020\u0100"; + + private static int [] zzUnpackcmap_top() { + int [] result = new int[4352]; + int offset = 0; + offset = zzUnpackcmap_top(ZZ_CMAP_TOP_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackcmap_top(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + + /** + * Second-level tables for translating characters to character classes + */ + private static final int [] ZZ_CMAP_BLOCKS = zzUnpackcmap_blocks(); + + private static final String ZZ_CMAP_BLOCKS_PACKED_0 = + "\11\0\1\1\1\2\2\3\1\2\22\0\1\1\1\4"+ + "\1\5\5\0\1\6\1\7\1\10\1\0\1\11\1\12"+ + "\1\13\1\14\12\15\1\16\1\17\1\0\1\20\1\0"+ + "\1\21\1\22\32\23\1\24\1\25\1\26\1\0\1\27"+ + "\1\30\1\31\1\23\1\32\1\33\1\34\1\35\1\36"+ + "\1\23\1\37\2\23\1\40\1\41\1\42\1\43\1\44"+ + "\1\23\1\45\1\46\1\47\1\50\5\23\1\51\1\52"+ + "\1\53\7\0\1\54\u01a2\0\2\54\326\0\u0100\54"; + + private static int [] zzUnpackcmap_blocks() { + int [] result = new int[1024]; + int offset = 0; + offset = zzUnpackcmap_blocks(ZZ_CMAP_BLOCKS_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackcmap_blocks(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + /** + * Translates DFA states to action switch labels. + */ + private static final int [] ZZ_ACTION = zzUnpackAction(); + + private static final String ZZ_ACTION_PACKED_0 = + "\1\0\1\1\1\2\1\3\1\4\1\5\1\6\1\7"+ + "\1\1\1\10\1\1\1\11\1\12\1\13\1\14\1\15"+ + "\1\16\1\17\1\20\1\21\1\1\4\17\1\22\1\23"+ + "\1\24\1\4\3\0\1\25\3\0\5\17\1\26\2\0"+ + "\1\11\7\17\3\0\1\27\5\17\1\27\1\0\1\30"+ + "\2\17\1\31\1\17\1\32\1\30\1\33\6\17\1\34"+ + "\1\35"; + + private static int [] zzUnpackAction() { + int [] result = new int[79]; + int offset = 0; + offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAction(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + + /** + * Translates a state to a row index in the transition table + */ + private static final int [] ZZ_ROWMAP = zzUnpackRowMap(); + + private static final String ZZ_ROWMAP_PACKED_0 = + "\0\0\0\55\0\132\0\55\0\207\0\55\0\55\0\55"+ + "\0\264\0\341\0\u010e\0\u013b\0\55\0\55\0\55\0\55"+ + "\0\55\0\u0168\0\55\0\55\0\u0195\0\u01c2\0\u01ef\0\u021c"+ + "\0\u0249\0\55\0\55\0\55\0\55\0\u0276\0\u02a3\0\u02d0"+ + "\0\u02fd\0\u032a\0\u0357\0\u0384\0\u03b1\0\u03de\0\u040b\0\u0438"+ + "\0\u0465\0\55\0\u0492\0\u04bf\0\u032a\0\55\0\u0357\0\u04ec"+ + "\0\u0519\0\u0546\0\u0573\0\u05a0\0\u05cd\0\u05fa\0\u0627\0\u05fa"+ + "\0\u0654\0\u0681\0\u06ae\0\u06db\0\u0708\0\55\0\u0735\0\u0492"+ + "\0\u0762\0\u078f\0\u0168\0\u07bc\0\u0168\0\55\0\u0168\0\u07e9"+ + "\0\u0816\0\u0843\0\u0870\0\u089d\0\u08ca\0\u0168\0\u0168"; + + private static int [] zzUnpackRowMap() { + int [] result = new int[79]; + int offset = 0; + offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackRowMap(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length() - 1; + while (i < l) { + int high = packed.charAt(i++) << 16; + result[j++] = high | packed.charAt(i++); + } + return j; + } + + /** + * The transition table of the DFA + */ + private static final int [] ZZ_TRANS = zzUnpacktrans(); + + private static final String ZZ_TRANS_PACKED_0 = + "\1\2\3\3\1\4\1\5\1\6\1\7\1\2\1\10"+ + "\1\11\1\12\1\13\1\14\1\15\1\16\1\17\1\20"+ + "\1\21\1\22\1\23\1\2\1\24\1\2\1\25\6\22"+ + "\1\26\1\22\1\27\1\30\5\22\1\31\1\32\1\33"+ + "\1\34\1\2\56\0\3\3\51\0\2\5\1\0\2\5"+ + "\1\35\17\5\1\36\27\5\15\0\1\14\52\0\1\37"+ + "\51\0\1\40\3\0\1\41\53\0\1\42\1\0\1\14"+ + "\51\0\1\22\2\0\1\22\5\0\1\22\3\0\1\22"+ + "\1\0\20\22\4\0\25\43\1\44\2\43\1\0\24\43"+ + "\12\0\1\22\2\0\1\22\5\0\1\22\3\0\1\22"+ + "\1\0\10\22\1\45\1\46\6\22\16\0\1\22\2\0"+ + "\1\22\5\0\1\22\3\0\1\22\1\0\12\22\1\47"+ + "\5\22\16\0\1\22\2\0\1\22\5\0\1\22\3\0"+ + "\1\22\1\0\1\50\17\22\16\0\1\22\2\0\1\22"+ + "\5\0\1\22\3\0\1\22\1\0\15\22\1\51\2\22"+ + "\4\0\2\5\1\0\52\5\13\0\1\52\41\0\10\53"+ + "\1\54\44\53\2\41\2\0\50\41\16\0\1\55\37\0"+ + "\25\43\1\44\2\43\1\56\51\43\1\44\2\43\1\57"+ + "\24\43\12\0\1\22\2\0\1\22\5\0\1\22\3\0"+ + "\1\22\1\0\13\22\1\60\4\22\16\0\1\22\2\0"+ + "\1\22\5\0\1\22\3\0\1\22\1\0\16\22\1\61"+ + "\1\22\16\0\1\22\2\0\1\22\5\0\1\22\3\0"+ + "\1\22\1\0\2\22\1\62\15\22\16\0\1\22\2\0"+ + "\1\22\5\0\1\22\3\0\1\22\1\0\10\22\1\63"+ + "\7\22\16\0\1\22\2\0\1\22\5\0\1\22\3\0"+ + "\1\22\1\0\6\22\1\64\11\22\4\0\10\53\1\65"+ + "\44\53\10\66\1\67\3\66\1\70\40\66\12\0\1\22"+ + "\2\0\1\22\5\0\1\22\3\0\1\22\1\0\12\22"+ + "\1\71\5\22\16\0\1\22\2\0\1\22\5\0\1\22"+ + "\3\0\1\22\1\0\3\22\1\72\14\22\16\0\1\22"+ + "\2\0\1\22\5\0\1\22\3\0\1\22\1\0\3\22"+ + "\1\73\14\22\16\0\1\22\2\0\1\22\5\0\1\22"+ + "\3\0\1\22\1\0\3\22\1\74\14\22\16\0\1\22"+ + "\2\0\1\22\5\0\1\22\3\0\1\22\1\0\11\22"+ + "\1\75\6\22\4\0\14\53\1\76\40\53\10\66\1\77"+ + "\54\66\1\54\3\66\1\100\40\66\12\0\1\22\2\0"+ + "\1\22\5\0\1\22\3\0\1\22\1\0\14\22\1\101"+ + "\3\22\16\0\1\22\2\0\1\22\5\0\1\22\3\0"+ + "\1\22\1\0\14\22\1\102\3\22\16\0\1\22\2\0"+ + "\1\22\5\0\1\22\3\0\1\22\1\0\7\22\1\103"+ + "\10\22\16\0\1\22\2\0\1\22\5\0\1\22\3\0"+ + "\1\22\1\0\15\22\1\104\2\22\16\0\1\22\2\0"+ + "\1\22\5\0\1\22\3\0\1\22\1\0\5\22\1\105"+ + "\12\22\4\0\14\66\1\106\40\66\12\0\1\22\2\0"+ + "\1\22\5\0\1\22\3\0\1\22\1\0\16\22\1\107"+ + "\1\22\16\0\1\22\2\0\1\22\5\0\1\22\3\0"+ + "\1\22\1\0\4\22\1\110\13\22\16\0\1\22\2\0"+ + "\1\22\5\0\1\22\3\0\1\22\1\0\13\22\1\111"+ + "\4\22\16\0\1\22\2\0\1\22\5\0\1\22\3\0"+ + "\1\22\1\0\1\112\17\22\16\0\1\22\2\0\1\22"+ + "\5\0\1\22\3\0\1\22\1\0\1\113\17\22\16\0"+ + "\1\22\2\0\1\22\5\0\1\22\3\0\1\22\1\0"+ + "\1\22\1\114\16\22\16\0\1\22\2\0\1\22\5\0"+ + "\1\22\3\0\1\22\1\0\1\22\1\115\16\22\16\0"+ + "\1\22\2\0\1\22\5\0\1\22\3\0\1\22\1\0"+ + "\3\22\1\116\14\22\16\0\1\22\2\0\1\22\5\0"+ + "\1\22\3\0\1\22\1\0\3\22\1\117\14\22\4\0"; + + private static int [] zzUnpacktrans() { + int [] result = new int[2295]; + int offset = 0; + offset = zzUnpacktrans(ZZ_TRANS_PACKED_0, offset, result); + return result; + } + + private static int zzUnpacktrans(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + value--; + do result[j++] = value; while (--count > 0); + } + return j; + } + + + /* error codes */ + private static final int ZZ_UNKNOWN_ERROR = 0; + private static final int ZZ_NO_MATCH = 1; + private static final int ZZ_PUSHBACK_2BIG = 2; + + /* error messages for the codes above */ + private static final String[] ZZ_ERROR_MSG = { + "Unknown internal scanner error", + "Error: could not match input", + "Error: pushback value was too large" + }; + + /** + * ZZ_ATTRIBUTE[aState] contains the attributes of state {@code aState} + */ + private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); + + private static final String ZZ_ATTRIBUTE_PACKED_0 = + "\1\0\1\11\1\1\1\11\1\1\3\11\4\1\5\11"+ + "\1\1\2\11\5\1\4\11\3\0\1\1\3\0\5\1"+ + "\1\11\2\0\1\1\1\11\6\1\3\0\6\1\1\11"+ + "\1\0\6\1\1\11\11\1"; + + private static int [] zzUnpackAttribute() { + int [] result = new int[79]; + int offset = 0; + offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAttribute(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + /** the input device */ + private java.io.Reader zzReader; + + /** the current state of the DFA */ + private int zzState; + + /** the current lexical state */ + private int zzLexicalState = YYINITIAL; + + /** this buffer contains the current text to be matched and is + the source of the yytext() string */ + private CharSequence zzBuffer = ""; + + /** the textposition at the last accepting state */ + private int zzMarkedPos; + + /** the current text position in the buffer */ + private int zzCurrentPos; + + /** startRead marks the beginning of the yytext() string in the buffer */ + private int zzStartRead; + + /** endRead marks the last character in the buffer, that has been read + from input */ + private int zzEndRead; + + /** zzAtEOF == true <=> the scanner is at the EOF */ + private boolean zzAtEOF; + + /** Number of newlines encountered up to the start of the matched text. */ + @SuppressWarnings("unused") + private int yyline; + + /** Number of characters from the last newline up to the start of the matched text. */ + @SuppressWarnings("unused") + protected int yycolumn; + + /** Number of characters up to the start of the matched text. */ + @SuppressWarnings("unused") + private long yychar; + + /** Whether the scanner is currently at the beginning of a line. */ + @SuppressWarnings("unused") + private boolean zzAtBOL = true; + + /** Whether the user-EOF-code has already been executed. */ + @SuppressWarnings("unused") + private boolean zzEOFDone; + + /* user code: */ + public _TypeSpecLexer() { + this((java.io.Reader)null); + } + + + /** + * Creates a new scanner + * + * @param in the java.io.Reader to read input from. + */ + public _TypeSpecLexer(java.io.Reader in) { + this.zzReader = in; + } + + + /** Returns the maximum size of the scanner buffer, which limits the size of tokens. */ + private int zzMaxBufferLen() { + return Integer.MAX_VALUE; + } + + /** Whether the scanner buffer can grow to accommodate a larger token. */ + private boolean zzCanGrow() { + return true; + } + + /** + * Translates raw input code points to DFA table row + */ + private static int zzCMap(int input) { + int offset = input & 255; + return offset == input ? ZZ_CMAP_BLOCKS[offset] : ZZ_CMAP_BLOCKS[ZZ_CMAP_TOP[input >> 8] | offset]; + } + + public final int getTokenStart() { + return zzStartRead; + } + + public final int getTokenEnd() { + return getTokenStart() + yylength(); + } + + public void reset(CharSequence buffer, int start, int end, int initialState) { + zzBuffer = buffer; + zzCurrentPos = zzMarkedPos = zzStartRead = start; + zzAtEOF = false; + zzAtBOL = true; + zzEndRead = end; + yybegin(initialState); + } + + /** + * Refills the input buffer. + * + * @return {@code false}, iff there was new input. + * + * @exception java.io.IOException if any I/O-Error occurs + */ + private boolean zzRefill() throws java.io.IOException { + return true; + } + + + /** + * Returns the current lexical state. + */ + public final int yystate() { + return zzLexicalState; + } + + + /** + * Enters a new lexical state + * + * @param newState the new lexical state + */ + public final void yybegin(int newState) { + zzLexicalState = newState; + } + + + /** + * Returns the text matched by the current regular expression. + */ + public final CharSequence yytext() { + return zzBuffer.subSequence(zzStartRead, zzMarkedPos); + } + + + /** + * Returns the character at position {@code pos} from the + * matched text. + * + * It is equivalent to yytext().charAt(pos), but faster + * + * @param pos the position of the character to fetch. + * A value from 0 to yylength()-1. + * + * @return the character at position pos + */ + public final char yycharat(int pos) { + return zzBuffer.charAt(zzStartRead+pos); + } + + + /** + * Returns the length of the matched text region. + */ + public final int yylength() { + return zzMarkedPos-zzStartRead; + } + + + /** + * Reports an error that occurred while scanning. + * + * In a wellformed scanner (no or only correct usage of + * yypushback(int) and a match-all fallback rule) this method + * will only be called with things that "Can't Possibly Happen". + * If this method is called, something is seriously wrong + * (e.g. a JFlex bug producing a faulty scanner etc.). + * + * Usual syntax/scanner level error handling should be done + * in error fallback rules. + * + * @param errorCode the code of the errormessage to display + */ + private void zzScanError(int errorCode) { + String message; + try { + message = ZZ_ERROR_MSG[errorCode]; + } + catch (ArrayIndexOutOfBoundsException e) { + message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; + } + + throw new Error(message); + } + + + /** + * Pushes the specified amount of characters back into the input stream. + * + * They will be read again by then next call of the scanning method + * + * @param number the number of characters to be read again. + * This number must not be greater than yylength()! + */ + public void yypushback(int number) { + if ( number > yylength() ) + zzScanError(ZZ_PUSHBACK_2BIG); + + zzMarkedPos -= number; + } + + + /** + * Resumes scanning until the next regular expression is matched, + * the end of input is encountered or an I/O-Error occurs. + * + * @return the next token + * @exception java.io.IOException if any I/O-Error occurs + */ + public IElementType advance() throws java.io.IOException + { + int zzInput; + int zzAction; + + // cached fields: + int zzCurrentPosL; + int zzMarkedPosL; + int zzEndReadL = zzEndRead; + CharSequence zzBufferL = zzBuffer; + + int [] zzTransL = ZZ_TRANS; + int [] zzRowMapL = ZZ_ROWMAP; + int [] zzAttrL = ZZ_ATTRIBUTE; + + while (true) { + zzMarkedPosL = zzMarkedPos; + + zzAction = -1; + + zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; + + zzState = ZZ_LEXSTATE[zzLexicalState]; + + // set up zzAction for empty match case: + int zzAttributes = zzAttrL[zzState]; + if ( (zzAttributes & 1) == 1 ) { + zzAction = zzState; + } + + + zzForAction: { + while (true) { + + if (zzCurrentPosL < zzEndReadL) { + zzInput = Character.codePointAt(zzBufferL, zzCurrentPosL); + zzCurrentPosL += Character.charCount(zzInput); + } + else if (zzAtEOF) { + zzInput = YYEOF; + break zzForAction; + } + else { + // store back cached positions + zzCurrentPos = zzCurrentPosL; + zzMarkedPos = zzMarkedPosL; + boolean eof = zzRefill(); + // get translated positions and possibly new buffer + zzCurrentPosL = zzCurrentPos; + zzMarkedPosL = zzMarkedPos; + zzBufferL = zzBuffer; + zzEndReadL = zzEndRead; + if (eof) { + zzInput = YYEOF; + break zzForAction; + } + else { + zzInput = Character.codePointAt(zzBufferL, zzCurrentPosL); + zzCurrentPosL += Character.charCount(zzInput); + } + } + int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMap(zzInput) ]; + if (zzNext == -1) break zzForAction; + zzState = zzNext; + + zzAttributes = zzAttrL[zzState]; + if ( (zzAttributes & 1) == 1 ) { + zzAction = zzState; + zzMarkedPosL = zzCurrentPosL; + if ( (zzAttributes & 8) == 8 ) break zzForAction; + } + + } + } + + // store back cached position + zzMarkedPos = zzMarkedPosL; + + if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { + zzAtEOF = true; + return null; + } + else { + switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { + case 1: + { return BAD_CHARACTER; + } + // fall through + case 30: break; + case 2: + { return WHITE_SPACE; + } + // fall through + case 31: break; + case 3: + { return EXCL; + } + // fall through + case 32: break; + case 4: + { return STRING_LITERAL; + } + // fall through + case 33: break; + case 5: + { return LPAREN; + } + // fall through + case 34: break; + case 6: + { return RPAREN; + } + // fall through + case 35: break; + case 7: + { return COMMA; + } + // fall through + case 36: break; + case 8: + { return DOT; + } + // fall through + case 37: break; + case 9: + { return NUMERIC_LITERAL; + } + // fall through + case 38: break; + case 10: + { return COLON; + } + // fall through + case 39: break; + case 11: + { return SEMICOLON; + } + // fall through + case 40: break; + case 12: + { return EQ; + } + // fall through + case 41: break; + case 13: + { return QUEST; + } + // fall through + case 42: break; + case 14: + { return AT; + } + // fall through + case 43: break; + case 15: + { return IDENTIFIER; + } + // fall through + case 44: break; + case 16: + { return LBRACKET; + } + // fall through + case 45: break; + case 17: + { return RBRACKET; + } + // fall through + case 46: break; + case 18: + { return LBRACE; + } + // fall through + case 47: break; + case 19: + { return PIPE; + } + // fall through + case 48: break; + case 20: + { return RBRACE; + } + // fall through + case 49: break; + case 21: + { return LINE_COMMENT; + } + // fall through + case 50: break; + case 22: + { return DOTDOTDOT; + } + // fall through + case 51: break; + case 23: + { return BLOCK_COMMENT; + } + // fall through + case 52: break; + case 24: + { return DOC_COMMENT; + } + // fall through + case 53: break; + case 25: + { return MODEL; + } + // fall through + case 54: break; + case 26: + { return USING; + } + // fall through + case 55: break; + case 27: + { return IMPORT; + } + // fall through + case 56: break; + case 28: + { return INTERFACE; + } + // fall through + case 57: break; + case 29: + { return NAMESPACE; + } + // fall through + case 58: break; + default: + zzScanError(ZZ_NO_MATCH); + } + } + } + } + + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecArgumentsList.java b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecArgumentsList.java new file mode 100644 index 0000000..972e116 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecArgumentsList.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface TypeSpecArgumentsList extends TypeSpecElement { + + @NotNull + List getExpressionList(); + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecArrayType.java b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecArrayType.java new file mode 100644 index 0000000..45bb109 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecArrayType.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface TypeSpecArrayType extends TypeSpecType { + + @NotNull + TypeSpecType getType(); + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecDecorator.java b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecDecorator.java new file mode 100644 index 0000000..8673498 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecDecorator.java @@ -0,0 +1,16 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface TypeSpecDecorator extends TypeSpecElement { + + @Nullable + TypeSpecArgumentsList getArgumentsList(); + + @NotNull + TypeSpecPathExpression getPathExpression(); + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecElementTypes.java b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecElementTypes.java new file mode 100644 index 0000000..0d3333f --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecElementTypes.java @@ -0,0 +1,140 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.psi; + +import com.intellij.psi.tree.IElementType; +import com.intellij.psi.PsiElement; +import com.intellij.lang.ASTNode; +import jp.s6n.idea.typespec.lang.psi.impl.*; + +public interface TypeSpecElementTypes { + + IElementType ARGUMENTS_LIST = new TypeSpecElementType("ARGUMENTS_LIST"); + IElementType ARRAY_TYPE = new TypeSpecElementType("ARRAY_TYPE"); + IElementType DECORATOR = new TypeSpecElementType("DECORATOR"); + IElementType EXPRESSION = new TypeSpecElementType("EXPRESSION"); + IElementType IMPORT_STATEMENT = new TypeSpecElementType("IMPORT_STATEMENT"); + IElementType INTERFACE_OPERATION = new TypeSpecElementType("INTERFACE_OPERATION"); + IElementType INTERFACE_STATEMENT = new TypeSpecElementType("INTERFACE_STATEMENT"); + IElementType LITERAL_EXPRESSION = new TypeSpecElementType("LITERAL_EXPRESSION"); + IElementType LITERAL_TYPE = new TypeSpecElementType("LITERAL_TYPE"); + IElementType MODEL_PROPERTY = new TypeSpecElementType("MODEL_PROPERTY"); + IElementType MODEL_STATEMENT = new TypeSpecElementType("MODEL_STATEMENT"); + IElementType NAMED_ARGUMENT = new TypeSpecElementType("NAMED_ARGUMENT"); + IElementType NAMESPACE_STATEMENT = new TypeSpecElementType("NAMESPACE_STATEMENT"); + IElementType OBJECT_EXPRESSION = new TypeSpecElementType("OBJECT_EXPRESSION"); + IElementType OBJECT_EXPRESSION_PROPERTY = new TypeSpecElementType("OBJECT_EXPRESSION_PROPERTY"); + IElementType OPERATION = new TypeSpecElementType("OPERATION"); + IElementType OPERATION_ARGUMENT = new TypeSpecElementType("OPERATION_ARGUMENT"); + IElementType OPERATION_ARGUMENT_LIST = new TypeSpecElementType("OPERATION_ARGUMENT_LIST"); + IElementType PATH = new TypeSpecElementType("PATH"); + IElementType PATH_EXPRESSION = new TypeSpecElementType("PATH_EXPRESSION"); + IElementType PATH_TYPE = new TypeSpecElementType("PATH_TYPE"); + IElementType TYPE = new TypeSpecElementType("TYPE"); + IElementType UNION_TYPE = new TypeSpecElementType("UNION_TYPE"); + IElementType USING_STATEMENT = new TypeSpecElementType("USING_STATEMENT"); + IElementType VARIADIC_ARGUMENT = new TypeSpecElementType("VARIADIC_ARGUMENT"); + + IElementType AT = new TypeSpecTokenType("@"); + IElementType BLOCK_COMMENT = new TypeSpecTokenType("BLOCK_COMMENT"); + IElementType COLON = new TypeSpecTokenType(":"); + IElementType COMMA = new TypeSpecTokenType(","); + IElementType DOC_COMMENT = new TypeSpecTokenType("DOC_COMMENT"); + IElementType DOT = new TypeSpecTokenType("."); + IElementType DOTDOTDOT = new TypeSpecTokenType("..."); + IElementType EQ = new TypeSpecTokenType("="); + IElementType EXCL = new TypeSpecTokenType("!"); + IElementType IDENTIFIER = new TypeSpecTokenType("IDENTIFIER"); + IElementType IMPORT = new TypeSpecTokenType("import"); + IElementType INTERFACE = new TypeSpecTokenType("interface"); + IElementType LBRACE = new TypeSpecTokenType("{"); + IElementType LBRACKET = new TypeSpecTokenType("["); + IElementType LINE_COMMENT = new TypeSpecTokenType("LINE_COMMENT"); + IElementType LPAREN = new TypeSpecTokenType("("); + IElementType MODEL = new TypeSpecTokenType("model"); + IElementType NAMESPACE = new TypeSpecTokenType("namespace"); + IElementType NUMERIC_LITERAL = new TypeSpecTokenType("NUMERIC_LITERAL"); + IElementType PIPE = new TypeSpecTokenType("|"); + IElementType QUEST = new TypeSpecTokenType("?"); + IElementType RBRACE = new TypeSpecTokenType("}"); + IElementType RBRACKET = new TypeSpecTokenType("]"); + IElementType RPAREN = new TypeSpecTokenType(")"); + IElementType SEMICOLON = new TypeSpecTokenType(";"); + IElementType STRING_LITERAL = new TypeSpecTokenType("STRING_LITERAL"); + IElementType USING = new TypeSpecTokenType("using"); + + class Factory { + public static PsiElement createElement(ASTNode node) { + IElementType type = node.getElementType(); + if (type == ARGUMENTS_LIST) { + return new TypeSpecArgumentsListImpl(node); + } + else if (type == ARRAY_TYPE) { + return new TypeSpecArrayTypeImpl(node); + } + else if (type == DECORATOR) { + return new TypeSpecDecoratorImpl(node); + } + else if (type == IMPORT_STATEMENT) { + return new TypeSpecImportStatementImpl(node); + } + else if (type == INTERFACE_OPERATION) { + return new TypeSpecInterfaceOperationImpl(node); + } + else if (type == INTERFACE_STATEMENT) { + return new TypeSpecInterfaceStatementImpl(node); + } + else if (type == LITERAL_EXPRESSION) { + return new TypeSpecLiteralExpressionImpl(node); + } + else if (type == LITERAL_TYPE) { + return new TypeSpecLiteralTypeImpl(node); + } + else if (type == MODEL_PROPERTY) { + return new TypeSpecModelPropertyImpl(node); + } + else if (type == MODEL_STATEMENT) { + return new TypeSpecModelStatementImpl(node); + } + else if (type == NAMED_ARGUMENT) { + return new TypeSpecNamedArgumentImpl(node); + } + else if (type == NAMESPACE_STATEMENT) { + return new TypeSpecNamespaceStatementImpl(node); + } + else if (type == OBJECT_EXPRESSION) { + return new TypeSpecObjectExpressionImpl(node); + } + else if (type == OBJECT_EXPRESSION_PROPERTY) { + return new TypeSpecObjectExpressionPropertyImpl(node); + } + else if (type == OPERATION) { + return new TypeSpecOperationImpl(node); + } + else if (type == OPERATION_ARGUMENT) { + return new TypeSpecOperationArgumentImpl(node); + } + else if (type == OPERATION_ARGUMENT_LIST) { + return new TypeSpecOperationArgumentListImpl(node); + } + else if (type == PATH) { + return new TypeSpecPathImpl(node); + } + else if (type == PATH_EXPRESSION) { + return new TypeSpecPathExpressionImpl(node); + } + else if (type == PATH_TYPE) { + return new TypeSpecPathTypeImpl(node); + } + else if (type == UNION_TYPE) { + return new TypeSpecUnionTypeImpl(node); + } + else if (type == USING_STATEMENT) { + return new TypeSpecUsingStatementImpl(node); + } + else if (type == VARIADIC_ARGUMENT) { + return new TypeSpecVariadicArgumentImpl(node); + } + throw new AssertionError("Unknown element type: " + type); + } + } +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecExpression.java b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecExpression.java new file mode 100644 index 0000000..60e9846 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecExpression.java @@ -0,0 +1,10 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface TypeSpecExpression extends TypeSpecElement { + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecImportStatement.java b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecImportStatement.java new file mode 100644 index 0000000..14fd84a --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecImportStatement.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface TypeSpecImportStatement extends TypeSpecElement { + + @NotNull + PsiElement getStringLiteral(); + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecInterfaceOperation.java b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecInterfaceOperation.java new file mode 100644 index 0000000..6798ec9 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecInterfaceOperation.java @@ -0,0 +1,16 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface TypeSpecInterfaceOperation extends TypeSpecElement { + + @NotNull + List getDecoratorList(); + + @NotNull + TypeSpecOperation getOperation(); + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecInterfaceStatement.java b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecInterfaceStatement.java new file mode 100644 index 0000000..1499b87 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecInterfaceStatement.java @@ -0,0 +1,19 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface TypeSpecInterfaceStatement extends TypeSpecElement { + + @NotNull + List getDecoratorList(); + + @NotNull + List getInterfaceOperationList(); + + @NotNull + PsiElement getIdentifier(); + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecLiteralExpression.java b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecLiteralExpression.java new file mode 100644 index 0000000..8090391 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecLiteralExpression.java @@ -0,0 +1,16 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface TypeSpecLiteralExpression extends TypeSpecExpression { + + @Nullable + PsiElement getNumericLiteral(); + + @Nullable + PsiElement getStringLiteral(); + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecLiteralType.java b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecLiteralType.java new file mode 100644 index 0000000..6b49c7d --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecLiteralType.java @@ -0,0 +1,16 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface TypeSpecLiteralType extends TypeSpecType { + + @Nullable + PsiElement getNumericLiteral(); + + @Nullable + PsiElement getStringLiteral(); + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecModelProperty.java b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecModelProperty.java new file mode 100644 index 0000000..9d75f9f --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecModelProperty.java @@ -0,0 +1,19 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface TypeSpecModelProperty extends TypeSpecElement { + + @NotNull + List getDecoratorList(); + + @NotNull + TypeSpecType getType(); + + @NotNull + PsiElement getIdentifier(); + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecModelStatement.java b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecModelStatement.java new file mode 100644 index 0000000..aa625d0 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecModelStatement.java @@ -0,0 +1,19 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface TypeSpecModelStatement extends TypeSpecElement { + + @NotNull + List getDecoratorList(); + + @NotNull + List getModelPropertyList(); + + @NotNull + PsiElement getIdentifier(); + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecNamedArgument.java b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecNamedArgument.java new file mode 100644 index 0000000..ad4cf77 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecNamedArgument.java @@ -0,0 +1,19 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface TypeSpecNamedArgument extends TypeSpecElement { + + @NotNull + List getDecoratorList(); + + @NotNull + TypeSpecType getType(); + + @NotNull + PsiElement getIdentifier(); + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecNamespaceStatement.java b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecNamespaceStatement.java new file mode 100644 index 0000000..2304344 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecNamespaceStatement.java @@ -0,0 +1,31 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface TypeSpecNamespaceStatement extends TypeSpecElement { + + @NotNull + List getDecoratorList(); + + @NotNull + List getImportStatementList(); + + @NotNull + List getInterfaceStatementList(); + + @NotNull + List getModelStatementList(); + + @NotNull + List getNamespaceStatementList(); + + @NotNull + TypeSpecPath getPath(); + + @NotNull + List getUsingStatementList(); + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecObjectExpression.java b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecObjectExpression.java new file mode 100644 index 0000000..2cbf708 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecObjectExpression.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface TypeSpecObjectExpression extends TypeSpecExpression { + + @NotNull + List getObjectExpressionPropertyList(); + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecObjectExpressionProperty.java b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecObjectExpressionProperty.java new file mode 100644 index 0000000..b58d66d --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecObjectExpressionProperty.java @@ -0,0 +1,16 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface TypeSpecObjectExpressionProperty extends TypeSpecElement { + + @NotNull + TypeSpecExpression getExpression(); + + @NotNull + PsiElement getIdentifier(); + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecOperation.java b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecOperation.java new file mode 100644 index 0000000..6ae2f7d --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecOperation.java @@ -0,0 +1,19 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface TypeSpecOperation extends TypeSpecElement { + + @NotNull + TypeSpecOperationArgumentList getOperationArgumentList(); + + @NotNull + TypeSpecType getType(); + + @NotNull + PsiElement getIdentifier(); + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecOperationArgument.java b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecOperationArgument.java new file mode 100644 index 0000000..8d658d5 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecOperationArgument.java @@ -0,0 +1,16 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface TypeSpecOperationArgument extends TypeSpecElement { + + @Nullable + TypeSpecNamedArgument getNamedArgument(); + + @Nullable + TypeSpecVariadicArgument getVariadicArgument(); + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecOperationArgumentList.java b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecOperationArgumentList.java new file mode 100644 index 0000000..050bace --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecOperationArgumentList.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface TypeSpecOperationArgumentList extends TypeSpecElement { + + @NotNull + List getOperationArgumentList(); + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecPath.java b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecPath.java new file mode 100644 index 0000000..b3741c1 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecPath.java @@ -0,0 +1,10 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface TypeSpecPath extends TypeSpecElement { + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecPathExpression.java b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecPathExpression.java new file mode 100644 index 0000000..ae890df --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecPathExpression.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface TypeSpecPathExpression extends TypeSpecExpression { + + @NotNull + TypeSpecPath getPath(); + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecPathType.java b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecPathType.java new file mode 100644 index 0000000..a188f75 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecPathType.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface TypeSpecPathType extends TypeSpecType { + + @NotNull + TypeSpecPath getPath(); + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecSimpleType.java b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecSimpleType.java new file mode 100644 index 0000000..92d4877 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecSimpleType.java @@ -0,0 +1,16 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface TypeSpecSimpleType extends TypeSpecElement { + + @Nullable + TypeSpecLiteralType getLiteralType(); + + @Nullable + TypeSpecPathType getPathType(); + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecType.java b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecType.java new file mode 100644 index 0000000..4a5a2f2 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecType.java @@ -0,0 +1,10 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface TypeSpecType extends TypeSpecElement { + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecUnionType.java b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecUnionType.java new file mode 100644 index 0000000..9e6dcab --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecUnionType.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface TypeSpecUnionType extends TypeSpecType { + + @NotNull + List getTypeList(); + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecUsingStatement.java b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecUsingStatement.java new file mode 100644 index 0000000..20c0aa2 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecUsingStatement.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface TypeSpecUsingStatement extends TypeSpecElement { + + @NotNull + TypeSpecPath getPath(); + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecVariadicArgument.java b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecVariadicArgument.java new file mode 100644 index 0000000..92aa813 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecVariadicArgument.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface TypeSpecVariadicArgument extends TypeSpecElement { + + @NotNull + PsiElement getIdentifier(); + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecVisitor.java b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecVisitor.java new file mode 100644 index 0000000..f5a5edb --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/TypeSpecVisitor.java @@ -0,0 +1,113 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.psi; + +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElementVisitor; + +public class TypeSpecVisitor extends PsiElementVisitor { + + public void visitArgumentsList(@NotNull TypeSpecArgumentsList o) { + visitElement(o); + } + + public void visitArrayType(@NotNull TypeSpecArrayType o) { + visitType(o); + } + + public void visitDecorator(@NotNull TypeSpecDecorator o) { + visitElement(o); + } + + public void visitExpression(@NotNull TypeSpecExpression o) { + visitElement(o); + } + + public void visitImportStatement(@NotNull TypeSpecImportStatement o) { + visitElement(o); + } + + public void visitInterfaceOperation(@NotNull TypeSpecInterfaceOperation o) { + visitElement(o); + } + + public void visitInterfaceStatement(@NotNull TypeSpecInterfaceStatement o) { + visitElement(o); + } + + public void visitLiteralExpression(@NotNull TypeSpecLiteralExpression o) { + visitExpression(o); + } + + public void visitLiteralType(@NotNull TypeSpecLiteralType o) { + visitType(o); + } + + public void visitModelProperty(@NotNull TypeSpecModelProperty o) { + visitElement(o); + } + + public void visitModelStatement(@NotNull TypeSpecModelStatement o) { + visitElement(o); + } + + public void visitNamedArgument(@NotNull TypeSpecNamedArgument o) { + visitElement(o); + } + + public void visitNamespaceStatement(@NotNull TypeSpecNamespaceStatement o) { + visitElement(o); + } + + public void visitObjectExpression(@NotNull TypeSpecObjectExpression o) { + visitExpression(o); + } + + public void visitObjectExpressionProperty(@NotNull TypeSpecObjectExpressionProperty o) { + visitElement(o); + } + + public void visitOperation(@NotNull TypeSpecOperation o) { + visitElement(o); + } + + public void visitOperationArgument(@NotNull TypeSpecOperationArgument o) { + visitElement(o); + } + + public void visitOperationArgumentList(@NotNull TypeSpecOperationArgumentList o) { + visitElement(o); + } + + public void visitPath(@NotNull TypeSpecPath o) { + visitElement(o); + } + + public void visitPathExpression(@NotNull TypeSpecPathExpression o) { + visitExpression(o); + } + + public void visitPathType(@NotNull TypeSpecPathType o) { + visitType(o); + } + + public void visitType(@NotNull TypeSpecType o) { + visitElement(o); + } + + public void visitUnionType(@NotNull TypeSpecUnionType o) { + visitType(o); + } + + public void visitUsingStatement(@NotNull TypeSpecUsingStatement o) { + visitElement(o); + } + + public void visitVariadicArgument(@NotNull TypeSpecVariadicArgument o) { + visitElement(o); + } + + public void visitElement(@NotNull TypeSpecElement o) { + super.visitElement(o); + } + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecArgumentsListImpl.java b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecArgumentsListImpl.java new file mode 100644 index 0000000..120f0d3 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecArgumentsListImpl.java @@ -0,0 +1,35 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.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 jp.s6n.idea.typespec.lang.psi.TypeSpecElementTypes.*; +import jp.s6n.idea.typespec.lang.psi.*; + +public class TypeSpecArgumentsListImpl extends TypeSpecElementImpl implements TypeSpecArgumentsList { + + public TypeSpecArgumentsListImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull TypeSpecVisitor visitor) { + visitor.visitArgumentsList(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof TypeSpecVisitor) accept((TypeSpecVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public List getExpressionList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, TypeSpecExpression.class); + } + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecArrayTypeImpl.java b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecArrayTypeImpl.java new file mode 100644 index 0000000..d64fcf7 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecArrayTypeImpl.java @@ -0,0 +1,36 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.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 jp.s6n.idea.typespec.lang.psi.TypeSpecElementTypes.*; +import jp.s6n.idea.typespec.lang.psi.*; + +public class TypeSpecArrayTypeImpl extends TypeSpecTypeImpl implements TypeSpecArrayType { + + public TypeSpecArrayTypeImpl(@NotNull ASTNode node) { + super(node); + } + + @Override + public void accept(@NotNull TypeSpecVisitor visitor) { + visitor.visitArrayType(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof TypeSpecVisitor) accept((TypeSpecVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public TypeSpecType getType() { + return findNotNullChildByClass(TypeSpecType.class); + } + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecDecoratorImpl.java b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecDecoratorImpl.java new file mode 100644 index 0000000..5cf0996 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecDecoratorImpl.java @@ -0,0 +1,41 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.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 jp.s6n.idea.typespec.lang.psi.TypeSpecElementTypes.*; +import jp.s6n.idea.typespec.lang.psi.*; + +public class TypeSpecDecoratorImpl extends TypeSpecElementImpl implements TypeSpecDecorator { + + public TypeSpecDecoratorImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull TypeSpecVisitor visitor) { + visitor.visitDecorator(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof TypeSpecVisitor) accept((TypeSpecVisitor)visitor); + else super.accept(visitor); + } + + @Override + @Nullable + public TypeSpecArgumentsList getArgumentsList() { + return findChildByClass(TypeSpecArgumentsList.class); + } + + @Override + @NotNull + public TypeSpecPathExpression getPathExpression() { + return findNotNullChildByClass(TypeSpecPathExpression.class); + } + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecExpressionImpl.java b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecExpressionImpl.java new file mode 100644 index 0000000..aaa37e0 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecExpressionImpl.java @@ -0,0 +1,29 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.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 jp.s6n.idea.typespec.lang.psi.TypeSpecElementTypes.*; +import jp.s6n.idea.typespec.lang.psi.*; + +public abstract class TypeSpecExpressionImpl extends TypeSpecElementImpl implements TypeSpecExpression { + + public TypeSpecExpressionImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull TypeSpecVisitor visitor) { + visitor.visitExpression(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof TypeSpecVisitor) accept((TypeSpecVisitor)visitor); + else super.accept(visitor); + } + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecImportStatementImpl.java b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecImportStatementImpl.java new file mode 100644 index 0000000..4f7368d --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecImportStatementImpl.java @@ -0,0 +1,35 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.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 jp.s6n.idea.typespec.lang.psi.TypeSpecElementTypes.*; +import jp.s6n.idea.typespec.lang.psi.*; + +public class TypeSpecImportStatementImpl extends TypeSpecElementImpl implements TypeSpecImportStatement { + + public TypeSpecImportStatementImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull TypeSpecVisitor visitor) { + visitor.visitImportStatement(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof TypeSpecVisitor) accept((TypeSpecVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public PsiElement getStringLiteral() { + return findNotNullChildByType(STRING_LITERAL); + } + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecInterfaceOperationImpl.java b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecInterfaceOperationImpl.java new file mode 100644 index 0000000..e662f1e --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecInterfaceOperationImpl.java @@ -0,0 +1,41 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.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 jp.s6n.idea.typespec.lang.psi.TypeSpecElementTypes.*; +import jp.s6n.idea.typespec.lang.psi.*; + +public class TypeSpecInterfaceOperationImpl extends TypeSpecElementImpl implements TypeSpecInterfaceOperation { + + public TypeSpecInterfaceOperationImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull TypeSpecVisitor visitor) { + visitor.visitInterfaceOperation(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof TypeSpecVisitor) accept((TypeSpecVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public List getDecoratorList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, TypeSpecDecorator.class); + } + + @Override + @NotNull + public TypeSpecOperation getOperation() { + return findNotNullChildByClass(TypeSpecOperation.class); + } + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecInterfaceStatementImpl.java b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecInterfaceStatementImpl.java new file mode 100644 index 0000000..da5d137 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecInterfaceStatementImpl.java @@ -0,0 +1,47 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.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 jp.s6n.idea.typespec.lang.psi.TypeSpecElementTypes.*; +import jp.s6n.idea.typespec.lang.psi.*; + +public class TypeSpecInterfaceStatementImpl extends TypeSpecElementImpl implements TypeSpecInterfaceStatement { + + public TypeSpecInterfaceStatementImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull TypeSpecVisitor visitor) { + visitor.visitInterfaceStatement(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof TypeSpecVisitor) accept((TypeSpecVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public List getDecoratorList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, TypeSpecDecorator.class); + } + + @Override + @NotNull + public List getInterfaceOperationList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, TypeSpecInterfaceOperation.class); + } + + @Override + @NotNull + public PsiElement getIdentifier() { + return findNotNullChildByType(IDENTIFIER); + } + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecLiteralExpressionImpl.java b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecLiteralExpressionImpl.java new file mode 100644 index 0000000..cc290c7 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecLiteralExpressionImpl.java @@ -0,0 +1,42 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.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 jp.s6n.idea.typespec.lang.psi.TypeSpecElementTypes.*; +import jp.s6n.idea.typespec.lang.psi.*; + +public class TypeSpecLiteralExpressionImpl extends TypeSpecExpressionImpl implements TypeSpecLiteralExpression { + + public TypeSpecLiteralExpressionImpl(@NotNull ASTNode node) { + super(node); + } + + @Override + public void accept(@NotNull TypeSpecVisitor visitor) { + visitor.visitLiteralExpression(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof TypeSpecVisitor) accept((TypeSpecVisitor)visitor); + else super.accept(visitor); + } + + @Override + @Nullable + public PsiElement getNumericLiteral() { + return findChildByType(NUMERIC_LITERAL); + } + + @Override + @Nullable + public PsiElement getStringLiteral() { + return findChildByType(STRING_LITERAL); + } + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecLiteralTypeImpl.java b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecLiteralTypeImpl.java new file mode 100644 index 0000000..e10cbe8 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecLiteralTypeImpl.java @@ -0,0 +1,42 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.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 jp.s6n.idea.typespec.lang.psi.TypeSpecElementTypes.*; +import jp.s6n.idea.typespec.lang.psi.*; + +public class TypeSpecLiteralTypeImpl extends TypeSpecTypeImpl implements TypeSpecLiteralType { + + public TypeSpecLiteralTypeImpl(@NotNull ASTNode node) { + super(node); + } + + @Override + public void accept(@NotNull TypeSpecVisitor visitor) { + visitor.visitLiteralType(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof TypeSpecVisitor) accept((TypeSpecVisitor)visitor); + else super.accept(visitor); + } + + @Override + @Nullable + public PsiElement getNumericLiteral() { + return findChildByType(NUMERIC_LITERAL); + } + + @Override + @Nullable + public PsiElement getStringLiteral() { + return findChildByType(STRING_LITERAL); + } + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecModelPropertyImpl.java b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecModelPropertyImpl.java new file mode 100644 index 0000000..ec7dcb5 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecModelPropertyImpl.java @@ -0,0 +1,47 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.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 jp.s6n.idea.typespec.lang.psi.TypeSpecElementTypes.*; +import jp.s6n.idea.typespec.lang.psi.*; + +public class TypeSpecModelPropertyImpl extends TypeSpecElementImpl implements TypeSpecModelProperty { + + public TypeSpecModelPropertyImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull TypeSpecVisitor visitor) { + visitor.visitModelProperty(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof TypeSpecVisitor) accept((TypeSpecVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public List getDecoratorList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, TypeSpecDecorator.class); + } + + @Override + @NotNull + public TypeSpecType getType() { + return findNotNullChildByClass(TypeSpecType.class); + } + + @Override + @NotNull + public PsiElement getIdentifier() { + return findNotNullChildByType(IDENTIFIER); + } + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecModelStatementImpl.java b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecModelStatementImpl.java new file mode 100644 index 0000000..4483193 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecModelStatementImpl.java @@ -0,0 +1,47 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.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 jp.s6n.idea.typespec.lang.psi.TypeSpecElementTypes.*; +import jp.s6n.idea.typespec.lang.psi.*; + +public class TypeSpecModelStatementImpl extends TypeSpecElementImpl implements TypeSpecModelStatement { + + public TypeSpecModelStatementImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull TypeSpecVisitor visitor) { + visitor.visitModelStatement(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof TypeSpecVisitor) accept((TypeSpecVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public List getDecoratorList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, TypeSpecDecorator.class); + } + + @Override + @NotNull + public List getModelPropertyList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, TypeSpecModelProperty.class); + } + + @Override + @NotNull + public PsiElement getIdentifier() { + return findNotNullChildByType(IDENTIFIER); + } + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecNamedArgumentImpl.java b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecNamedArgumentImpl.java new file mode 100644 index 0000000..876bc66 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecNamedArgumentImpl.java @@ -0,0 +1,47 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.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 jp.s6n.idea.typespec.lang.psi.TypeSpecElementTypes.*; +import jp.s6n.idea.typespec.lang.psi.*; + +public class TypeSpecNamedArgumentImpl extends TypeSpecElementImpl implements TypeSpecNamedArgument { + + public TypeSpecNamedArgumentImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull TypeSpecVisitor visitor) { + visitor.visitNamedArgument(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof TypeSpecVisitor) accept((TypeSpecVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public List getDecoratorList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, TypeSpecDecorator.class); + } + + @Override + @NotNull + public TypeSpecType getType() { + return findNotNullChildByClass(TypeSpecType.class); + } + + @Override + @NotNull + public PsiElement getIdentifier() { + return findNotNullChildByType(IDENTIFIER); + } + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecNamespaceStatementImpl.java b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecNamespaceStatementImpl.java new file mode 100644 index 0000000..c2e2eb3 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecNamespaceStatementImpl.java @@ -0,0 +1,71 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.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 jp.s6n.idea.typespec.lang.psi.TypeSpecElementTypes.*; +import jp.s6n.idea.typespec.lang.psi.*; + +public class TypeSpecNamespaceStatementImpl extends TypeSpecElementImpl implements TypeSpecNamespaceStatement { + + public TypeSpecNamespaceStatementImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull TypeSpecVisitor visitor) { + visitor.visitNamespaceStatement(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof TypeSpecVisitor) accept((TypeSpecVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public List getDecoratorList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, TypeSpecDecorator.class); + } + + @Override + @NotNull + public List getImportStatementList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, TypeSpecImportStatement.class); + } + + @Override + @NotNull + public List getInterfaceStatementList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, TypeSpecInterfaceStatement.class); + } + + @Override + @NotNull + public List getModelStatementList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, TypeSpecModelStatement.class); + } + + @Override + @NotNull + public List getNamespaceStatementList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, TypeSpecNamespaceStatement.class); + } + + @Override + @NotNull + public TypeSpecPath getPath() { + return findNotNullChildByClass(TypeSpecPath.class); + } + + @Override + @NotNull + public List getUsingStatementList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, TypeSpecUsingStatement.class); + } + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecObjectExpressionImpl.java b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecObjectExpressionImpl.java new file mode 100644 index 0000000..edc088e --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecObjectExpressionImpl.java @@ -0,0 +1,36 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.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 jp.s6n.idea.typespec.lang.psi.TypeSpecElementTypes.*; +import jp.s6n.idea.typespec.lang.psi.*; + +public class TypeSpecObjectExpressionImpl extends TypeSpecExpressionImpl implements TypeSpecObjectExpression { + + public TypeSpecObjectExpressionImpl(@NotNull ASTNode node) { + super(node); + } + + @Override + public void accept(@NotNull TypeSpecVisitor visitor) { + visitor.visitObjectExpression(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof TypeSpecVisitor) accept((TypeSpecVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public List getObjectExpressionPropertyList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, TypeSpecObjectExpressionProperty.class); + } + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecObjectExpressionPropertyImpl.java b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecObjectExpressionPropertyImpl.java new file mode 100644 index 0000000..cef3044 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecObjectExpressionPropertyImpl.java @@ -0,0 +1,41 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.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 jp.s6n.idea.typespec.lang.psi.TypeSpecElementTypes.*; +import jp.s6n.idea.typespec.lang.psi.*; + +public class TypeSpecObjectExpressionPropertyImpl extends TypeSpecElementImpl implements TypeSpecObjectExpressionProperty { + + public TypeSpecObjectExpressionPropertyImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull TypeSpecVisitor visitor) { + visitor.visitObjectExpressionProperty(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof TypeSpecVisitor) accept((TypeSpecVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public TypeSpecExpression getExpression() { + return findNotNullChildByClass(TypeSpecExpression.class); + } + + @Override + @NotNull + public PsiElement getIdentifier() { + return findNotNullChildByType(IDENTIFIER); + } + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecOperationArgumentImpl.java b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecOperationArgumentImpl.java new file mode 100644 index 0000000..aec222c --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecOperationArgumentImpl.java @@ -0,0 +1,41 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.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 jp.s6n.idea.typespec.lang.psi.TypeSpecElementTypes.*; +import jp.s6n.idea.typespec.lang.psi.*; + +public class TypeSpecOperationArgumentImpl extends TypeSpecElementImpl implements TypeSpecOperationArgument { + + public TypeSpecOperationArgumentImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull TypeSpecVisitor visitor) { + visitor.visitOperationArgument(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof TypeSpecVisitor) accept((TypeSpecVisitor)visitor); + else super.accept(visitor); + } + + @Override + @Nullable + public TypeSpecNamedArgument getNamedArgument() { + return findChildByClass(TypeSpecNamedArgument.class); + } + + @Override + @Nullable + public TypeSpecVariadicArgument getVariadicArgument() { + return findChildByClass(TypeSpecVariadicArgument.class); + } + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecOperationArgumentListImpl.java b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecOperationArgumentListImpl.java new file mode 100644 index 0000000..d32cee2 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecOperationArgumentListImpl.java @@ -0,0 +1,35 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.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 jp.s6n.idea.typespec.lang.psi.TypeSpecElementTypes.*; +import jp.s6n.idea.typespec.lang.psi.*; + +public class TypeSpecOperationArgumentListImpl extends TypeSpecElementImpl implements TypeSpecOperationArgumentList { + + public TypeSpecOperationArgumentListImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull TypeSpecVisitor visitor) { + visitor.visitOperationArgumentList(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof TypeSpecVisitor) accept((TypeSpecVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public List getOperationArgumentList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, TypeSpecOperationArgument.class); + } + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecOperationImpl.java b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecOperationImpl.java new file mode 100644 index 0000000..d15104e --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecOperationImpl.java @@ -0,0 +1,47 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.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 jp.s6n.idea.typespec.lang.psi.TypeSpecElementTypes.*; +import jp.s6n.idea.typespec.lang.psi.*; + +public class TypeSpecOperationImpl extends TypeSpecElementImpl implements TypeSpecOperation { + + public TypeSpecOperationImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull TypeSpecVisitor visitor) { + visitor.visitOperation(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof TypeSpecVisitor) accept((TypeSpecVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public TypeSpecOperationArgumentList getOperationArgumentList() { + return findNotNullChildByClass(TypeSpecOperationArgumentList.class); + } + + @Override + @NotNull + public TypeSpecType getType() { + return findNotNullChildByClass(TypeSpecType.class); + } + + @Override + @NotNull + public PsiElement getIdentifier() { + return findNotNullChildByType(IDENTIFIER); + } + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecPathExpressionImpl.java b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecPathExpressionImpl.java new file mode 100644 index 0000000..319af24 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecPathExpressionImpl.java @@ -0,0 +1,36 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.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 jp.s6n.idea.typespec.lang.psi.TypeSpecElementTypes.*; +import jp.s6n.idea.typespec.lang.psi.*; + +public class TypeSpecPathExpressionImpl extends TypeSpecExpressionImpl implements TypeSpecPathExpression { + + public TypeSpecPathExpressionImpl(@NotNull ASTNode node) { + super(node); + } + + @Override + public void accept(@NotNull TypeSpecVisitor visitor) { + visitor.visitPathExpression(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof TypeSpecVisitor) accept((TypeSpecVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public TypeSpecPath getPath() { + return findNotNullChildByClass(TypeSpecPath.class); + } + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecPathImpl.java b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecPathImpl.java new file mode 100644 index 0000000..6f70653 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecPathImpl.java @@ -0,0 +1,29 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.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 jp.s6n.idea.typespec.lang.psi.TypeSpecElementTypes.*; +import jp.s6n.idea.typespec.lang.psi.*; + +public class TypeSpecPathImpl extends TypeSpecElementImpl implements TypeSpecPath { + + public TypeSpecPathImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull TypeSpecVisitor visitor) { + visitor.visitPath(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof TypeSpecVisitor) accept((TypeSpecVisitor)visitor); + else super.accept(visitor); + } + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecPathTypeImpl.java b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecPathTypeImpl.java new file mode 100644 index 0000000..987e0dd --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecPathTypeImpl.java @@ -0,0 +1,36 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.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 jp.s6n.idea.typespec.lang.psi.TypeSpecElementTypes.*; +import jp.s6n.idea.typespec.lang.psi.*; + +public class TypeSpecPathTypeImpl extends TypeSpecTypeImpl implements TypeSpecPathType { + + public TypeSpecPathTypeImpl(@NotNull ASTNode node) { + super(node); + } + + @Override + public void accept(@NotNull TypeSpecVisitor visitor) { + visitor.visitPathType(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof TypeSpecVisitor) accept((TypeSpecVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public TypeSpecPath getPath() { + return findNotNullChildByClass(TypeSpecPath.class); + } + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecTypeImpl.java b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecTypeImpl.java new file mode 100644 index 0000000..0adf552 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecTypeImpl.java @@ -0,0 +1,29 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.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 jp.s6n.idea.typespec.lang.psi.TypeSpecElementTypes.*; +import jp.s6n.idea.typespec.lang.psi.*; + +public abstract class TypeSpecTypeImpl extends TypeSpecElementImpl implements TypeSpecType { + + public TypeSpecTypeImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull TypeSpecVisitor visitor) { + visitor.visitType(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof TypeSpecVisitor) accept((TypeSpecVisitor)visitor); + else super.accept(visitor); + } + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecUnionTypeImpl.java b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecUnionTypeImpl.java new file mode 100644 index 0000000..f04bc5f --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecUnionTypeImpl.java @@ -0,0 +1,36 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.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 jp.s6n.idea.typespec.lang.psi.TypeSpecElementTypes.*; +import jp.s6n.idea.typespec.lang.psi.*; + +public class TypeSpecUnionTypeImpl extends TypeSpecTypeImpl implements TypeSpecUnionType { + + public TypeSpecUnionTypeImpl(@NotNull ASTNode node) { + super(node); + } + + @Override + public void accept(@NotNull TypeSpecVisitor visitor) { + visitor.visitUnionType(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof TypeSpecVisitor) accept((TypeSpecVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public List getTypeList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, TypeSpecType.class); + } + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecUsingStatementImpl.java b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecUsingStatementImpl.java new file mode 100644 index 0000000..fdb43f8 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecUsingStatementImpl.java @@ -0,0 +1,35 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.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 jp.s6n.idea.typespec.lang.psi.TypeSpecElementTypes.*; +import jp.s6n.idea.typespec.lang.psi.*; + +public class TypeSpecUsingStatementImpl extends TypeSpecElementImpl implements TypeSpecUsingStatement { + + public TypeSpecUsingStatementImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull TypeSpecVisitor visitor) { + visitor.visitUsingStatement(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof TypeSpecVisitor) accept((TypeSpecVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public TypeSpecPath getPath() { + return findNotNullChildByClass(TypeSpecPath.class); + } + +} diff --git a/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecVariadicArgumentImpl.java b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecVariadicArgumentImpl.java new file mode 100644 index 0000000..c1a0502 --- /dev/null +++ b/gen/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecVariadicArgumentImpl.java @@ -0,0 +1,35 @@ +// This is a generated file. Not intended for manual editing. +package jp.s6n.idea.typespec.lang.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 jp.s6n.idea.typespec.lang.psi.TypeSpecElementTypes.*; +import jp.s6n.idea.typespec.lang.psi.*; + +public class TypeSpecVariadicArgumentImpl extends TypeSpecElementImpl implements TypeSpecVariadicArgument { + + public TypeSpecVariadicArgumentImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull TypeSpecVisitor visitor) { + visitor.visitVariadicArgument(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof TypeSpecVisitor) accept((TypeSpecVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public PsiElement getIdentifier() { + return findNotNullChildByType(IDENTIFIER); + } + +} diff --git a/grammars/TypeSpec.bnf b/grammars/TypeSpec.bnf new file mode 100644 index 0000000..96572f9 --- /dev/null +++ b/grammars/TypeSpec.bnf @@ -0,0 +1,124 @@ +{ + parserClass='jp.s6n.idea.typespec.lang.parser.TypeSpecParser' + parserUtilClass='jp.s6n.idea.typespec.lang.parser.TypeSpecParserUtil' + + implements='jp.s6n.idea.typespec.lang.psi.TypeSpecElement' + extends='jp.s6n.idea.typespec.lang.psi.impl.TypeSpecElementImpl' + + elementTypeHolderClass='jp.s6n.idea.typespec.lang.psi.TypeSpecElementTypes' + elementTypeClass='jp.s6n.idea.typespec.lang.psi.TypeSpecElementType' + tokenTypeClass='jp.s6n.idea.typespec.lang.psi.TypeSpecTokenType' + + psiClassPrefix='TypeSpec' + psiImplClassSuffix='Impl' + psiPackage='jp.s6n.idea.typespec.lang.psi' + psiImplPackage='jp.s6n.idea.typespec.lang.psi.impl' + + tokens=[ + IMPORT = 'import' + USING = 'using' + NAMESPACE = 'namespace' + MODEL = 'model' + INTERFACE = 'interface' + + LBRACE = '{' + RBRACE = '}' + LPAREN = '(' + RPAREN = ')' + LBRACKET = '[' + RBRACKET = ']' + EQ = '=' + DOTDOTDOT = '...' + DOT = '.' + COLON = ':' + SEMICOLON = ';' + QUEST = '?' + EXCL = '!' + AT = '@' + COMMA = ',' + PIPE = '|' + + STRING_LITERAL = 'regexp:"([^\\"\r\n]|\\[^\r\n])*"?' + NUMERIC_LITERAL = 'regexp:-?\d+(\.\d+)?' + IDENTIFIER = 'regexp:[a-zA-Z][a-zA-Z0-9\-_]*|`(\\`|[^`])+`' + WHITE_SPACE = 'regexp:\s+' + + DOC_COMMENT = 'regexp:/\*\*([^*]|\*[^/])*\*/' + BLOCK_COMMENT = 'regexp:/\*([^*]|\*[^/])*\*/' + LINE_COMMENT = 'regexp://.*' + ] +} + +File ::= Statement* + +private Statement ::= + ImportStatement + | UsingStatement + | NamespaceStatement + | ModelStatement + | InterfaceStatement + +ImportStatement ::= IMPORT STRING_LITERAL SEMICOLON + +UsingStatement ::= USING Path SEMICOLON + +NamespaceStatement ::= Decorator* NAMESPACE Path (SEMICOLON | LBRACE Statement* RBRACE) + +ModelStatement ::= Decorator* MODEL Identifier ModelPropertiesBlock + +private ModelPropertiesBlock ::= LBRACE ModelProperty* RBRACE + +ModelProperty ::= Decorator* Identifier QUEST? COLON Type SEMICOLON + +InterfaceStatement ::= Decorator* INTERFACE Identifier InterfaceOperationsBlock + +private InterfaceOperationsBlock ::= LBRACE InterfaceOperation* RBRACE + +InterfaceOperation ::= Decorator* Operation SEMICOLON + +Operation ::= Identifier OperationArgumentList COLON Type + +OperationArgumentList ::= LPAREN [OperationArgument (COMMA OperationArgument)*] RPAREN + +OperationArgument ::= + NamedArgument + | VariadicArgument + +NamedArgument ::= Decorator* Identifier COLON Type + +VariadicArgument ::= DOTDOTDOT Identifier + +Decorator ::= AT PathExpression ArgumentsList? + +ArgumentsList ::= LPAREN [Expression (COMMA Expression)*] RPAREN + +Expression ::= + ObjectExpression + | PathExpression + | LiteralExpression + +ObjectExpression ::= LBRACE [ObjectExpressionProperty (COMMA ObjectExpressionProperty)* COMMA?] RBRACE {extends=Expression} + +ObjectExpressionProperty ::= Identifier COLON Expression + +PathExpression ::= Path {extends=Expression} + +LiteralExpression ::= STRING_LITERAL | NUMERIC_LITERAL {extends=Expression} + +Type ::= + UnionType + | ArrayType + | PathType + | LiteralType + +UnionType ::= Type (PIPE Type)+ {extends=Type} + +ArrayType ::= Type LBRACKET RBRACKET {extends=Type} + +PathType ::= Path {extends=Type} + +LiteralType ::= STRING_LITERAL | NUMERIC_LITERAL {extends=Type} + +Path ::= Identifier (DOT Identifier)* + +private Identifier ::= IDENTIFIER diff --git a/grammars/_TypeSpecLexer.flex b/grammars/_TypeSpecLexer.flex new file mode 100644 index 0000000..dc8d72e --- /dev/null +++ b/grammars/_TypeSpecLexer.flex @@ -0,0 +1,72 @@ +package jp.s6n.idea.typespec.lang.parser; + +import com.intellij.lexer.FlexLexer; +import com.intellij.psi.tree.IElementType; + +import static com.intellij.psi.TokenType.BAD_CHARACTER; +import static com.intellij.psi.TokenType.WHITE_SPACE; +import static jp.s6n.idea.typespec.lang.psi.TypeSpecElementTypes.*; + +%% + +%{ + public _TypeSpecLexer() { + this((java.io.Reader)null); + } +%} + +%public +%class _TypeSpecLexer +%implements FlexLexer +%function advance +%type IElementType +%unicode + +EOL=\R +WHITE_SPACE=\s+ + +STRING_LITERAL=\"([^\\\"\r\n]|\\[^\r\n])*\"? +NUMERIC_LITERAL=-?[0-9]+(\.[0-9]+)? +IDENTIFIER=[a-zA-Z][a-zA-Z0-9\-_]*|`(\\`|[^`])+` +WHITE_SPACE=[ \t\n\x0B\f\r]+ +DOC_COMMENT="/"\*\*([^*]|\*[^/])*\*"/" +BLOCK_COMMENT="/"\*([^*]|\*[^/])*\*"/" +LINE_COMMENT="//".* + +%% + { + {WHITE_SPACE} { return WHITE_SPACE; } + + "import" { return IMPORT; } + "using" { return USING; } + "namespace" { return NAMESPACE; } + "model" { return MODEL; } + "interface" { return INTERFACE; } + "{" { return LBRACE; } + "}" { return RBRACE; } + "(" { return LPAREN; } + ")" { return RPAREN; } + "[" { return LBRACKET; } + "]" { return RBRACKET; } + "=" { return EQ; } + "..." { return DOTDOTDOT; } + "." { return DOT; } + ":" { return COLON; } + ";" { return SEMICOLON; } + "?" { return QUEST; } + "!" { return EXCL; } + "@" { return AT; } + "," { return COMMA; } + "|" { return PIPE; } + + {STRING_LITERAL} { return STRING_LITERAL; } + {NUMERIC_LITERAL} { return NUMERIC_LITERAL; } + {IDENTIFIER} { return IDENTIFIER; } + {WHITE_SPACE} { return WHITE_SPACE; } + {DOC_COMMENT} { return DOC_COMMENT; } + {BLOCK_COMMENT} { return BLOCK_COMMENT; } + {LINE_COMMENT} { return LINE_COMMENT; } + +} + +[^] { return BAD_CHARACTER; } diff --git a/src/main/kotlin/jp/s6n/idea/typespec/highlighting/TypeSpecColorSettingsPage.kt b/src/main/kotlin/jp/s6n/idea/typespec/highlighting/TypeSpecColorSettingsPage.kt new file mode 100644 index 0000000..613c072 --- /dev/null +++ b/src/main/kotlin/jp/s6n/idea/typespec/highlighting/TypeSpecColorSettingsPage.kt @@ -0,0 +1,14 @@ +package jp.s6n.idea.typespec.highlighting + +import com.intellij.openapi.editor.colors.TextAttributesKey +import com.intellij.openapi.options.OptionsBundle +import com.intellij.openapi.options.colors.AttributesDescriptor + +private val DESCRIPTORS = arrayOf( + AttributesDescriptor( + OptionsBundle.messagePointer("options.language.defaults.block.comment"), + TypeSpecColors.DECORATOR + ), +) + +private val ADDITIONAL_DESCRIPTORS = mapOf() diff --git a/src/main/kotlin/jp/s6n/idea/typespec/highlighting/TypeSpecColors.kt b/src/main/kotlin/jp/s6n/idea/typespec/highlighting/TypeSpecColors.kt new file mode 100644 index 0000000..2c8f0a8 --- /dev/null +++ b/src/main/kotlin/jp/s6n/idea/typespec/highlighting/TypeSpecColors.kt @@ -0,0 +1,24 @@ +package jp.s6n.idea.typespec.highlighting + +import com.intellij.openapi.editor.DefaultLanguageHighlighterColors +import com.intellij.openapi.editor.colors.TextAttributesKey.createTextAttributesKey + +object TypeSpecColors { + val DOC_COMMENT = createTextAttributesKey("TYPESPEC_BLOCK_COMMENT", DefaultLanguageHighlighterColors.DOC_COMMENT) + val BLOCK_COMMENT = createTextAttributesKey("TYPESPEC_BLOCK_COMMENT", DefaultLanguageHighlighterColors.BLOCK_COMMENT) + val LINE_COMMENT = createTextAttributesKey("TYPESPEC_LINE_COMMENT", DefaultLanguageHighlighterColors.LINE_COMMENT) + val STRING_LITERAL = createTextAttributesKey("TYPESPEC_STRING_LITERAL", DefaultLanguageHighlighterColors.STRING) + val KEYWORD = createTextAttributesKey("TYPESPEC_KEYWORD", DefaultLanguageHighlighterColors.KEYWORD) + val IDENTIFIER = createTextAttributesKey("TYPESPEC_IDENTIFIER", DefaultLanguageHighlighterColors.IDENTIFIER) + val NUMBER = createTextAttributesKey("TYPESPEC_NUMBER", DefaultLanguageHighlighterColors.NUMBER) + val BRACKETS = createTextAttributesKey("TYPESPEC_BRACKETS", DefaultLanguageHighlighterColors.BRACKETS) + val PARENTHESES = createTextAttributesKey("TYPESPEC_PARENTHESES", DefaultLanguageHighlighterColors.PARENTHESES) + val BRACES = createTextAttributesKey("TYPESPEC_BRACES", DefaultLanguageHighlighterColors.BRACES) + val DOT = createTextAttributesKey("TYPESPEC_DOT", DefaultLanguageHighlighterColors.DOT) + val COMMA = createTextAttributesKey("TYPESPEC_COMMA", DefaultLanguageHighlighterColors.COMMA) + val OPERATION_SIGN = + createTextAttributesKey("TYPESPEC_OPERATION_SIGN", DefaultLanguageHighlighterColors.OPERATION_SIGN) + + val DECORATOR = createTextAttributesKey("TYPESPEC_DECORATOR", DefaultLanguageHighlighterColors.METADATA) + val TYPE = createTextAttributesKey("TYPESPEC_TYPE", DefaultLanguageHighlighterColors.CLASS_NAME) +} diff --git a/src/main/kotlin/jp/s6n/idea/typespec/highlighting/TypeSpecHighlightingAnnotator.kt b/src/main/kotlin/jp/s6n/idea/typespec/highlighting/TypeSpecHighlightingAnnotator.kt new file mode 100644 index 0000000..1e54e63 --- /dev/null +++ b/src/main/kotlin/jp/s6n/idea/typespec/highlighting/TypeSpecHighlightingAnnotator.kt @@ -0,0 +1,27 @@ +package jp.s6n.idea.typespec.highlighting + +import com.intellij.lang.annotation.AnnotationHolder +import com.intellij.lang.annotation.Annotator +import com.intellij.lang.annotation.HighlightSeverity +import com.intellij.openapi.editor.colors.TextAttributesKey +import com.intellij.psi.PsiElement +import jp.s6n.idea.typespec.lang.psi.TypeSpecDecorator +import jp.s6n.idea.typespec.lang.psi.TypeSpecPathType + +class TypeSpecHighlightingAnnotator : Annotator { + override fun annotate(element: PsiElement, holder: AnnotationHolder) { + when (element) { + is TypeSpecPathType -> newAnnotation(element, holder, TypeSpecColors.TYPE) + is TypeSpecDecorator -> newAnnotation(element.pathExpression, holder, TypeSpecColors.DECORATOR) + } + } + + private fun newAnnotation( + element: PsiElement, holder: AnnotationHolder, textAttributesKey: TextAttributesKey + ) { + holder.newSilentAnnotation(HighlightSeverity.INFORMATION) + .textAttributes(textAttributesKey) + .range(element) + .create() + } +} diff --git a/src/main/kotlin/jp/s6n/idea/typespec/highlighting/TypeSpecSyntaxHighlighter.kt b/src/main/kotlin/jp/s6n/idea/typespec/highlighting/TypeSpecSyntaxHighlighter.kt new file mode 100644 index 0000000..f73a0cf --- /dev/null +++ b/src/main/kotlin/jp/s6n/idea/typespec/highlighting/TypeSpecSyntaxHighlighter.kt @@ -0,0 +1,36 @@ +package jp.s6n.idea.typespec.highlighting + +import com.intellij.lexer.Lexer +import com.intellij.openapi.editor.colors.TextAttributesKey +import com.intellij.openapi.fileTypes.SyntaxHighlighterBase +import com.intellij.psi.tree.IElementType +import jp.s6n.idea.typespec.lang.lexer.TypeSpecLexer +import jp.s6n.idea.typespec.lang.psi.* + +class TypeSpecSyntaxHighlighter : SyntaxHighlighterBase() { + override fun getHighlightingLexer(): Lexer = TypeSpecLexer() + + override fun getTokenHighlights(tokenType: IElementType): Array = + pack(ATTRIBUTES[tokenType]) +} + +private val ATTRIBUTES = buildMap { + put(TypeSpecElementTypes.DOC_COMMENT, TypeSpecColors.DOC_COMMENT) + put(TypeSpecElementTypes.BLOCK_COMMENT, TypeSpecColors.BLOCK_COMMENT) + put(TypeSpecElementTypes.LINE_COMMENT, TypeSpecColors.LINE_COMMENT) + put(TypeSpecElementTypes.STRING_LITERAL, TypeSpecColors.STRING_LITERAL) + put(TypeSpecElementTypes.IDENTIFIER, TypeSpecColors.IDENTIFIER) + put(TypeSpecElementTypes.NUMERIC_LITERAL, TypeSpecColors.NUMBER) + put(TypeSpecElementTypes.COMMA, TypeSpecColors.COMMA) + put(TypeSpecElementTypes.DOT, TypeSpecColors.DOT) + put(TypeSpecElementTypes.EQ, TypeSpecColors.OPERATION_SIGN) + put(TypeSpecElementTypes.COLON, TypeSpecColors.OPERATION_SIGN) + put(TypeSpecElementTypes.QUEST, TypeSpecColors.OPERATION_SIGN) + put(TypeSpecElementTypes.EXCL, TypeSpecColors.OPERATION_SIGN) + put(TypeSpecElementTypes.AT, TypeSpecColors.DECORATOR) + + SyntaxHighlighterBase.fillMap(this, TYPESPEC_KEYWORDS, TypeSpecColors.KEYWORD) + SyntaxHighlighterBase.fillMap(this, TYPESPEC_BRACKETS, TypeSpecColors.BRACKETS) + SyntaxHighlighterBase.fillMap(this, TYPESPEC_BRACES, TypeSpecColors.BRACES) + SyntaxHighlighterBase.fillMap(this, TYPESPEC_PARENTHESES, TypeSpecColors.PARENTHESES) +} diff --git a/src/main/kotlin/jp/s6n/idea/typespec/highlighting/TypeSpecSyntaxHighlighterFactory.kt b/src/main/kotlin/jp/s6n/idea/typespec/highlighting/TypeSpecSyntaxHighlighterFactory.kt new file mode 100644 index 0000000..27ade28 --- /dev/null +++ b/src/main/kotlin/jp/s6n/idea/typespec/highlighting/TypeSpecSyntaxHighlighterFactory.kt @@ -0,0 +1,12 @@ +package jp.s6n.idea.typespec.highlighting + +import com.intellij.openapi.fileTypes.SyntaxHighlighter +import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory +import com.intellij.openapi.project.Project +import com.intellij.openapi.vfs.VirtualFile + +class TypeSpecSyntaxHighlighterFactory : SyntaxHighlighterFactory() { + override fun getSyntaxHighlighter(p0: Project?, p1: VirtualFile?): SyntaxHighlighter { + return TypeSpecSyntaxHighlighter() + } +} diff --git a/src/main/kotlin/jp/s6n/idea/typespec/lang/TypeSpecFileType.kt b/src/main/kotlin/jp/s6n/idea/typespec/lang/TypeSpecFileType.kt new file mode 100644 index 0000000..7ff98a4 --- /dev/null +++ b/src/main/kotlin/jp/s6n/idea/typespec/lang/TypeSpecFileType.kt @@ -0,0 +1,12 @@ +package jp.s6n.idea.typespec.lang + +import com.intellij.icons.AllIcons +import com.intellij.openapi.fileTypes.LanguageFileType +import javax.swing.Icon + +object TypeSpecFileType : LanguageFileType(TypeSpecLanguage) { + override fun getName() = "TypeSpec" + override fun getDescription() = "TypeSpec file" + override fun getDefaultExtension() = "tsp" + override fun getIcon(): Icon = AllIcons.FileTypes.Json +} diff --git a/src/main/kotlin/jp/s6n/idea/typespec/lang/TypeSpecLanguage.kt b/src/main/kotlin/jp/s6n/idea/typespec/lang/TypeSpecLanguage.kt new file mode 100644 index 0000000..89c9a0d --- /dev/null +++ b/src/main/kotlin/jp/s6n/idea/typespec/lang/TypeSpecLanguage.kt @@ -0,0 +1,7 @@ +package jp.s6n.idea.typespec.lang + +import com.intellij.lang.Language + +object TypeSpecLanguage : Language("TypeSpec") { + override fun getDisplayName(): String = "TypeSpec" +} diff --git a/src/main/kotlin/jp/s6n/idea/typespec/lang/lexer/TypeSpecLexer.kt b/src/main/kotlin/jp/s6n/idea/typespec/lang/lexer/TypeSpecLexer.kt new file mode 100644 index 0000000..6d5329e --- /dev/null +++ b/src/main/kotlin/jp/s6n/idea/typespec/lang/lexer/TypeSpecLexer.kt @@ -0,0 +1,6 @@ +package jp.s6n.idea.typespec.lang.lexer + +import com.intellij.lexer.FlexAdapter +import jp.s6n.idea.typespec.lang.parser._TypeSpecLexer + +class TypeSpecLexer : FlexAdapter(_TypeSpecLexer()) diff --git a/src/main/kotlin/jp/s6n/idea/typespec/lang/parser/TypeSpecParserDefinition.kt b/src/main/kotlin/jp/s6n/idea/typespec/lang/parser/TypeSpecParserDefinition.kt new file mode 100644 index 0000000..fabeeb9 --- /dev/null +++ b/src/main/kotlin/jp/s6n/idea/typespec/lang/parser/TypeSpecParserDefinition.kt @@ -0,0 +1,30 @@ +package jp.s6n.idea.typespec.lang.parser + +import com.intellij.lang.ASTNode +import com.intellij.lang.ParserDefinition +import com.intellij.openapi.project.Project +import com.intellij.psi.FileViewProvider +import com.intellij.psi.PsiElement +import com.intellij.psi.tree.IFileElementType +import jp.s6n.idea.typespec.lang.TypeSpecLanguage +import jp.s6n.idea.typespec.lang.lexer.TypeSpecLexer +import jp.s6n.idea.typespec.lang.psi.* + +class TypeSpecParserDefinition : ParserDefinition { + override fun createLexer(project: Project?) = TypeSpecLexer() + + override fun createParser(project: Project?) = TypeSpecParser() + + override fun getFileNodeType() = FILE + + override fun getCommentTokens() = TYPESPEC_COMMENTS + + override fun getStringLiteralElements() = TYPESPEC_STRINGS + + override fun createElement(node: ASTNode?): PsiElement = TypeSpecElementTypes.Factory.createElement(node) + + override fun createFile(viewProvider: FileViewProvider) = TypeSpecFile(viewProvider) + +} + +val FILE = IFileElementType(TypeSpecLanguage) diff --git a/src/main/kotlin/jp/s6n/idea/typespec/lang/parser/TypeSpecParserUtil.kt b/src/main/kotlin/jp/s6n/idea/typespec/lang/parser/TypeSpecParserUtil.kt new file mode 100644 index 0000000..9985b2a --- /dev/null +++ b/src/main/kotlin/jp/s6n/idea/typespec/lang/parser/TypeSpecParserUtil.kt @@ -0,0 +1,5 @@ +package jp.s6n.idea.typespec.lang.parser + +import com.intellij.lang.parser.GeneratedParserUtilBase + +class TypeSpecParserUtil : GeneratedParserUtilBase() diff --git a/src/main/kotlin/jp/s6n/idea/typespec/lang/psi/TypeSpecElement.kt b/src/main/kotlin/jp/s6n/idea/typespec/lang/psi/TypeSpecElement.kt new file mode 100644 index 0000000..b2a471e --- /dev/null +++ b/src/main/kotlin/jp/s6n/idea/typespec/lang/psi/TypeSpecElement.kt @@ -0,0 +1,5 @@ +package jp.s6n.idea.typespec.lang.psi + +import com.intellij.psi.PsiElement + +interface TypeSpecElement : PsiElement diff --git a/src/main/kotlin/jp/s6n/idea/typespec/lang/psi/TypeSpecElementType.kt b/src/main/kotlin/jp/s6n/idea/typespec/lang/psi/TypeSpecElementType.kt new file mode 100644 index 0000000..704777f --- /dev/null +++ b/src/main/kotlin/jp/s6n/idea/typespec/lang/psi/TypeSpecElementType.kt @@ -0,0 +1,6 @@ +package jp.s6n.idea.typespec.lang.psi + +import com.intellij.psi.tree.IElementType +import jp.s6n.idea.typespec.lang.TypeSpecLanguage + +class TypeSpecElementType(debugName: String) : IElementType(debugName, TypeSpecLanguage) diff --git a/src/main/kotlin/jp/s6n/idea/typespec/lang/psi/TypeSpecFile.kt b/src/main/kotlin/jp/s6n/idea/typespec/lang/psi/TypeSpecFile.kt new file mode 100644 index 0000000..99210a4 --- /dev/null +++ b/src/main/kotlin/jp/s6n/idea/typespec/lang/psi/TypeSpecFile.kt @@ -0,0 +1,10 @@ +package jp.s6n.idea.typespec.lang.psi + +import com.intellij.extapi.psi.PsiFileBase +import com.intellij.psi.FileViewProvider +import jp.s6n.idea.typespec.lang.TypeSpecFileType +import jp.s6n.idea.typespec.lang.TypeSpecLanguage + +class TypeSpecFile(viewProvider: FileViewProvider) : PsiFileBase(viewProvider, TypeSpecLanguage) { + override fun getFileType() = TypeSpecFileType +} diff --git a/src/main/kotlin/jp/s6n/idea/typespec/lang/psi/TypeSpecPsiUtils.kt b/src/main/kotlin/jp/s6n/idea/typespec/lang/psi/TypeSpecPsiUtils.kt new file mode 100644 index 0000000..4750f88 --- /dev/null +++ b/src/main/kotlin/jp/s6n/idea/typespec/lang/psi/TypeSpecPsiUtils.kt @@ -0,0 +1,8 @@ +package jp.s6n.idea.typespec.lang.psi + +import com.intellij.psi.PsiElement +import com.intellij.psi.util.PsiTreeUtil + +fun TypeSpecPathExpression.findTopmostPathParent(): PsiElement? { + return PsiTreeUtil.skipParentsOfType(this, TypeSpecPathExpression::class.java) +} diff --git a/src/main/kotlin/jp/s6n/idea/typespec/lang/psi/TypeSpecTokenType.kt b/src/main/kotlin/jp/s6n/idea/typespec/lang/psi/TypeSpecTokenType.kt new file mode 100644 index 0000000..845692a --- /dev/null +++ b/src/main/kotlin/jp/s6n/idea/typespec/lang/psi/TypeSpecTokenType.kt @@ -0,0 +1,15 @@ +package jp.s6n.idea.typespec.lang.psi + +import com.intellij.psi.tree.IElementType +import com.intellij.psi.tree.TokenSet.* +import jp.s6n.idea.typespec.lang.TypeSpecLanguage +import jp.s6n.idea.typespec.lang.psi.TypeSpecElementTypes.* + +class TypeSpecTokenType(debugName: String) : IElementType(debugName, TypeSpecLanguage) + +val TYPESPEC_STRINGS = create(STRING_LITERAL) +val TYPESPEC_COMMENTS = create(DOC_COMMENT, BLOCK_COMMENT, LINE_COMMENT) +val TYPESPEC_KEYWORDS = create(IMPORT, USING, NAMESPACE, MODEL, INTERFACE) +val TYPESPEC_BRACES = create(LBRACE, RBRACE) +val TYPESPEC_BRACKETS = create(LBRACKET, RBRACKET) +val TYPESPEC_PARENTHESES = create(LPAREN, RPAREN) diff --git a/src/main/kotlin/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecElementImpl.kt b/src/main/kotlin/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecElementImpl.kt new file mode 100644 index 0000000..61e4d41 --- /dev/null +++ b/src/main/kotlin/jp/s6n/idea/typespec/lang/psi/impl/TypeSpecElementImpl.kt @@ -0,0 +1,7 @@ +package jp.s6n.idea.typespec.lang.psi.impl + +import com.intellij.extapi.psi.ASTWrapperPsiElement +import com.intellij.lang.ASTNode +import jp.s6n.idea.typespec.lang.psi.TypeSpecElement + +open class TypeSpecElementImpl(node: ASTNode) : ASTWrapperPsiElement(node), TypeSpecElement diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 6eefd0a..d5f3eb5 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -24,6 +24,17 @@ + + + + + + + + + + +