mariofusco commented on code in PR #6024:
URL: 
https://github.com/apache/incubator-kie-drools/pull/6024#discussion_r1678869516


##########
drools-base/src/main/java/org/drools/base/rule/EvalCondition.java:
##########
@@ -223,4 +230,36 @@ public void setCloned(List<EvalCondition> cloned) {
     public String toString() {
         return this.expression.toString();
     }
+
+    public static void logWarnIfImproperEval(EvalCondition evalCondition, 
String evalExpression) {
+        if (warnLogCounter == 10) {
+            warnLogCounter++;
+            LOG.warn("More eval warnings will be suppressed...");
+            return;
+        } else if (warnLogCounter > 10) {
+            return; // avoid flooding the logs
+        }
+
+        if (evalExpression == null || evalExpression.isEmpty()) {
+            return; // cannot provide a meaningful warning
+        }
+
+        StringBuilder sb = new StringBuilder();
+        for (Declaration declaration : 
evalCondition.getRequiredDeclarations()) {
+            if (declaration.getPattern() != null) {
+                sb.append("'");
+                sb.append(declaration.getIdentifier());
+                sb.append("' comes from previous pattern '");
+                String className = 
declaration.getPattern().getObjectType().getClassName();
+                sb.append(className.substring(className.lastIndexOf('.') + 1));
+                sb.append("'. ");
+            }
+        }

Review Comment:
   No, this is also what I had in mind. I cannot think to any other condition 
at the moment. 



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