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 58494 - [editorhints] Better recognition when cast is needed
Summary: [editorhints] Better recognition when cast is needed
Status: RESOLVED FIXED
Alias: None
Product: contrib
Classification: Unclassified
Component: Code (show other bugs)
Version: 4.x
Hardware: All All
: P3 blocker (vote)
Assignee: _ leonchiver
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-02 16:23 UTC by Martin Krauskopf
Modified: 2005-05-09 07:46 UTC (History)
2 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Krauskopf 2005-05-02 16:23:11 UTC
When you have the following code the only hint offered is to create method
"private void doBasicProjectTest(Object object, boolean b)". It would be nice if
also a hint with "Cast to JBProject" was offered.

The result would be:

  doBasicProjectTest((JBProject) projects.toArray()[0], true); // **


Example code follows:

  hello() {
    Collection/*<JBProject>*/ projects = iterator.getProjects();
    doBasicProjectTest(projects.toArray()[0], true); // **
  }

  void doBasicProjectTest(JBProject project, boolean hasLibraries) {
    // blablabla
  }
Comment 1 Martin Krauskopf 2005-05-03 10:40:06 UTC
Better and very common example which should offer the cast (to File) on the
first place:

for (Iterator it = libs.iterator(); it.hasNext(); ) {
    FileObject fo = FileUtil.toFileObject(it.next());
}
Comment 2 Jan Lahoda 2005-05-03 10:43:37 UTC
I agree in particular with the second example.
Comment 3 _ leonchiver 2005-05-03 14:08:55 UTC
was already planning to do something like this
Comment 4 Jan Lahoda 2005-05-03 15:53:49 UTC
Ok, please go ahead.
Comment 5 _ leonchiver 2005-05-03 18:01:34 UTC
Jan, I was thinking that the issue was assigned to me. 
Now I saw that you were the initial owner of it. Maybe this sounds stupid, but I
don't wanna "steal" it from you. So if you wanna fix it, it's yours. Otherwise I
will take care of it at the end of the week.
Comment 6 Martin Krauskopf 2005-05-03 19:48:33 UTC
Regarding assignment. I don't know to whom should I assign issues. I know you
both are working on the module so once I assign it to (CC) Leon, once to Honza.
If there are some rules please tell me so. I will assign it appropriately next time.
Anyway, thanks for the great work. It's really usable and *stable* for me (using
-J-Dorg.netbeans.modules.java.hints.experimental=true).
Comment 7 Jan Lahoda 2005-05-03 20:21:38 UTC
In fact, this bug was originally assigned to you, Leon. I considered it to be my
mistake (that I have not considered it when I wrote the add cast hint), so I
assigned it to myself (and have "stolen" it from you, sorry). If you want to fix
it, you are welcome (and it was originally your bug :-)).

Martin, you can assign the bugs to both me and Leon, we will reassign it as
necessary.
Comment 8 _ leonchiver 2005-05-05 22:59:33 UTC
probably fixed

Checking in JavaHintsProvider.java;
/cvs/contrib/editorhints/java/src/org/netbeans/modules/java/hints/JavaHintsProvider.java,v
 <--  JavaHintsProvider.java
new revision: 1.44; previous revision: 1.43
done

will close it tomorrow after writing a few tests.
Comment 9 _ leonchiver 2005-05-06 11:05:14 UTC
well, the fix is only partial. it doesn't work in case of method overloading:

doStuff(String a, String b) {
}

doStuff(String a) {
}

and you use doStuff(Object); 

this is because the compiler message is different. will take care of this case too.
Comment 10 _ leonchiver 2005-05-09 07:46:25 UTC
RCS file: /cvs/contrib/editorhints/java/tasklist.ics,v
done
Checking in java/tasklist.ics;
/cvs/contrib/editorhints/java/tasklist.ics,v  <--  tasklist.ics
initial revision: 1.1
done
Checking in java/src/org/netbeans/modules/java/hints/CreateElementJavaHint.java;
/cvs/contrib/editorhints/java/src/org/netbeans/modules/java/hints/CreateElementJavaHint.java,v
 <--  CreateElementJavaHint.java
new revision: 1.19; previous revision: 1.18
done
Checking in java/src/org/netbeans/modules/java/hints/DeclarationInfo.java;
/cvs/contrib/editorhints/java/src/org/netbeans/modules/java/hints/DeclarationInfo.java,v
 <--  DeclarationInfo.java
new revision: 1.15; previous revision: 1.14
done
Checking in java/src/org/netbeans/modules/java/hints/GeneratorUtils.java;
/cvs/contrib/editorhints/java/src/org/netbeans/modules/java/hints/GeneratorUtils.java,v
 <--  GeneratorUtils.java
new revision: 1.10; previous revision: 1.9
done
Checking in java/src/org/netbeans/modules/java/hints/JavaHintsProvider.java;
/cvs/contrib/editorhints/java/src/org/netbeans/modules/java/hints/JavaHintsProvider.java,v
 <--  JavaHintsProvider.java
new revision: 1.48; previous revision: 1.47
done
RCS file:
/cvs/contrib/editorhints/java/test/qa-functional/data/goldenfiles/org/netbeans/modules/java/hints/test/JavaHintsTest/testCastOrMethodInvocation58494c-hints.pass,v
done
Checking in
java/test/qa-functional/data/goldenfiles/org/netbeans/modules/java/hints/test/JavaHintsTest/testCastOrMethodInvocation58494c-hints.pass;
/cvs/contrib/editorhints/java/test/qa-functional/data/goldenfiles/org/netbeans/modules/java/hints/test/JavaHintsTest/testCastOrMethodInvocation58494c-hints.pass,v
 <--  testCastOrMethodInvocation58494c-hints.pass
initial revision: 1.1
done
RCS file:
/cvs/contrib/editorhints/java/test/qa-functional/data/goldenfiles/org/netbeans/modules/java/hints/test/JavaHintsTest/testCastOrMethodInvocation58494c.pass,v
done
Checking in
java/test/qa-functional/data/goldenfiles/org/netbeans/modules/java/hints/test/JavaHintsTest/testCastOrMethodInvocation58494c.pass;
/cvs/contrib/editorhints/java/test/qa-functional/data/goldenfiles/org/netbeans/modules/java/hints/test/JavaHintsTest/testCastOrMethodInvocation58494c.pass,v
 <--  testCastOrMethodInvocation58494c.pass
initial revision: 1.1
done
RCS file:
/cvs/contrib/editorhints/java/test/qa-functional/data/goldenfiles/org/netbeans/modules/java/hints/test/JavaHintsTest/testCastOrMethodInvocation58494d-hints.pass,v
done
Checking in
java/test/qa-functional/data/goldenfiles/org/netbeans/modules/java/hints/test/JavaHintsTest/testCastOrMethodInvocation58494d-hints.pass;
/cvs/contrib/editorhints/java/test/qa-functional/data/goldenfiles/org/netbeans/modules/java/hints/test/JavaHintsTest/testCastOrMethodInvocation58494d-hints.pass,v
 <--  testCastOrMethodInvocation58494d-hints.pass
initial revision: 1.1
done
RCS file:
/cvs/contrib/editorhints/java/test/qa-functional/data/goldenfiles/org/netbeans/modules/java/hints/test/JavaHintsTest/testCastOrMethodInvocation58494d.pass,v
done
Checking in
java/test/qa-functional/data/goldenfiles/org/netbeans/modules/java/hints/test/JavaHintsTest/testCastOrMethodInvocation58494d.pass;
/cvs/contrib/editorhints/java/test/qa-functional/data/goldenfiles/org/netbeans/modules/java/hints/test/JavaHintsTest/testCastOrMethodInvocation58494d.pass,v
 <--  testCastOrMethodInvocation58494d.pass
initial revision: 1.1
done
RCS file:
/cvs/contrib/editorhints/java/test/qa-functional/data/goldenfiles/org/netbeans/modules/java/hints/test/JavaHintsTest/testCastOrMethodInvocation58494e-hints.pass,v
done
Checking in
java/test/qa-functional/data/goldenfiles/org/netbeans/modules/java/hints/test/JavaHintsTest/testCastOrMethodInvocation58494e-hints.pass;
/cvs/contrib/editorhints/java/test/qa-functional/data/goldenfiles/org/netbeans/modules/java/hints/test/JavaHintsTest/testCastOrMethodInvocation58494e-hints.pass,v
 <--  testCastOrMethodInvocation58494e-hints.pass
initial revision: 1.1
done
RCS file:
/cvs/contrib/editorhints/java/test/qa-functional/data/goldenfiles/org/netbeans/modules/java/hints/test/JavaHintsTest/testCastOrMethodInvocation58494f-hints.pass,v
done
Checking in
java/test/qa-functional/data/goldenfiles/org/netbeans/modules/java/hints/test/JavaHintsTest/testCastOrMethodInvocation58494f-hints.pass;
/cvs/contrib/editorhints/java/test/qa-functional/data/goldenfiles/org/netbeans/modules/java/hints/test/JavaHintsTest/testCastOrMethodInvocation58494f-hints.pass,v
 <--  testCastOrMethodInvocation58494f-hints.pass
