Copilot commented on code in PR #3998:
URL:
https://github.com/apache/incubator-kie-tools/pull/3998#discussion_r4004927643
##########
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:
This condition merges imports between two package-less documents because
both extracted package names are `""`, while the PR description explicitly says
that a document with no package declaration merges with nothing. Please either
guard against an empty `ownPackage` and update the positive package-less test,
or update the stated requirement if default-package merging is intentional.
--
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]