mbien commented on code in PR #9210:
URL: https://github.com/apache/netbeans/pull/9210#discussion_r2825243151
##########
java/java.editor/src/org/netbeans/modules/editor/java/GoToSupport.java:
##########
@@ -478,30 +476,16 @@ public static Context resolveContext(CompilationInfo
controller, Document doc, i
}
}
if (el != null && el.getKind() == ElementKind.METHOD) {
- for (Element peer :
el.getEnclosingElement().getEnclosedElements()) {
- if
(peer.getKind().name().contains("RECORD_COMPONENT")) {
- try {
- Class<?> recordComponent =
Class.forName("javax.lang.model.element.RecordComponentElement", true,
VariableTree.class.getClassLoader());
- Method getAccessor =
recordComponent.getDeclaredMethod("getAccessor");
- Method getRecordComponents =
TypeElement.class.getDeclaredMethod("getRecordComponents");
- for (Element component :
(Iterable<Element>) getRecordComponents.invoke(peer.getEnclosingElement())) {
- if (Objects.equals(el,
getAccessor.invoke(component))) {
+ Element enclosing = el.getEnclosingElement();
+ if (enclosing.getKind() == ElementKind.RECORD) {
+ for (Element peer :
enclosing.getEnclosedElements()) {
+ if (peer.getKind() ==
ElementKind.RECORD_COMPONENT) {
+ for (RecordComponentElement component :
((TypeElement)peer.getEnclosingElement()).getRecordComponents()) {
Review Comment:
> (I probably would just do enclosing.getEnclosingElement(), though.)
you mean changing
```java
for (RecordComponentElement component :
((TypeElement)peer.getEnclosingElement()).getRecordComponents()) {
```
into
```java
for (RecordComponentElement component :
((TypeElement)enclosing).getRecordComponents()) {
```
good idea,
--
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]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists