tkobayas commented on code in PR #6786:
URL:
https://github.com/apache/incubator-kie-drools/pull/6786#discussion_r3533301363
##########
drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/generator/RuleContext.java:
##########
@@ -316,15 +316,15 @@ public Optional<MethodCallExpr> findBindingExpression(
String boundVar ) {
public void addGlobalDeclarations() {
Map<String, java.lang.reflect.Type> globals = getGlobals();
- // also takes globals defined in different packages imported with a
wildcard
- packageModel.getImports().stream()
- .filter( imp -> imp.endsWith(".*") )
- .map( imp -> imp.substring(0, imp.length()-2) )
- .map( imp -> typeDeclarationContext.getPackageRegistry(imp) )
+ // Globals are kbase-wide: include globals declared in any package of
the kbase, not only
+ // those in the current package or in packages imported with a
wildcard. This matches the
+ // classic (non-executable-model) behavior where a global is visible
from every package, so
+ // a constraint can reference a global declared in another DRL without
a wildcard import.
+ typeDeclarationContext.getPackageRegistry().values().stream()
.filter( Objects::nonNull )
- .map( pkgRegistry -> pkgRegistry.getPackage().getGlobals() )
- .forEach( globals::putAll );
-
+ .filter( pkgRegistry -> pkgRegistry.getPackage() != null )
+ .forEach( pkgRegistry -> globals.putAll(
pkgRegistry.getPackage().getGlobals() ) );
+
Review Comment:
Thank you @drccrd . While the global seeder approach works with the test
cases, I see that global is conceptually owned by a package (even though
viewable kiebase-wide), so for example, removing a package causes a problem. I
raised a PR to your branch
https://github.com/drccrd/incubator-kie-drools/pull/1 with a different approach
(`externalGlobals`). 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]