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 159875

Summary: guess better the used classes to do imports
Product: java Reporter: ddv36a78 <ddv36a78>
Component: EditorAssignee: Dusan Balek <dbalek>
Status: NEW ---    
Severity: blocker    
Priority: P2    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:

Description ddv36a78 2009-03-08 19:46:27 UTC
Suppose I have 3 packages :
- x : class Image
- y : class Image + ImageProvider
- z : class Main

Class y.ImageProvider has the following method:

public static y.Image getImage() {
  doSomething();
  return ...;
}

So, class y.ImageProvider returns/uses the y.Image class, so the Image class of the same package.

Let's imagine, I define the following method into the z.Main class:

public static Image f() {
        return ImageProvider.getImage();
}

First, z.Main class has no import: several red underline markings appear for Image, and ImageProvider.

I first click on hint for ImageProvider and NetBeans introduces "import y.ImageProvider;"

Still remains a red underline for Image. NetBeans does not know if it is x.Image or y.Image class to use.

But as f() returns "ImageProvider.getImage();", NetBeans should be able to guess f() has the same return type as
getImage() method. So, NetBeans should be able to guess it's y.Image class to use.

It's an improvement that could help a lot. Just think, for example, about how many Action classes developers define into
different frameworks !
Having a better guessing algorithm could help a lot for programming.
Thanks.