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

Default parameters: constructor call not found by Call Hierarchy #775

Closed
mauromol opened this issue Nov 30, 2018 · 3 comments
Closed

Default parameters: constructor call not found by Call Hierarchy #775

mauromol opened this issue Nov 30, 2018 · 3 comments
Assignees
Milestone

Comments

@mauromol
Copy link

Somewhat follow up to #768

Consider this:

package test42

class GBean {

	GBean() {}
	
	GBean(String foo, String bar = 'hello') {}
	
	void doSomething() {}
	
	void doSomething(String foo, String bar = 'bar') {}
}

And this:

package test42;

class Test43 {

	void test() {
		def b2 = new GBean('foo')
		
		b2.doSomething()
		b2.doSomething('foo')
		b2.doSomething('foo', 'bar')
	}
}

Go to test42.GBean.GBean(String, String). and invoke Call Hierarchy: the call from test42.Test43.test() is not found.

@mauromol mauromol changed the title Default parameters: conctructor call not found by Call Hierarchy Default parameters: constructor call not found by Call Hierarchy Nov 30, 2018
@eric-milles
Copy link
Member

I had started to look into this one when adding support for find references of overloaded constructors. If GBean is in the same file, I think the search and Call Hierarchy works as expected. When they are in separate sources, the conversion from Groovy to Java model is missing the links between the original constructor (the one with 2 parameters) and the generated constructor (the synthetic one with 1 parameter). The conversion is done in JDTClassNode and I am looking for some clue in the MethodBinding that a given method or constructor is generated as a result of a defaulted parameter.

eric-milles referenced this issue Jan 15, 2019
GroovyCompUnitDecl maps MethodNode -> AbstractMethodDeclaration
MethodScope.createMethod maps AbstractMethodDeclaration -> MethodBinding
JDTClassNode.methodBindingToMethodNode maps MethodBinding -> MethodNode
@eric-milles eric-milles self-assigned this Jan 15, 2019
@eric-milles eric-milles added this to the v3.3.0 milestone Jan 15, 2019
@eric-milles
Copy link
Member

Ready to test

@mauromol
Copy link
Author

This works fine in 3.3.0.xx-201901152207-e49, thank you! 👍

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