diff --git a/ide/csl.api/nbproject/project.properties b/ide/csl.api/nbproject/project.properties index 217459ef0edf..b25098a738ac 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 2c97bab489d7..6f5ab184b6be 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 boolean isCaseSensitive() { } 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 a5f392a9b598..f1eae35b5d44 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 e5d659e31abd..f18d0044a292 100644 --- a/php/php.editor/nbproject/project.xml +++ b/php/php.editor/nbproject/project.xml @@ -84,7 +84,7 @@ 2 - 2.72 + 2.78 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 d01a10709cac..a9a77c3604f1 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 CodeCompletionResult complete(CodeCompletionContext completionContext) { 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 000000000000..f4e1c7f0916a --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH4494.php @@ -0,0 +1,53 @@ + +
Code completion result for source line:
+gh44|94_aa_bbb();
+(QueryType=DOCUMENTATION, prefixSearch=false, caseSensitive=true)
+METHOD     gh4494_aa_bbb()                 [PUBLIC]   issueGH4494.php
+

Documentation:

gh4494_aa_bbb

+function gh4494_aa_bb(). +
+

Returns:

+ +
Type:void
\ 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 000000000000..74e6c82bfd1a --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH4494.php.testIssueGH4494_02.html @@ -0,0 +1,11 @@ + +
Code completion result for source line:
+gh4494_aa|_bbb();
+(QueryType=DOCUMENTATION, prefixSearch=false, caseSensitive=true)
+METHOD     gh4494_aa_bbb()                 [PUBLIC]   issueGH4494.php
+

Documentation:

gh4494_aa_bbb

+function gh4494_aa_bb(). +
+

Returns:

+ +
Type:void
\ 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 000000000000..aa5ad8cfde42 --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH4494.php.testIssueGH4494_03.html @@ -0,0 +1,11 @@ + +
Code completion result for source line:
+gh4494_aa_b|bb();
+(QueryType=DOCUMENTATION, prefixSearch=false, caseSensitive=true)
+METHOD     gh4494_aa_bbb()                 [PUBLIC]   issueGH4494.php
+

Documentation:

gh4494_aa_bbb

+function gh4494_aa_bb(). +
+

Returns:

+ +
Type:void
\ 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 000000000000..d63442af7346 --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH4494.php.testIssueGH4494_04.html @@ -0,0 +1,11 @@ + +
Code completion result for source line:
+gh4494|_aa_bb_cc();
+(QueryType=DOCUMENTATION, prefixSearch=false, caseSensitive=true)
+METHOD     gh4494_aa_bb_cc()               [PUBLIC]   issueGH4494.php
+

Documentation:

gh4494_aa_bb_cc

+function gh4494_aa_bb_cc(). +
+

Returns:

+ +
Type:void
\ 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 000000000000..21fe2ae4ffd8 --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH4494.php.testIssueGH4494_05.html @@ -0,0 +1,11 @@ + +
Code completion result for source line:
+gh4494_aa|_bb_cc();
+(QueryType=DOCUMENTATION, prefixSearch=false, caseSensitive=true)
+METHOD     gh4494_aa_bb_cc()               [PUBLIC]   issueGH4494.php
+

Documentation:

gh4494_aa_bb_cc

+function gh4494_aa_bb_cc(). +
+

Returns:

+ +
Type:void
\ 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 000000000000..0a6703c55200 --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH4494.php.testIssueGH4494_06.html @@ -0,0 +1,11 @@ + +
Code completion result for source line:
+gh4494_aa_bb|_cc();
+(QueryType=DOCUMENTATION, prefixSearch=false, caseSensitive=true)
+METHOD     gh4494_aa_bb_cc()               [PUBLIC]   issueGH4494.php
+

Documentation:

gh4494_aa_bb_cc

+function gh4494_aa_bb_cc(). +
+

Returns:

+ +
Type:void
\ 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 000000000000..520b02d69113 --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH4494.php.testIssueGH4494_07.html @@ -0,0 +1,11 @@ + +
Code completion result for source line:
+gh4494_aa_bb_cc|();
+(QueryType=DOCUMENTATION, prefixSearch=false, caseSensitive=true)
+METHOD     gh4494_aa_bb_cc()               [PUBLIC]   issueGH4494.php
+

Documentation:

gh4494_aa_bb_cc

+function gh4494_aa_bb_cc(). +
+

Returns:

+ +
Type:void
\ 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 0bc08f6f6eaf..ab6a8b9bfa10 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.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 void testIssueGH5426_02() throws Exception { 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 void checkCompletionDocumentation(final String file, final String caretLi } } + private void checkCompletionOnlyDocumentation(String filePath, String caretLine) throws Exception { + checkCompletionDocumentation(filePath, caretLine, false, "", QueryType.DOCUMENTATION); + } + @Override protected Map createClassPathsForTest() { return Collections.singletonMap(