drccrd commented on code in PR #3998:
URL:
https://github.com/apache/incubator-kie-tools/pull/3998#discussion_r4004896253
##########
packages/drools-lsp/drools-completion/src/main/java/org/drools/completion/DRLWorkspaceTypeIndex.java:
##########
@@ -256,6 +257,58 @@ static void forEachSiblingFile(Path documentPath,
Map<Path, String> openFiles,
}
}
+ /**
+ * Returns the imports contributed by sibling files that declare the
+ * <em>same</em> Drools package as the current document. Drools merges
every
+ * file sharing a package into one namespace, so an import declared in any
+ * same-package sibling is in scope here — a consumer that would otherwise
+ * flag such a type (the unknown-type lint) must honor them.
+ *
+ * <p>Siblings come from the active {@link WorkspaceSiblingResolver}
alone, so
+ * grouping stays whatever the workspace configured; open unsaved buffers
+ * shadow their on-disk counterpart, matching {@link #forEachSiblingType}.
+ * A null/blank {@code ownPackage} contributes nothing — a package-less
file
+ * merges with no other file. Wildcard imports keep their {@code .*}
suffix.
+ */
+ public static List<String> siblingImports(Path documentPath, String
ownPackage,
+ Map<Path, String> openFiles) {
+ if (documentPath == null || ownPackage == null ||
ownPackage.isBlank()) {
+ return List.of();
+ }
+ String pkg = ownPackage.trim();
+ Path docNorm = documentPath.toAbsolutePath().normalize();
+ Path dir = docNorm.getParent();
+ Set<Path> shadowed = new HashSet<>();
+ List<String> imports = new ArrayList<>();
+
+ // Layer 2: open unsaved siblings (buffer content shadows disk).
+ if (openFiles != null) {
+ for (Map.Entry<Path, String> e : openFiles.entrySet()) {
+ Path p = normalizedSibling(e.getKey(), docNorm, dir);
+ if (p == null) {
+ continue;
+ }
Review Comment:
reworked the import mechanisms to cover this correctly, including unit test:
[bc4ef1c](https://github.com/apache/incubator-kie-tools/pull/3998/commits/bc4ef1c3fe948df9a924f2a0a19e53cf3f97b77b)
--
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]