This is an automated email from the ASF dual-hosted git repository. tmysik pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push: new f25bbd17d8 Fix being shown incorrect documentation #4494 new bceb81b737 Merge pull request #5701 from junichi11/php-gh-4494-show-documentation f25bbd17d8 is described below commit f25bbd17d82d862e70a3bd42dd52d9c4e1f5a886 Author: Junichi Yamamoto <junich...@apache.org> AuthorDate: Thu Mar 23 01:55:08 2023 +0900 Fix being shown incorrect documentation #4494 - https://github.com/apache/netbeans/issues/4494 - Add a new test method for checking documentation when a `QueryType` is `DOCUMENTATION` to `CslTestBase` - If `QueryType` is `DOCUMENTATION`, get a whole identifier as a prefix - Add unit tests - Increase spec versions --- ide/csl.api/nbproject/project.properties | 2 +- .../netbeans/modules/csl/api/test/CslTestBase.java | 6 ++- php/php.editor/nbproject/project.properties | 2 +- php/php.editor/nbproject/project.xml | 2 +- .../php/editor/completion/PHPCodeCompletion.java | 8 +++- .../completion/documentation/issueGH4494.php | 53 ++++++++++++++++++++++ .../issueGH4494.php.testIssueGH4494_01.html | 11 +++++ .../issueGH4494.php.testIssueGH4494_02.html | 11 +++++ .../issueGH4494.php.testIssueGH4494_03.html | 11 +++++ .../issueGH4494.php.testIssueGH4494_04.html | 11 +++++ .../issueGH4494.php.testIssueGH4494_05.html | 11 +++++ .../issueGH4494.php.testIssueGH4494_06.html | 11 +++++ .../issueGH4494.php.testIssueGH4494_07.html | 11 +++++ .../editor/completion/PHPCCDocumentationTest.java | 33 ++++++++++++++ 14 files changed, 178 insertions(+), 5 deletions(-) diff --git a/ide/csl.api/nbproject/project.properties b/ide/csl.api/nbproject/project.properties index 217459ef0e..b25098a738 100644 --- a/ide/csl.api/nbproject/project.properties +++ b/ide/csl.api/nbproject/project.properties @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -spec.version.base=2.77.0 +spec.version.base=2.78.0 is.autoload=true javac.source=1.8 diff --git a/ide/csl.api/test/unit/src/org/netbeans/modules/csl/api/test/CslTestBase.java b/ide/csl.api/test/unit/src/org/netbeans/modules/csl/api/test/CslTestBase.java index 2c97bab489..6f5ab184b6 100644 --- a/ide/csl.api/test/unit/src/org/netbeans/modules/csl/api/test/CslTestBase.java +++ b/ide/csl.api/test/unit/src/org/netbeans/modules/csl/api/test/CslTestBase.java @@ -3062,8 +3062,12 @@ public abstract class CslTestBase extends NbTestCase { } public void checkCompletionDocumentation(final String file, final String caretLine, final boolean includeModifiers, final String itemPrefix) throws Exception { + checkCompletionDocumentation(file, caretLine, includeModifiers, itemPrefix, QueryType.COMPLETION); + } + + public void checkCompletionDocumentation(final String file, final String caretLine, final boolean includeModifiers, final String itemPrefix, QueryType queryType) throws Exception { // TODO call TestCompilationInfo.setCaretOffset! - final QueryType type = QueryType.COMPLETION; + final QueryType type = queryType; final boolean caseSensitive = true; Source testSource = getTestSource(getTestFile(file)); diff --git a/php/php.editor/nbproject/project.properties b/php/php.editor/nbproject/project.properties index a5f392a9b5..f1eae35b5d 100644 --- a/php/php.editor/nbproject/project.properties +++ b/php/php.editor/nbproject/project.properties @@ -18,7 +18,7 @@ javac.source=1.8 javac.compilerargs=-Xlint -Xlint:-serial nbjavac.ignore.missing.enclosing=**/CUP$ASTPHP5Parser$actions.class nbm.needs.restart=true -spec.version.base=2.23.0 +spec.version.base=2.24.0 release.external/predefined_vars-1.0.zip=docs/predefined_vars.zip sigtest.gen.fail.on.error=false diff --git a/php/php.editor/nbproject/project.xml b/php/php.editor/nbproject/project.xml index e5d659e31a..f18d0044a2 100644 --- a/php/php.editor/nbproject/project.xml +++ b/php/php.editor/nbproject/project.xml @@ -84,7 +84,7 @@ <compile-dependency/> <run-dependency> <release-version>2</release-version> - <specification-version>2.72</specification-version> + <specification-version>2.78</specification-version> </run-dependency> </dependency> <dependency> diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletion.java b/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletion.java index d01a10709c..a9a77c3604 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletion.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletion.java @@ -330,7 +330,13 @@ public class PHPCodeCompletion implements CodeCompletionHandler2 { PHPCompletionItem.CompletionRequest request = new PHPCompletionItem.CompletionRequest(); request.context = context; - String prefix = getPrefix(info, caretOffset, true, PrefixBreaker.WITH_NS_PARTS); + QueryType queryType = completionContext.getQueryType(); + String prefix; + if (queryType == QueryType.DOCUMENTATION) { // GH-4494 + prefix = getPrefix(info, caretOffset, false, PrefixBreaker.WITH_NS_PARTS); + } else { + prefix = getPrefix(info, caretOffset, true, PrefixBreaker.WITH_NS_PARTS); + } if (prefix == null) { return CodeCompletionResult.NONE; } diff --git a/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH4494.php b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH4494.php new file mode 100644 index 0000000000..f4e1c7f091 --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH4494.php @@ -0,0 +1,53 @@ +<?php +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/** + * function gh4494(). + * + * @return void + */ +function gh4494(): void { +} + +/** + * function gh4494_aa(). + * + * @return void + */ +function gh4494_aa(): void { +} + +/** + * function gh4494_aa_bb(). + * + * @return void + */ +function gh4494_aa_bbb(): void { +} + +/** + * function gh4494_aa_bb_cc(). + * + * @return void + */ +function gh4494_aa_bb_cc(): void { +} + +gh4494_aa_bb_cc(); +gh4494_aa_bbb(); diff --git a/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH4494.php.testIssueGH4494_01.html b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH4494.php.testIssueGH4494_01.html new file mode 100644 index 0000000000..daeaf4409d --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH4494.php.testIssueGH4494_01.html @@ -0,0 +1,11 @@ +<html><body> +<pre>Code completion result for source line: +gh44|94_aa_bbb(); +(QueryType=DOCUMENTATION, prefixSearch=false, caseSensitive=true) +METHOD gh4494_aa_bbb() [PUBLIC] issueGH4494.php +</pre><h2>Documentation:</h2><div align="right"><font size=-1></font></div><b>gh4494_aa_bbb</b><br/><br/> +function gh4494_aa_bb(). +<br /> +<h3>Returns:</h3> +<table> +<tr><th align="left">Type:</th><td>void</td></tr></table></body></html> \ No newline at end of file diff --git a/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH4494.php.testIssueGH4494_02.html b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH4494.php.testIssueGH4494_02.html new file mode 100644 index 0000000000..74e6c82bfd --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH4494.php.testIssueGH4494_02.html @@ -0,0 +1,11 @@ +<html><body> +<pre>Code completion result for source line: +gh4494_aa|_bbb(); +(QueryType=DOCUMENTATION, prefixSearch=false, caseSensitive=true) +METHOD gh4494_aa_bbb() [PUBLIC] issueGH4494.php +</pre><h2>Documentation:</h2><div align="right"><font size=-1></font></div><b>gh4494_aa_bbb</b><br/><br/> +function gh4494_aa_bb(). +<br /> +<h3>Returns:</h3> +<table> +<tr><th align="left">Type:</th><td>void</td></tr></table></body></html> \ No newline at end of file diff --git a/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH4494.php.testIssueGH4494_03.html b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH4494.php.testIssueGH4494_03.html new file mode 100644 index 0000000000..aa5ad8cfde --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH4494.php.testIssueGH4494_03.html @@ -0,0 +1,11 @@ +<html><body> +<pre>Code completion result for source line: +gh4494_aa_b|bb(); +(QueryType=DOCUMENTATION, prefixSearch=false, caseSensitive=true) +METHOD gh4494_aa_bbb() [PUBLIC] issueGH4494.php +</pre><h2>Documentation:</h2><div align="right"><font size=-1></font></div><b>gh4494_aa_bbb</b><br/><br/> +function gh4494_aa_bb(). +<br /> +<h3>Returns:</h3> +<table> +<tr><th align="left">Type:</th><td>void</td></tr></table></body></html> \ No newline at end of file diff --git a/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH4494.php.testIssueGH4494_04.html b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH4494.php.testIssueGH4494_04.html new file mode 100644 index 0000000000..d63442af73 --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH4494.php.testIssueGH4494_04.html @@ -0,0 +1,11 @@ +<html><body> +<pre>Code completion result for source line: +gh4494|_aa_bb_cc(); +(QueryType=DOCUMENTATION, prefixSearch=false, caseSensitive=true) +METHOD gh4494_aa_bb_cc() [PUBLIC] issueGH4494.php +</pre><h2>Documentation:</h2><div align="right"><font size=-1></font></div><b>gh4494_aa_bb_cc</b><br/><br/> +function gh4494_aa_bb_cc(). +<br /> +<h3>Returns:</h3> +<table> +<tr><th align="left">Type:</th><td>void</td></tr></table></body></html> \ No newline at end of file diff --git a/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH4494.php.testIssueGH4494_05.html b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH4494.php.testIssueGH4494_05.html new file mode 100644 index 0000000000..21fe2ae4ff --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH4494.php.testIssueGH4494_05.html @@ -0,0 +1,11 @@ +<html><body> +<pre>Code completion result for source line: +gh4494_aa|_bb_cc(); +(QueryType=DOCUMENTATION, prefixSearch=false, caseSensitive=true) +METHOD gh4494_aa_bb_cc() [PUBLIC] issueGH4494.php +</pre><h2>Documentation:</h2><div align="right"><font size=-1></font></div><b>gh4494_aa_bb_cc</b><br/><br/> +function gh4494_aa_bb_cc(). +<br /> +<h3>Returns:</h3> +<table> +<tr><th align="left">Type:</th><td>void</td></tr></table></body></html> \ No newline at end of file diff --git a/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH4494.php.testIssueGH4494_06.html b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH4494.php.testIssueGH4494_06.html new file mode 100644 index 0000000000..0a6703c552 --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH4494.php.testIssueGH4494_06.html @@ -0,0 +1,11 @@ +<html><body> +<pre>Code completion result for source line: +gh4494_aa_bb|_cc(); +(QueryType=DOCUMENTATION, prefixSearch=false, caseSensitive=true) +METHOD gh4494_aa_bb_cc() [PUBLIC] issueGH4494.php +</pre><h2>Documentation:</h2><div align="right"><font size=-1></font></div><b>gh4494_aa_bb_cc</b><br/><br/> +function gh4494_aa_bb_cc(). +<br /> +<h3>Returns:</h3> +<table> +<tr><th align="left">Type:</th><td>void</td></tr></table></body></html> \ No newline at end of file diff --git a/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH4494.php.testIssueGH4494_07.html b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH4494.php.testIssueGH4494_07.html new file mode 100644 index 0000000000..520b02d691 --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH4494.php.testIssueGH4494_07.html @@ -0,0 +1,11 @@ +<html><body> +<pre>Code completion result for source line: +gh4494_aa_bb_cc|(); +(QueryType=DOCUMENTATION, prefixSearch=false, caseSensitive=true) +METHOD gh4494_aa_bb_cc() [PUBLIC] issueGH4494.php +</pre><h2>Documentation:</h2><div align="right"><font size=-1></font></div><b>gh4494_aa_bb_cc</b><br/><br/> +function gh4494_aa_bb_cc(). +<br /> +<h3>Returns:</h3> +<table> +<tr><th align="left">Type:</th><td>void</td></tr></table></body></html> \ No newline at end of file diff --git a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/completion/PHPCCDocumentationTest.java b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/completion/PHPCCDocumentationTest.java index 0bc08f6f6e..ab6a8b9bfa 100644 --- a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/completion/PHPCCDocumentationTest.java +++ b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/completion/PHPCCDocumentationTest.java @@ -23,6 +23,7 @@ import java.io.File; import java.util.Collections; import java.util.Map; import org.netbeans.api.java.classpath.ClassPath; +import org.netbeans.modules.csl.api.CodeCompletionHandler.QueryType; import org.netbeans.modules.php.project.api.PhpSourcePath; import org.netbeans.spi.java.classpath.support.ClassPathSupport; import org.openide.filesystems.FileObject; @@ -291,6 +292,34 @@ public class PHPCCDocumentationTest extends PHPCodeCompletionTestBase { checkCompletionDocumentation("testfiles/completion/documentation/issueGH5426.php", " $this->testMetho^d(null);", false, ""); } + public void testIssueGH4494_01() throws Exception { + checkCompletionOnlyDocumentation("testfiles/completion/documentation/issueGH4494.php", "gh44^94_aa_bbb();"); + } + + public void testIssueGH4494_02() throws Exception { + checkCompletionOnlyDocumentation("testfiles/completion/documentation/issueGH4494.php", "gh4494_aa^_bbb();"); + } + + public void testIssueGH4494_03() throws Exception { + checkCompletionOnlyDocumentation("testfiles/completion/documentation/issueGH4494.php", "gh4494_aa_b^bb();"); + } + + public void testIssueGH4494_04() throws Exception { + checkCompletionOnlyDocumentation("testfiles/completion/documentation/issueGH4494.php", "gh4494^_aa_bb_cc();"); + } + + public void testIssueGH4494_05() throws Exception { + checkCompletionOnlyDocumentation("testfiles/completion/documentation/issueGH4494.php", "gh4494_aa^_bb_cc();"); + } + + public void testIssueGH4494_06() throws Exception { + checkCompletionOnlyDocumentation("testfiles/completion/documentation/issueGH4494.php", "gh4494_aa_bb^_cc();"); + } + + public void testIssueGH4494_07() throws Exception { + checkCompletionOnlyDocumentation("testfiles/completion/documentation/issueGH4494.php", "gh4494_aa_bb_cc^();"); + } + @Override protected String alterDocumentationForTest(String documentation) { int start = documentation.indexOf("file:"); @@ -316,6 +345,10 @@ public class PHPCCDocumentationTest extends PHPCodeCompletionTestBase { } } + private void checkCompletionOnlyDocumentation(String filePath, String caretLine) throws Exception { + checkCompletionDocumentation(filePath, caretLine, false, "", QueryType.DOCUMENTATION); + } + @Override protected Map<String, ClassPath> createClassPathsForTest() { return Collections.singletonMap( --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org For additional commands, e-mail: commits-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists