tkobayas commented on code in PR #7096:
URL: https://github.com/apache/incubator-kie/pull/7096#discussion_r3976441272


##########
drools-compiler/src/main/java/org/drools/compiler/rule/builder/PatternBuilder.java:
##########
@@ -1818,6 +1823,30 @@ protected ConstraintConnectiveDescr 
parseExpression(final RuleBuildContext conte
         return result;
     }
 
+    static boolean containsTernaryOperator(String expr) {
+        boolean foundQuestion = false;
+        for (int i = 0; i < expr.length(); i++) {
+            char c = expr.charAt(i);
+            if (c == '"' || c == '\'') {
+                char quote = c;
+                i++;
+                while (i < expr.length()) {
+                    if (expr.charAt(i) == '\\') {
+                        i++;
+                    } else if (expr.charAt(i) == quote) {
+                        break;
+                    }
+                    i++;
+                }
+            } else if (!foundQuestion && c == '?' && (i + 1 >= expr.length() 
|| expr.charAt(i + 1) != '.')) {
+                foundQuestion = true;
+            } else if (foundQuestion && c == ':') {
+                return true;
+            }
+        }
+        return false;
+    }

Review Comment:
   @gitgabrio Javaparser cannot parse MVEL syntax (e.g., single quoted string 
`'foo'`), so we cannot use it here. Instead, we have Antlr and DRL grammar 
files, so implemented Lexer based approach. I think it's more readable than 
String manipulation. @mariofusco @yesamer Do you like this?



-- 
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]

Reply via email to