Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method pointers not shown in Call Hiearchy #509

Closed
mauromol opened this issue Mar 5, 2018 · 3 comments
Closed

Method pointers not shown in Call Hiearchy #509

mauromol opened this issue Mar 5, 2018 · 3 comments
Assignees
Milestone

Comments

@mauromol
Copy link

mauromol commented Mar 5, 2018

Something like a follow-up to #489:
Consider this Java class:

package test22;
public class MyBean {
	private String foo;
	public void setFoo(String foo) {
		this.foo = foo;
	}
	public String getFoo() {
		return foo;
	}
}

And this Groovy class:

package test22

import groovy.transform.CompileStatic

@CompileStatic
class Test22 {
	public Test22() {
		def b = new MyBean(foo: 'c')
		def m = b.&setFoo
	}
}

Invoke Call Hierarchy on MyBean.setFoo(String): I think the reference to this method in def m = b.&setFoo should not be lost and shown in the Call Hierarchy in some way.
Creating an equivalent Java Class and using a method reference (which is much like a Groovy method pointer), I see it shown in Call Hierarchy just like a regular call. We could argue that is not really a "call" (at least where it's just assigned), but at least it is not lost. So perhaps Greclipse should at least mimic what JDT does.

Here's an "equivalent" Java class to test the behaviour:

package test22;

import java.util.function.Consumer;

class Test22Java {
	public Test22Java() {
		MyBean b = new MyBean();
		Consumer<String> m = b::setFoo;
	}
}
@eric-milles eric-milles added this to the v3.1.0 milestone Apr 19, 2018
@eric-milles eric-milles self-assigned this Sep 2, 2018
@eric-milles
Copy link
Member

org.eclipse.jdt.groovy.search.MethodReferenceSearchRequestor.acceptASTNode(ASTNode, TypeLookupResult, IJavaElement) finds the desired reference, but returns it as an "inaccurate" match and so the Call Hierarchy does not show it.

@eric-milles
Copy link
Member

Ready to test

@mauromol
Copy link
Author

mauromol commented Sep 3, 2018

This works well in 3.1.0.xx-201809022023-e47! Thank you! 👍

@mauromol mauromol closed this as completed Sep 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants