This is an automated email from the ASF dual-hosted git repository. sdedic pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push: new 633c89c [NETBEANS-6291] Navigation to fields sometimes doesn't work in Groovy new fe526a5 Merge pull request #3368 from ppisl/NETBEANS-6291 633c89c is described below commit 633c89c5b5ef932922db3ebe28075fefced494ee Author: Petr Pisl <petr.p...@oracle.com> AuthorDate: Mon Dec 13 18:19:12 2021 +0100 [NETBEANS-6291] Navigation to fields sometimes doesn't work in Groovy --- .../groovy/editor/language/GroovyDeclarationFinder.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/language/GroovyDeclarationFinder.java b/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/language/GroovyDeclarationFinder.java index c944e93..5eb9d30 100644 --- a/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/language/GroovyDeclarationFinder.java +++ b/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/language/GroovyDeclarationFinder.java @@ -298,6 +298,17 @@ public class GroovyDeclarationFinder implements DeclarationFinder { } // TODO try to find it in Groovy + + // This resolves the problem only partially. + // I reuse the VariableScopeVisitor and if it finds the FiledNode, it return its position. + VariableScopeVisitor vsv = new VariableScopeVisitor(((ModuleNode)root).getContext(), path, doc, astOffset); + vsv.collect(); + for (ASTNode astNode : vsv.getOccurrences()) { + if (astNode instanceof FieldNode) { + int offset = ASTUtils.getOffset(doc, astNode.getLineNumber(), astNode.getColumnNumber()); + return new DeclarationLocation(fo, offset); + } + } } } } else if (closest instanceof DeclarationExpression @@ -868,5 +879,7 @@ public class GroovyDeclarationFinder implements DeclarationFinder { } return DeclarationLocation.NONE; } + + } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org For additional commands, e-mail: commits-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists