You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by sk...@apache.org on 2020/04/30 15:37:11 UTC
[netbeans] branch master updated: [NETBEANS-4070] fixed JavaDoc in
tooltip (ctrl+mouse hover) duplicates the description of parameters of a
method when the method overrides the parent method
This is an automated email from the ASF dual-hosted git repository.
skygo 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 ed9016b [NETBEANS-4070] fixed JavaDoc in tooltip (ctrl+mouse hover) duplicates the description of parameters of a method when the method overrides the parent method
new aca67e6 Merge pull request #2047 from dmochalov/fix-java-doc-inherited
ed9016b is described below
commit ed9016bce009694186280f5421324fd4b0f979f3
Author: Dmitry Mochalov <ri...@gmail.com>
AuthorDate: Thu Mar 26 12:05:32 2020 +0300
[NETBEANS-4070] fixed JavaDoc in tooltip (ctrl+mouse hover) duplicates the description of parameters of a method when the method overrides the parent method
---
.../api/java/source/ui/ElementJavadoc.java | 54 ++++++++++++----------
1 file changed, 30 insertions(+), 24 deletions(-)
diff --git a/java/java.sourceui/src/org/netbeans/api/java/source/ui/ElementJavadoc.java b/java/java.sourceui/src/org/netbeans/api/java/source/ui/ElementJavadoc.java
index 109d4cd..9d06ecd 100644
--- a/java/java.sourceui/src/org/netbeans/api/java/source/ui/ElementJavadoc.java
+++ b/java/java.sourceui/src/org/netbeans/api/java/source/ui/ElementJavadoc.java
@@ -1020,35 +1020,41 @@ public class ElementJavadoc {
}
break;
}
- if (element.getKind() == ElementKind.METHOD) {
- if (!ret.containsKey(DocTree.Kind.RETURN)) {
+ }
+
+ if (element.getKind() == ElementKind.METHOD) {
+ if (!ret.containsKey(DocTree.Kind.RETURN)) {
+ //If the method does not have a return javadoc then we need to get javadoc from parent.
+ if (inheritedDoc == null && !inheritedDocNeeded.getAndSet(true)) {
+ inheritedDoc = getInherited((ExecutableElement)element, (TypeElement)element.getEnclosingElement(), info, funct);
+ }
+ if (inheritedDoc != null && inheritedDoc.containsKey(DocTree.Kind.RETURN)) {
+ ret.put(DocTree.Kind.RETURN, new StringBuilder(inheritedDoc.get(DocTree.Kind.RETURN)));
+ }
+ }
+ for (int i = 0; i < ((ExecutableElement)element).getParameters().size(); i++) {
+ //Check every parameters in the method. If the current parameter has javadoc we do nothing.
+ //If the current parameter does not have javadoc we try to get javadoc from the parent.
+ if (!ret.containsKey(i)) {
if (inheritedDoc == null && !inheritedDocNeeded.getAndSet(true)) {
inheritedDoc = getInherited((ExecutableElement)element, (TypeElement)element.getEnclosingElement(), info, funct);
}
- if (inheritedDoc != null && inheritedDoc.containsKey(DocTree.Kind.RETURN)) {
- ret.put(DocTree.Kind.RETURN, new StringBuilder(inheritedDoc.get(DocTree.Kind.RETURN)));
- }
- }
- for (int i = 0; i < ((ExecutableElement)element).getParameters().size(); i++) {
- if (!ret.containsKey(i)) {
- if (inheritedDoc == null && !inheritedDocNeeded.getAndSet(true)) {
- inheritedDoc = getInherited((ExecutableElement)element, (TypeElement)element.getEnclosingElement(), info, funct);
- }
- if (inheritedDoc != null && inheritedDoc.containsKey(i)) {
- ret.put(i, new StringBuilder(inheritedDoc.get(i)));
- }
+ if (inheritedDoc != null && inheritedDoc.containsKey(i)) {
+ ret.put(i, new StringBuilder(inheritedDoc.get(i)));
}
}
- for (TypeMirror thrownType : ((ExecutableElement)element).getThrownTypes()) {
- Element e = thrownType.getKind() == TypeKind.TYPEVAR ? ((TypeVariable)thrownType).asElement() : ((DeclaredType)thrownType).asElement();
- if (!ret.containsKey(e)) {
- if (inheritedDoc == null && !inheritedDocNeeded.getAndSet(true)) {
- inheritedDoc = getInherited((ExecutableElement)element, (TypeElement)element.getEnclosingElement(), info, funct);
- }
- if (inheritedDoc != null && inheritedDoc.containsKey(e)) {
- ret.put(e, new StringBuilder(inheritedDoc.get(e)));
- }
- }
+ }
+ for (TypeMirror thrownType : ((ExecutableElement)element).getThrownTypes()) {
+ //Check every throwables listed in the method. If for the current throwable there is not a javadoc try to get it from the parent.
+ //If for the current throwable there is a javadoc we show the current javadoc.
+ Element e = thrownType.getKind() == TypeKind.TYPEVAR ? ((TypeVariable)thrownType).asElement() : ((DeclaredType)thrownType).asElement();
+ if (!ret.containsKey(e)) {
+ if (inheritedDoc == null && !inheritedDocNeeded.getAndSet(true)) {
+ inheritedDoc = getInherited((ExecutableElement)element, (TypeElement)element.getEnclosingElement(), info, funct);
+ }
+ if (inheritedDoc != null && inheritedDoc.containsKey(e)) {
+ ret.put(e, new StringBuilder(inheritedDoc.get(e)));
+ }
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists