You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by "drccrd (via GitHub)" <gi...@apache.org> on 2026/09/09 18:02:17 UTC
[PR] kie-tools#3966: [drl-vscode-extension] static members after a type name [incubator-kie-tools]
drccrd opened a new pull request, #3999:
URL: https://github.com/apache/incubator-kie-tools/pull/3999
Closes https://github.com/apache/incubator-kie-tools/issues/3966
### What changes
Java permits only statics directly after a type name. Completion offered the *instance* view there — the one set that cannot legally follow a type name — and hover described a static as nothing.
`JavaMemberSource` gains `staticFieldsOf` (name and type) and `staticMethodsOf` (signatures), implemented by reflection in `ClassMemberIndex` and from the parsed model in `JavaSourceTypeIndex`, both following `constructorsOf`'s existing fallback-on-load-failure pattern. `JavaSourceType`'s static field *names* became typed fields plus method signatures; the parser already saw the modifiers and the type, and was discarding the latter.
The consumers needed little: both walks already knew whether a chain head was a type reference or a value, and neither propagated it. Each now does, clearing the flag after one hop — `Rounding.SCALE.precision` resumes instance members, because a constant is an ordinary value of its own type.
Also fixed, since a type's own hover never showed statics either: its "Constants" section was filtered from `membersOf`, which excludes statics, so it could only ever populate for an enum. A type whose whole API is static (`java.lang.Math`, a constants holder) rendered as a bare header.
### Notes for review
- **Interface constants moved to the static view.** An interface field is implicitly `public static final`, so reflection reports it only as a static; the source path had it in `membersOf`. This is the one change to existing behaviour beyond statics, and it improves parity between the two paths.
- **Qualified type names get the same treatment**, so `Order.X` and `com.example.Order.X` agree. Not in the issue text, but the alternative is the two disagreeing.
- **Inherited statics are included** (`getFields()`/`getMethods()`), since Java permits reaching an inherited static through a subtype's name.
- Static method signatures carry the return type (`describe(int, String) : String`); constructors keep the shape they had.
- Removed `isPublicInstanceMember`, now dead — its javadoc argued statics should not be modelled separately, which this reverses — and renamed `constructorSignature` to `signatureOf`, shared by methods and constructors.
### Verification
`mvn test` in `packages/drools-lsp`: drools-completion 392, drools-lsp-server 52, all green, from a 370-test baseline on `main`. 22 new tests across the seam, both member sources, completion and hover, including the issue's own reproducer (`Pet.` no longer offering `name`/`friendly`/`legs`) and a parity test holding the source and reflected views to each other rather than to a hand-written expectation. No client files touched.
### Possible follow-ups
Two gaps found while exercising this, both wider than statics and neither attempted here:
1. **Go-to-definition on members.** `DRLDefinitionHelper` resolves a single word to a *type* and jumps to its declaration; there is no chain walk, and `JavaSourceLocator` locates types by regex with no notion of member positions. So `Rounding.SCALE` fails because go-to-definition on any member is unsupported, instance or static.
2. **Bindings to method calls.** `LhsBindingResolver` models field, nested-path, accumulate and JDK-accessor bindings but not calls, so `$x : Rounding.roundHalfUp(y)` resolves to nothing in hover and in inlay hints — as does `$x : $order.getTotal()`. The accumulate case shows the shape a fix would take (an injected lookup, keeping the resolver pure regex over text), but inlay hints currently receive no `ClassMemberIndex` or `ClassIndex`, so it would widen that helper's API. Overload ambiguity is an open question there: the binding site carries an argument list the resolver does not type-check.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-tools#3966: [drl-vscode-extension] static members after a type name [incubator-kie-tools]
Posted by "drccrd (via GitHub)" <gi...@apache.org>.
drccrd commented on code in PR #3999:
URL: https://github.com/apache/incubator-kie-tools/pull/3999#discussion_r4005262193
##########
packages/drools-lsp/drools-completion/src/main/java/org/drools/completion/DRLCompletionHelper.java:
##########
@@ -313,11 +313,13 @@ private static List<CompletionItem> memberItemsForChain(String[] chain, String t
String head = chain[0];
String rootType;
int firstFieldSegment = 1;
+ boolean typeReference = false;
if (head.startsWith("$")) {
rootType = LhsBindingResolver.resolveAt(text, DRLHoverHelper.positionToOffset(text, caret), typeIndex)
.get(head.substring(1));
} else if (!head.isEmpty() && Character.isUpperCase(head.charAt(0))) {
rootType = head;
+ typeReference = true;
Review Comment:
re-used existing qualified-prefix detection from `DRLHoverHelper` in [2a77d85](https://github.com/apache/incubator-kie-tools/pull/3999/commits/2a77d85378e399fe89fe696a7c5e7420ca5e7693)
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-tools#3966: [drl-vscode-extension] static members after a type name [incubator-kie-tools]
Posted by "drccrd (via GitHub)" <gi...@apache.org>.
drccrd commented on code in PR #3999:
URL: https://github.com/apache/incubator-kie-tools/pull/3999#discussion_r4006965009
##########
packages/drools-lsp/drools-completion/src/main/java/org/drools/completion/DeclaredType.java:
##########
@@ -51,4 +52,21 @@ public class DeclaredType {
this.nameCol = nameCol;
this.extendsName = extendsName;
}
+
+ /**
+ * The constants of a declared enum — the fields carrying the enum's own
+ * name as their type — or an empty list for a non-enum declare.
+ */
+ List<Field> enumConstants() {
+ if (!isEnum) {
+ return List.of();
+ }
+ List<Field> constants = new ArrayList<>();
+ for (Field field : fields) {
+ if (name.equals(field.type)) {
+ constants.add(field);
Review Comment:
From the suppressed comments from the last review the `varargs` point, the `[][]` point, and the documentation point were also all address in individual commits
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-tools#3966: [drl-vscode-extension] static members after a type name [incubator-kie-tools]
Posted by "drccrd (via GitHub)" <gi...@apache.org>.
drccrd commented on code in PR #3999:
URL: https://github.com/apache/incubator-kie-tools/pull/3999#discussion_r4005274956
##########
packages/drools-lsp/drools-completion/src/main/java/org/drools/completion/DRLCompletionHelper.java:
##########
@@ -329,6 +331,28 @@ private static List<CompletionItem> memberItemsForChain(String[] chain, String t
return null;
}
+ // After a type name Java permits only statics — the one set the instance
+ // view cannot legally offer. A DRL declare is exempt: it has no statics,
+ // and its enum constants are already members, which the walk below
+ // offers. Only the first hop is static; past it, instance members
+ // resume, because a constant is an ordinary value of its own type.
+ if (typeReference && typeIndex.get(simpleNameOf(rootType)) == null) {
Review Comment:
split behavior for enums and non-enums in [ae11261](https://github.com/apache/incubator-kie-tools/pull/3999/commits/ae11261e05fe882f5370ac861878ebda5f852339)
##########
packages/drools-lsp/drools-completion/src/main/java/org/drools/completion/DRLHoverHelper.java:
##########
@@ -309,10 +311,10 @@ private static Hover hoverChain(Chain chain, String text, Position position,
segment, segment, parsed.compilationUnit, classIndex);
if (fqcn != null) {
if (hovered) {
- return markdown(renderJavaType(segment, fqcn, memberIndex.membersOf(fqcn),
- memberIndex.constructorsOf(fqcn)));
+ return markdown(renderJavaType(segment, fqcn, memberIndex));
}
runningType = fqcn;
+ fromTypeRef = true;
Review Comment:
split behavior for enums and non-enums in [ae11261](https://github.com/apache/incubator-kie-tools/pull/3999/commits/ae11261e05fe882f5370ac861878ebda5f852339)
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-tools#3966: [drl-vscode-extension] static members after a type name [incubator-kie-tools]
Posted by "drccrd (via GitHub)" <gi...@apache.org>.
drccrd commented on code in PR #3999:
URL: https://github.com/apache/incubator-kie-tools/pull/3999#discussion_r4006954298
##########
packages/drools-lsp/drools-completion/src/main/java/org/drools/completion/DeclaredType.java:
##########
@@ -51,4 +52,21 @@ public class DeclaredType {
this.nameCol = nameCol;
this.extendsName = extendsName;
}
+
+ /**
+ * The constants of a declared enum — the fields carrying the enum's own
+ * name as their type — or an empty list for a non-enum declare.
+ */
+ List<Field> enumConstants() {
+ if (!isEnum) {
+ return List.of();
+ }
+ List<Field> constants = new ArrayList<>();
+ for (Field field : fields) {
+ if (name.equals(field.type)) {
+ constants.add(field);
Review Comment:
Fixed in [7149bae](https://github.com/apache/incubator-kie-tools/pull/3999/commits/7149bae4de6d1f3059346bd8ae9adef1e56cabad)
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-tools#3966: [drl-vscode-extension] static members after a type name [incubator-kie-tools]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #3999:
URL: https://github.com/apache/incubator-kie-tools/pull/3999#discussion_r4002673589
##########
packages/drools-lsp/drools-completion/src/main/java/org/drools/completion/DRLCompletionHelper.java:
##########
@@ -313,11 +313,13 @@ private static List<CompletionItem> memberItemsForChain(String[] chain, String t
String head = chain[0];
String rootType;
int firstFieldSegment = 1;
+ boolean typeReference = false;
if (head.startsWith("$")) {
rootType = LhsBindingResolver.resolveAt(text, DRLHoverHelper.positionToOffset(text, caret), typeIndex)
.get(head.substring(1));
} else if (!head.isEmpty() && Character.isUpperCase(head.charAt(0))) {
rootType = head;
+ typeReference = true;
Review Comment:
Fully qualified type references still do not reach this branch. For `org.drools.completion.fixtures.Rounding.`, `head` is `org`, so it is treated as a lower-case field of the enclosing pattern and the walk returns no static items. Consume the longest class-indexed qualified prefix as a type reference (as `DRLHoverHelper.fqcnPrefixEnd` already does) before applying the static first hop.
##########
packages/drools-lsp/drools-completion/src/main/java/org/drools/completion/DRLHoverHelper.java:
##########
@@ -309,10 +311,10 @@ private static Hover hoverChain(Chain chain, String text, Position position,
segment, segment, parsed.compilationUnit, classIndex);
if (fqcn != null) {
if (hovered) {
- return markdown(renderJavaType(segment, fqcn, memberIndex.membersOf(fqcn),
- memberIndex.constructorsOf(fqcn)));
+ return markdown(renderJavaType(segment, fqcn, memberIndex));
}
runningType = fqcn;
+ fromTypeRef = true;
Review Comment:
Only classpath types set `fromTypeRef`, so `Person.field` for a non-enum DRL declaration still falls through to `findField` and renders an instance field as valid type-qualified access. Declared enums need their existing constant handling, but other declared type references should stop the chain instead.
##########
packages/drools-lsp/drools-completion/src/main/java/org/drools/completion/JavaSourceTypeParser.java:
##########
@@ -172,22 +178,26 @@ private static JavaSourceType fromInterface(JavaParser.InterfaceDeclarationConte
List<String> interfaces = (id.EXTENDS() != null && !id.typeList().isEmpty())
? simplifyAll(id.typeList(0)) : List.of();
- List<Field> fields = new ArrayList<>();
+ // An interface field is implicitly public static final, so
+ // collectInterfaceMember's field list is the constant list: it becomes
+ // the static view, not the member view, matching what reflection
+ // reports once the interface is compiled.
+ List<Field> constants = new ArrayList<>();
List<Field> getters = new ArrayList<>();
if (id.interfaceBody() != null) {
for (JavaParser.InterfaceBodyDeclarationContext ibd : id.interfaceBody().interfaceBodyDeclaration()) {
try {
- collectInterfaceMember(ibd, fields, getters);
+ collectInterfaceMember(ibd, constants, getters);
} catch (Exception e) {
logger.fine(() -> "Skipping interface member in " + simpleName + ": " + e.getMessage());
}
}
}
Map<String, Field> members = new LinkedHashMap<>();
- mergeGettersThenFields(members, getters, fields);
+ mergeGettersThenFields(members, getters, List.of());
return new JavaSourceType(fqcn(pkg, simpleName), simpleName, false, null, interfaces,
- new ArrayList<>(members.values()), List.of(), List.of(),
+ new ArrayList<>(members.values()), List.of(), constants, List.of(),
Review Comment:
Interface static methods are never captured: this constructor hard-codes an empty `staticMethods` list, although interfaces may declare public static methods and reflection returns them after compilation. Extend interface-member collection to emit signatures for static interface methods so source fallback remains consistent.
This issue also appears on line 226 of the same file.
##########
packages/drools-lsp/drools-completion/src/main/java/org/drools/completion/JavaSourceTypeParser.java:
##########
@@ -255,40 +265,33 @@ private static void collectBodyMembers(List<JavaParser.ClassBodyDeclarationConte
boolean isStatic = hasStaticModifier(cbd.modifier());
for (JavaParser.VariableDeclaratorContext vd : fd.variableDeclarators().variableDeclarator()) {
String name = vd.variableDeclaratorId().identifier().getText();
- if (isStatic) {
- // Kept by name only: reachable as Type.NAME, but not a
- // property of a fact, so out of the member list.
- staticFieldsOut.add(name);
- } else {
- fieldsOut.add(new Field(name, type, null, Field.Origin.FIELD));
- }
+ // A static is reachable as Type.NAME but is not a property
+ // of a fact, so the two views stay disjoint.
+ (isStatic ? staticFieldsOut : fieldsOut)
+ .add(new Field(name, type, null, Field.Origin.FIELD));
Review Comment:
Static field types are stored after `simplify` has stripped array brackets. A source declaration such as `public static String[] NAMES` is exposed as `String`, whereas reflection exposes `String[]`; hover details and the second-hop member walk therefore change after a build. Preserve array dimensions for the static field view.
This issue also appears on line 276 of the same file.
##########
packages/drools-lsp/drools-completion/src/main/java/org/drools/completion/DRLCompletionHelper.java:
##########
@@ -329,6 +331,28 @@ private static List<CompletionItem> memberItemsForChain(String[] chain, String t
return null;
}
+ // After a type name Java permits only statics — the one set the instance
+ // view cannot legally offer. A DRL declare is exempt: it has no statics,
+ // and its enum constants are already members, which the walk below
+ // offers. Only the first hop is static; past it, instance members
+ // resume, because a constant is an ordinary value of its own type.
+ if (typeReference && typeIndex.get(simpleNameOf(rootType)) == null) {
Review Comment:
This exemption covers every DRL-declared type, not just declared enums. Consequently `Person.` still offers `Person`'s instance fields even though they cannot be accessed through the type name. Preserve the enum-constant special case, but return no members for a non-enum declared type reference.
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-tools#3966: [drl-vscode-extension] static members after a type name [incubator-kie-tools]
Posted by "drccrd (via GitHub)" <gi...@apache.org>.
drccrd commented on code in PR #3999:
URL: https://github.com/apache/incubator-kie-tools/pull/3999#discussion_r4005304682
##########
packages/drools-lsp/drools-completion/src/main/java/org/drools/completion/JavaSourceTypeParser.java:
##########
@@ -255,40 +265,33 @@ private static void collectBodyMembers(List<JavaParser.ClassBodyDeclarationConte
boolean isStatic = hasStaticModifier(cbd.modifier());
for (JavaParser.VariableDeclaratorContext vd : fd.variableDeclarators().variableDeclarator()) {
String name = vd.variableDeclaratorId().identifier().getText();
- if (isStatic) {
- // Kept by name only: reachable as Type.NAME, but not a
- // property of a fact, so out of the member list.
- staticFieldsOut.add(name);
- } else {
- fieldsOut.add(new Field(name, type, null, Field.Origin.FIELD));
- }
+ // A static is reachable as Type.NAME but is not a property
+ // of a fact, so the two views stay disjoint.
+ (isStatic ? staticFieldsOut : fieldsOut)
+ .add(new Field(name, type, null, Field.Origin.FIELD));
Review Comment:
Dimensions preserved in simplify: https://github.com/apache/incubator-kie-tools/pull/3999/commits/1bf836bf7adb1ce14788680218f2ca6bd5a312b6
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-tools#3966: [drl-vscode-extension] static members after a type name [incubator-kie-tools]
Posted by "drccrd (via GitHub)" <gi...@apache.org>.
drccrd commented on code in PR #3999:
URL: https://github.com/apache/incubator-kie-tools/pull/3999#discussion_r4005291852
##########
packages/drools-lsp/drools-completion/src/main/java/org/drools/completion/JavaSourceTypeParser.java:
##########
@@ -172,22 +178,26 @@ private static JavaSourceType fromInterface(JavaParser.InterfaceDeclarationConte
List<String> interfaces = (id.EXTENDS() != null && !id.typeList().isEmpty())
? simplifyAll(id.typeList(0)) : List.of();
- List<Field> fields = new ArrayList<>();
+ // An interface field is implicitly public static final, so
+ // collectInterfaceMember's field list is the constant list: it becomes
+ // the static view, not the member view, matching what reflection
+ // reports once the interface is compiled.
+ List<Field> constants = new ArrayList<>();
List<Field> getters = new ArrayList<>();
if (id.interfaceBody() != null) {
for (JavaParser.InterfaceBodyDeclarationContext ibd : id.interfaceBody().interfaceBodyDeclaration()) {
try {
- collectInterfaceMember(ibd, fields, getters);
+ collectInterfaceMember(ibd, constants, getters);
} catch (Exception e) {
logger.fine(() -> "Skipping interface member in " + simpleName + ": " + e.getMessage());
}
}
}
Map<String, Field> members = new LinkedHashMap<>();
- mergeGettersThenFields(members, getters, fields);
+ mergeGettersThenFields(members, getters, List.of());
return new JavaSourceType(fqcn(pkg, simpleName), simpleName, false, null, interfaces,
- new ArrayList<>(members.values()), List.of(), List.of(),
+ new ArrayList<>(members.values()), List.of(), constants, List.of(),
Review Comment:
passed static interface methods through in [bad86b9](https://github.com/apache/incubator-kie-tools/pull/3999/commits/bad86b913e439f797c99b7667de59fc6cbe99a0d)
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] incubator-kie-tools#3966: [drl-vscode-extension] static members after a type name [incubator-kie-tools]
Posted by "tkobayas (via GitHub)" <gi...@apache.org>.
tkobayas commented on PR #3999:
URL: https://github.com/apache/incubator-kie-tools/pull/3999#issuecomment-5881101655
Hi @yesamer @tiagobento @thiagoelg @jomarko , this PR requires one more approval. Can someone have a look? Thanks!
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-tools#3966: [drl-vscode-extension] static members after a type name [incubator-kie-tools]
Posted by "drccrd (via GitHub)" <gi...@apache.org>.
drccrd commented on code in PR #3999:
URL: https://github.com/apache/incubator-kie-tools/pull/3999#discussion_r4006965009
##########
packages/drools-lsp/drools-completion/src/main/java/org/drools/completion/DeclaredType.java:
##########
@@ -51,4 +52,21 @@ public class DeclaredType {
this.nameCol = nameCol;
this.extendsName = extendsName;
}
+
+ /**
+ * The constants of a declared enum — the fields carrying the enum's own
+ * name as their type — or an empty list for a non-enum declare.
+ */
+ List<Field> enumConstants() {
+ if (!isEnum) {
+ return List.of();
+ }
+ List<Field> constants = new ArrayList<>();
+ for (Field field : fields) {
+ if (name.equals(field.type)) {
+ constants.add(field);
Review Comment:
From the suppressed comments from the last review the `varargs` point, the `[][]` point, and the documentation point were also all addressed in individual commits
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-tools#3966: [drl-vscode-extension] static members after a type name [incubator-kie-tools]
Posted by "drccrd (via GitHub)" <gi...@apache.org>.
drccrd commented on PR #3999:
URL: https://github.com/apache/incubator-kie-tools/pull/3999#issuecomment-5666751658
@tkobayas all done with copilots review and functional testing - this exposes static members and functions from java classes which we use a lot as helper classes.
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-tools#3966: [drl-vscode-extension] static members after a type name [incubator-kie-tools]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #3999:
URL: https://github.com/apache/incubator-kie-tools/pull/3999#discussion_r4005371669
##########
packages/drools-lsp/drools-completion/src/main/java/org/drools/completion/DeclaredType.java:
##########
@@ -51,4 +52,21 @@ public class DeclaredType {
this.nameCol = nameCol;
this.extendsName = extendsName;
}
+
+ /**
+ * The constants of a declared enum — the fields carrying the enum's own
+ * name as their type — or an empty list for a non-enum declare.
+ */
+ List<Field> enumConstants() {
+ if (!isEnum) {
+ return List.of();
+ }
+ List<Field> constants = new ArrayList<>();
+ for (Field field : fields) {
+ if (name.equals(field.type)) {
+ constants.add(field);
Review Comment:
Type equality does not uniquely identify enum constants. A valid declared enum may have an ordinary self-typed field such as `next : Color`; this helper then offers `Color.next` as a static constant and hover accepts that illegal access. Mark parsed enumeratives with `Field.Origin.ENUM_CONSTANT` and filter on that origin here instead.
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] incubator-kie-tools#3966: [drl-vscode-extension] static members after a type name [incubator-kie-tools]
Posted by "tkobayas (via GitHub)" <gi...@apache.org>.
tkobayas merged PR #3999:
URL: https://github.com/apache/incubator-kie-tools/pull/3999
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org