Bug 255345 - Problems in new NamingConventions APIs
Summary: Problems in new NamingConventions APIs
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M4   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 251670
  Show dependency tree
 
Reported: 2008-11-14 08:00 EST by Markus Keller CLA
Modified: 2008-12-09 05:52 EST (History)
3 users (show)

See Also:


Attachments
Javadoc patch for NamingConventions (6.99 KB, patch)
2008-11-17 06:27 EST, Markus Keller CLA
no flags Details | Diff
Proposed fix (21.88 KB, patch)
2008-11-20 04:31 EST, David Audel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2008-11-14 08:00:31 EST
I20081112-1200

While adopting the new NamingConventions APIs from bug 38111, I ran into a few issues:

- VK_CONSTANT_FIELD should be called VK_STATIC_FINAL_FIELD (we should continue reserving the term 'constant' for compile-time constants)

- suggestSetter/GetterName(..) methods should also consider CODEASSIST_STATIC_FINAL_FIELD_*FIXES constants and use getBaseName(..) to convert e.g. 'K_CONST_ANT' into 'getConstAnt' (with static final prefix "K_")

- suggestVariableNames(CONSTANT_FIELD, BK_TYPE_NAME, "int", ..) returns "i", but I would expect "I" or "INT" (our old implementation returned "INT").
  - For baseName "A", it should return "A", not "a" (problem with single letters)

- getBaseName(..): Javadoc should tell that this method also strips pre- and suffixes, depending on the variable kind and the settings in the given project

- see other Javadoc corrections in the attached patch (typos and missing references to new constants)

In the fix for bug 251670, I added StubUtility.NAMING_CONVENTIONS_BUGS which should shield JDT/UI from these problems (except for the VK_CONSTANT_FIELD rename).
Comment 1 David Audel CLA 2008-11-17 05:21:46 EST
(In reply to comment #0)
> - see other Javadoc corrections in the attached patch (typos and missing
> references to new constants)

It seems that you forgot to attach the patch
Comment 2 Markus Keller CLA 2008-11-17 06:27:51 EST
Created attachment 118040 [details]
Javadoc patch for NamingConventions

> It seems that you forgot to attach the patch
Oops, sorry about that.
Comment 3 Markus Keller CLA 2008-11-18 09:50:18 EST
I just realized we had a test failure in CodeCompletionTest#testGetterCompletion1() due to a subtle difference between NamingConventions#getBaseName(..) and the now-deprecated removePrefixAndSuffixFor*Name(..) methods.

In the old days, the base name for e.g. field "fWriter" with prefix "f" was "writer". Now, getBaseName() returns "Writer" (with capital first letter).

I've put a workaround for this into StubUtility, but I think getBaseName(..) should return uncapitalized names, since it returns a *variable* name, and those are traditionally uncapitalized. Together with 10.c) from bug 38111, this would completely spare clients from having to care about casing of names.
Comment 4 David Audel CLA 2008-11-20 04:31:26 EST
Created attachment 118341 [details]
Proposed fix

This patch contains the following modifications:
- VK_STATIC_FINAL_FIELD is added to replace VK_CONSTANT_FIELD. I will remove VK_CONSTANT_FIELD when you will use VK_STATIC_FINAL_FIELD.
	VK_CONSTANT_FIELD was shorter but VK_STATIC_FINAL_FIELD is closer to the name of the associated options CODEASSIST_STATIC_FINAL_FIELD_*FIXES
- suggestVariableNames() returns capitalized type name for base type (int -> INT).
- suggestVariableNames() returns capitalized name when the name contains only one letter (a -> A).
- Javadoc of getBaseName() is improved.
- getBaseName() returns name starting with a lowercase.

I also corrected typos and missing references to new constants (thanks for the patch)

I did not modify suggestSetter/GetterName. I will fix them with the fix for bug 251693
Comment 5 David Audel CLA 2008-11-20 04:35:25 EST
Released for 3.5M4.

Tests added
  NamingConventions#testSuggestFieldName039() -> testSuggestFieldName040()

Tests updated
  NamingConventions#testGetBaseName001() -> testGetBaseName004()
  NamingConventions#testSuggestFieldName021() -> testSuggestFieldName022()
  NamingConventions#testSuggestFieldName025() -> testSuggestFieldName028()
Comment 6 Markus Keller CLA 2008-11-20 10:56:38 EST
Thanks, I've removed the references to VK_CONSTANT_FIELD and the workarounds in JDT/UI.
Comment 7 Srikanth Sankaran CLA 2008-12-09 04:24:57 EST
Verified for 3.5M4 using I20081208-1800 build