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 159704 - go to declaration in js open files at random
Summary: go to declaration in js open files at random
Status: RESOLVED FIXED
Alias: None
Product: javascript
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: PC Linux
: P2 blocker (vote)
Assignee: Marek Fukala
URL:
Keywords:
: 179773 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-03-05 17:19 UTC by ndwolf
Modified: 2011-02-09 06:05 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Testcase in web project zip file (15.88 KB, application/octet-stream)
2010-01-22 00:13 UTC, bht
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ndwolf 2009-03-05 17:19:03 UTC
I have declarations to the same method in different .js
so when I want to "go to declaration" i need netbeans to show me a list with the posible alternatives.
but netbeans open random declarations instead
Comment 1 Marek Fukala 2009-04-28 09:52:24 UTC
reproducible, the requested functionality is ok.
Comment 2 bht 2010-01-22 00:13:19 UTC
Created attachment 93474 [details]
Testcase in web project zip file

Here is a testcase from 179773 which I am closing.

Please refer to the two js files tree.js and tree_1.js in the web folder of 
the attached testcase.

How to reproduce:
- Open tree_1.js
- Open tree.js
- In tree.js, go to line 9, position your cursor on privateFunction();
- Press [Ctrl+B], Go to Declaration
- Do the same as above in tree_1.js

Expected result: Cursor should go to declaration in same file
Actual result: Cursor goes to declaration in other file
Comment 3 bht 2010-01-22 00:15:59 UTC
*** Bug 179773 has been marked as a duplicate of this bug. ***
Comment 4 bht 2010-09-02 02:43:12 UTC
If there are multiple occurrences, involving multiple files, then there is a list to chose from. However, the occurrence in the current file is not included in the list. This indicates that the occurrence of the current file is ignored.
Comment 5 Marek Fukala 2011-02-03 14:24:05 UTC
No list of choices is shown for me when I try to hyperlink or go to declaration on the method declaration or method usage. It just somehow chooses once particular declaration and uses it. The others are ignored even if they are properly found via find usages.
Comment 6 Marek Fukala 2011-02-03 15:11:18 UTC
cause by JsIndex.getAllNames() returning s Set of IndexElement-s. IndexElement however doesn't take the source element file location into account so even if the method properly finds all occurrences, only one is kept randomly in the resulting HashSet.

Find usages works because *it doesn't use index at all!!!*. It parses all files from classpath and finds the searched element in the parse trees. Crazy!!!
Comment 7 Marek Fukala 2011-02-04 15:42:11 UTC
Now the source FileObject is take into account in the IndexedElemen's equals() and hashCode() methods. This is however still not correct since if there are multiple occurrences of the same method in one source file, the will appear equal. But since the JsIndexer doesn't store the element's offset in the source I cannot easily resolve this. For the sake of fixing the issue the changes are enough.
Comment 8 Marek Fukala 2011-02-04 15:45:28 UTC
And I would appreciate if Petr reviews the change since as he is more experienced in this area he may be able to foresee the possible negative consequence I cannot spot. Thanks in advance.

fixed in web-main#faabf7291a2a
Comment 9 Quality Engineering 2011-02-09 06:05:35 UTC
Integrated into 'main-golden', will be available in build *201102090000* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/faabf7291a2a
User: Marek Fukala <mfukala@netbeans.org>
Log: #159704 - go to declaration in js open files at random