drccrd commented on code in PR #3965:
URL:
https://github.com/apache/incubator-kie-tools/pull/3965#discussion_r3842362650
##########
packages/drools-lsp/drools-completion/src/main/java/org/drools/completion/DRLTypeHierarchyHelper.java:
##########
@@ -217,17 +222,40 @@ private static TypeHierarchyItem declareItem(Declared d) {
return item; // data left null → re-resolved from uri + name
}
- /** Builds a navigable classpath item, or {@code null} when no project
source resolves. */
- private static TypeHierarchyItem classpathItem(String fqcn, Set<Path>
buildOutputDirs) {
+ /**
+ * Builds a navigable classpath item: a compiled {@code .class}'s project
+ * source first, else — when no {@code .class} exists yet (pre-build) —
+ * {@code sourceIndex}'s parsed location; {@code null} when neither
+ * resolves.
+ */
+ private static TypeHierarchyItem classpathItem(String fqcn, Set<Path>
buildOutputDirs,
+ JavaSourceTypeIndex
sourceIndex) {
if (fqcn == null) {
return null;
}
JavaSourceLocator.Result res = JavaSourceLocator.locate(fqcn,
buildOutputDirs);
- if (res == null) {
+ if (res != null) {
+ TypeHierarchyItem item = new TypeHierarchyItem(simpleName(fqcn),
res.kind,
+ res.location.getUri(), res.location.getRange(),
res.location.getRange());
+ item.setData(fqcn);
+ item.setDetail(fqcn);
+ return item;
+ }
+ return sourceItem(fqcn, sourceIndex);
+ }
+
+ /** As the source-index branch of {@link #classpathItem}; {@code null}
when {@code fqcn} is unindexed. */
+ private static TypeHierarchyItem sourceItem(String fqcn,
JavaSourceTypeIndex sourceIndex) {
+ Path file = sourceIndex.fileOf(fqcn);
+ JavaSourceType type = sourceIndex.byFqcn(fqcn);
+ if (file == null || type == null) {
return null;
}
- TypeHierarchyItem item = new TypeHierarchyItem(simpleName(fqcn),
res.kind,
- res.location.getUri(), res.location.getRange(),
res.location.getRange());
+ Range range = new Range(new Position(type.declLine, type.declColumn),
+ new Position(type.declLine, type.declColumn +
type.simpleName.length()));
+ SymbolKind kind = type.isEnum ? SymbolKind.Enum : SymbolKind.Class;
+ TypeHierarchyItem item = new TypeHierarchyItem(type.simpleName, kind,
+ file.toUri().toString(), range, range);
Review Comment:
This one as well I think represents a larger change than the value it
provides - I don't the change would really be meaningful to users.
--
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]