Go to definition doesn't compute/find results on methods inside an anonymous class
See original GitHub issueI first thought this is a more generic regression caused by https://github.com/eclipse/eclipse.jdt.ls/pull/1807 but it turns it already happened before.
Eclipse.jdt.ls version: Tested both with latest master (https://github.com/eclipse/eclipse.jdt.ls/commit/6f7d39ae3d1481f7873d7a27ef022af8a2599e60) and (https://github.com/eclipse/eclipse.jdt.ls/commit/3121ad987dc3d9178af4b569c5c44adbfe02abd0) JDK: OpenJDK 16.0.1+9
An example:
public class App {
public void test() {
foo();
}
public String getGreeting() {
return "foo";
}
public static void main(String[] args) {
// Here go to definition on `getGreeting` works
System.out.println(new App().getGreeting());
Function<Integer, Integer> foo = new Function<>() {
@Override
public Integer apply(Integer t) {
// Go to definition on `getGreeting` doesn't work
new App().getGreeting();
return 10;
}
};
}
}
Also visible here:
https://user-images.githubusercontent.com/38700/124632820-f573fa00-de84-11eb-9d52-a6dfc7196406.mp4
(Code in question would be available here: https://github.com/crate/crate/blob/573bd2feb9052f9a83c01bd36cfb3c7485d0e9d3/server/src/main/java/io/crate/planner/operators/InsertFromValues.java#L653-L700)
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Overriding an anonymous class's methods in Java
With the above example, I wanted to understand whether we can override an anonymous class's methods or not?. Again, the main motive is...
Read more >Anonymous Inner Class in Java - GeeksforGeeks
An anonymous class cannot access local variables in its enclosing ... Anonymous Inner class that defines inside method/constructor argument.
Read more >Anonymous method in C# - TutorialsTeacher
This tutorial explains anonymous methods in C#. As the name suggests, an anonymous method is a method without a name. Anonymous methods can...
Read more >Anonymous Classes - Java™ Tutorials
An anonymous class cannot access local variables in its enclosing scope that are not declared as final or effectively final. Like a nested...
Read more >Writing Classes and Javadoc
All we must do is place these other method definitions inside the class, ... if the method itself doesn't have one, Java goes...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

https://bugs.eclipse.org/bugs/show_bug.cgi?id=576121#c3 has been fixed and merged.
Looks like the change proposed by @snjeza was recently merged upstream for this. We should expect I20210806-1800 (not yet built) to contain the fix.