NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Variable autocomplete sources entire project?


Joined: 29 Aug 2007
Posts: 39
Reply with quote
Has this behavior changed recently?

When I'm typing in a variable the autocomplete pops up, but instead of just showing variables defined in the current scope, it shows them all from the entire project (apparently).

For example, I'm editing a simple page with no includes, and I go to type in a new variable (say $test) and as I'm typing, every other variable in the site is shown, despite the fact they are not visible to (and have no relationship to) this page.

I seem to remember it working differently, where only variables defined in the current page or included files was autocompleted. Or maybe I just thought that?

Can anyone clarify this? And if this is not the current behavior, is there any possibility that it can be made this way?

Thanks
View user's profileFind all posts by StryksSend private message
Guru master

Joined: 05 Jul 2004
Posts: 659
Location: Belgium
Reply with quote
I'm thinking you imagined that. What would be the use of having autocompletion that only shows things from the current file? Start from a blank file and you have no autocompletion at all? Smile
PhpED does keep the scope of the variable in my afaik. So it will only show variables that could be reached from that place in your code. But it has always been like that iirc.

There is an option that says "Limit scope to includes" in the Code Insight > Settings entry under the Options, perhaps that is something that you had turned on before
and that got turned off again when you upgraded?
View user's profileFind all posts by BlizzSend private messageVisit poster's website


Joined: 29 Aug 2007
Posts: 39
Reply with quote
Quote:
Start from a blank file and you have no autocompletion at all?


Well ... for variables like $test that were used in a file somewhere else in the site .... yes.

At the moment, when I go to enter a variable in a blank file, I get a dropdown showing all of these. It looks like every variable that I have used *anywhere*.

I'll try setting that option and see if it brings things back in line for me, but the current behavior is a pain.

Cheers
View user's profileFind all posts by StryksSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
Well, it's a php mudule-less paradigm. It does not support scopes other than objects (and namespaces starting with forthcoming 5.3). Indeed, even if you have absolutely no includes, it does not mean that your file is not included into the other files. If it is included, it will see all the variabels of the other files and from the files being included into them. Say you have file B which is included into A and A also includes C. The fact that B is included into A is enough to have all variables from A and C accessible in B even though B has no includes at all.
It works this way because PHP does not link the modules, it just make them merged and it does this in run-time.
The problem easily gets complicated if you have auto-loaded modules (by the class name for example) and finally you may have some files names "calculated" for the include (for example "mymessages_{$LANG}.inc". As far as I know, there are no tools that may resolve the include statements with such constructs automacially.


So, there are two choises:
1) forget about visibility for the global variables and make code completion working as if they are visible from everywhere.
2) track all include statements and manually resolve all includes non-resolved by the IDE.

First way is followed by default.
To make the IDE working by the 2nd way, you have to a) turn on "Limit scope to includes" in Tools->Settings->Code Insight, settings. b) make resolved all the entries on Project properties->Includes tab.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Variable autocomplete sources entire project?
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic