Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-implemented from the scratch Lexer and Parser for User Rights block #435

Merged
merged 1 commit into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
- Inspection rule: validate that `lang` modifier value is present in the `lang.packs` [#417](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/417)
- Inspection rule: validate that `lang` modifier is used only for localized attributes [#418](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/418)

### `ImpEx` - `User Rights` 2.0
- SAP Help Portal - [User Rights](https://help.sap.com/docs/SAP_COMMERCE/50c996852b32456c96d3161a95544cdb/e472718cafe840c39fbb5ceb00002e52.html?locale=en-US)
- Re-implemented from the scratch Lexer and Parser for `$START_USERRIGHTS` block [#435](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/435)

### `FlexibleSearch` enhancements
- Added possibility to copy FlexibleSearch from the Java 15 text block `"""SELECT * FROM {Product}"""` [#428](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/428)
- Added FlexibleSearch language injection into Java 15 text block `"""SELECT * FROM {Product}"""` [#430](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/430)
Expand Down Expand Up @@ -111,7 +115,7 @@
- Added generate Diagram run line marker for `items.xml`
- Added generate Diagram run line marker for `extensioninfo.xml` [#332](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/332)

### FlexibleSearch 2.0
### `FlexibleSearch` 2.0
- Rewritten from the Scratch
- Folding support
- Brand-new possibility to Unify case of the reserved words, change to upper or lowercase with a single click
Expand Down Expand Up @@ -175,7 +179,7 @@
- Enabled possibility to disable validation of the generated classes [#313](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/313)
- Project import will respect extensions registered via `path` with `autoload=true` [#319](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/319)

### New inspection rules for `items.xml`
### `items.xml` inspection rules
- Relation qualifier and modifiers must not be declared for `navigable='false'` end [#307](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/307)
- Only one side of many-to-many relation must be `navigable='false'` [#315](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/315)
- Qualifier must exist for `navigable='true'` part in many-to-many relation [#318](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/318)
Expand Down
306 changes: 295 additions & 11 deletions gen/com/intellij/idea/plugin/hybris/impex/ImpexParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,7 @@ private static boolean recover_parameters_0(PsiBuilder b, int l) {
/* ********************************************************** */
// !(
// CRLF
// | user_rights_start
// | HEADER_MODE_INSERT
// | HEADER_MODE_INSERT_UPDATE
// | HEADER_MODE_REMOVE
Expand All @@ -816,6 +817,7 @@ static boolean recover_root(PsiBuilder b, int l) {
}

// CRLF
// | user_rights_start
// | HEADER_MODE_INSERT
// | HEADER_MODE_INSERT_UPDATE
// | HEADER_MODE_REMOVE
Expand All @@ -832,6 +834,7 @@ private static boolean recover_root_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "recover_root_0")) return false;
boolean r;
r = consumeToken(b, CRLF);
if (!r) r = user_rights_start(b, l + 1);
if (!r) r = consumeToken(b, HEADER_MODE_INSERT);
if (!r) r = consumeToken(b, HEADER_MODE_INSERT_UPDATE);
if (!r) r = consumeToken(b, HEADER_MODE_REMOVE);
Expand Down Expand Up @@ -893,7 +896,8 @@ private static boolean root_1_2(PsiBuilder b, int l) {
}

/* ********************************************************** */
// root_macro_usage
// user_rights
// | root_macro_usage
// | header_line
// | value_line
// | comment
Expand All @@ -904,38 +908,39 @@ static boolean root_group(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "root_group")) return false;
boolean r;
Marker m = enter_section_(b, l, _NONE_);
r = root_macro_usage(b, l + 1);
r = user_rights(b, l + 1);
if (!r) r = root_macro_usage(b, l + 1);
if (!r) r = header_line(b, l + 1);
if (!r) r = value_line(b, l + 1);
if (!r) r = comment(b, l + 1);
if (!r) r = bean_shell(b, l + 1);
if (!r) r = root_group_5(b, l + 1);
if (!r) r = root_group_6(b, l + 1);
if (!r) r = macro_declaration(b, l + 1);
exit_section_(b, l, m, r, false, ImpexParser::not_line_break);
return r;
}

// string (';')?
private static boolean root_group_5(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "root_group_5")) return false;
private static boolean root_group_6(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "root_group_6")) return false;
boolean r;
Marker m = enter_section_(b);
r = string(b, l + 1);
r = r && root_group_5_1(b, l + 1);
r = r && root_group_6_1(b, l + 1);
exit_section_(b, m, null, r);
return r;
}

// (';')?
private static boolean root_group_5_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "root_group_5_1")) return false;
root_group_5_1_0(b, l + 1);
private static boolean root_group_6_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "root_group_6_1")) return false;
root_group_6_1_0(b, l + 1);
return true;
}

// (';')
private static boolean root_group_5_1_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "root_group_5_1_0")) return false;
private static boolean root_group_6_1_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "root_group_6_1_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeToken(b, ";");
Expand Down Expand Up @@ -1056,6 +1061,285 @@ public static boolean sub_type_name(PsiBuilder b, int l) {
return r;
}

/* ********************************************************** */
// user_rights_start CRLF (user_rights_header_line CRLF)? (user_rights_value_line CRLF)* user_rights_end
public static boolean user_rights(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "user_rights")) return false;
boolean r, p;
Marker m = enter_section_(b, l, _NONE_, USER_RIGHTS, "<user rights>");
r = user_rights_start(b, l + 1);
p = r; // pin = 1
r = r && report_error_(b, consumeToken(b, CRLF));
r = p && report_error_(b, user_rights_2(b, l + 1)) && r;
r = p && report_error_(b, user_rights_3(b, l + 1)) && r;
r = p && user_rights_end(b, l + 1) && r;
exit_section_(b, l, m, r, p, ImpexParser::recover_root);
return r || p;
}

// (user_rights_header_line CRLF)?
private static boolean user_rights_2(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "user_rights_2")) return false;
user_rights_2_0(b, l + 1);
return true;
}

// user_rights_header_line CRLF
private static boolean user_rights_2_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "user_rights_2_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = user_rights_header_line(b, l + 1);
r = r && consumeToken(b, CRLF);
exit_section_(b, m, null, r);
return r;
}

// (user_rights_value_line CRLF)*
private static boolean user_rights_3(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "user_rights_3")) return false;
while (true) {
int c = current_position_(b);
if (!user_rights_3_0(b, l + 1)) break;
if (!empty_element_parsed_guard_(b, "user_rights_3", c)) break;
}
return true;
}

// user_rights_value_line CRLF
private static boolean user_rights_3_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "user_rights_3_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = user_rights_value_line(b, l + 1);
r = r && consumeToken(b, CRLF);
exit_section_(b, m, null, r);
return r;
}

/* ********************************************************** */
// END_USERRIGHTS
public static boolean user_rights_end(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "user_rights_end")) return false;
if (!nextTokenIs(b, END_USERRIGHTS)) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeToken(b, END_USERRIGHTS);
exit_section_(b, m, USER_RIGHTS_END, r);
return r;
}

/* ********************************************************** */
// user_rights_header_parameter (PARAMETERS_SEPARATOR user_rights_header_parameter)*
public static boolean user_rights_header_line(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "user_rights_header_line")) return false;
boolean r, p;
Marker m = enter_section_(b, l, _NONE_, USER_RIGHTS_HEADER_LINE, "<user rights header line>");
r = user_rights_header_parameter(b, l + 1);
p = r; // pin = 1
r = r && user_rights_header_line_1(b, l + 1);
exit_section_(b, l, m, r, p, ImpexParser::user_rights_header_line_recover);
return r || p;
}

// (PARAMETERS_SEPARATOR user_rights_header_parameter)*
private static boolean user_rights_header_line_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "user_rights_header_line_1")) return false;
while (true) {
int c = current_position_(b);
if (!user_rights_header_line_1_0(b, l + 1)) break;
if (!empty_element_parsed_guard_(b, "user_rights_header_line_1", c)) break;
}
return true;
}

// PARAMETERS_SEPARATOR user_rights_header_parameter
private static boolean user_rights_header_line_1_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "user_rights_header_line_1_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeToken(b, PARAMETERS_SEPARATOR);
r = r && user_rights_header_parameter(b, l + 1);
exit_section_(b, m, null, r);
return r;
}

/* ********************************************************** */
// !(CRLF | user_rights_end | user_rights_value_line )
static boolean user_rights_header_line_recover(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "user_rights_header_line_recover")) return false;
boolean r;
Marker m = enter_section_(b, l, _NOT_);
r = !user_rights_header_line_recover_0(b, l + 1);
exit_section_(b, l, m, r, false, null);
return r;
}

// CRLF | user_rights_end | user_rights_value_line
private static boolean user_rights_header_line_recover_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "user_rights_header_line_recover_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeToken(b, CRLF);
if (!r) r = user_rights_end(b, l + 1);
if (!r) r = user_rights_value_line(b, l + 1);
exit_section_(b, m, null, r);
return r;
}

/* ********************************************************** */
// USER_RIGHTS_HEADER_PARAMETER_NAME
public static boolean user_rights_header_parameter(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "user_rights_header_parameter")) return false;
boolean r;
Marker m = enter_section_(b, l, _NONE_, USER_RIGHTS_HEADER_PARAMETER, "<user rights header parameter>");
r = consumeToken(b, USER_RIGHTS_HEADER_PARAMETER_NAME);
exit_section_(b, l, m, r, false, ImpexParser::not_line_break_or_parameters_separator);
return r;
}

