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 188107 - Links to external classes not working
Summary: Links to external classes not working
Status: VERIFIED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P2 normal with 1 vote (vote)
Assignee: Petr Pisl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-25 22:37 UTC by chris4beta
Modified: 2011-04-07 15:06 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Expected behavior - NB 6.8 (30.74 KB, image/gif)
2010-08-19 20:37 UTC, chris4beta
Details
Incorrect behavior - build 201008190001 (23.49 KB, image/gif)
2010-08-19 20:38 UTC, chris4beta
Details
Sample CI project setup (389.27 KB, application/octet-stream)
2011-03-15 20:28 UTC, chris4beta
Details

Note You need to log in before you can comment on or make changes to this bug.
Description chris4beta 2010-06-25 22:37:28 UTC
I'm sorry if my title was not very descriptive, but I'm not sure the correct terminology for it.

When working in NB 6.8 on a CodeIgniter PHP project, once I've loaded a library:

$this->load->library('upload');

Later in the code, I could hold Ctrl and hover over "do_upload" in the following:

$this->upload->do_upload();

And it would popup info about the class, and clicking it would open that class's PHP file and take me to that function. NB 6.9 does not have this same functionality, which is pretty important IMHO.
Comment 1 rmatous 2010-08-18 14:16:34 UTC
http://hg.netbeans.org/web-main/rev/bc0b5355953f

should work now, don't forget to customize properly the include path
Comment 2 chris4beta 2010-08-18 20:28:06 UTC
Thank you. I'll look for it in the nightly.
Comment 3 Quality Engineering 2010-08-19 03:23:25 UTC
Integrated into 'main-golden', will be available in build *201008190001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/bc0b5355953f
User: Radek Matous <rmatous@netbeans.org>
Log: #188107 - Links to external classes not working
Comment 4 chris4beta 2010-08-19 20:37:06 UTC
Created attachment 101543 [details]
Expected behavior - NB 6.8
Comment 5 chris4beta 2010-08-19 20:37:53 UTC
Build *201008190001* does NOT resolve this issue for me with my CodeIgniter project.

I've attached two examples - the first is from NB 6.8 and demonstrates the expected behavior. You can see when I CTRL-click on 'from', I get a list of declarations and I can select one and go right to it.

The second is what happens in build 201008190001. I CTRL-click on it and nothing happens.

This is the same project open in both builds, and all class files are within the root project folder.
Comment 6 chris4beta 2010-08-19 20:38:34 UTC
Created attachment 101544 [details]
Incorrect behavior - build 201008190001
Comment 7 rmatous 2010-08-19 21:12:27 UTC
OK, I will reevaluate
Comment 8 Filip Zamboj 2010-09-15 12:32:12 UTC
batch reassigning
Comment 9 chris4beta 2010-11-18 20:16:07 UTC
This seems to be fixed in the 7.0 beta. I can now stop using 6.8 :)
Comment 10 chris4beta 2010-11-18 20:32:26 UTC
I spoke too soon. This is still an issue in 7.0 beta. It will work for some classes and not others, despite all files being within the project root. This is a show-stopper bug for me.

I'll continue using 6.8.
Comment 11 chris4beta 2011-02-21 20:35:52 UTC
This bug is still present, exactly as described, in NB 7.2 beta.
Comment 12 Petr Pisl 2011-03-15 09:21:24 UTC
Could you somehow more specify, which for which classes it doesn't work? It would be great to have a reproducible case.
Comment 13 Petr Pisl 2011-03-15 11:21:19 UTC
So I found the case and also why it doesn't work from NB 6.9. In summary in NetBeans 6.8 it's a bug. I know it's stupid, but in NB 6.9 it started to work correctly, when there was improved type reference recognition. It doesn't influence only code navigation, but also code completion. I will try to clarify this. 

In your example I expect that the $db property is type of CI_DB_active_record. When you look at the DB_active_rec.php file you can see that in the php doc for select method is written "@return object". The type reference can not find the object type, because such type is not defined anywhere. So the code completion and navigation doesn't work for such object type.

In NB 6.8 it works because there is simple type reference recognition and in some cases the ide is able to count the type only for the first call in a call chain. This is exactly the case. The first call ($this->db) returns CI_DB_active_record and this type is then used for all other calls in the chain as well. Which is wrong.

I don't know how to fix it correctly, except special hack for the CI_DB_active_record class, which is ugly.
Comment 14 chris4beta 2011-03-15 13:33:55 UTC
So basically NB 6.8 was doing it right, but was actually wrong? Here are some more examples:

To load models in CodeIgniter:

$this->load->model('Accounts_model', 'acctdb');

To use the model:

$foo = $this->acctdb->get_location_contacts($loc_id, $term);

In NB 6.8, I could ctrl-click on "get_location_contacts" and it would open my accounts_model.php file and take me to the function. In every version since, nothing happens when I click.

--------------------------------

To use the form validation library:

$this->load->library('form_validation');

To use:

$this->form_validation->set_rules('foo', 'Bar', 'required');

Again, I used to be able to click on "set_rules" and it would open the correct file take me to that function. Not anymore.

--------------------------------

I guess it has to do with how things are loaded withing CodeIgniter and every little thing is called through $this->

I've gotten so used to being able to quickly jump around to any function with NB 6.8, I don't think I'd ever upgrade if that functionality wasn't there.
Comment 15 Petr Pisl 2011-03-15 16:16:50 UTC
So I have created a fix, when a return type of a method is type 'object' and there is no find such type in the project, then the return type of the method is returned the class. This doesn't have to be the right type, but it's better then return nothing and it will fix this issue. 

