Bug 204500 - PHP code completion inside strings should be more intelligent
Summary: PHP code completion inside strings should be more intelligent
Status: CONFIRMED
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: PHP (show other bugs)
Version: git master
Platform: openSUSE Linux
: LO wishlist
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-08-20 11:28 UTC by Alexander
Modified: 2009-08-20 13:20 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander 2009-08-20 11:28:59 UTC
Version:           SVN (using KDE 4.3.0)
Compiler:          gcc 4.3.2 
OS:                Linux
Installed from:    SuSE RPMs

Current implementation of PHP language support in KDevelop pops up a completion box when writing strings (inside "", '' and heredoc).

Most of the time this sort of completion is of no help, and gets in a way of writing arbitrary text in the strings (since the return key chooses the completion entry instead of printing a newline).

I can think of several exceptions to this:

* Completing inside defined("") - this may show a list of constants. Usually, the constants checked this way are not defined anyway, so the popup wouldn't really be helpful.

* Completing inside constant(""). This is usually used when the constant is not available during parse time.

* Completing function and class names when they are at the start of the string. For example,
$f="strlen"; $f("hello");
Usually, this style is used when the function in question may not exist at the time of this call (function_exists() may be used to check that), so again, completing this wouldn't be of much help.
Same thing goes for classes.

* Completing function names in call_user_func("") and friends. Again, usually not much of a help for the reasons stated above.

As you see, global symbols inside strings are usually used when the completion wouldn't be helpful anyway, so disabling it for all types of strings would be nice.


Thanks a lot,
Alex
Comment 1 Milian Wolff 2009-08-20 12:10:56 UTC
My opinion on this matter:

a) no completion in '...' strings
b) only completion of variables in "..." strings, and only do auto completion of e.g. member variables or array keys when the first var was prepended by a "{"

exception:

do only function completion inside '...' or "..." inside call_user_func, function_exists, call-back arguments etc. We should do this since our global PHP file includes pretty much all modules which might not exist at runtime, hence completion would make sense. Also with full project parsing you get all functions of your project, and the function you are looking for will exist _somewhere_ in there.

when the call-back argument is an array, first do class completion, then method completion.

Low priority though.
Comment 2 Alexander 2009-08-20 12:30:36 UTC
(In reply to comment #1)
> My opinion on this matter:
...

Sounds completely reasonable.

I guess the a) rule could be applied to heredoc, and b) could be applied to newdoc as well.

For b), the member variables are always prefixed with $this-> (AFAIK), so I guess they should be shown only for "...{$this->".

Thanks
Comment 3 Milian Wolff 2009-08-20 12:45:21 UTC
Yes, here- and nowdoc should be handled just like their quoted counterparts.

And regarding $this, what about _this_ ;-)

$a = new stdClass;
$a->b = 1;

$foo = "asdf {$a->

=> we should get completion for b ;-)
Comment 4 Alexander 2009-08-20 13:20:48 UTC
(In reply to comment #3)
> And regarding $this, what about _this_ ;-)
> 
> $a = new stdClass;
> $a->b = 1;
> 
> $foo = "asdf {$a->
> 
> => we should get completion for b ;-)

Ah yes :)

I wrongly assumed you were talking about members of the current class, so that members would pop up without $this-> (like in C++). I guess I've been writing in too many languages simultaneously. :)