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 131551 - IllegalArgumentException when navigating to Find Usages results in the case files aren't open
Summary: IllegalArgumentException when navigating to Find Usages results in the case f...
Status: VERIFIED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: All All
: P1 blocker (vote)
Assignee: Vladimir Voskresensky
URL:
Keywords: REGRESSION
: 130806 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-03-30 18:01 UTC by Vladimir Kvashin
Modified: 2008-04-07 12:59 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
the stack (1.95 KB, text/plain)
2008-03-30 18:04 UTC, Vladimir Kvashin
Details
Anyone knows why you override method instead of leaving the original impl? (675 bytes, patch)
2008-04-02 12:07 UTC, Jaroslav Tulach
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Kvashin 2008-03-30 18:01:36 UTC
Create Args project.
Find usages of the printf function.
Close all source files.
Double click on usage in the Find Usages pane - exception occurs.
Comment 1 Vladimir Kvashin 2008-03-30 18:04:04 UTC
Created attachment 59365 [details]
the stack
Comment 2 Vladimir Kvashin 2008-03-30 18:05:07 UTC
In the case the file is already open, no exception occurs.
Comment 3 Vladimir Kvashin 2008-03-30 18:09:55 UTC
There is no cnd module in stack.
The position that is returned is correct: it opens ok an the second attempt (when the file is already open).
Comment 4 Vladimir Voskresensky 2008-03-30 18:38:56 UTC
The reason is that after

        CloneableEditorSupport editSupp=beginPos.getCloneableEditorSupport();
        editSupp.edit();
        JEditorPane[] panes=editSupp.getOpenedPanes();

panes[0].getDocument().getLength(); is zero...
Comment 5 Vladimir Voskresensky 2008-03-30 19:00:55 UTC
*** Issue 130806 has been marked as a duplicate of this issue. ***
Comment 6 Vladimir Voskresensky 2008-03-30 19:11:11 UTC
How to 100% reproduce:
- Create Args project.
- open args.c file
- try Find Usages for local variable "argc"
- close args.c file
- try click on argc usages in Find Usages pane => exception.

As I said, the reason is that panes[0].getDocument().getLength(); is zero
this is zero, because incorrect document in pane is returned.
this is incorrect pane, because in editSupp.getOpenedPanes(); there is line:

if (getLastSelected() == ed) {
   ll.addFirst(p);
} 
BUT getLastSelected() stores dropped pane which has PlainText editor instead instead of CppEditor...

reassign to editor for evaluation

Comment 7 Jan Lahoda 2008-03-30 20:31:22 UTC
CloneableEditorSupport is maintained by openide.text (aka openide/editor).
Comment 8 Vladimir Voskresensky 2008-03-30 21:17:14 UTC
Probably such exceptions started to appear when "Loading" text for documents was added...
Comment 9 Jesse Grodnik 2008-03-31 17:10:21 UTC
Serious regression for find usages for C++, making feature unusable.
Comment 10 Jesse Grodnik 2008-03-31 21:03:10 UTC
A workaround is possible in the C/C++ cluster if this issue cannot be safely fixed in the openide for NetBeans 6.1.
Comment 11 Lukas Hasik 2008-04-01 10:41:19 UTC
Jardo, could you look at this issue? Isn't it caused by your "Loading" feature?

jgrodnik, do you really consider it as P1? It seems that workaround exists.
Comment 12 Vladimir Voskresensky 2008-04-01 14:51:36 UTC
workaround is in trunk
http://hg.netbeans.org/main?cmd=changeset;node=dcd9dc225272
for investigation of regression you can disable overriden function BaseRefactoringElementImpl.openInEditor
Comment 13 Jesse Grodnik 2008-04-01 16:25:47 UTC
We can fix per workaround (in C/C++ cluster) per Vladimir's previous entry. Best is to fix the regression though. In
either case a fix is needed. Let us know how you prefer to proceed. If you advise that we apply the workaround than you
may downgrade this defect to P2.
Comment 14 Jaroslav Tulach 2008-04-02 09:34:28 UTC
OK.
Comment 15 Jaroslav Tulach 2008-04-02 10:44:08 UTC
Btw. another fix is to use putClientProperty("oldInitialization") on your CloneableEditor class:
http://bits.netbeans.org/dev/javadoc/org-openide-text/architecture-summary.html#property-oldInitialization
Comment 16 Jaroslav Tulach 2008-04-02 12:07:31 UTC
Created attachment 59538 [details]
Anyone knows why you override method instead of leaving the original impl?
Comment 17 Jaroslav Tulach 2008-04-02 12:10:17 UTC
Now you have two possible fixes. Either the property or the attached patch. Applying one of them should be enough.
Comment 18 Vladimir Voskresensky 2008-04-04 15:51:33 UTC
removing getPane method is the best idea. Thanks!
I'm integrating this in trunk and remove our workaround, because now everything works fine.
http://hg.netbeans.org/main?cmd=changeset;node=f3d919629e6f
Comment 19 Alexander Pepin 2008-04-04 16:53:33 UTC
fix verified in nb6.1 branch build 20080404 with updated org-netbeans-module-cnd.jar
Comment 20 Alexander Simon 2008-04-04 16:57:40 UTC
to jtulach:
The method breaks the principle "Command-query separation".
I think that it is a main cause of method overriding.
Second: class breaks the principle "Field encapsulation".
So the bug is a consequence of bad base class design.
Comment 21 Vladimir Voskresensky 2008-04-04 19:17:55 UTC
integrated into 6.1 http://hg.netbeans.org/release61?cmd=changeset;node=40e72fcd2f55
Comment 22 dnikitin 2008-04-07 12:59:17 UTC
Verified in NetBeans IDE Dev (Build 200804060002)