This is an automated email from the ASF dual-hosted git repository.
junichi11 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 c78cd55 [NETBEANS-3413] Implicit inheritance of PHPDoc descriptions
new b8fa73e Merge pull request #2122 from KacerCZ/netbeans-3413
c78cd55 is described below
commit c78cd553fcd8246154aa8b738feaf83f7b9a6649
Author: Tomas Prochazka <[email protected]>
AuthorDate: Sat May 2 10:02:28 2020 +0200
[NETBEANS-3413] Implicit inheritance of PHPDoc descriptions
Uses description of inherited element when no PHPDoc is present.
---
.../modules/php/editor/completion/DocRenderer.java | 28 ++++++++++++++--------
.../php/editor/completion/DocRendererTest.java | 2 +-
2 files changed, 19 insertions(+), 11 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 cf576b9..5886277 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
@@ -32,6 +32,7 @@ import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.netbeans.api.annotations.common.CheckForNull;
+import org.netbeans.api.annotations.common.NullAllowed;
import org.netbeans.api.lexer.Token;
import org.netbeans.api.lexer.TokenSequence;
import org.netbeans.api.project.FileOwnerQuery;
@@ -242,9 +243,10 @@ final class DocRenderer {
private final PhpElement indexedElement;
private final List<String> links = new ArrayList<>();
private final ASTNode node;
+ @NullAllowed
private PHPDocBlock phpDocBlock;
- public PHPDocExtractor(CCDocHtmlFormatter header, PhpElement
indexedElement, ASTNode node, PHPDocBlock phpDocBlock) {
+ public PHPDocExtractor(CCDocHtmlFormatter header, PhpElement
indexedElement, ASTNode node, @NullAllowed PHPDocBlock phpDocBlock) {
this.header = header;
this.indexedElement = indexedElement;
this.node = node;
@@ -380,9 +382,6 @@ final class DocRenderer {
}
private void extractPHPDocBlock() {
- if (phpDocBlock == null) {
- return;
- }
List<PHPDocVarTypeTag> params = new ArrayList<>();
List<PHPDocTypeTag> returns = new ArrayList<>();
StringBuilder others = new StringBuilder();
@@ -391,10 +390,11 @@ final class DocRenderer {
List<PhpElement> inheritedElements = getInheritedElements();
List<PHPDocBlock> inheritedComments =
getInheritedComments(inheritedElements);
- String description = phpDocBlock.getDescription();
+ String description = phpDocBlock == null ? null :
phpDocBlock.getDescription();
description = composeDescription(description, inheritedComments);
- for (PHPDocTag tag : phpDocBlock.getTags()) {
+ List<PHPDocTag> tags = phpDocBlock == null ?
Collections.emptyList() : phpDocBlock.getTags();
+ for (PHPDocTag tag : tags) {
AnnotationParsedLine kind = tag.getKind();
if (kind.equals(PHPDocTag.Type.PARAM)) {
PHPDocVarTypeTag paramTag = (PHPDocVarTypeTag) tag;
@@ -574,7 +574,11 @@ final class DocRenderer {
return ret;
}
- private String replaceInheritdocForDescription(String description,
String parentDescription) {
+ @CheckForNull
+ private String replaceInheritdocForDescription(@NullAllowed String
description, @NullAllowed String parentDescription) {
+ if (description == null) {
+ return parentDescription;
+ }
if (description != null && hasInlineInheritdoc(description)) {
if (parentDescription != null &&
!parentDescription.trim().isEmpty()) {
if
(INLINE_INHERITDOC_PATTERN.matcher(description.trim()).matches()) {
@@ -717,7 +721,7 @@ final class DocRenderer {
private boolean needInheritedElements() {
if (phpDocBlock == null) {
- return false;
+ return true;
}
String description = phpDocBlock.getDescription();
if (hasInlineInheritdoc(description)) {
@@ -752,7 +756,7 @@ final class DocRenderer {
for (PhpElement element : elements) {
PHPDocBlock docBlock = getPhpDocBlock(element);
if (docBlock != null) {
- if (isOnlyInheritdoc(phpDocBlock)) {
+ if (phpDocBlock == null || isOnlyInheritdoc(phpDocBlock)) {
phpDocBlock = docBlock;
} else {
inheritedComments.add(docBlock);
@@ -767,7 +771,11 @@ final class DocRenderer {
&& phpDocBlock.getTags().isEmpty();
}
- static String replaceInlineInheritdoc(String description, String
inheritdoc) {
+ @CheckForNull
+ static String replaceInlineInheritdoc(@NullAllowed String description,
@NullAllowed String inheritdoc) {
+ if (description == null && inheritdoc != null) {
+ return inheritdoc;
+ }
if (description == null || inheritdoc == null) {
return description;
}
diff --git
a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/completion/DocRendererTest.java
b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/completion/DocRendererTest.java
index 8b9fe16..8b42c96 100644
---
a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/completion/DocRendererTest.java
+++
b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/completion/DocRendererTest.java
@@ -258,7 +258,7 @@ public class DocRendererTest extends PHPTestBase {
public void testReplaceInlineInheritdoc_04() {
checkReplaceInlineInheritdoc(
- null,
+ "Parent Description",
null,
"Parent Description"
);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists