Bug 149088 - [organize imports] Organize Imports confused by 'c'
Summary: [organize imports] Organize Imports confused by 'c'
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.1.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 M7   Edit
Assignee: Martin Aeschlimann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 149567
Blocks:
  Show dependency tree
 
Reported: 2006-06-28 18:01 EDT by C. Lamont Gilbert CLA
Modified: 2007-05-09 06:23 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description C. Lamont Gilbert CLA 2006-06-28 18:01:58 EDT
When I try organize imports with the following code it tries to import some weird sun packages (com.sun.rsasign.c and sun.security.krb5.internal.crypto.c)


package com.rgdsft.wadgef.editpart;

import org.eclipse.gef.commands.Command;
import org.eclipse.gef.requests.GroupRequest;
import java.util.ArrayList;

public class FuncConnectionEditPolicy extends org.eclipse.gef.editpolicies.ConnectionEditPolicy {

	public FuncConnectionEditPolicy() {
		super();
	}
    protected Command getDeleteCommand(GroupRequest request) {
        List c = new ArrayList();
        c.add(null);
        return c;
    }
}


It seems to think the 'c', on the line including c.setCircuitModel, is a type for some reason.  If I rename the variable this does not happen.  Also any type works, it does not have to be this ConnectionCommand.  As long as the variable is named c.
Comment 1 Dani Megert CLA 2006-06-29 02:39:54 EDT
steps1:
1. disable 'Do not create import for types starting with a lowercase letter'
2. paste this code into a Java project:
-----------  %< ------------
class FuncConnectionEditPolicy  {
    protected void getDeleteCommand() {
        List c = new ArrayList();
        c.add(null);
    }
}
-----------  %< ------------
3. Ctrl+Shift+O
Comment 2 C. Lamont Gilbert CLA 2006-06-29 11:52:02 EDT
It does not like 'l' either, responding with similar Sun classes.
Comment 3 Martin Aeschlimann CLA 2006-07-04 09:04:07 EDT
If possible, turn on the option 'Do not create import for types starting with a lowercase letter' on the Organize import order.
The problem is that 'c' didn't get a variable binding as its return type couldn't be evaluated. 
We have to either talk to jdt.core to allow incomplete variable bindings (bug 149567), or add code in organize impot that finds more information about the reference to 'v'.
Comment 4 C. Lamont Gilbert CLA 2007-02-20 14:15:48 EST
The problem is, it is attempting to import a type based on something located in a place that could not possibly contain a type.  Thats a variable location.

Hmm, then again

c.add(null);

'c' certainly could be a type there with 'add' being a static call.  So it would appear that once 'c' is determined to be a variable in the previous line, it should no longer be considered able to be a type in other lines within the same block.
Comment 5 Martin Aeschlimann CLA 2007-05-09 06:23:03 EDT
This is fixed in M7.