tkobayas commented on code in PR #5831:
URL:
https://github.com/apache/incubator-kie-drools/pull/5831#discussion_r1556999614
##########
drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/antlr4/Antlr4ParserStringUtils.java:
##########
@@ -66,13 +66,13 @@ public static String
getTokenTextPreservingWhitespace(ParserRuleContext ctx, Tok
}
/**
- * Just remove leading "then"
+ * Extract name from "then[name]" of RHS_NAMED_CONSEQUENCE_THEN
*/
- public static String trimThen(String rhs) {
- if (rhs.startsWith("then")) {
- return rhs.substring("then".length());
+ public static String extractNamedConsequenceName(String
namedConsequenceThen) {
+ if (namedConsequenceThen.toLowerCase().startsWith("then[") &&
namedConsequenceThen.endsWith("]")) {
+ return namedConsequenceThen.substring("then[".length(),
namedConsequenceThen.length() - 1);
Review Comment:
The String manipulation is not very nice, but if we split
`RHS_NAMED_CONSEQUENCE_THEN` into finer-grained tokens, Lexer and Parser would
get more complex while we want to retrieve RHS as simple text as possible.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]