The change: http://hg.netbeans.org/web-main/rev/a40f76f7d03f

Can someone from QA tested?
Thanks.
Comment 16 Petr Pisl 2011-03-15 16:18:23 UTC
In the NB 6.8 basically it was a bug. How is defined the methods in your example?
Comment 17 Petr Pisl 2011-03-15 16:26:14 UTC
NB doesn't resolve nothing according a framework or something like this. In your example:

$foo = $this->acctdb->get_location_contacts($loc_id, $term);

the type of acctdb is resolved, but for method get_location_contacts was not probably resolved and was used (due a bug) the type that was found for acctdb property. 

What is the php doc for get_location_contacts method and for set_rules method from your examples?

The fix will be available from build #2997 at http://bertram.netbeans.org/hudson/job/PHP-build/, you can try your situation with the build #2997 or newer.
Comment 18 Petr Pisl 2011-03-15 16:39:07 UTC
I have just noticed that the build #2997 doesn't contain the fix, probably the next one.
Comment 19 chris4beta 2011-03-15 17:03:53 UTC
get_location_contacts doesn't have any php doc, and the function set_rules is this:

/**
 * Set Rules
 *
 * This function takes an array of field names and validation
 * rules as input, validates the info, and stores it
 *
 * @access	public
 * @param	mixed
 * @param	string
 * @return	void
 */

So whether a method is 'found' or not depends on its documentation?
Comment 20 chris4beta 2011-03-15 20:27:02 UTC
I've tested build 2998 and is still not functioning as expected. I've attached a zip file (ci_test.zip) of a fresh CodeIgniter (CI) project with one controller and one model that will best illustrate this issue.

In application/controllers/welcome.php, line 12, I've loaded a model the standard CI way (http://codeigniter.com/user_guide/general/models.html#loading):

$this->load->model('Account_model', 'acct');

Then use the model:

$accounts = $this->acct->get_account_info();

The model file is located in application/models/account_model.php, and the method get_account_info returns an array.

This is a very simple setup, but the basic way things are loaded and used in CI. In NB 6.8, ctrl-clicking on get_account_info within the Welcome controller will open account_model.php and highlight the get_account_info method. In current versions, it will just move the cursor to the beginning of the Welcome controller.

This is the functionality that I loved in NB 6.8, and makes working with CI a joy. Without it, you can't easily navigate through a CI project.
Comment 21 chris4beta 2011-03-15 20:28:14 UTC
Created attachment 107028 [details]
Sample CI project setup
Comment 22 Quality Engineering 2011-03-16 09:42:23 UTC
Integrated into 'main-golden', will be available in build *201103160400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/a40f76f7d03f
User: Petr Pisl <ppisl@netbeans.org>
Log: #188107 - Links to external classes not working
Comment 23 Petr Pisl 2011-03-16 10:39:02 UTC
I will try explain in more details. The big difference between NB 6.8 and NB 7.0 is that NB 7.0 use type reference. It's trying to find out a type of a property or return type of a function / method. The features like code completion, navigation, refactoring are base on the type reference. 

In NB 6.8 there was very very simple type reference, basically only the first level call. It's mean that the code completion doesn't work correctly for second level in a call chain (if it works at all), refactoring wasn't possible and the navigation works in different way. So why it works in NB 6.8 in your example with get_account_info() ?  In NB 6.8 the navigation was looking for all method/functions of the same name in the project and if it was found, then was offered to navigate there. 

Neither NB 6.8 nor NB 7.0 don't know how the CodeInteger framework works and they don't know what is the $acct property that you refer in expression $this->acct->get_account_info(). Because NB 7.0 relay on the type reference that fails in this case (nowhere is defined acct property in a code, I expect that it's a magic property, that is created in runtime), it fails also navigation.

But there is good solution for you. It's simple, define type of the acct property. For example:

/**
 * @property Account_model $acct
 */
class Welcome extends CI_Controller {

(Probably it will be better to place the definition of the property into CI_Controller, because I think that it's propety of this class.)

and then the code completion will offer acct property after $this-> and even all public properties and methods in Account_model class after $this->acct-> . And sure the navigation will work correctly in NB 7.0 . 

Sure the navigation could be "fixed". If the type is not resolved, the return type of a method/function is not resolved through type reference, then the old approach can be used for navigation. But then the cc will not working still. 

I would prefer the new approach, to help NetBeans with the definition of $acct property of this type. Is it ok for you?
Comment 24 chris4beta 2011-03-16 18:02:57 UTC
Petr, I was unaware of the @property solution to my problem. I'd only have to add a few of those and all my quick navigation would come back... that's all I wanted.

Thank you very much for taking the time to explain the entire situation, and I understand why the internal changes were made.
Comment 25 Petr Pisl 2011-03-16 18:19:21 UTC
IMHO the CodeIgniter source code should contain the magic properties in the php doc and the magic methods as well. So the user of this framework should push CodeIgniter developers to improve the php doc. I'm not sure, but I think that there was a guy who add these information the a CodeIgniter version.

Anyway I want to add the change http://hg.netbeans.org/main/rev/a40f76f7d03f to the NB 7.0, because it improve the work with methods that have in their php doc '@return object'.
Comment 26 Vladimir Riha 2011-04-07 15:06:32 UTC
Assuming I understood this bug correctly, I can verify it.