NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Associative array key name autocomplete


Joined: 30 Jun 2009
Posts: 79
Reply with quote
How difficult would it be to do the following.

Say I'm in the middle of a debug session and there's an associative array in memory like:

Code:
$array = [
    'number' => 123,
    'string' => 'Hello'
]


Can you enable autocomplete of array's keys, so when I start typing "$array[", a popup would appear with choice of 'number' and 'string' (including single/double quotes).

That would be a big time saver. Right now there is some kind of hint showing, but it lists keys that aren't part of the array.

Thanks,
Temuri[/code]
View user's profileFind all posts by temuriSend private message


Joined: 26 Sep 2007
Posts: 25
Reply with quote
+1
View user's profileFind all posts by PureFormSend private message
Guru master

Joined: 24 Jul 2009
Posts: 737
Reply with quote
+1
View user's profileFind all posts by plugnplaySend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
you must be joking as it works fine:


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

Joined: 24 Jul 2009
Posts: 737
Reply with quote
Most of the code that I work with uses array():

Code:
<?php
  $array = array(
    'number' => 123,
    'string' => 'Hello',
  );
  $array['st']


Code completion doesn't appear to work with that Sad
View user's profileFind all posts by plugnplaySend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
It does not matter how you declare the array.
It auto-shows the dropdown right after you press ' in $array[|]
(where | denotes cursor position)
If it does not, check that "Array Indices" checkbox is turned on in Tools->Settings->CodeCompletion on PHP tab.

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

Joined: 24 Jul 2009
Posts: 737
Reply with quote
Hi Dmitri, I have that option ticked (all code completion options are ticked) and when I enter that code, when I type in [' the code completions pops up with a whole bunch of a few hundred items from the project.

I just mucked around with the parser settings and when I went back to the code to test again, got an access violation in phped.exe and I've just submitted the report for that.

Yesterday I'm sure I tried the ['number'=>123] syntax and code completion worked, then last night I went back to array() and it didn't work (shows hundreds of options). At this moment I cannot get either syntax to work. I'll upgrade to latest 9051 and see if behaviour changes.
View user's profileFind all posts by plugnplaySend private message


Joined: 30 Jun 2009
Posts: 79
Reply with quote
dmitri,

in your example you only have one file and one array. of course you're getting the right keys.

however, in real life, just as I said above "it lists keys that aren't part of the array" - and in my project that list is HUGE - a hundred of items or so. No way to find the right key - faster to type.

so to make it perfectly clear, I expect that ONLY 'number' and 'string' are shown in autocomplete popup.

Thanks
View user's profileFind all posts by temuriSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
plugnplay wrote:
the code completions pops up with a whole bunch of a few hundred items from the project


In the beginning I thoght "it does not work" means you don't get the popup at all. Now with clarifications it's clear that only "valid" for particular array indices are expected.

temuri wrote:
faster to type


Right. But with long names it's still faster to start typing then pick from the dropdown NUMBER_OF_CHILDREN_NODES.
Same goes to the other elements. I can hardly imagine you would type $a using code completion.

temuri wrote:
so to make it perfectly clear, I expect that ONLY 'number' and 'string' are shown in autocomplete popup.


I'm sorry, but it's not possible, not in current code insight scheme.
But we'll review this possibility in the future.

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

Joined: 24 Jul 2009
Posts: 737
Reply with quote
Hi Dmitri, today Sergey requested me to submit this problem as a 'problem with functionality'. Does this mean it is functioning as expected and there is no point in me submitting it as a problem?
View user's profileFind all posts by plugnplaySend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
Yes, it is functioning as expected and a post on this part of the forum is enough for us include the request to "WTR" plans. So, you don't have to submit the same in the report.

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


Joined: 30 Jun 2009
Posts: 79
Reply with quote
Sorry, what's "WTR"?

Thanks!
View user's profileFind all posts by temuriSend private message
Associative array key name autocomplete
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