This is an automated email from the ASF dual-hosted git repository.
akhileshsingh 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 b78d6a3f2c remove jdk18 reflection calls and updated the usages (#4012)
b78d6a3f2c is described below
commit b78d6a3f2c1e538e23172bf5e5356bc8f169ac97
Author: Akhilesh Singh <[email protected]>
AuthorDate: Mon Jul 4 17:42:17 2022 +0530
remove jdk18 reflection calls and updated the usages (#4012)
* remove jdk18 reflection calls and updated the usages
---
.../modules/editor/java/GoToSupportTest.java | 181 +++++----------------
.../netbeans/modules/java/source/TreeShims.java | 56 +++----
.../transform/ImmutableDocTreeTranslator.java | 8 +-
.../api/java/source/ui/ElementJavadoc.java | 21 +--
4 files changed, 82 insertions(+), 184 deletions(-)
diff --git
a/java/java.editor/test/unit/src/org/netbeans/modules/editor/java/GoToSupportTest.java
b/java/java.editor/test/unit/src/org/netbeans/modules/editor/java/GoToSupportTest.java
index 7d4074dcd4..2afff1e676 100644
---
a/java/java.editor/test/unit/src/org/netbeans/modules/editor/java/GoToSupportTest.java
+++
b/java/java.editor/test/unit/src/org/netbeans/modules/editor/java/GoToSupportTest.java
@@ -1583,10 +1583,6 @@ public class GoToSupportTest extends NbTestCase {
}
public void testJavadocSnippetHighlightRecord() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
-
if (!hasRecords()) {
return;
}
@@ -1598,10 +1594,6 @@ public class GoToSupportTest extends NbTestCase {
}
public void testHighlightUsingSubstring() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
-
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -1610,10 +1602,6 @@ public class GoToSupportTest extends NbTestCase {
}
public void testHesthighlightUsingRegex() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
-
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -1622,10 +1610,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testHighlightUsingSubstringAndRegex() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
-
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -1634,9 +1619,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testHighlightUsingSubstringRegexAndType() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
@@ -1646,9 +1629,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testHighlightUsingMultipleSnippetTagInOneJavaDocWithRegion()
throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
@@ -1658,9 +1639,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testHighlightUsingNestedRegions() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
@@ -1670,9 +1649,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testHighlightUsingRegionsEndedWithDoubleColon() throws
Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
@@ -1682,9 +1659,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testNoMarkupTagPresent() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
@@ -1694,9 +1669,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testHighlightTagSubstringApplyToNextLine() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
@@ -1706,9 +1679,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testHighlightTagRegexWithAllCharacterChange() throws Exception
{
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
@@ -1718,9 +1689,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testHighlightTagRegexWithAllCharacterChangeUsingDot() throws
Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
@@ -1730,9 +1699,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testSingleLine_Replace_Regex() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -1740,9 +1707,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testSingleLine_Replace_RegexDotStar() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -1750,9 +1715,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testSingleLine_Replace_RegexDot() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -1760,9 +1723,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testSingleLine_Replace_Substring() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -1770,9 +1731,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testSingleLine_MultipleReplaceAnnotation_Regex() throws
Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -1780,9 +1739,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testSingleLine_MultipleReplaceAnnotation_Substring() throws
Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -1790,9 +1747,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testSingleLine_ReplaceAnnotation_Regex_DoubleQuote() throws
Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -1800,9 +1755,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testRegion_ReplaceAnnotation_Regex() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -1810,9 +1763,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testRegion_ReplaceAnnotation_RegexInnComment() throws
Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -1820,9 +1771,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testNestedRegion_ReplaceAnnotation_Substring() throws
Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -1830,9 +1779,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testNestedRegion_ReplaceAnnotation_Regex() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -1840,9 +1787,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testNestedRegion_Highlight_And_replace() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -1850,9 +1795,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testHighlightAndReplace_cornercase() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -1860,9 +1803,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testLinkTag() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -1871,9 +1812,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testLinkTag_With_RegexAndRegion() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -1882,9 +1821,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testLinkTag_AppliesToNextLine() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -1893,9 +1830,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testLink_MultipleTag_OnSameLine() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -1903,9 +1838,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testLinkTag_With_RegionAttribute() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -1913,9 +1846,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testLinkTag_Ref_ToThisClass_UsingHash() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -1923,9 +1854,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testLinkTag_FieldRef_ToThisClass_UsingHash() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -1933,9 +1862,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testLinkTag_AlongWith_HighlightTag() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -1943,9 +1870,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testLinkTag_AlongWith_ReplaceTag() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -1953,9 +1878,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testLinkTag_AlongWith_SubStringAndReplaceTag() throws
Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -1963,9 +1886,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testLinkTag_EmptyReplacementValue() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -1973,9 +1894,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testError_HighlightTag() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -1983,9 +1902,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testError_ReplaceTag() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -1993,9 +1910,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testError_LinkTag() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -2003,9 +1918,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testError_UnpairedRegion() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -2013,9 +1926,7 @@ public class GoToSupportTest extends NbTestCase {
}
public void testError_NoRegionToEnd() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
+
this.sourceLevel = getLatestSourceVersion();
EXTRA_OPTIONS.add("--enable-preview");
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
@@ -2023,9 +1934,6 @@ public class GoToSupportTest extends NbTestCase {
}
public void testErrorFileEmpty() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
if (!hasRecords()) {
return;
@@ -2038,10 +1946,6 @@ public class GoToSupportTest extends NbTestCase {
}
public void testErrorFileInvalid() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
-
if (!hasRecords()) {
return;
}
@@ -2053,9 +1957,6 @@ public class GoToSupportTest extends NbTestCase {
}
public void testExternalSnippetFile() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
if (!hasRecords()) {
return;
@@ -2068,9 +1969,6 @@ public class GoToSupportTest extends NbTestCase {
}
public void testErrorRegionInvalid() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
if (!hasRecords()) {
return;
@@ -2083,9 +1981,6 @@ public class GoToSupportTest extends NbTestCase {
}
public void testExternalRegionValid() throws Exception {
- if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
- return;
- }
if (!hasRecords()) {
return;
diff --git
a/java/java.source.base/src/org/netbeans/modules/java/source/TreeShims.java
b/java/java.source.base/src/org/netbeans/modules/java/source/TreeShims.java
index 7a309cd9f9..46389a0a19 100644
--- a/java/java.source.base/src/org/netbeans/modules/java/source/TreeShims.java
+++ b/java/java.source.base/src/org/netbeans/modules/java/source/TreeShims.java
@@ -366,31 +366,31 @@ public class TreeShims {
// }
// return null;
// }
- public static List<DocTree> getSnippetDocTreeAttributes(DocTree node) {
- try {
- Class gpt = Class.forName("com.sun.source.doctree.SnippetTree");
//NOI18N
- return isJDKVersionRelease18_Or_Above()
- ? (List<DocTree>)
gpt.getDeclaredMethod("getAttributes").invoke(node) //NOI18N
- : Collections.emptyList();
- } catch (NoSuchMethodException | ClassNotFoundException ex) {
- return null;
- } catch (IllegalAccessException | IllegalArgumentException |
InvocationTargetException ex) {
- throw TreeShims.<RuntimeException>throwAny(ex);
- }
- }
-
- public static TextTree getSnippetDocTreeText(DocTree node) {
- try {
- Class gpt = Class.forName("com.sun.source.doctree.SnippetTree");
//NOI18N
- return isJDKVersionRelease18_Or_Above()
- ? (TextTree) gpt.getDeclaredMethod("getBody").invoke(node)
//NOI18N
- : null;
- } catch (NoSuchMethodException | ClassNotFoundException ex) {
- return null;
- } catch (IllegalAccessException | IllegalArgumentException |
InvocationTargetException ex) {
- throw TreeShims.<RuntimeException>throwAny(ex);
- }
- }
+// public static List<DocTree> getSnippetDocTreeAttributes(DocTree node) {
+// try {
+// Class gpt = Class.forName("com.sun.source.doctree.SnippetTree");
//NOI18N
+// return isJDKVersionRelease18_Or_Above()
+// ? (List<DocTree>)
gpt.getDeclaredMethod("getAttributes").invoke(node) //NOI18N
+// : null;
+// } catch (NoSuchMethodException | ClassNotFoundException ex) {
+// return null;
+// } catch (IllegalAccessException | IllegalArgumentException |
InvocationTargetException ex) {
+// throw TreeShims.<RuntimeException>throwAny(ex);
+// }
+// }
+//
+// public static TextTree getSnippetDocTreeText(DocTree node) {
+// try {
+// Class gpt = Class.forName("com.sun.source.doctree.SnippetTree");
//NOI18N
+// return isJDKVersionRelease18_Or_Above()
+// ? (TextTree)
gpt.getDeclaredMethod("getBody").invoke(node) //NOI18N
+// : null;
+// } catch (NoSuchMethodException | ClassNotFoundException ex) {
+// return null;
+// } catch (IllegalAccessException | IllegalArgumentException |
InvocationTargetException ex) {
+// throw TreeShims.<RuntimeException>throwAny(ex);
+// }
+// }
public static Element toRecordComponent(Element el) {
if (el == null ||el.getKind() != ElementKind.FIELD) {
@@ -425,9 +425,9 @@ public class TreeShims {
return
Integer.valueOf(SourceVersion.latest().name().split("_")[1]).compareTo(17) >= 0;
}
- public static boolean isJDKVersionRelease18_Or_Above() {
- return
Integer.valueOf(SourceVersion.latest().name().split("_")[1]).compareTo(18) >= 0;
- }
+// public static boolean isJDKVersionRelease18_Or_Above() {
+// return
Integer.valueOf(SourceVersion.latest().name().split("_")[1]).compareTo(18) >= 0;
+// }
@SuppressWarnings("unchecked")
public static <T extends Throwable> RuntimeException throwAny(Throwable t)
throws T {
diff --git
a/java/java.source.base/src/org/netbeans/modules/java/source/transform/ImmutableDocTreeTranslator.java
b/java/java.source.base/src/org/netbeans/modules/java/source/transform/ImmutableDocTreeTranslator.java
index 9e3fd125ad..05507fe0e6 100644
---
a/java/java.source.base/src/org/netbeans/modules/java/source/transform/ImmutableDocTreeTranslator.java
+++
b/java/java.source.base/src/org/netbeans/modules/java/source/transform/ImmutableDocTreeTranslator.java
@@ -52,6 +52,7 @@ import com.sun.source.doctree.UnknownInlineTagTree;
import com.sun.source.doctree.UsesTree;
import com.sun.source.doctree.ValueTree;
import com.sun.source.doctree.VersionTree;
+import com.sun.source.doctree.SnippetTree;
import com.sun.source.tree.ExpressionTree;
import com.sun.source.tree.Tree;
import com.sun.tools.javac.tree.DCTree;
@@ -377,9 +378,10 @@ public class ImmutableDocTreeTranslator extends
ImmutableTreeTranslator implemen
protected final DocTree rewriteSnippetChildren(DocTree tree) {
DocTree value = tree;
- List<? extends DocTree> snippetTreeAttributes =
translateDoc(TreeShims.getSnippetDocTreeAttributes(tree));
- TextTree snippetTreeText = (TextTree)
translate(TreeShims.getSnippetDocTreeText(tree));
- if((snippetTreeAttributes !=
TreeShims.getSnippetDocTreeAttributes(tree)) || (snippetTreeText !=
TreeShims.getSnippetDocTreeText(tree))){
+ SnippetTree javadocSnippet = (SnippetTree)tree;
+ List<? extends DocTree> snippetTreeAttributes =
translateDoc(javadocSnippet.getAttributes());
+ TextTree snippetTreeText = (TextTree)
translate(javadocSnippet.getBody());
+ if((snippetTreeAttributes != javadocSnippet.getAttributes()) ||
(snippetTreeText != javadocSnippet.getBody())){
value=make.Snippet(snippetTreeAttributes, snippetTreeText);
}
return value;
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 7728b743d1..d55f029fcb 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
@@ -35,6 +35,7 @@ import com.sun.source.doctree.ReferenceTree;
import com.sun.source.doctree.ReturnTree;
import com.sun.source.doctree.SeeTree;
import com.sun.source.doctree.SinceTree;
+import com.sun.source.doctree.SnippetTree;
import com.sun.source.doctree.StartElementTree;
import com.sun.source.doctree.TextTree;
import com.sun.source.doctree.ThrowsTree;
@@ -1319,27 +1320,27 @@ public class ElementJavadoc {
case TEXT:
TextTree ttag = (TextTree)tag;
sb.append(ttag.getBody());
- break;
- default:
- if (tag.getKind().toString().equals("SNIPPET")) {
- snippetCount++;
- processDocSnippet(sb, tag, snippetCount,docPath, doc,
trees);
- }
+ break;
+ case SNIPPET:
+ snippetCount++;
+ processDocSnippet(sb, (SnippetTree)tag,
snippetCount,docPath, doc, trees);
+ break;
}
}
return sb;
}
- private void processDocSnippet(StringBuilder sb, DocTree tag, Integer
snippetCount, TreePath docPath,DocCommentTree doc, DocTrees trees) {
+ private void processDocSnippet(StringBuilder sb, SnippetTree
javadocSnippet, Integer snippetCount, TreePath docPath,DocCommentTree doc,
DocTrees trees) {
sb.append("<div id=\"snippet").append(snippetCount).append("\"
style=\"font-size: 10px; border: 1px solid black; margin-top: 2px;
margin-bottom: 2px\">"); //NOI18N
sb.append("<div align=right>" //NOI18N
+ "<a
href=\"copy.snippet").append(snippetCount).append("\">Copy</a>" //NOI18N
+ "</div>\n"); //NOI18N
+
sb.append("<pre>"); //NOI18N
sb.append("<code>"); //NOI18N
- List<DocTree> attributes = (List<DocTree>)
TreeShims.getSnippetDocTreeAttributes(tag);
+ List<? extends DocTree> attributes = javadocSnippet.getAttributes();
String fileName = null;
String regionName = null;
@@ -1394,8 +1395,8 @@ public class ElementJavadoc {
}
if (!isExternalSnippet) {
- if(TreeShims.getSnippetDocTreeText(tag)!=null) {
- text = TreeShims.getSnippetDocTreeText(tag).toString();
+ if(javadocSnippet.getBody() != null) {
+ text = javadocSnippet.getBody().toString();
}
}
---------------------------------------------------------------------
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