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 fe99e893ce [GH-5427] PHP: Fix for displaying property type in documentation if @var tag is not specified in phpDoc new 5c04b3a2e9 Merge pull request #5443 from troizet/fix_gh_5427 fe99e893ce is described below commit fe99e893cedef9f26aacf991ffcc6981addae090 Author: Alexey Borokhvostov <troi...@gmail.com> AuthorDate: Mon Feb 6 22:36:41 2023 +0700 [GH-5427] PHP: Fix for displaying property type in documentation if @var tag is not specified in phpDoc --- .../modules/php/editor/completion/DocRenderer.java | 18 +++++++++++++-- .../completion/documentation/issueGH5427.php | 27 ++++++++++++++++++++++ .../issueGH5427.php.testIssueGH5427_01.html | 9 ++++++++ .../issueGH5427.php.testIssueGH5427_02.html | 11 +++++++++ .../issueGH5427.php.testIssueGH5427_03.html | 10 ++++++++ .../editor/completion/PHPCCDocumentationTest.java | 12 ++++++++++ 6 files changed, 85 insertions(+), 2 deletions(-) diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/completion/DocRenderer.java b/php/php.editor/src/org/netbeans/modules/php/editor/completion/DocRenderer.java index d2df49d392..e2fb4642d3 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/completion/DocRenderer.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/completion/DocRenderer.java @@ -439,8 +439,8 @@ final class DocRenderer { } } - // field without phpdoc - if (phpDocBlock == null + // field without phpdoc or with but without @var tag + if ((phpDocBlock == null || !tagInTagsList(tags, PHPDocTag.Type.VAR)) && indexedElement instanceof FieldElement) { FieldElement fieldElement = (FieldElement) indexedElement; Set<TypeResolver> types = fieldElement.getInstanceTypes(); @@ -454,6 +454,20 @@ final class DocRenderer { others.toString())); } + private boolean tagInTagsList(List<PHPDocTag> tags, AnnotationParsedLine tagKind) { + boolean hasVarTag = false; + + for (PHPDocTag tag : tags) { + AnnotationParsedLine kind = tag.getKind(); + if (kind.equals(tagKind)) { + hasVarTag = true; + break; + } + } + + return hasVarTag; + } + protected String processDescription(String text) { StringBuilder result = new StringBuilder(); int lastIndex = 0; diff --git a/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH5427.php b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH5427.php new file mode 100644 index 0000000000..a2a37fd04b --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH5427.php @@ -0,0 +1,27 @@ +<?php + +class ClassName { + + //The type should be displayed here. + public string $test_without_doc; + + /** + * The type should be displayed here.. + */ + public string $test_without_var_tag; + + /** + * The type should be displayed here. + * @var string + */ + public string $test_with_var_tag; + + public function test() { + $this->test_without_doc; + $this->test_without_var_tag; + $this->test_with_var_tag; + } + +} + +?> \ No newline at end of file diff --git a/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH5427.php.testIssueGH5427_01.html b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH5427.php.testIssueGH5427_01.html new file mode 100644 index 0000000000..d510150283 --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH5427.php.testIssueGH5427_01.html @@ -0,0 +1,9 @@ +<html><body> +<pre>Code completion result for source line: +$this->test_without_d|oc; +(QueryType=COMPLETION, prefixSearch=false, caseSensitive=true) +VARIABLE string test_without_doc [PUBLIC] ClassName +</pre><h2>Documentation:</h2><div align="right"><font size=-1></font></div><b>$test_without_doc</b><br/><br/><br /> +<table> +<tr><th align="left">Type:</th><td>string</td></tr></table> +</body></html> \ No newline at end of file diff --git a/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH5427.php.testIssueGH5427_02.html b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH5427.php.testIssueGH5427_02.html new file mode 100644 index 0000000000..13f94ecd01 --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH5427.php.testIssueGH5427_02.html @@ -0,0 +1,11 @@ +<html><body> +<pre>Code completion result for source line: +$this->test_without_v|ar_tag; +(QueryType=COMPLETION, prefixSearch=false, caseSensitive=true) +VARIABLE string test_without_var_tag [PUBLIC] ClassName +</pre><h2>Documentation:</h2><div align="right"><font size=-1></font></div><b>$test_without_var_tag</b><br/><br/> +The type should be displayed here.. +<br /> +<table> +<tr><th align="left">Type:</th><td>string</td></tr></table> +</body></html> \ No newline at end of file diff --git a/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH5427.php.testIssueGH5427_03.html b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH5427.php.testIssueGH5427_03.html new file mode 100644 index 0000000000..7fc5654029 --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH5427.php.testIssueGH5427_03.html @@ -0,0 +1,10 @@ +<html><body> +<pre>Code completion result for source line: +$this->test_with_v|ar_tag; +(QueryType=COMPLETION, prefixSearch=false, caseSensitive=true) +VARIABLE string test_with_var_tag [PUBLIC] ClassName +</pre><h2>Documentation:</h2><div align="right"><font size=-1></font></div><b>$test_with_var_tag</b><br/><br/> +The type should be displayed here.<br /> +<table> +<tr><th align="left">Type:</th><td>string</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 8f4d2cda70..2d7675ada1 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 @@ -262,6 +262,18 @@ public class PHPCCDocumentationTest extends PHPCodeCompletionTestBase { public void testFunctionIntersectionTypeWithoutPhpDoc() throws Exception { checkCompletionDocumentation("testfiles/completion/documentation/functionWithoutPhpDoc.php", "testIntersectionTy^pe(null, null); // function", false, ""); } + + public void testIssueGH5427_01() throws Exception { + checkCompletionDocumentation("testfiles/completion/documentation/issueGH5427.php", "$this->test_without_d^oc", false, ""); + } + + public void testIssueGH5427_02() throws Exception { + checkCompletionDocumentation("testfiles/completion/documentation/issueGH5427.php", "$this->test_without_v^ar_tag", false, ""); + } + + public void testIssueGH5427_03() throws Exception { + checkCompletionDocumentation("testfiles/completion/documentation/issueGH5427.php", "$this->test_with_v^ar_tag", false, ""); + } @Override protected String alterDocumentationForTest(String documentation) { --------------------------------------------------------------------- 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