/* ********************************************************** */
// START_USERRIGHTS
public static boolean user_rights_start(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "user_rights_start")) return false;
if (!nextTokenIs(b, START_USERRIGHTS)) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeToken(b, START_USERRIGHTS);
exit_section_(b, m, USER_RIGHTS_START, r);
return r;
}

/* ********************************************************** */
// USER_RIGHTS_VALUE DOT USER_RIGHTS_VALUE
static boolean user_rights_type_attribute(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "user_rights_type_attribute")) return false;
if (!nextTokenIs(b, USER_RIGHTS_VALUE)) return false;
boolean r, p;
Marker m = enter_section_(b, l, _NONE_);
r = consumeTokens(b, 2, USER_RIGHTS_VALUE, DOT, USER_RIGHTS_VALUE);
p = r; // pin = 2
exit_section_(b, l, m, r, p, null);
return r || p;
}

/* ********************************************************** */
// PERMISSION_DENIED
// | PERMISSION_ALLOWED
// | user_rights_type_attribute
// | USER_RIGHTS_VALUE
static boolean user_rights_value_dec(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "user_rights_value_dec")) return false;
boolean r;
r = consumeToken(b, PERMISSION_DENIED);
if (!r) r = consumeToken(b, PERMISSION_ALLOWED);
if (!r) r = user_rights_type_attribute(b, l + 1);
if (!r) r = consumeToken(b, USER_RIGHTS_VALUE);
return r;
}

/* ********************************************************** */
// user_rights_value_dec (COMMA user_rights_value_dec)*
public static boolean user_rights_value_group(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "user_rights_value_group")) return false;
boolean r;
Marker m = enter_section_(b, l, _NONE_, USER_RIGHTS_VALUE_GROUP, "<user rights value group>");
r = user_rights_value_dec(b, l + 1);
r = r && user_rights_value_group_1(b, l + 1);
exit_section_(b, l, m, r, false, null);
return r;
}

// (COMMA user_rights_value_dec)*
private static boolean user_rights_value_group_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "user_rights_value_group_1")) return false;
while (true) {
int c = current_position_(b);
if (!user_rights_value_group_1_0(b, l + 1)) break;
if (!empty_element_parsed_guard_(b, "user_rights_value_group_1", c)) break;
}
return true;
}

// COMMA user_rights_value_dec
private static boolean user_rights_value_group_1_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "user_rights_value_group_1_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeToken(b, COMMA);
r = r && user_rights_value_dec(b, l + 1);
exit_section_(b, m, null, r);
return r;
}

/* ********************************************************** */
// user_rights_value_group? (FIELD_VALUE_SEPARATOR user_rights_value_group?)*
public static boolean user_rights_value_line(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "user_rights_value_line")) return false;
boolean r;
Marker m = enter_section_(b, l, _NONE_, USER_RIGHTS_VALUE_LINE, "<user rights value line>");
r = user_rights_value_line_0(b, l + 1);
r = r && user_rights_value_line_1(b, l + 1);
exit_section_(b, l, m, r, false, ImpexParser::user_rights_value_line_recover);
return r;
}

// user_rights_value_group?
private static boolean user_rights_value_line_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "user_rights_value_line_0")) return false;
user_rights_value_group(b, l + 1);
return true;
}

// (FIELD_VALUE_SEPARATOR user_rights_value_group?)*
private static boolean user_rights_value_line_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "user_rights_value_line_1")) return false;
while (true) {
int c = current_position_(b);
if (!user_rights_value_line_1_0(b, l + 1)) break;
if (!empty_element_parsed_guard_(b, "user_rights_value_line_1", c)) break;
}
return true;
}

// FIELD_VALUE_SEPARATOR user_rights_value_group?
private static boolean user_rights_value_line_1_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "user_rights_value_line_1_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeToken(b, FIELD_VALUE_SEPARATOR);
r = r && user_rights_value_line_1_0_1(b, l + 1);
exit_section_(b, m, null, r);
return r;
}

// user_rights_value_group?
private static boolean user_rights_value_line_1_0_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "user_rights_value_line_1_0_1")) return false;
user_rights_value_group(b, l + 1);
return true;
}

/* ********************************************************** */
// !(CRLF | user_rights_end)
static boolean user_rights_value_line_recover(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "user_rights_value_line_recover")) return false;
boolean r;
Marker m = enter_section_(b, l, _NOT_);
r = !user_rights_value_line_recover_0(b, l + 1);
exit_section_(b, l, m, r, false, null);
return r;
}

// CRLF | user_rights_end
private static boolean user_rights_value_line_recover_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "user_rights_value_line_recover_0")) return false;
boolean r;
r = consumeToken(b, CRLF);
if (!r) r = user_rights_end(b, l + 1);
return r;
}

/* ********************************************************** */
// (( FIELD_VALUE
// | FIELD_VALUE_URL
Expand Down
Loading