netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

PHP: Show documentation (ctrl+shift+space) displays incorrect documentation

Open troizet opened this issue 2 years ago • 5 comments

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

troizet avatar Aug 10 '22 15:08 troizet

Could you please provide an example code to reproduce it?

junichi11 avatar Oct 03 '22 05:10 junichi11

You can check on the example of the standard function is_numeric():

  1. Write is_numeric()
  2. Set a caret between is_nu and meric()
  3. Click Source -> Show documentation
  4. The documentation for is_null() will be displayed
  5. Set the caret between is_num and eric()
  6. Click Source -> Show documentation.
  7. The documentation for is_numeric() will be displayed

troizet avatar Oct 03 '22 16:10 troizet

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;

nb-gh-4494

junichi11 avatar Oct 06 '22 22:10 junichi11

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)

troizet avatar Oct 12 '22 05:10 troizet

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.

troizet avatar Oct 12 '22 05:10 troizet

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.

fyodorovich avatar Dec 01 '22 08:12 fyodorovich

I can reproduce it with an example of the PR. Thanks.

junichi11 avatar Mar 23 '23 06:03 junichi11