From 98cbd9c5eb3d09035786a42a28d514d17e3ded0e Mon Sep 17 00:00:00 2001 From: Daniil Ovchinnikov Date: Mon, 28 May 2018 16:35:37 +0300 Subject: [PATCH] [groovy] parser: rename some rules to match class names (IDEA-191728) - type_parameter_bounds -> type_parameter_bounds_list; - array_declarator -> array_declaration; - anonymous_class -> anonymous_type_definition. --- .../lang/parser/GroovyGeneratedParser.java | 104 +++++++++--------- .../groovy/lang/psi/GroovyElementTypes.java | 6 +- .../lang/parser/GroovyElementTypes.java | 6 +- .../plugins/groovy/lang/parser/groovy.bnf | 18 +-- 4 files changed, 67 insertions(+), 67 deletions(-) diff --git a/plugins/groovy/groovy-psi/gen/org/jetbrains/plugins/groovy/lang/parser/GroovyGeneratedParser.java b/plugins/groovy/groovy-psi/gen/org/jetbrains/plugins/groovy/lang/parser/GroovyGeneratedParser.java index 1f83dc686542..47e432f781c9 100644 --- a/plugins/groovy/groovy-psi/gen/org/jetbrains/plugins/groovy/lang/parser/GroovyGeneratedParser.java +++ b/plugins/groovy/groovy-psi/gen/org/jetbrains/plugins/groovy/lang/parser/GroovyGeneratedParser.java @@ -45,8 +45,8 @@ public class GroovyGeneratedParser implements PsiParser, LightPsiParser { else if (t == ANNOTATION_TYPE_DEFINITION) { r = annotation_type_definition(b, 0); } - else if (t == ANONYMOUS_CLASS) { - r = anonymous_class(b, 0); + else if (t == ANONYMOUS_TYPE_DEFINITION) { + r = anonymous_type_definition(b, 0); } else if (t == APPLICATION_ARGUMENT_LIST) { r = application_argument_list(b, 0); @@ -60,8 +60,8 @@ public class GroovyGeneratedParser implements PsiParser, LightPsiParser { else if (t == ARGUMENT_LABEL) { r = argument_label(b, 0); } - else if (t == ARRAY_DECLARATOR) { - r = array_declarator(b, 0); + else if (t == ARRAY_DECLARATION) { + r = array_declaration(b, 0); } else if (t == ARRAY_TYPE_ELEMENT) { r = array_type_element(b, 0); @@ -237,8 +237,8 @@ public class GroovyGeneratedParser implements PsiParser, LightPsiParser { else if (t == TYPE_PARAMETER) { r = type_parameter(b, 0); } - else if (t == TYPE_PARAMETER_BOUNDS) { - r = type_parameter_bounds(b, 0); + else if (t == TYPE_PARAMETER_BOUNDS_LIST) { + r = type_parameter_bounds_list(b, 0); } else if (t == TYPE_PARAMETER_LIST) { r = type_parameter_list(b, 0); @@ -694,14 +694,14 @@ public class GroovyGeneratedParser implements PsiParser, LightPsiParser { /* ********************************************************** */ // code_reference call_argument_list class_body - public static boolean anonymous_class(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "anonymous_class")) return false; + public static boolean anonymous_type_definition(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "anonymous_type_definition")) return false; boolean r; - Marker m = enter_section_(b, l, _NONE_, ANONYMOUS_CLASS, ""); + Marker m = enter_section_(b); r = code_reference(b, l + 1); r = r && call_argument_list(b, l + 1); r = r && class_body(b, l + 1); - exit_section_(b, l, m, r, false, null); + exit_section_(b, m, ANONYMOUS_TYPE_DEFINITION, r); return r; } @@ -1012,24 +1012,24 @@ public class GroovyGeneratedParser implements PsiParser, LightPsiParser { /* ********************************************************** */ // mandatory_expression optional_expression* - public static boolean array_declarator(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "array_declarator")) return false; + public static boolean array_declaration(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "array_declaration")) return false; if (!nextTokenIsFast(b, T_LBRACK)) return false; boolean r; Marker m = enter_section_(b); r = mandatory_expression(b, l + 1); - r = r && array_declarator_1(b, l + 1); - exit_section_(b, m, ARRAY_DECLARATOR, r); + r = r && array_declaration_1(b, l + 1); + exit_section_(b, m, ARRAY_DECLARATION, r); return r; } // optional_expression* - private static boolean array_declarator_1(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "array_declarator_1")) return false; + private static boolean array_declaration_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "array_declaration_1")) return false; while (true) { int c = current_position_(b); if (!optional_expression(b, l + 1)) break; - if (!empty_element_parsed_guard_(b, "array_declarator_1", c)) break; + if (!empty_element_parsed_guard_(b, "array_declaration_1", c)) break; } return true; } @@ -2937,9 +2937,9 @@ public class GroovyGeneratedParser implements PsiParser, LightPsiParser { } /* ********************************************************** */ - public static boolean empty_type_parameter_bounds(PsiBuilder b, int l) { + public static boolean empty_type_parameter_bounds_list(PsiBuilder b, int l) { Marker m = enter_section_(b); - exit_section_(b, m, TYPE_PARAMETER_BOUNDS, true); + exit_section_(b, m, TYPE_PARAMETER_BOUNDS_LIST, true); return true; } @@ -6296,7 +6296,7 @@ public class GroovyGeneratedParser implements PsiParser, LightPsiParser { } /* ********************************************************** */ - // IDENTIFIER (type_parameter_bounds | empty_type_parameter_bounds) + // IDENTIFIER (type_parameter_bounds_list | empty_type_parameter_bounds_list) public static boolean type_parameter(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "type_parameter")) return false; if (!nextTokenIs(b, "", IDENTIFIER)) return false; @@ -6308,56 +6308,56 @@ public class GroovyGeneratedParser implements PsiParser, LightPsiParser { return r; } - // type_parameter_bounds | empty_type_parameter_bounds + // type_parameter_bounds_list | empty_type_parameter_bounds_list private static boolean type_parameter_1(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "type_parameter_1")) return false; boolean r; - r = type_parameter_bounds(b, l + 1); - if (!r) r = empty_type_parameter_bounds(b, l + 1); + r = type_parameter_bounds_list(b, l + 1); + if (!r) r = empty_type_parameter_bounds_list(b, l + 1); return r; } /* ********************************************************** */ - // 'extends' type_parameter_bounds_list - public static boolean type_parameter_bounds(PsiBuilder b, int l) { + // type_code_reference type_parameter_bounds_tail* + static boolean type_parameter_bounds(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "type_parameter_bounds")) return false; - if (!nextTokenIs(b, KW_EXTENDS)) return false; - boolean r, p; - Marker m = enter_section_(b, l, _NONE_, TYPE_PARAMETER_BOUNDS, null); - r = consumeToken(b, KW_EXTENDS); - p = r; // pin = 1 - r = r && type_parameter_bounds_list(b, l + 1); - exit_section_(b, l, m, r, p, null); - return r || p; - } - - /* ********************************************************** */ - // type_code_reference type_parameter_bounds_list_tail* - static boolean type_parameter_bounds_list(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "type_parameter_bounds_list")) return false; boolean r; Marker m = enter_section_(b); r = type_code_reference(b, l + 1); - r = r && type_parameter_bounds_list_1(b, l + 1); + r = r && type_parameter_bounds_1(b, l + 1); exit_section_(b, m, null, r); return r; } - // type_parameter_bounds_list_tail* - private static boolean type_parameter_bounds_list_1(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "type_parameter_bounds_list_1")) return false; + // type_parameter_bounds_tail* + private static boolean type_parameter_bounds_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "type_parameter_bounds_1")) return false; while (true) { int c = current_position_(b); - if (!type_parameter_bounds_list_tail(b, l + 1)) break; - if (!empty_element_parsed_guard_(b, "type_parameter_bounds_list_1", c)) break; + if (!type_parameter_bounds_tail(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "type_parameter_bounds_1", c)) break; } return true; } + /* ********************************************************** */ + // 'extends' type_parameter_bounds + public static boolean type_parameter_bounds_list(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "type_parameter_bounds_list")) return false; + if (!nextTokenIs(b, KW_EXTENDS)) return false; + boolean r, p; + Marker m = enter_section_(b, l, _NONE_, TYPE_PARAMETER_BOUNDS_LIST, null); + r = consumeToken(b, KW_EXTENDS); + p = r; // pin = 1 + r = r && type_parameter_bounds(b, l + 1); + exit_section_(b, l, m, r, p, null); + return r || p; + } + /* ********************************************************** */ // '&' type_code_reference - static boolean type_parameter_bounds_list_tail(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "type_parameter_bounds_list_tail")) return false; + static boolean type_parameter_bounds_tail(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "type_parameter_bounds_tail")) return false; if (!nextTokenIs(b, T_BAND)) return false; boolean r, p; Marker m = enter_section_(b, l, _NONE_); @@ -7075,7 +7075,7 @@ public class GroovyGeneratedParser implements PsiParser, LightPsiParser { return r; } - // 'new' type_argument_list? anonymous_class + // 'new' type_argument_list? anonymous_type_definition public static boolean new_anonymous_expression(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "new_anonymous_expression")) return false; if (!nextTokenIsSmart(b, KW_NEW)) return false; @@ -7083,7 +7083,7 @@ public class GroovyGeneratedParser implements PsiParser, LightPsiParser { Marker m = enter_section_(b); r = consumeTokenSmart(b, KW_NEW); r = r && new_anonymous_expression_1(b, l + 1); - r = r && anonymous_class(b, l + 1); + r = r && anonymous_type_definition(b, l + 1); exit_section_(b, m, NEW_EXPRESSION, r); return r; } @@ -7097,7 +7097,7 @@ public class GroovyGeneratedParser implements PsiParser, LightPsiParser { // 'new' type_argument_list? // (primitive_type_element | <>) - // (call_argument_list_start call_argument_list | array_declarator) + // (call_argument_list_start call_argument_list | array_declaration) public static boolean new_expression(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "new_expression")) return false; if (!nextTokenIsSmart(b, KW_NEW)) return false; @@ -7130,13 +7130,13 @@ public class GroovyGeneratedParser implements PsiParser, LightPsiParser { return r; } - // call_argument_list_start call_argument_list | array_declarator + // call_argument_list_start call_argument_list | array_declaration private static boolean new_expression_3(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "new_expression_3")) return false; boolean r; Marker m = enter_section_(b); r = new_expression_3_0(b, l + 1); - if (!r) r = array_declarator(b, l + 1); + if (!r) r = array_declaration(b, l + 1); exit_section_(b, m, null, r); return r; } diff --git a/plugins/groovy/groovy-psi/gen/org/jetbrains/plugins/groovy/lang/psi/GroovyElementTypes.java b/plugins/groovy/groovy-psi/gen/org/jetbrains/plugins/groovy/lang/psi/GroovyElementTypes.java index d297de78f5a3..0634d5648619 100644 --- a/plugins/groovy/groovy-psi/gen/org/jetbrains/plugins/groovy/lang/psi/GroovyElementTypes.java +++ b/plugins/groovy/groovy-psi/gen/org/jetbrains/plugins/groovy/lang/psi/GroovyElementTypes.java @@ -49,13 +49,13 @@ public interface GroovyElementTypes { GrNameValuePairElementType ANNOTATION_MEMBER_VALUE_PAIR = new GrNameValuePairElementType("ANNOTATION_MEMBER_VALUE_PAIR"); GrAnnotationMethodElementType ANNOTATION_METHOD = new GrAnnotationMethodElementType("ANNOTATION_METHOD"); GrAnnotationDefinitionElementType ANNOTATION_TYPE_DEFINITION = new GrAnnotationDefinitionElementType("ANNOTATION_TYPE_DEFINITION"); - GrAnonymousElementType ANONYMOUS_CLASS = new GrAnonymousElementType("ANONYMOUS_CLASS"); + GrAnonymousElementType ANONYMOUS_TYPE_DEFINITION = new GrAnonymousElementType("ANONYMOUS_TYPE_DEFINITION"); GroovyElementType APPLICATION_ARGUMENT_LIST = new GroovyElementType("APPLICATION_ARGUMENT_LIST"); GroovyElementType APPLICATION_EXPRESSION = new GroovyElementType("APPLICATION_EXPRESSION"); GroovyElementType APPLICATION_INDEX = new GroovyElementType("APPLICATION_INDEX"); GroovyElementType ARGUMENT_LABEL = new GroovyElementType("ARGUMENT_LABEL"); GroovyElementType ARGUMENT_LIST = new GroovyElementType("ARGUMENT_LIST"); - GroovyElementType ARRAY_DECLARATOR = new GroovyElementType("ARRAY_DECLARATOR"); + GroovyElementType ARRAY_DECLARATION = new GroovyElementType("ARRAY_DECLARATION"); GroovyElementType ARRAY_TYPE_ELEMENT = new GroovyElementType("ARRAY_TYPE_ELEMENT"); GroovyElementType ASSERT_STATEMENT = new GroovyElementType("ASSERT_STATEMENT"); GroovyElementType ASSIGNMENT_EXPRESSION = new GroovyElementType("ASSIGNMENT_EXPRESSION"); @@ -149,7 +149,7 @@ public interface GroovyElementTypes { GroovyElementType TYPE_ARGUMENT_LIST = new GroovyElementType("TYPE_ARGUMENT_LIST"); GroovyElementType TYPE_ELEMENT = new GroovyElementType("TYPE_ELEMENT"); GrTypeParameterElementType TYPE_PARAMETER = new GrTypeParameterElementType("TYPE_PARAMETER"); - GrTypeParameterBoundsElementType TYPE_PARAMETER_BOUNDS = new GrTypeParameterBoundsElementType("TYPE_PARAMETER_BOUNDS"); + GrTypeParameterBoundsElementType TYPE_PARAMETER_BOUNDS_LIST = new GrTypeParameterBoundsElementType("TYPE_PARAMETER_BOUNDS_LIST"); GrTypeParameterListElementType TYPE_PARAMETER_LIST = new GrTypeParameterListElementType("TYPE_PARAMETER_LIST"); GroovyElementType UNARY_EXPRESSION = new GroovyElementType("UNARY_EXPRESSION"); GrVariableElementType VARIABLE = new GrVariableElementType("VARIABLE"); diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/parser/GroovyElementTypes.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/parser/GroovyElementTypes.java index 57114267fb52..dd8f7aa17b84 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/parser/GroovyElementTypes.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/parser/GroovyElementTypes.java @@ -40,7 +40,7 @@ public interface GroovyElementTypes { GrStubElementType INTERFACE_DEFINITION = INTERFACE_TYPE_DEFINITION; GrStubElementType ENUM_DEFINITION = ENUM_TYPE_DEFINITION; GrStubElementType ANNOTATION_DEFINITION = ANNOTATION_TYPE_DEFINITION; - GrStubElementType ANONYMOUS_CLASS_DEFINITION = ANONYMOUS_CLASS; + GrStubElementType ANONYMOUS_CLASS_DEFINITION = ANONYMOUS_TYPE_DEFINITION; GrStubElementType TRAIT_DEFINITION = TRAIT_TYPE_DEFINITION; GrStubElementType ENUM_CONSTANT_INITIALIZER = org.jetbrains.plugins.groovy.lang.psi.GroovyElementTypes.ENUM_CONSTANT_INITIALIZER; @@ -142,7 +142,7 @@ public interface GroovyElementTypes { IElementType REGEX = org.jetbrains.plugins.groovy.lang.psi.GroovyElementTypes.REGEX; //types IElementType REFERENCE_ELEMENT = CODE_REFERENCE; - IElementType ARRAY_DECLARATOR = org.jetbrains.plugins.groovy.lang.psi.GroovyElementTypes.ARRAY_DECLARATOR; + IElementType ARRAY_DECLARATOR = ARRAY_DECLARATION; IElementType TYPE_ARGUMENTS = TYPE_ARGUMENT_LIST; IElementType TYPE_ARGUMENT = WILDCARD_TYPE_ELEMENT; @@ -150,7 +150,7 @@ public interface GroovyElementTypes { GrStubElementType TYPE_PARAMETER = org.jetbrains.plugins.groovy.lang.psi.GroovyElementTypes.TYPE_PARAMETER; - IStubElementType TYPE_PARAMETER_EXTENDS_BOUND_LIST = TYPE_PARAMETER_BOUNDS; + IStubElementType TYPE_PARAMETER_EXTENDS_BOUND_LIST = TYPE_PARAMETER_BOUNDS_LIST; IElementType DEFAULT_ANNOTATION_VALUE = new GroovyElementType("default annotation value"); diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/parser/groovy.bnf b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/parser/groovy.bnf index 254aeffdcf19..b5febb927c57 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/parser/groovy.bnf +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/parser/groovy.bnf @@ -522,19 +522,19 @@ type_parameter_list ::= '<' type_parameters '>' private type_parameters ::= type_parameter type_parameters_tail* private type_parameters_tail ::= ',' type_parameter { pin = 1 } -type_parameter ::= IDENTIFIER (type_parameter_bounds | empty_type_parameter_bounds) +type_parameter ::= IDENTIFIER (type_parameter_bounds_list | empty_type_parameter_bounds_list) { name = 'type parameter' elementTypeClass = 'org.jetbrains.plugins.groovy.lang.psi.stubs.elements.GrTypeParameterElementType' } -type_parameter_bounds ::= 'extends' type_parameter_bounds_list +type_parameter_bounds_list ::= 'extends' type_parameter_bounds { pin = 1 elementTypeClass = 'org.jetbrains.plugins.groovy.lang.psi.stubs.elements.GrTypeParameterBoundsElementType' } -empty_type_parameter_bounds ::= { elementType = type_parameter_bounds } -private type_parameter_bounds_list ::= type_code_reference type_parameter_bounds_list_tail* -private type_parameter_bounds_list_tail ::= '&' type_code_reference { pin = 1 } +empty_type_parameter_bounds_list ::= { elementType = type_parameter_bounds_list } +private type_parameter_bounds ::= type_code_reference type_parameter_bounds_tail* +private type_parameter_bounds_tail ::= '&' type_code_reference { pin = 1 } type_argument_list ::= diamond_type_argument_list | non_empty_type_argument_list private diamond_type_argument_list ::= <> fast_l_angle '>' @@ -918,19 +918,19 @@ private priority1_1 ::= new_anonymous_expression | new_expression new_expression ::= 'new' type_argument_list? (primitive_type_element | <>) - (call_argument_list_start call_argument_list | array_declarator) + (call_argument_list_start call_argument_list | array_declaration) { pin = 1 } -new_anonymous_expression ::= 'new' type_argument_list? anonymous_class +new_anonymous_expression ::= 'new' type_argument_list? anonymous_type_definition { elementType = new_expression } -anonymous_class ::= code_reference call_argument_list class_body +anonymous_type_definition ::= code_reference call_argument_list class_body { elementTypeClass = 'org.jetbrains.plugins.groovy.lang.psi.stubs.elements.GrAnonymousElementType' } -array_declarator ::= mandatory_expression optional_expression* { consumeTokenMethod = 'consumeTokenFast' } +array_declaration ::= mandatory_expression optional_expression* { consumeTokenMethod = 'consumeTokenFast' } private mandatory_expression ::= '[' expression ']' { pin = 1 consumeTokenMethod = 'consumeTokenFast' } private optional_expression ::= '[' expression? ']' { pin = 1 consumeTokenMethod = 'consumeTokenFast' }