Bug 3666 CodeCompletion - Hungry code assist (1GDRYW5)
jkca (5/15/2001 11:04:56 AM) jre-sdk 106 Under certain circumstances code assist eats too much code. Consider the enclosed class. As a programmer, I must add a parameter to the baz call in bar to make the program correct. Steps: 1. Change the baz call to baz(x.x.foo()) 2. Place the cursor after the first "x." 3. Ctrl-Space to bring up code assist 4. Type "f" to filter the list. 5. Select, "foo()" 6. The code is changed to: baz(x.foo().foo()) I would rather it gave me baz(x.foo()x.foo()) public class X { void bar(X x) { baz(x.foo()); } int foo() { return 5; } void baz(int i, int j) { } } KUM (5/21/01 9:02:11 AM) The text to replace is computed by the code assist infrastructure. Moved to ITPJCORE. PM (9/4/2001 2:58:56 PM) Option was added. PM (9/25/2001 2:20:50 PM) Removing option. UI can decide whether it wants to use the codeassist end position (until the end of current identifier) or the cursor location it used to start with, so as to control the amount of source to replace. The choice amongst one or the other should be conditioned by a keystroke (enter=replace until end, insert=replace until cursor location). Moving to ITPJUI. Removing codeassist option.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ResultCollector.java
ArrayList result= new ArrayList();
		ProposalComparator comperator= new ProposalComparator();
		for (int i= 0; i < fResults.length; i++) {
			ArrayList bucket = fResults[i];
			int size= bucket.size();
			if (size == 1) {
				result.add(bucket.get(0));
			} else if (size > 1) {
				Object[] sortedBucket = new Object[size];
				bucket.toArray(sortedBucket);
				Arrays.sort(sortedBucket, comperator);
				for (int j= 0; j < sortedBucket.length; j++)
					result.add(sortedBucket[j]);
			}
		}		
		return (ICompletionProposal[]) result.toArray(new ICompletionProposal[result.size()]);
	}
	protected JavaCompletionProposal createMethodCompletion(char[] declaringTypeName, char[] name, char[][] parameterTypeNames, char[][] parameterNames, char[] returnTypeName, char[] completionName, int modifiers, int start, int end) {
		String iconName= JavaPluginImages.IMG_MISC_DEFAULT;
		if (Flags.isPublic(modifiers)) {
			iconName= JavaPluginImages.IMG_MISC_PUBLIC;
		} else if (Flags.isProtected(modifiers)) {
			iconName= JavaPluginImages.IMG_MISC_PROTECTED;
		} else if (Flags.isPrivate(modifiers)) {
			iconName= JavaPluginImages.IMG_MISC_PRIVATE;
		}
		StringBuffer nameBuffer= new StringBuffer();
		nameBuffer.append(name);
		nameBuffer.append('(');
		if (parameterTypeNames.length > 0) {