initial revision: 1.1
done
RCS file:
/cvs/contrib/editorhints/java/test/qa-functional/data/goldenfiles/org/netbeans/modules/java/hints/test/JavaHintsTest/testCastOrMethodInvocation58494f.pass,v
done
Checking in
java/test/qa-functional/data/goldenfiles/org/netbeans/modules/java/hints/test/JavaHintsTest/testCastOrMethodInvocation58494f.pass;
/cvs/contrib/editorhints/java/test/qa-functional/data/goldenfiles/org/netbeans/modules/java/hints/test/JavaHintsTest/testCastOrMethodInvocation58494f.pass,v
 <--  testCastOrMethodInvocation58494f.pass
initial revision: 1.1
done
RCS file:
/cvs/contrib/editorhints/java/test/qa-functional/data/projects/default/src/org/netbeans/test/java/hints/CastOrMethodInvocation58494c.java,v
done
Checking in
java/test/qa-functional/data/projects/default/src/org/netbeans/test/java/hints/CastOrMethodInvocation58494c.java;
/cvs/contrib/editorhints/java/test/qa-functional/data/projects/default/src/org/netbeans/test/java/hints/CastOrMethodInvocation58494c.java,v
 <--  CastOrMethodInvocation58494c.java
initial revision: 1.1
done
RCS file:
/cvs/contrib/editorhints/java/test/qa-functional/data/projects/default/src/org/netbeans/test/java/hints/CastOrMethodInvocation58494d.java,v
done
Checking in
java/test/qa-functional/data/projects/default/src/org/netbeans/test/java/hints/CastOrMethodInvocation58494d.java;
/cvs/contrib/editorhints/java/test/qa-functional/data/projects/default/src/org/netbeans/test/java/hints/CastOrMethodInvocation58494d.java,v
 <--  CastOrMethodInvocation58494d.java
initial revision: 1.1
done
RCS file:
/cvs/contrib/editorhints/java/test/qa-functional/data/projects/default/src/org/netbeans/test/java/hints/CastOrMethodInvocation58494e.java,v
done
Checking in
java/test/qa-functional/data/projects/default/src/org/netbeans/test/java/hints/CastOrMethodInvocation58494e.java;
/cvs/contrib/editorhints/java/test/qa-functional/data/projects/default/src/org/netbeans/test/java/hints/CastOrMethodInvocation58494e.java,v
 <--  CastOrMethodInvocation58494e.java
initial revision: 1.1
done
RCS file:
/cvs/contrib/editorhints/java/test/qa-functional/data/projects/default/src/org/netbeans/test/java/hints/CastOrMethodInvocation58494f.java,v
done
Checking in
java/test/qa-functional/data/projects/default/src/org/netbeans/test/java/hints/CastOrMethodInvocation58494f.java;
/cvs/contrib/editorhints/java/test/qa-functional/data/projects/default/src/org/netbeans/test/java/hints/CastOrMethodInvocation58494f.java,v
 <--  CastOrMethodInvocation58494f.java
initial revision: 1.1
done
RCS file:
/cvs/contrib/editorhints/java/test/qa-functional/data/projects/default/src/org/netbeans/test/java/hints/pkg/CastOrMethodInvocation58494cUsee.java,v
done
Checking in
java/test/qa-functional/data/projects/default/src/org/netbeans/test/java/hints/pkg/CastOrMethodInvocation58494cUsee.java;
/cvs/contrib/editorhints/java/test/qa-functional/data/projects/default/src/org/netbeans/test/java/hints/pkg/CastOrMethodInvocation58494cUsee.java,v
 <--  CastOrMethodInvocation58494cUsee.java
initial revision: 1.1
done
RCS file:
/cvs/contrib/editorhints/java/test/qa-functional/data/projects/default/src/org/netbeans/test/java/hints/pkg/CastOrMethodInvocation58494dUsee.java,v
done
Checking in
java/test/qa-functional/data/projects/default/src/org/netbeans/test/java/hints/pkg/CastOrMethodInvocation58494dUsee.java;
/cvs/contrib/editorhints/java/test/qa-functional/data/projects/default/src/org/netbeans/test/java/hints/pkg/CastOrMethodInvocation58494dUsee.java,v
 <--  CastOrMethodInvocation58494dUsee.java
initial revision: 1.1
done
Checking in
java/test/qa-functional/src/org/netbeans/modules/java/hints/test/JavaHintsTest.java;
/cvs/contrib/editorhints/java/test/qa-functional/src/org/netbeans/modules/java/hints/test/JavaHintsTest.java,v
 <--  JavaHintsTest.java
new revision: 1.26; previous revision: 1.25
done