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 257158 - goto method definition does not work when declared not in the same file as class
Summary: goto method definition does not work when declared not in the same file as class
Status: VERIFIED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Navigation (show other bugs)
Version: 8.2
Hardware: All All
: P3 normal (vote)
Assignee: Alexander Simon
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-15 16:40 UTC by andrey_p
Modified: 2016-02-04 11:17 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
jar to verify (94.32 KB, application/java-archive)
2015-12-18 13:37 UTC, Vladimir Voskresensky
Details

Note You need to log in before you can comment on or make changes to this bug.
Description andrey_p 2015-12-15 16:40:53 UTC
Setup:
- there is a c++ class (InterpreterGenerator) declared in a .hpp file (InterpreterGenerator.hpp)
- there is a method (lock_method()) declared in another .hpp file (interpreterGenerator_x86_32.hpp)
- the second .hpp file is included inside first one, effectively resulting in declaring method InterpreterGenerator::lock_method()
- there is an implementation of the method in .cpp file (src/cpu/x86/vm/templateInterpreter_x86_32.cpp)

The problem:
The body of the method cannot be navigated to with "Go to definition/declaration" and is not listed in the "Go to symbol" window. Instead "Go to definition/declaration" contains two entries: the global function "lock_method()" declared in interpreterGenerator_x86_32.hpp and "InterpreterGenerator::lock_method()" method declared at the same place.
Note that "Go to declaration/definition" works correctly when cursor is positioned at method body at src/cpu/x86/vm/templateInterpreter_x86_32.cpp so apparently code model has at least one-way correct relation between these two locations. The problem seem to be systematic - there are other methods declared in a similar way and all of them exhibit the same problem

The code the problem is found in is OpenJDK 8
The problem is found in both Netbeans 8.1 and development version 20151124
Comment 1 Vladimir Voskresensky 2015-12-16 11:57:52 UTC
As the fix I propose to make ctrl+click navigation and Go To Symbol navigation consistent:
- when ident under cursor is method call => IDE jumps by ctrl+click to definition (InterpreterGenerator::lock_method()) which is OK

Let's make Go To Symbol to behave similarly: 
- when selected item in dialog is method => open it's definition when exists and  declaration only as backup
Comment 2 Alexander Simon 2015-12-16 15:41:18 UTC
fixed in enum, change set:
a9938d0650ca
Comment 3 Vladimir Voskresensky 2015-12-18 13:37:37 UTC
Created attachment 157844 [details]
jar to verify
Comment 4 andrey_p 2015-12-18 15:16:52 UTC
Fixed mostly:
- now only 2 lines are shown in "Go To Symbol", one for .hpp and another one for .cpp. That is correct
- both of these lines native to proper places. Good
- however the lines only list function name and file location. The class name is missing, so the info misleads the the symbol is a function rather than a class method. Bad
Comment 5 Alexander Simon 2015-12-21 12:21:31 UTC
Additional fix for comment #4.
Change set in enum:
ff5c22eedf80
Comment 6 Quality Engineering 2015-12-22 02:27:32 UTC
Integrated into 'main-silver', will be available in build *201512220002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/a488e9027414
User: Alexander Simon <alexvsimon@netbeans.org>
Log: fixed Bug #257158 goto method definition does not work when declared not in the same file as class
(transplanted from a9938d0650ca4689a1a4bb81dbaac76b2cdab589)
Comment 7 Quality Engineering 2016-01-12 02:28:29 UTC
Integrated into 'main-silver', will be available in build *201601120002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/9588666d0999
User: Alexander Simon <alexvsimon@netbeans.org>
Log: fixed Bug #257158 goto method definition does not work when declared not in the same file as class
- fix regression:
however the lines only list function name and file location. The class name is missing, so the info misleads the the symbol is a function rather than a class method. Bad
(transplanted from ff5c22eedf80aba195991c3de5314615c5c2a8b9)
Comment 9 soldatov 2016-02-04 11:17:15 UTC
Verified in NetBeans 8.1 patch1
Now same functions can be found in "Go to Symbol" dialog.