Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 99651

Summary: [quick fix] Create method quick fix gives poor names for parameters with parameterized types
Product: [Eclipse Project] JDT Reporter: David Saff <david>
Component: CoreAssignee: David Audel <david_audel>
Status: CLOSED WONTFIX QA Contact:
Severity: minor    
Priority: P3 CC: david_audel, martinae
Version: 3.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug

Description David Saff CLA 2005-06-13 10:06:01 EDT
In RC2.  Given code:

private void foo() {
	a(new ArrayList());
	b(new ArrayList<Object>());
}

Use quick fix to create a and b:

	private void a(ArrayList list) {
		// TODO Auto-generated method stub
		
	}

	private void b(ArrayList<Object> name) {
		// TODO Auto-generated method stub
		
	}

Note that b's parameter is always named "name", not something more likely to be
useful, like "list".
Comment 1 Dirk Baeumer CLA 2005-06-13 18:06:12 EDT
Not critical for 3.1.
Comment 2 Martin Aeschlimann CLA 2005-06-15 05:12:43 EDT
We're using NamingConventions.suggestArgumentNames with 'ArrayList<Object>'.
Comment 3 Olivier Thomann CLA 2006-10-06 15:17:01 EDT
Reproduced with latest.
Comment 4 David Audel CLA 2006-10-09 04:51:23 EDT
'name' is the default name when NamingConventions.suggestArgumentNames() is unable to suggest a name.

The parameter qualifiedTypename of suggestArgumentNames() must be only a qualified type name (java.util.ArrayList or ArrayList) and must not be a parameterized type. 
JDT/UI should call suggestArgumentNames() with only ArrayList and not with ArrayList<Object>.

If we want to take into account types arguments in naming suggestion, we would need new API methods. But i don't think that's interesting because won't be able to suggest useful name.  e.g. what name for java.util.Map<String, String> ?

Move to JDT/UI.



Comment 5 Martin Aeschlimann CLA 2006-10-09 06:30:20 EDT
Are you sure that 'qualifiedTypeName' is meant to be the fully qualified type name? There is also an argument 'packageName' first. So I believe you meant 'typeQualifiedName' as in IType.getTypeQualifiedName

But anyways, we don't always have the fully qualified name and passing just a simple name should be fine for NamingConvention too, it can be treated like a type from the default package.

For '<..>', We'd be happy if you could treat that as well, otherwise we have to build this on top.
And it makes sense to add suggestions based on the parameters: List<String> -> listOfStrings.
But of course ignoring the type parameters is ok too.

Moving back to jdt.core. Let us know if you want update your code to also handle type parameters (with the existing API).
Comment 6 Eclipse Genie CLA 2020-03-13 17:18:21 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.