Bug 31652 - NamingConvention.suggestXXNames: Put the most relevant first
Summary: NamingConvention.suggestXXNames: Put the most relevant first
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows 2000
: P3 enhancement (vote)
Target Milestone: 2.1 RC1   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-02-12 07:39 EST by Martin Aeschlimann CLA
Modified: 2003-03-04 11:19 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Aeschlimann CLA 2003-02-12 07:39:37 EST
20030211

It would be helpful for me if in cases that i just have to get a single 
variable name, i can simply take the first element of the proposals returned by 
the NamingConvention.

In particular the 'Assign expression to field' just needs a single name 
proposal. See bug 31230

I know that the suggested solution is just a small hack, because with the 
current intrastructure we can't offer the user to really choose what his 
favourite field name convention it. But I think we still win when we apply our 
personal preference.
My preference would be to take the first prefix of the prefix list (together 
with the full name). If the prefix list is empty, take the first of the suffix 
list.
Comment 1 David Audel CLA 2003-02-13 06:31:09 EST
Could you sort the expected proposals for the following tests case ?
1) type name : OneName
   prefixes : {no prefix}
   suffixes : {no suffix}
2) type name : OneName
   prefixes : p1, p2
   suffixes : s1, s2 
3) type name : OneName
   prefixes : p1, p2
   suffixes : {no suffix}
4) type name : OneName
   prefixes : {no prefix}
   suffixes : s1, s2

I need to know what you really want. Your previous comment is not very specific.
Comment 2 David Audel CLA 2003-02-13 06:36:03 EST
Another question: This is the result of NamingConvention.suggestXXXnames that 
must be sorted or the result of code completion ?
Comment 3 Martin Aeschlimann CLA 2003-02-13 08:55:59 EST
The sorting of what suggestXXXnames returns. But the code assist could take 
this order to use in relevance.

Not that I really care about the first being the best choice.

This what I would do
1) type name : OneName
   prefixes : {no prefix}
   suffixes : {no suffix}
  -> oneName, name
 
2) type name : OneName
   prefixes : p1, p2
   suffixes : s1, s2

 -> p1OneName, p1Name, p2OneName, p2Name, oneNames1, names1, oneNames2, names2, 
oneName, name

3) type name : OneName
   prefixes : p1, p2
   suffixes : {no suffix}
p1OneName, p1Name, p2OneName, p2Name, oneName, name


4) type name : OneName
   prefixes : {no prefix}
   suffixes : s1, s2
oneNames1, names1, oneNames2, names2, oneName, name
Comment 4 Philipe Mulet CLA 2003-02-13 12:36:20 EST
Martin, in case 2), what about suffixes ? 
Comment 5 Martin Aeschlimann CLA 2003-02-13 12:50:17 EST
It's a pure personal choice. As I said, the current setup doesn't allow the 
user to really specify its preference about the favourite name. 
Insetad of two lists (prefix, suffix), meybe it would have been better to have 
one list with entries like f*, *_m, * ... ect
So even we can't solve the problem, we improrve the situation by having our 
personal favourite at first position. My argumentation is, if somebody 
specified prefixes, he probably uses them (but of course there are use cases 
where this is not the case)
Comment 6 David Audel CLA 2003-02-14 05:34:05 EST
I think, if somebody specified a prefix and a suffix then this suffix is as 
important as the prefix. So the first proposal should be p1OneNames1.
But this proposal is not in your list for case 2).

My suggestion is to propose the names in th following order
{0}-name with the first prefix and the first suffix
{1}-names with prefix and suffix
{2}-names with prefix
{3}-names with suffix
{4}-others

For completion the names {0} are more relevant than {1}, {1} are more relevant 
than {2}, {2} are more relevant than {3} and {3} are more relevant than {4}.
Comment 7 Martin Aeschlimann CLA 2003-02-14 08:15:15 EST
Even I would never use prefix and suffix together, it's fine with me. 
Comment 8 David Audel CLA 2003-02-14 12:21:47 EST
CodeAssist :
- Variable name proposal is more relevant if this proposal contains a prefix
- Variable name proposal is more relevant if this proposal contains a suffix
- variable name proposal is more relevant if this proposal contians the first 
prefix.
- variable name proposal is more relevant if this proposal contians the first 
suffix.
So a name with a prefix and a suffix is more relevant than a proposal with a 
prefix and no suffix. A name with the first prefix is mor relevant than a name 
with another prefix.

NamingConventions: suggestions are given in the following order (it is the same 
order as relevance for code assist)
- names with first prefix and first suffix
- names with first prefix and a suffix
- names with a prefix and the first siffix
- names with a prefix and a suffix
- names with the first prefix
- names with a prefix
- names with the first suffix
- names with a suffix
- other names

Fixed.

Comment 9 David Audel CLA 2003-02-14 12:23:51 EST
Martin - Becareful, this change could break your test. ;)
Comment 10 Martin Aeschlimann CLA 2003-02-14 13:28:48 EST
Thanks for the warning! It should be no problem, I disabled the tests that 
relied on the order.
Comment 11 David Audel CLA 2003-03-04 11:19:41 EST
Verified.