drccrd commented on code in PR #3998:
URL: 
https://github.com/apache/incubator-kie-tools/pull/3998#discussion_r4005377010


##########
packages/drools-lsp/drools-completion/src/main/java/org/drools/completion/DRLLintHelper.java:
##########
@@ -805,9 +806,22 @@ public static List<Diagnostic> lintUnknownTypes(String 
text, DRL10Parser.Compila
                 declared.putIfAbsent(dt.name, dt);
             }
         }
-        DRLWorkspaceTypeIndex.forEachSiblingType(documentPath, openFiles, (dt, 
uri) -> {
-            if (dt.name != null) {
-                declared.putIfAbsent(dt.name, dt);
+        // Imports declared in same-package sibling files are in scope here too
+        // (Drools merges files by package), so resolution must see them. 
Computed
+        // once and threaded through all three scan paths. Files without a 
package
+        // declaration all compile into the builder's default package
+        // (drools-compiler's CompositePackageCompilationPhase), so two
+        // package-less files merge as well.
+        String ownPackage = DRLDeclaredTypeParser.extractPackageName(cu);
+        List<String> siblingImports = new ArrayList<>();
+        DRLWorkspaceTypeIndex.forEachSiblingInfo(documentPath, openFiles, 
(info, uri) -> {
+            for (DeclaredType dt : info.types) {
+                if (dt.name != null) {
+                    declared.putIfAbsent(dt.name, dt);
+                }
+            }
+            if (ownPackage.equals(info.packageName)) {
+                siblingImports.addAll(info.imports);

Review Comment:
   The drools `CompositePackageCompilationPhase` assigns every file without a 
package declaration to the configured default package, so package-less files do 
merge with each other. The PR description is out of date.



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