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


##########
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:
   Hi @tkobayas ,
    thanks for the PR.
    Anyway, I think it would be better to use JavaParser here, since string 
manipulation of code has always been problematic. And, in the current scenario, 
the code proposed is very cumbersome to understand and properly debug: wdyt ?



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