NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
mark occurrences - shouldn't be too difficult to implement


Joined: 14 Apr 2007
Posts: 96
Reply with quote
One of my favorite little features is mark occurences. The way it works is that when you put your cursor on a variable, it will highlight all instances of a variable on the page. This makes it very easy to find where that variable is used.

Please?


Thank you!

-r
View user's profileFind all posts by rodericksimpsonSend private message


Joined: 08 Feb 2007
Posts: 67
Reply with quote
For my own interest, consider the following code:

Code:
1  $var = 1;
2  $anothervar = &$var;
3  $yetanother = $var;
4  $one_more = 'test';
5
6  print $var;
7  print $anothervar;
8  print $yetanother;
9  print $one_more


If you do 'mark occurences' on "$var", what would be marked? Only the text "$var"? Would "$anothervar" be marked as well 'cause it's a reference?
View user's profileFind all posts by nothsaSend private message


Joined: 14 Apr 2007
Posts: 96
Reply with quote
The way that I would like it to work is that only $var would be marked. The idea is that it makes it easy to see where variables are used on the page.
I find it to be very useful, and I use it every day - since there is no code folding or editing of .js files, please please - code folding and code explorer for .js files Smile.



-r
View user's profileFind all posts by rodericksimpsonSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
what's about code below?

Code:
class a {
  var $var;
}
$a = new a();
${'a'}->var=55;


I'm just curious if it will work for $a and $var and how many occurences it will find.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 14 Apr 2007
Posts: 96
Reply with quote
It should only find the exact match for $a. And in this example it wouldn't do anything since there is only one variable. If there was more than one it would mark them.

In this example:

class a {
var $var;
}
$a = new a(); <---------------------------- put your cursor on the $a here and this one would be marked
${'a'}->var=55;
$a = $b; <------------------------------------ and this one would be marked as well

This isn't supposed to deal with runtime references, or anything complicated. It is only meant to make it easy to find where a particular variable is used on a page. For performance reasons, it could even be limited to local scope if that would help. Or, it might only show up to x number of occurances. I would prefer everything on the page, but that could get out of hand if it was a big file.

My hope was to keep it simple so the feature can be implemented easily.

Thank you,

-r
View user's profileFind all posts by rodericksimpsonSend private message


Joined: 13 Nov 2008
Posts: 17
Reply with quote
I'm surprised PHPEd doesn't have this yet. I'd like to revive this thread.
View user's profileFind all posts by Archon810Send private messageVisit poster's website
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
Seems you did not get the idea. In php you don't need to write $var to access its content and there are some php frameworks that heavily use this "feature". If you try to replace all occurences of $var with another name, you'll break the code completely.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 13 Nov 2008
Posts: 17
Reply with quote
dmitri, I understand the idea but not having this feature is worse than having it and relying on it to match 100% of the time. I'd be quite happy if it highlighted just the exact matches for starters.
View user's profileFind all posts by Archon810Send private messageVisit poster's website
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
My opinion is the opposit. Having a feature that may destroy the sources is much worse than non-having it at all.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 13 Nov 2008
Posts: 17
Reply with quote
I don't see why it has to destroy anything. It's a very helpful feature to see where the variable your cursor is on is used in the code around, and I'm not the only one to think that, as you can see.

If we go by your logic, then you might as well disable the search/replace feature because someone might replace $var with $var2 and it'll break the sources. Please understand what we are asking before refusing it so adamantly, especially to paying users.

Thanks.
View user's profileFind all posts by Archon810Send private messageVisit poster's website


Joined: 14 Apr 2007
Posts: 96
Reply with quote
I agree with Archon810. The idea is not whether it will or will not find all actual references to the variable in question. It is simply a tool for locating a variable with the same spelling on the page. Sure, you can search for it, but this is only meant to be a quick way to identify where else the variable is being used.

It is similar to the search and replace function of the editor. It is just matching syntax, and not trying to chase down assignments or references. Kind of like a non-destructive, visual search and replace.

Rod
View user's profileFind all posts by rodericksimpsonSend private message


Joined: 13 Nov 2008
Posts: 17
Reply with quote
dmitri, can you give this another thought please? Please look at the way Eclipse is doing it - it's pretty much perfect - they even do name refactoring by selecting the whole name and then pressing alt-shift-r I think - then when you write the new variable name, all instances change. I know it's easier in Java due to type strictness but it's still definitely possible in PHP.
View user's profileFind all posts by Archon810Send private messageVisit poster's website
mark occurrences - shouldn't be too difficult to implement
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 2  

  
  
 Reply to topic