Bug 393781 - In case of non matching argument list the message is not informative if short class name matches
Summary: In case of non matching argument list the message is not informative if short...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.2.1   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 4.3 M4   Edit
Assignee: Jay Arthanareeswaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-07 10:53 EST by Gábor Lipták CLA
Modified: 2012-12-11 05:19 EST (History)
4 users (show)

See Also:


Attachments
Non informative message (197.62 KB, image/jpeg)
2012-11-07 10:53 EST, Gábor Lipták CLA
no flags Details
The cause is the wrong import (198.26 KB, image/jpeg)
2012-11-07 10:54 EST, Gábor Lipták CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gábor Lipták CLA 2012-11-07 10:53:47 EST
Created attachment 223308 [details]
Non informative message

I have imported some backport class instead of the normal JDK class by accident. The GUI told me, that the method arguments are not compatible, but it was not informative, since it showed the short name of the class. See in the pictures.

Enhancement could be to display the fully qualified names in the message if the short name is matching. Another enhancement could be a quick correction suggestion, which would look up other classes on the classpath with the same name as the class of the argument or the class, which declares the method.
Comment 1 Gábor Lipták CLA 2012-11-07 10:54:26 EST
Created attachment 223309 [details]
The cause is the wrong import
Comment 2 Markus Keller CLA 2012-11-07 13:05:10 EST
I agree it would be good to qualify the type names in the message if the simple names match.
Comment 3 Jay Arthanareeswaran CLA 2012-11-08 06:26:37 EST
For simplicity sake (of the code change), would it be enough if 

1. the qualified name is used only when all other parameters match 
2. all parameters are displayed with qualified name even when only one or some parameters have a matching simple name?

For e.g.,

public void bar(Map map, String str) {}  // Map is java.util.map
util.bar(map, "");  // map is a q.Map

Message displayed would be something like this:

The method bar(q.Map, java.lang.String) in the type Util is not applicable for the arguments (java.util.Map, java.lang.String)

Note that even when one of the parameters have a matching simple name, qualified name is used for all parameters.

And when the invocation is: 
util.bar(map);

The message would be something like this:

The method bar(Map, String) in the type Util is not applicable for the arguments (Map). The problem here is, this error alone is not helpful enough to fix the code completely
Comment 4 Gábor Lipták CLA 2012-11-08 06:33:32 EST
The main thing is to avoid a lot of thinking of the user. What you have described here is enough for me. So if it easy to have FQN for the arguments in the message, just do it please. 

Having quick fix options here could be a great enhancement later. Should we create a separate ticket for it?

(In reply to comment #3)
> For simplicity sake (of the code change), would it be enough if 
> 
> 1. the qualified name is used only when all other parameters match 
> 2. all parameters are displayed with qualified name even when only one or
> some parameters have a matching simple name?
> 
> For e.g.,
> 
> public void bar(Map map, String str) {}  // Map is java.util.map
> util.bar(map, "");  // map is a q.Map
> 
> Message displayed would be something like this:
> 
> The method bar(q.Map, java.lang.String) in the type Util is not applicable
> for the arguments (java.util.Map, java.lang.String)
> 
> Note that even when one of the parameters have a matching simple name,
> qualified name is used for all parameters.
> 
> And when the invocation is: 
> util.bar(map);
> 
> The message would be something like this:
> 
> The method bar(Map, String) in the type Util is not applicable for the
> arguments (Map). The problem here is, this error alone is not helpful enough
> to fix the code completely
Comment 5 Markus Keller CLA 2012-11-08 09:01:50 EST
(In reply to comment #3)
Yes, qualifying all types is fine (but only if at least one simple name conflict occurs).

(In reply to comment #4)
> Having quick fix options here could be a great enhancement later. Should we
> create a separate ticket for it?

Yes, that would be a separate enhancement request for JDT UI (quick fix to change existing import).
Comment 6 Jay Arthanareeswaran CLA 2012-11-09 05:34:26 EST
Released the fix and regression test via commit:

http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=699f7fbae3c0c490fd8a048eefa69e38ba0aed7a

All existing JDT Core and UI tests pass.
Comment 7 Gábor Lipták CLA 2012-11-09 06:54:16 EST
Quick fix feature request added:https://bugs.eclipse.org/bugs/show_bug.cgi?id=393964
Comment 8 Manoj N Palat CLA 2012-12-11 03:45:57 EST
Verified.

[ Following code was used to verify ]

import java.util.*;

public class X {
	private class Map {
		int i;
	}
	public static void main() {
		Map map = new Map();
		bar(map, "");// expected error: The method bar(Map, String) in the type X is not applicable for the arguments (X.Map, String)
		bar(1,"");// expected error: The method bar(Map, String) in the type X is not applicable for the arguments (int, String)
	}
	public void bar(java.util.Map map, String str) {}  	
}
Comment 9 Manoj N Palat CLA 2012-12-11 04:31:29 EST
(In reply to comment #8)
> Verified.

[ Following code was used to verify ]

import java.util.*;
> public class X {
	private class Map {
		int i;
	}
	public static void main()
> {
		Map map = new Map();
		bar(map, "");// expected error: The method
> bar(Map, String) in the type X is not applicable for the arguments (X.Map,
> String)
		bar(1,"");// expected error: The method bar(Map, String) in the
> type X is not applicable for the arguments (int, String)
	}
	public void
> bar(java.util.Map map, String str) {}  	
}

Verified for 4.3 M4 using I20121210-2000 build