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

Wrong navigation/Javadoc hover on DateGroovyMethods overloading #947

Open
mauromol opened this issue Aug 23, 2019 · 4 comments
Open

Wrong navigation/Javadoc hover on DateGroovyMethods overloading #947

mauromol opened this issue Aug 23, 2019 · 4 comments
Labels

Comments

@mauromol
Copy link

Consider this:

package test56

class Test56 {
	static Date foo(String foo) {
		new Date()
	}
	
	static Date bar(String bar) {
		foo(bar).clearTime()
	}
}

Hit F2 or F3 over clearTime(): Greclipse thinks that the invoked method is org.codehaus.groovy.runtime.DateGroovyMethods.clearTime(java.sql.Date), but it is org.codehaus.groovy.runtime.DateGroovyMethods.clearTime(java.util.Date) indeed.

@mauromol mauromol changed the title Wrong navigation/Javadoc hover Wrong navigation/Javadoc hover on DateGroovyMethods overloading Aug 23, 2019
@eric-milles
Copy link
Member

Resolved binary methods rely on JDT to find source ranges. org.eclipse.jdt.internal.core.SourceMapper has a map for each method signature (with unqualified types). So clearTime(java.sql.Date) and clearTime(java.util.Date) map to the same entry.

		SourceRange[] ranges = (SourceRange[]) this.sourceRanges.get(element); // element is [static java.util.Date clearTime(java.util.Date) {key=Lorg/codehaus/groovy/runtime/DateGroovyMethods;.clearTime(Ljava/util/Date;)Ljava/util/Date;}
		if (ranges == null) {
			return UNKNOWN_RANGE;
		} else {
			return ranges[0]; // selects the first of 2 matching source ranges
		}

@eric-milles
Copy link
Member

This bug seems related. The Java editor's Open Declaration (F3) is finding 2 methods (due to missing packages in parameter types) and then presents a dialog to select the desired method (still missing packages). https://bugs.eclipse.org/bugs/show_bug.cgi?id=441489

The Groovy editor is resolving the target method more accurately, but the supporting framework for determining the source range of the element is not coded to handle overloads like this.

@eric-milles
Copy link
Member

@eric-milles eric-milles self-assigned this Aug 31, 2019
@eric-milles eric-milles removed their assignment Oct 25, 2019
@eric-milles
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants