mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[groovy] parser: don't create empty string content nodes
This commit is contained in:
+71
-171
@@ -2291,19 +2291,42 @@ public class GroovyBnfParser implements PsiParser, LightPsiParser {
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// <<begin>> <<a_b_a <<content>> string_injection>> <<end>>
|
||||
// <<begin>> (<<string_content <<content>>>> | string_injection)* <<end>>
|
||||
static boolean compound_string(PsiBuilder b, int l, Parser _begin, Parser _content, Parser _end) {
|
||||
if (!recursion_guard_(b, l, "compound_string")) return false;
|
||||
boolean r, p;
|
||||
Marker m = enter_section_(b, l, _NONE_);
|
||||
r = _begin.parse(b, l);
|
||||
p = r; // pin = 1
|
||||
r = r && report_error_(b, a_b_a(b, l + 1, _content, string_injection_parser_));
|
||||
r = r && report_error_(b, compound_string_1(b, l + 1, _content));
|
||||
r = p && _end.parse(b, l) && r;
|
||||
exit_section_(b, l, m, r, p, null);
|
||||
return r || p;
|
||||
}
|
||||
|
||||
// (<<string_content <<content>>>> | string_injection)*
|
||||
private static boolean compound_string_1(PsiBuilder b, int l, Parser _content) {
|
||||
if (!recursion_guard_(b, l, "compound_string_1")) return false;
|
||||
int c = current_position_(b);
|
||||
while (true) {
|
||||
if (!compound_string_1_0(b, l + 1, _content)) break;
|
||||
if (!empty_element_parsed_guard_(b, "compound_string_1", c)) break;
|
||||
c = current_position_(b);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// <<string_content <<content>>>> | string_injection
|
||||
private static boolean compound_string_1_0(PsiBuilder b, int l, Parser _content) {
|
||||
if (!recursion_guard_(b, l, "compound_string_1_0")) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b);
|
||||
r = string_content(b, l + 1, _content);
|
||||
if (!r) r = string_injection(b, l + 1);
|
||||
exit_section_(b, m, null, r);
|
||||
return r;
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// constructor_identifier parse_parameter_list nl_throws [mb_nl lazy_constructor_block]
|
||||
public static boolean constructor(PsiBuilder b, int l) {
|
||||
@@ -2594,79 +2617,31 @@ public class GroovyBnfParser implements PsiParser, LightPsiParser {
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// DOLLAR_SLASHY_CONTENT | empty_dollar_slashy_content
|
||||
public static boolean dollar_slashy_content_inner(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "dollar_slashy_content_inner")) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b, l, _COLLAPSE_, STRING_CONTENT, null);
|
||||
r = consumeTokenFast(b, DOLLAR_SLASHY_CONTENT);
|
||||
if (!r) r = emptyStringContent(b, l + 1, DOLLAR_SLASHY_CONTENT);
|
||||
exit_section_(b, l, m, r, false, null);
|
||||
return r;
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// DOLLAR_SLASHY_BEGIN fast_dollar_slashy_content? DOLLAR_SLASHY_END | dollar_slashy_literal_pin
|
||||
// DOLLAR_SLASHY_BEGIN fast_dollar_slashy_content? !'$' DOLLAR_SLASHY_END
|
||||
public static boolean dollar_slashy_literal(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "dollar_slashy_literal")) return false;
|
||||
if (!nextTokenIs(b, DOLLAR_SLASHY_BEGIN)) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b);
|
||||
r = dollar_slashy_literal_0(b, l + 1);
|
||||
if (!r) r = dollar_slashy_literal_pin(b, l + 1);
|
||||
exit_section_(b, m, DOLLAR_SLASHY_LITERAL, r);
|
||||
return r;
|
||||
}
|
||||
|
||||
// DOLLAR_SLASHY_BEGIN fast_dollar_slashy_content? DOLLAR_SLASHY_END
|
||||
private static boolean dollar_slashy_literal_0(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "dollar_slashy_literal_0")) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b);
|
||||
r = consumeToken(b, DOLLAR_SLASHY_BEGIN);
|
||||
r = r && dollar_slashy_literal_0_1(b, l + 1);
|
||||
r = r && consumeToken(b, DOLLAR_SLASHY_END);
|
||||
exit_section_(b, m, null, r);
|
||||
return r;
|
||||
}
|
||||
|
||||
// fast_dollar_slashy_content?
|
||||
private static boolean dollar_slashy_literal_0_1(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "dollar_slashy_literal_0_1")) return false;
|
||||
fast_dollar_slashy_content(b, l + 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// DOLLAR_SLASHY_BEGIN (fast_dollar_slashy_content | <<string_content empty_dollar_slashy_content>>) !'$' DOLLAR_SLASHY_END
|
||||
static boolean dollar_slashy_literal_pin(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "dollar_slashy_literal_pin")) return false;
|
||||
if (!nextTokenIs(b, DOLLAR_SLASHY_BEGIN)) return false;
|
||||
boolean r, p;
|
||||
Marker m = enter_section_(b, l, _NONE_);
|
||||
Marker m = enter_section_(b, l, _NONE_, DOLLAR_SLASHY_LITERAL, null);
|
||||
r = consumeToken(b, DOLLAR_SLASHY_BEGIN);
|
||||
r = r && dollar_slashy_literal_pin_1(b, l + 1);
|
||||
r = r && dollar_slashy_literal_pin_2(b, l + 1);
|
||||
r = r && dollar_slashy_literal_1(b, l + 1);
|
||||
r = r && dollar_slashy_literal_2(b, l + 1);
|
||||
p = r; // pin = 3
|
||||
r = r && consumeToken(b, DOLLAR_SLASHY_END);
|
||||
exit_section_(b, l, m, r, p, null);
|
||||
return r || p;
|
||||
}
|
||||
|
||||
// fast_dollar_slashy_content | <<string_content empty_dollar_slashy_content>>
|
||||
private static boolean dollar_slashy_literal_pin_1(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "dollar_slashy_literal_pin_1")) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b);
|
||||
r = fast_dollar_slashy_content(b, l + 1);
|
||||
if (!r) r = string_content(b, l + 1, empty_dollar_slashy_content_parser_);
|
||||
exit_section_(b, m, null, r);
|
||||
return r;
|
||||
// fast_dollar_slashy_content?
|
||||
private static boolean dollar_slashy_literal_1(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "dollar_slashy_literal_1")) return false;
|
||||
fast_dollar_slashy_content(b, l + 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
// !'$'
|
||||
private static boolean dollar_slashy_literal_pin_2(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "dollar_slashy_literal_pin_2")) return false;
|
||||
private static boolean dollar_slashy_literal_2(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "dollar_slashy_literal_2")) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b, l, _NOT_);
|
||||
r = !consumeToken(b, T_DOLLAR);
|
||||
@@ -2675,9 +2650,9 @@ public class GroovyBnfParser implements PsiParser, LightPsiParser {
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// <<compound_string DOLLAR_SLASHY_BEGIN dollar_slashy_content_inner DOLLAR_SLASHY_END>>
|
||||
// <<compound_string DOLLAR_SLASHY_BEGIN fast_dollar_slashy_content DOLLAR_SLASHY_END>>
|
||||
static boolean dollar_slashy_string(PsiBuilder b, int l) {
|
||||
return compound_string(b, l + 1, DOLLAR_SLASHY_BEGIN_parser_, dollar_slashy_content_inner_parser_, DOLLAR_SLASHY_END_parser_);
|
||||
return compound_string(b, l + 1, DOLLAR_SLASHY_BEGIN_parser_, fast_dollar_slashy_content_parser_, DOLLAR_SLASHY_END_parser_);
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
@@ -3213,6 +3188,12 @@ public class GroovyBnfParser implements PsiParser, LightPsiParser {
|
||||
return consumeTokenFast(b, SLASHY_CONTENT);
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// GSTRING_CONTENT
|
||||
static boolean fast_string_content(PsiBuilder b, int l) {
|
||||
return consumeTokenFast(b, GSTRING_CONTENT);
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// var
|
||||
public static boolean field(PsiBuilder b, int l) {
|
||||
@@ -3413,24 +3394,6 @@ public class GroovyBnfParser implements PsiParser, LightPsiParser {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// GSTRING_CONTENT | empty_gstring_content
|
||||
public static boolean gstring_content_inner(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "gstring_content_inner")) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b, l, _COLLAPSE_, STRING_CONTENT, null);
|
||||
r = consumeTokenFast(b, GSTRING_CONTENT);
|
||||
if (!r) r = emptyStringContent(b, l + 1, GSTRING_CONTENT);
|
||||
exit_section_(b, l, m, r, false, null);
|
||||
return r;
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// GSTRING_END
|
||||
static boolean gstring_end(PsiBuilder b, int l) {
|
||||
return consumeToken(b, GSTRING_END);
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// 'if' after_if_keyword
|
||||
public static boolean if_statement(PsiBuilder b, int l) {
|
||||
@@ -5200,72 +5163,24 @@ public class GroovyBnfParser implements PsiParser, LightPsiParser {
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// SLASHY_CONTENT | empty_slashy_content
|
||||
public static boolean slashy_content_inner(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "slashy_content_inner")) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b, l, _COLLAPSE_, STRING_CONTENT, null);
|
||||
r = consumeTokenFast(b, SLASHY_CONTENT);
|
||||
if (!r) r = emptyStringContent(b, l + 1, SLASHY_CONTENT);
|
||||
exit_section_(b, l, m, r, false, null);
|
||||
return r;
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// SLASHY_BEGIN fast_slashy_content SLASHY_END | slashy_literal_pin
|
||||
// SLASHY_BEGIN fast_slashy_content !'$' SLASHY_END
|
||||
public static boolean slashy_literal(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "slashy_literal")) return false;
|
||||
if (!nextTokenIs(b, SLASHY_BEGIN)) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b);
|
||||
r = slashy_literal_0(b, l + 1);
|
||||
if (!r) r = slashy_literal_pin(b, l + 1);
|
||||
exit_section_(b, m, SLASHY_LITERAL, r);
|
||||
return r;
|
||||
}
|
||||
|
||||
// SLASHY_BEGIN fast_slashy_content SLASHY_END
|
||||
private static boolean slashy_literal_0(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "slashy_literal_0")) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b);
|
||||
boolean r, p;
|
||||
Marker m = enter_section_(b, l, _NONE_, SLASHY_LITERAL, null);
|
||||
r = consumeToken(b, SLASHY_BEGIN);
|
||||
r = r && fast_slashy_content(b, l + 1);
|
||||
r = r && consumeToken(b, SLASHY_END);
|
||||
exit_section_(b, m, null, r);
|
||||
return r;
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// SLASHY_BEGIN (fast_slashy_content | <<string_content empty_slashy_content>>) !'$' SLASHY_END
|
||||
static boolean slashy_literal_pin(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "slashy_literal_pin")) return false;
|
||||
if (!nextTokenIs(b, SLASHY_BEGIN)) return false;
|
||||
boolean r, p;
|
||||
Marker m = enter_section_(b, l, _NONE_);
|
||||
r = consumeToken(b, SLASHY_BEGIN);
|
||||
r = r && slashy_literal_pin_1(b, l + 1);
|
||||
r = r && slashy_literal_pin_2(b, l + 1);
|
||||
r = r && slashy_literal_2(b, l + 1);
|
||||
p = r; // pin = 3
|
||||
r = r && consumeToken(b, SLASHY_END);
|
||||
exit_section_(b, l, m, r, p, null);
|
||||
return r || p;
|
||||
}
|
||||
|
||||
// fast_slashy_content | <<string_content empty_slashy_content>>
|
||||
private static boolean slashy_literal_pin_1(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "slashy_literal_pin_1")) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b);
|
||||
r = fast_slashy_content(b, l + 1);
|
||||
if (!r) r = string_content(b, l + 1, empty_slashy_content_parser_);
|
||||
exit_section_(b, m, null, r);
|
||||
return r;
|
||||
}
|
||||
|
||||
// !'$'
|
||||
private static boolean slashy_literal_pin_2(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "slashy_literal_pin_2")) return false;
|
||||
private static boolean slashy_literal_2(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "slashy_literal_2")) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b, l, _NOT_);
|
||||
r = !consumeToken(b, T_DOLLAR);
|
||||
@@ -5274,9 +5189,9 @@ public class GroovyBnfParser implements PsiParser, LightPsiParser {
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// <<compound_string SLASHY_BEGIN slashy_content_inner SLASHY_END>>
|
||||
// <<compound_string SLASHY_BEGIN fast_slashy_content SLASHY_END>>
|
||||
static boolean slashy_string(PsiBuilder b, int l) {
|
||||
return compound_string(b, l + 1, SLASHY_BEGIN_parser_, slashy_content_inner_parser_, SLASHY_END_parser_);
|
||||
return compound_string(b, l + 1, SLASHY_BEGIN_parser_, fast_slashy_content_parser_, SLASHY_END_parser_);
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
@@ -5396,9 +5311,9 @@ public class GroovyBnfParser implements PsiParser, LightPsiParser {
|
||||
public static boolean string_content(PsiBuilder b, int l, Parser _content) {
|
||||
if (!recursion_guard_(b, l, "string_content")) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b, l, _COLLAPSE_, STRING_CONTENT, null);
|
||||
Marker m = enter_section_(b);
|
||||
r = _content.parse(b, l);
|
||||
exit_section_(b, l, m, r, false, null);
|
||||
exit_section_(b, m, STRING_CONTENT, r);
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -7061,13 +6976,13 @@ public class GroovyBnfParser implements PsiParser, LightPsiParser {
|
||||
return r;
|
||||
}
|
||||
|
||||
// <<compound_string GSTRING_BEGIN gstring_content_inner gstring_end>>
|
||||
// <<compound_string GSTRING_BEGIN fast_string_content GSTRING_END>>
|
||||
public static boolean gstring(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "gstring")) return false;
|
||||
if (!nextTokenIsSmart(b, GSTRING_BEGIN)) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b);
|
||||
r = compound_string(b, l + 1, GSTRING_BEGIN_parser_, gstring_content_inner_parser_, gstring_end_parser_);
|
||||
r = compound_string(b, l + 1, GSTRING_BEGIN_parser_, fast_string_content_parser_, GSTRING_END_parser_);
|
||||
exit_section_(b, m, GSTRING, r);
|
||||
return r;
|
||||
}
|
||||
@@ -7107,7 +7022,12 @@ public class GroovyBnfParser implements PsiParser, LightPsiParser {
|
||||
};
|
||||
final static Parser GSTRING_BEGIN_parser_ = new Parser() {
|
||||
public boolean parse(PsiBuilder b, int l) {
|
||||
return consumeTokenSmart(b, GSTRING_BEGIN);
|
||||
return consumeToken(b, GSTRING_BEGIN);
|
||||
}
|
||||
};
|
||||
final static Parser GSTRING_END_parser_ = new Parser() {
|
||||
public boolean parse(PsiBuilder b, int l) {
|
||||
return consumeToken(b, GSTRING_END);
|
||||
}
|
||||
};
|
||||
final static Parser SLASHY_BEGIN_parser_ = new Parser() {
|
||||
@@ -7305,21 +7225,6 @@ public class GroovyBnfParser implements PsiParser, LightPsiParser {
|
||||
return declaration_tail(b, l + 1);
|
||||
}
|
||||
};
|
||||
final static Parser dollar_slashy_content_inner_parser_ = new Parser() {
|
||||
public boolean parse(PsiBuilder b, int l) {
|
||||
return dollar_slashy_content_inner(b, l + 1);
|
||||
}
|
||||
};
|
||||
final static Parser empty_dollar_slashy_content_parser_ = new Parser() {
|
||||
public boolean parse(PsiBuilder b, int l) {
|
||||
return emptyStringContent(b, l + 1, DOLLAR_SLASHY_CONTENT);
|
||||
}
|
||||
};
|
||||
final static Parser empty_slashy_content_parser_ = new Parser() {
|
||||
public boolean parse(PsiBuilder b, int l) {
|
||||
return emptyStringContent(b, l + 1, SLASHY_CONTENT);
|
||||
}
|
||||
};
|
||||
final static Parser expression_or_application_inner_parser_ = new Parser() {
|
||||
public boolean parse(PsiBuilder b, int l) {
|
||||
return expression_or_application_inner(b, l + 1);
|
||||
@@ -7340,14 +7245,19 @@ public class GroovyBnfParser implements PsiParser, LightPsiParser {
|
||||
return extends_recovery(b, l + 1);
|
||||
}
|
||||
};
|
||||
final static Parser gstring_content_inner_parser_ = new Parser() {
|
||||
final static Parser fast_dollar_slashy_content_parser_ = new Parser() {
|
||||
public boolean parse(PsiBuilder b, int l) {
|
||||
return gstring_content_inner(b, l + 1);
|
||||
return fast_dollar_slashy_content(b, l + 1);
|
||||
}
|
||||
};
|
||||
final static Parser gstring_end_parser_ = new Parser() {
|
||||
final static Parser fast_slashy_content_parser_ = new Parser() {
|
||||
public boolean parse(PsiBuilder b, int l) {
|
||||
return gstring_end(b, l + 1);
|
||||
return fast_slashy_content(b, l + 1);
|
||||
}
|
||||
};
|
||||
final static Parser fast_string_content_parser_ = new Parser() {
|
||||
public boolean parse(PsiBuilder b, int l) {
|
||||
return fast_string_content(b, l + 1);
|
||||
}
|
||||
};
|
||||
final static Parser implements_list_item_parser_ = new Parser() {
|
||||
@@ -7420,16 +7330,6 @@ public class GroovyBnfParser implements PsiParser, LightPsiParser {
|
||||
return semicolon_recovery(b, l + 1);
|
||||
}
|
||||
};
|
||||
final static Parser slashy_content_inner_parser_ = new Parser() {
|
||||
public boolean parse(PsiBuilder b, int l) {
|
||||
return slashy_content_inner(b, l + 1);
|
||||
}
|
||||
};
|
||||
final static Parser string_injection_parser_ = new Parser() {
|
||||
public boolean parse(PsiBuilder b, int l) {
|
||||
return string_injection(b, l + 1);
|
||||
}
|
||||
};
|
||||
final static Parser throws_list_item_parser_ = new Parser() {
|
||||
public boolean parse(PsiBuilder b, int l) {
|
||||
return throws_list_item(b, l + 1);
|
||||
|
||||
@@ -166,13 +166,11 @@
|
||||
elementType('.*_modifier_list') = modifier_list
|
||||
elementType('.*_reference_expression') = reference_expression
|
||||
elementType('.*_class_type_element') = class_type_element
|
||||
elementType('.*_content_inner') = string_content
|
||||
consumeTokenMethod('.*_expression') = 'consumeTokenFast'
|
||||
consumeTokenMethod('.*_shift.*_sign') = 'consumeTokenFast'
|
||||
consumeTokenMethod('.*_content_inner') = 'consumeTokenFast'
|
||||
consumeTokenMethod('fast.*') = 'consumeTokenFast'
|
||||
consumeTokenMethod('.*_type_definition') = 'consumeTokenFast'
|
||||
name(".*type_element") = 'type'
|
||||
name('.*_content_inner') = ''
|
||||
name('.*type_definition') = ''
|
||||
}
|
||||
|
||||
@@ -877,44 +875,21 @@ private simple_literal_tokens ::= NUM_INT
|
||||
consumeTokenMethod = 'consumeTokenFast'
|
||||
}
|
||||
|
||||
private regex_literal ::= slashy_literal | dollar_slashy_literal
|
||||
{
|
||||
consumeTokenMethod = 'consumeTokenFast'
|
||||
}
|
||||
slashy_literal ::= SLASHY_BEGIN fast_slashy_content SLASHY_END | slashy_literal_pin
|
||||
private fast_slashy_content ::= SLASHY_CONTENT { consumeTokenMethod = 'consumeTokenFast'}
|
||||
private slashy_literal_pin ::= SLASHY_BEGIN (fast_slashy_content | <<string_content empty_slashy_content>>) !'$' SLASHY_END
|
||||
{
|
||||
pin = 3
|
||||
}
|
||||
dollar_slashy_literal ::= DOLLAR_SLASHY_BEGIN fast_dollar_slashy_content? DOLLAR_SLASHY_END | dollar_slashy_literal_pin
|
||||
private fast_dollar_slashy_content ::= DOLLAR_SLASHY_CONTENT { consumeTokenMethod = 'consumeTokenFast'}
|
||||
private dollar_slashy_literal_pin ::= DOLLAR_SLASHY_BEGIN (fast_dollar_slashy_content | <<string_content empty_dollar_slashy_content>>) !'$' DOLLAR_SLASHY_END
|
||||
{
|
||||
pin = 3
|
||||
}
|
||||
private regex_literal ::= slashy_literal | dollar_slashy_literal { consumeTokenMethod = 'consumeTokenFast' }
|
||||
slashy_literal ::= SLASHY_BEGIN fast_slashy_content !'$' SLASHY_END { pin = 3 }
|
||||
dollar_slashy_literal ::= DOLLAR_SLASHY_BEGIN fast_dollar_slashy_content? !'$' DOLLAR_SLASHY_END { pin = 3 }
|
||||
|
||||
gstring ::= (<<compound_string GSTRING_BEGIN gstring_content_inner gstring_end>>)
|
||||
{
|
||||
extends = expression
|
||||
consumeTokenMethod = 'consumeTokenFast'
|
||||
}
|
||||
private gstring_end ::= GSTRING_END
|
||||
regex ::= slashy_string | dollar_slashy_string
|
||||
{
|
||||
extends = expression
|
||||
}
|
||||
private slashy_string ::= <<compound_string SLASHY_BEGIN slashy_content_inner SLASHY_END>>
|
||||
private dollar_slashy_string ::= <<compound_string DOLLAR_SLASHY_BEGIN dollar_slashy_content_inner DOLLAR_SLASHY_END>>
|
||||
private meta compound_string ::= <<begin>> <<a_b_a <<content>> string_injection>> <<end>> { pin = 1 }
|
||||
gstring ::= <<compound_string GSTRING_BEGIN fast_string_content GSTRING_END>> { extends = expression }
|
||||
regex ::= slashy_string | dollar_slashy_string { extends = expression }
|
||||
private slashy_string ::= <<compound_string SLASHY_BEGIN fast_slashy_content SLASHY_END>>
|
||||
private dollar_slashy_string ::= <<compound_string DOLLAR_SLASHY_BEGIN fast_dollar_slashy_content DOLLAR_SLASHY_END>>
|
||||
|
||||
private fast_slashy_content ::= SLASHY_CONTENT
|
||||
private fast_dollar_slashy_content ::= DOLLAR_SLASHY_CONTENT
|
||||
private fast_string_content ::= GSTRING_CONTENT
|
||||
|
||||
private meta compound_string ::= <<begin>> (<<string_content <<content>>>> | string_injection)* <<end>> { pin = 1 }
|
||||
meta string_content ::= <<content>>
|
||||
gstring_content_inner ::= GSTRING_CONTENT | empty_gstring_content
|
||||
slashy_content_inner ::= SLASHY_CONTENT | empty_slashy_content
|
||||
dollar_slashy_content_inner ::= DOLLAR_SLASHY_CONTENT | empty_dollar_slashy_content
|
||||
//TODO get rid of this weird logic
|
||||
private external empty_gstring_content ::= emptyStringContent 'GSTRING_CONTENT'
|
||||
private external empty_slashy_content ::= emptyStringContent 'SLASHY_CONTENT'
|
||||
private external empty_dollar_slashy_content ::= emptyStringContent 'DOLLAR_SLASHY_CONTENT'
|
||||
string_injection ::= '$' string_injection_body
|
||||
{
|
||||
pin = 1
|
||||
|
||||
+1
-19
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.groovy.lang.psi.util;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
@@ -488,7 +474,6 @@ public class GrStringUtil {
|
||||
final GrExpression expression = factory.createExpressionFromText("\"\"\"${}" + literalText + "\"\"\"");
|
||||
|
||||
expression.getFirstChild().delete();//quote
|
||||
expression.getFirstChild().delete();//empty gstring content
|
||||
expression.getFirstChild().delete();//empty injection
|
||||
|
||||
final ASTNode node = grString.getNode();
|
||||
@@ -564,9 +549,6 @@ public class GrStringUtil {
|
||||
PsiElement child = gString.getFirstChild();
|
||||
if (!(child.getNode().getElementType() == GroovyTokenTypes.mGSTRING_BEGIN)) return false;
|
||||
|
||||
child = child.getNextSibling();
|
||||
if (!(child instanceof GrStringContent)) return false;
|
||||
|
||||
child = child.getNextSibling();
|
||||
if (!(child instanceof GrStringInjection)) return false;
|
||||
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
Groovy script
|
||||
Compound Gstring
|
||||
PsiElement(Gstring begin)('"')
|
||||
GrStringContentImpl(STRING_CONTENT)
|
||||
ASTWrapperPsiElement(Gstring content)
|
||||
<empty list>
|
||||
GString injection
|
||||
PsiElement($)('$')
|
||||
Reference expression
|
||||
|
||||
@@ -10,9 +10,6 @@ Groovy script
|
||||
PsiElement($)('$')
|
||||
Reference expression
|
||||
PsiElement(identifier)('str')
|
||||
GrStringContentImpl(STRING_CONTENT)
|
||||
ASTWrapperPsiElement(Gstring content)
|
||||
<empty list>
|
||||
GString injection
|
||||
PsiElement($)('$')
|
||||
Reference expression
|
||||
@@ -34,9 +31,6 @@ Groovy script
|
||||
Reference expression
|
||||
PsiElement(identifier)('str')
|
||||
PsiElement(})('}')
|
||||
GrStringContentImpl(STRING_CONTENT)
|
||||
ASTWrapperPsiElement(Gstring content)
|
||||
<empty list>
|
||||
GString injection
|
||||
PsiElement($)('$')
|
||||
Reference expression
|
||||
|
||||
@@ -9,8 +9,5 @@ Groovy script
|
||||
PsiWhiteSpace(' ')
|
||||
Compound Gstring
|
||||
PsiElement(Gstring begin)('"')
|
||||
GrStringContentImpl(STRING_CONTENT)
|
||||
ASTWrapperPsiElement(Gstring content)
|
||||
<empty list>
|
||||
PsiErrorElement:Gstring end expected
|
||||
<empty list>
|
||||
@@ -10,9 +10,6 @@ Groovy script
|
||||
PsiWhiteSpace(' ')
|
||||
Compound Gstring
|
||||
PsiElement(Gstring begin)('"')
|
||||
GrStringContentImpl(STRING_CONTENT)
|
||||
ASTWrapperPsiElement(Gstring content)
|
||||
<empty list>
|
||||
PsiErrorElement:Gstring end expected
|
||||
<empty list>
|
||||
PsiElement(new line)('\n')
|
||||
|
||||
-6
@@ -14,14 +14,8 @@ Groovy script
|
||||
Reference expression
|
||||
PsiElement(identifier)('href')
|
||||
PsiElement(})('}')
|
||||
GrStringContentImpl(STRING_CONTENT)
|
||||
ASTWrapperPsiElement(Gstring content)
|
||||
<empty list>
|
||||
GString injection
|
||||
PsiElement($)('$')
|
||||
Reference expression
|
||||
PsiElement(identifier)('x')
|
||||
GrStringContentImpl(STRING_CONTENT)
|
||||
ASTWrapperPsiElement(Gstring content)
|
||||
<empty list>
|
||||
PsiElement(Gstring end)('"""')
|
||||
@@ -23,9 +23,6 @@ Groovy script
|
||||
PsiElement(.)('.')
|
||||
Compound regular expression
|
||||
PsiElement(regex begin)('/')
|
||||
GrStringContentImpl(STRING_CONTENT)
|
||||
ASTWrapperPsiElement(regex content)
|
||||
<empty list>
|
||||
GString injection
|
||||
PsiElement($)('$')
|
||||
Closable block
|
||||
@@ -35,9 +32,6 @@ Groovy script
|
||||
Reference expression
|
||||
PsiElement(identifier)('a')
|
||||
PsiElement(})('}')
|
||||
GrStringContentImpl(STRING_CONTENT)
|
||||
ASTWrapperPsiElement(regex content)
|
||||
<empty list>
|
||||
PsiElement(regex end)('/')
|
||||
PsiElement(.)('.')
|
||||
Compound regular expression
|
||||
@@ -48,7 +42,4 @@ Groovy script
|
||||
PsiElement($)('$')
|
||||
Reference expression
|
||||
PsiElement(identifier)('g')
|
||||
GrStringContentImpl(STRING_CONTENT)
|
||||
ASTWrapperPsiElement($/ regex content)
|
||||
<empty list>
|
||||
PsiElement($/ regex end)('/$')
|
||||
@@ -18,8 +18,5 @@ Groovy script
|
||||
PsiElement($)('$')
|
||||
PsiErrorElement:Identifier or code block expected
|
||||
<empty list>
|
||||
GrStringContentImpl(STRING_CONTENT)
|
||||
ASTWrapperPsiElement($/ regex content)
|
||||
<empty list>
|
||||
PsiErrorElement:$/ regex end expected
|
||||
<empty list>
|
||||
@@ -13,8 +13,5 @@ Groovy script
|
||||
Literal
|
||||
GroovyASTPsiElementImpl(DOLLAR_SLASHY_LITERAL)
|
||||
PsiElement($/ regex begin)('$/')
|
||||
GrStringContentImpl(STRING_CONTENT)
|
||||
ASTWrapperPsiElement($/ regex content)
|
||||
<empty list>
|
||||
PsiErrorElement:$/ regex end expected
|
||||
<empty list>
|
||||
@@ -37,9 +37,6 @@ Groovy script
|
||||
Reference expression
|
||||
PsiElement(identifier)('b')
|
||||
PsiElement(})('}')
|
||||
GrStringContentImpl(STRING_CONTENT)
|
||||
ASTWrapperPsiElement(Gstring content)
|
||||
<empty list>
|
||||
PsiElement(Gstring end)('"')
|
||||
PsiElement(})('}')
|
||||
GrStringContentImpl(STRING_CONTENT)
|
||||
|
||||
@@ -3,15 +3,9 @@
|
||||
Groovy script
|
||||
Compound regular expression
|
||||
PsiElement(regex begin)('/')
|
||||
GrStringContentImpl(STRING_CONTENT)
|
||||
ASTWrapperPsiElement(regex content)
|
||||
<empty list>
|
||||
GString injection
|
||||
PsiElement($)('$')
|
||||
PsiErrorElement:Identifier or code block expected
|
||||
<empty list>
|
||||
GrStringContentImpl(STRING_CONTENT)
|
||||
ASTWrapperPsiElement(regex content)
|
||||
<empty list>
|
||||
PsiErrorElement:regex end expected
|
||||
<empty list>
|
||||
@@ -20,8 +20,5 @@ Groovy script
|
||||
Literal
|
||||
PsiElement(Integer)('2')
|
||||
PsiElement(})('}')
|
||||
GrStringContentImpl(STRING_CONTENT)
|
||||
ASTWrapperPsiElement(regex content)
|
||||
<empty list>
|
||||
PsiElement(regex end)('/')
|
||||
PsiElement())(')')
|
||||
@@ -3,9 +3,6 @@
|
||||
Groovy script
|
||||
Compound regular expression
|
||||
PsiElement(regex begin)('/')
|
||||
GrStringContentImpl(STRING_CONTENT)
|
||||
ASTWrapperPsiElement(regex content)
|
||||
<empty list>
|
||||
GString injection
|
||||
PsiElement($)('$')
|
||||
Closable block
|
||||
@@ -15,9 +12,6 @@ Groovy script
|
||||
Literal
|
||||
PsiElement(Integer)('1')
|
||||
PsiElement(})('}')
|
||||
GrStringContentImpl(STRING_CONTENT)
|
||||
ASTWrapperPsiElement(regex content)
|
||||
<empty list>
|
||||
GString injection
|
||||
PsiElement($)('$')
|
||||
Closable block
|
||||
@@ -27,7 +21,4 @@ Groovy script
|
||||
Literal
|
||||
PsiElement(Integer)('2')
|
||||
PsiElement(})('}')
|
||||
GrStringContentImpl(STRING_CONTENT)
|
||||
ASTWrapperPsiElement(regex content)
|
||||
<empty list>
|
||||
PsiElement(regex end)('/')
|
||||
@@ -3,9 +3,6 @@ $/${1}${2}/$
|
||||
Groovy script
|
||||
Compound regular expression
|
||||
PsiElement($/ regex begin)('$/')
|
||||
GrStringContentImpl(STRING_CONTENT)
|
||||
ASTWrapperPsiElement($/ regex content)
|
||||
<empty list>
|
||||
GString injection
|
||||
PsiElement($)('$')
|
||||
Closable block
|
||||
@@ -15,9 +12,6 @@ Groovy script
|
||||
Literal
|
||||
PsiElement(Integer)('1')
|
||||
PsiElement(})('}')
|
||||
GrStringContentImpl(STRING_CONTENT)
|
||||
ASTWrapperPsiElement($/ regex content)
|
||||
<empty list>
|
||||
GString injection
|
||||
PsiElement($)('$')
|
||||
Closable block
|
||||
@@ -27,7 +21,4 @@ Groovy script
|
||||
Literal
|
||||
PsiElement(Integer)('2')
|
||||
PsiElement(})('}')
|
||||
GrStringContentImpl(STRING_CONTENT)
|
||||
ASTWrapperPsiElement($/ regex content)
|
||||
<empty list>
|
||||
PsiElement($/ regex end)('/$')
|
||||
@@ -39,9 +39,6 @@ Groovy script
|
||||
Reference expression
|
||||
PsiElement(identifier)('b')
|
||||
PsiElement(})('}')
|
||||
GrStringContentImpl(STRING_CONTENT)
|
||||
ASTWrapperPsiElement(Gstring content)
|
||||
<empty list>
|
||||
PsiElement(Gstring end)('"')
|
||||
PsiElement(})('}')
|
||||
GrStringContentImpl(STRING_CONTENT)
|
||||
|
||||
@@ -40,9 +40,6 @@ Groovy script
|
||||
Reference expression
|
||||
PsiElement(identifier)('b')
|
||||
PsiElement(})('}')
|
||||
GrStringContentImpl(STRING_CONTENT)
|
||||
ASTWrapperPsiElement(Gstring content)
|
||||
<empty list>
|
||||
PsiElement(Gstring end)('"')
|
||||
PsiElement(})('}')
|
||||
GrStringContentImpl(STRING_CONTENT)
|
||||
|
||||
@@ -7,9 +7,6 @@ Groovy script
|
||||
Argument label
|
||||
Compound Gstring
|
||||
PsiElement(Gstring begin)('"')
|
||||
GrStringContentImpl(STRING_CONTENT)
|
||||
ASTWrapperPsiElement(Gstring content)
|
||||
<empty list>
|
||||
GString injection
|
||||
PsiElement($)('$')
|
||||
Reference expression
|
||||
@@ -24,9 +21,6 @@ Groovy script
|
||||
PsiWhiteSpace(' ')
|
||||
Compound Gstring
|
||||
PsiElement(Gstring begin)('"')
|
||||
GrStringContentImpl(STRING_CONTENT)
|
||||
ASTWrapperPsiElement(Gstring content)
|
||||
<empty list>
|
||||
GString injection
|
||||
PsiElement($)('$')
|
||||
Reference expression
|
||||
|
||||
@@ -39,9 +39,6 @@ Groovy script
|
||||
Literal
|
||||
PsiElement(Integer)('3')
|
||||
PsiElement(})('}')
|
||||
GrStringContentImpl(STRING_CONTENT)
|
||||
ASTWrapperPsiElement(Gstring content)
|
||||
<empty list>
|
||||
PsiErrorElement:Gstring end expected
|
||||
<empty list>
|
||||
PsiElement(new line)('\n ')
|
||||
@@ -51,8 +48,5 @@ Groovy script
|
||||
Command arguments
|
||||
Compound Gstring
|
||||
PsiElement(Gstring begin)('"""')
|
||||
GrStringContentImpl(STRING_CONTENT)
|
||||
ASTWrapperPsiElement(Gstring content)
|
||||
<empty list>
|
||||
PsiErrorElement:Gstring end expected
|
||||
<empty list>
|
||||
Reference in New Issue
Block a user