drccrd commented on code in PR #3998:
URL:
https://github.com/apache/incubator-kie-tools/pull/3998#discussion_r4007097635
##########
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:
And the point from the suppressed commentfrom the last review
> The newly unioned sibling wildcards flow into a branch that uses prefix
matching and returns the first hit. Consequently, import com.acme.* can
incorrectly resolve com.acme.sub.Order, and two wildcard-imported packages that
both provide Order resolve nondeterministically because imports is a HashSet.
Build exact package + simpleName candidates across all wildcard imports and
resolve only a unique candidate.
Is addressed in
https://github.com/apache/incubator-kie-tools/pull/3998/commits/771e116f2102885620429b79ecafd4aee949a86c
to resolve on package+simpleName and to report an ambiduous simpleName usage
if provided by two wildcard imports.
##########
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:
And the point from the suppressed commentfrom the last review
> The newly unioned sibling wildcards flow into a branch that uses prefix
matching and returns the first hit. Consequently, import com.acme.* can
incorrectly resolve com.acme.sub.Order, and two wildcard-imported packages that
both provide Order resolve nondeterministically because imports is a HashSet.
Build exact package + simpleName candidates across all wildcard imports and
resolve only a unique candidate.
Is addressed in
https://github.com/apache/incubator-kie-tools/pull/3998/commits/771e116f2102885620429b79ecafd4aee949a86c
to resolve on package+simpleName and to report an ambiguous simpleName usage
if provided by two wildcard imports.
--
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]