netbeans
netbeans copied to clipboard
PHP: Show documentation (ctrl+shift+space) displays incorrect documentation
Apache NetBeans version
Apache NetBeans 14
What happened
It looks like the documentation search for the display is not done by the full word, but by a few characters before the caret. Also the search is done for partial matches.
How to reproduce
https://user-images.githubusercontent.com/9607501/183941045-64279a04-e90e-4932-8c93-deacc94df6ec.mp4
Did this work correctly in an earlier version?
No / Don't know
Operating System
Ubuntu 20.04.4 LTS
JDK
OpenJDK 64-Bit Server VM 11.0.16+8-post-Ubuntu-0ubuntu120.04
Apache NetBeans packaging
Apache NetBeans provided installer
Anything else
Same behaviour on Apache NetBeans 15 release candidate 3.
Are you willing to submit a pull request?
No
Code of Conduct
Yes
Could you please provide an example code to reproduce it?
You can check on the example of the standard function is_numeric()
:
- Write
is_numeric()
- Set a caret between
is_nu
andmeric()
- Click Source -> Show documentation
- The documentation for
is_null()
will be displayed - Set the caret between
is_num
anderic()
- Click Source -> Show documentation.
- The documentation for
is_numeric()
will be displayed
I can't reproduce it...
My environment:
Product Version: Apache NetBeans IDE 15
Java: 11.0.16; OpenJDK 64-Bit Server VM 11.0.16+8-post-Ubuntu-0ubuntu120.04
Runtime: OpenJDK Runtime Environment 11.0.16+8-post-Ubuntu-0ubuntu120.04
System: Linux version 5.15.0-48-generic running on amd64; UTF-8;
I have checked on two environments on NetBeans versions starting from 12.6, the same behavior everywhere.
Product Version: Apache NetBeans IDE 15
Java: 11.0.16; OpenJDK 64-Bit Server VM 11.0.16+8-post-Ubuntu-0ubuntu120.04
Runtime: OpenJDK Runtime Environment 11.0.16+8-post-Ubuntu-0ubuntu120.04
System: Linux version 5.15.0-50-generic running on amd64; UTF-8; ru_RU (nb)
Product Version: Apache NetBeans IDE 15
Java: 11.0.16; OpenJDK 64-Bit Server VM 11.0.16+8-post-Debian-1deb10u1
Runtime: OpenJDK Runtime Environment 11.0.16+8-post-Debian-1deb10u1
System: Linux version 4.19.0-22-amd64 running on amd64; UTF-8; en_US (nb)
I tried to understand the code. The code that runs to display the documentation https://github.com/apache/netbeans/blob/f369361d1e92f2e04ab2add4bae52147a0acde51/ide/csl.api/src/org/netbeans/modules/csl/editor/completion/GsfCompletionProvider.java#L526-L573
Here we get the ElementHandle for which we want to display the documentation https://github.com/apache/netbeans/blob/f369361d1e92f2e04ab2add4bae52147a0acde51/ide/csl.api/src/org/netbeans/modules/csl/editor/completion/GsfCompletionProvider.java#L547
Judging by the code, PHPCodeCompletion
https://github.com/apache/netbeans/blob/f369361d1e92f2e04ab2add4bae52147a0acde51/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletion.java#L131
doesn't use prefix
, prefixMatch
and queryType.DOCUMENTATION
parameters passed to CodeCompletionContext.
And, in the is_numeric
example, where caret is set between is_nu
and meric()
, instead of using prefix = is_numeric
, prefix = is_nu
is used.
Therefore, instead of a specific ElementHandle for is_numeric
, PHPCodeCompletion returns a list of suggested ElementHandles for is_nu
.
In this case, is_null
and is_numeric
, where is_null
is first in the list, for which the documentation is displayed
It looks like we need to modify PHPCodeCompletion so that it uses the prefix
, prefixMatch
and queryType.DOCUMENTATION
parameters passed to CodeCompletionContext.
I see the same behaviour as @troizet. However, I regard this as a desirable UI behaviour. It allows the user a lot of flexibility. The displayed list is responsive to user input and allows users to obtain the correct function name simply by typing a few letters, then selecting from the list. It is an excellent didactic tool. It increases my knowledge and understanding of the language. I don't want this feature to change.
I can reproduce it with an example of the PR. Thanks.