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

Bug 296903

Summary: [content assist] method code completion overwrites for() declaration
Product: [Eclipse Project] JDT Reporter: Martijn Dashorst <martijn.dashorst>
Component: TextAssignee: Dani Megert <daniel_megert>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: markus.kell.r
Version: 3.6   
Target Milestone: 3.6   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Screen cast showing the described behavior none

Description Martijn Dashorst CLA 2009-12-04 05:19:38 EST
User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_2; en-us) AppleWebKit/531.21.8 (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10
Build Identifier: 20090920-1017

Given the code:

1. Method[] methods = taskClass.getDeclaredMethods();
2. 
3. for(Method method : methods)
4. {
5.     .......
when I try to sort the array before entering the loop by typing at line 2:
Arrays.sort<CTRL-SPACE>

Eclipse will garble the lines 3-5 into gibberish.


Reproducible: Always

Steps to Reproduce:
1.have a construct like for() 
2.type a part of a method invocation
3.use code completion to generate the method call and parameters
Comment 1 Martijn Dashorst CLA 2009-12-04 05:20:57 EST
Created attachment 153808 [details]
Screen cast showing the described behavior

This movie shows what happens with this bug report.
Comment 2 Martijn Dashorst CLA 2009-12-04 05:37:08 EST
It appears to relate to an organize imports race condition where several imports are substituted by a * import.
Comment 3 Markus Keller CLA 2009-12-04 12:15:48 EST
Reproduced with I20091201-1600 and 3.5.1:
- set number of imports for .* to 3
- content assist after Arrays.sort

package xy;

import java.lang.reflect.Method;
import java.util.List;
import java.util.ArrayList;

public class Try {
	void m(List l, ArrayList al) {
		Method[] methods = getClass().getDeclaredMethods();
		Arrays.sort
		for (Method method : methods) {
			if (method.isAnnotationPresent(Deprecated.class)) {
				System.out.println(method);
			}
		}
	}
}
Comment 4 Markus Keller CLA 2009-12-04 12:16:37 EST

*** This bug has been marked as a duplicate of bug 285137 ***