This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 71143 - enhancement of the camel case completion
Summary: enhancement of the camel case completion
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker with 1 vote (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-08 15:40 UTC by naoki
Modified: 2010-09-23 08:36 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
working image (3.87 KB, image/png)
2006-01-08 15:50 UTC, naoki
Details

Note You need to log in before you can comment on or make changes to this bug.
Description naoki 2006-01-08 15:40:58 UTC
The camel case completion is very useful.
But frequently, tremendous candidate appears and there is no way to narrow them.
So, I tried to customize NetBeans to narrow candidates of camel case completion 
by inputing lower character. 
It is very nice.

The source modified is shown bellow.

/java/editor/src/org/netbeans/modules/editor/java/JMIUtils.java
819:
java.util.regex.Pattern pat = java.util.regex.Pattern.compile("([A-Z]+)([^A-Z]*)
");
java.util.regex.Matcher mat = pat.matcher(name);        
boolean camelCase = mat.matches();
String up = "";
String lo = "";
if(camelCase){
	up = mat.group(1);
	lo = mat.group(2);
}

846:
if (!startsWith(featureName, name) && (!camelCase || !(feature instanceof 
JavaClass) || !matchesCamelCaseEx(featureName, up, lo))) continue;

1171:
public static boolean matchesCamelCaseEx(String simpleName, String up, String 
lo) {
    int sni;
    int pi;
    for (pi = 0, sni = 0; sni < simpleName.length() && pi < up.length(); sni++) 
{
        char ch = simpleName.charAt(sni);
        if (Character.isUpperCase(ch)) {
            if (ch != up.charAt(pi++)) {
                return false;
            }
        }
    }
    
    if(pi != up.length()) return false;
    
    if(lo.length() > 0){
        if(!simpleName.substring(sni).startsWith(lo)){
            return false;
        }
    }
    return true;
}

/java/editor/src/org/netbeans/modules/editor/java/JavaCompletionProvider.java
159:
java.util.regex.Pattern pat = java.util.regex.Pattern.compile("([A-Z]+)([^A-Z]*)
");
java.util.regex.Matcher mat = pat.matcher(prefix);        
boolean camelCase = mat.matches();
String up = "";
String lo = "";
if(camelCase){
	up = mat.group(1);
	lo = mat.group(2);
}

163:
|| (camelCase && (itm instanceof NbJMIResultItem.ClassResultItem) && JMIUtils.
matchesCamelCaseEx(itm.getItemText(), up, lo)))
Comment 1 naoki 2006-01-08 15:50:57 UTC
Created attachment 28281 [details]
working image
Comment 2 msundman 2007-06-25 03:03:08 UTC
Camel case completion is almost useless without this kind of enhancement. E.g., "IA" matches about a gazillion classes, 
whereas "InAdm" only matches "InvoiceAdmin".