Skip to content

Commit 7d7925b

Browse files
Merge pull request #9071 from makiam/html-comment-tag-fix
Fix for issue 9018: Javadoc viewer shows HTML comments
2 parents 5b39890 + 3db460a commit 7d7925b

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

java/java.sourceui/src/org/netbeans/api/java/source/ui/ElementJavadoc.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@
123123
import com.vladsch.flexmark.ext.tables.TablesExtension;
124124
import com.vladsch.flexmark.html.HtmlRenderer;
125125
import com.vladsch.flexmark.parser.Parser;
126-
import com.vladsch.flexmark.util.data.DataHolder;
127-
import com.vladsch.flexmark.util.data.MutableDataSet;
128126
import javax.lang.model.element.RecordComponentElement;
129127
import org.netbeans.api.java.queries.SourceLevelQuery;
130128
import org.netbeans.api.java.queries.SourceLevelQuery.Profile;
@@ -191,7 +189,7 @@ public class ElementJavadoc {
191189
}
192190

193191
/** Creates an object describing the Javadoc of given element. The object
194-
* is capable of getting the text formated into HTML, resolve the links,
192+
* is capable of getting the text formatted into HTML, resolve the links,
195193
* jump to external javadoc.
196194
*
197195
* @param compilationInfo CompilationInfo
@@ -203,7 +201,7 @@ public static final ElementJavadoc create(CompilationInfo compilationInfo, Eleme
203201
}
204202

205203
/** Creates an object describing the Javadoc of given element. The object
206-
* is capable of getting the text formated into HTML, resolve the links,
204+
* is capable of getting the text formatted into HTML, resolve the links,
207205
* jump to external javadoc.
208206
*
209207
* @param compilationInfo CompilationInfo
@@ -216,7 +214,7 @@ public static final ElementJavadoc create(CompilationInfo compilationInfo, Eleme
216214
return new ElementJavadoc(compilationInfo, element, null, cancel);
217215
}
218216

219-
/** Gets the javadoc comment formated as HTML.
217+
/** Gets the javadoc comment formatted as HTML.
220218
* @return HTML text of the javadoc
221219
*/
222220
public String getText() {
@@ -228,7 +226,7 @@ public String getText() {
228226
}
229227
}
230228

231-
/** Gets the javadoc comment formated as HTML.
229+
/** Gets the javadoc comment formatted as HTML.
232230
* @return {@link Future} of HTML text of the javadoc
233231
* @since 1.20
234232
*/
@@ -237,7 +235,7 @@ public Future<String> getTextAsync() {
237235
}
238236

239237
/** Gets URL of the external javadoc.
240-
* @return Text of the Javadoc comment formated as HTML
238+
* @return Text of the Javadoc comment formatted as HTML
241239
*/
242240
public URL getURL() {
243241
return docURL;
@@ -422,7 +420,7 @@ private ElementJavadoc(CompilationInfo compilationInfo, Element element, final U
422420
return;
423421
}
424422
try {
425-
//Optimisitic no http
423+
//Optimistic no http
426424
CharSequence doc = getElementDoc(element, compilationInfo, header, url, true);
427425
if (doc == null) {
428426
computeDocURL(Collections.emptyList(), true, cancel);
@@ -1392,6 +1390,8 @@ private StringBuilder inlineTags(List<? extends DocTree> tags, TreePath docPath,
13921390
sb.append(systemPropTag.getPropertyName());
13931391
sb.append("</code>"); //NOI18N
13941392
break;
1393+
case COMMENT:
1394+
break;
13951395
default:
13961396
sb.append("<code>"); //NOI18N
13971397
try {

java/java.sourceui/test/unit/src/org/netbeans/api/java/source/ui/ElementJavadocTest.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,27 @@ public void testLinkNoRef() throws Exception {
157157
String expectedJavadoc = "<pre>public class <b>Test</b><br>extends <a href='*0'>Object</a></pre><p>Hello!\n" +
158158
"\n" +
159159
"<p>";
160-
160+
161161
assertEquals(expectedJavadoc, actualJavadoc);
162162
}
163163

164+
/**
165+
* Test for issue 9018: Javadoc viewer shows HTML comments
166+
* @throws Exception
167+
*/
168+
public void testHiddenTagInDoc() throws Exception {
169+
prepareTest("test/Test.java", "/**\n" +
170+
" * Next commented text is not expected to be in output document\n" +
171+
" * <!-- This text not expected to be in output document -->\n" +
172+
" */\n" +
173+
"public class Te<caret>st {}");
174+
String actualJavadoc = ElementJavadoc.create(info, selectedElement).getText();
175+
String expectedJavadoc = "<pre>public class <b>Test</b><br>extends <a href='*0'>Object</a></pre><p>Next commented text is not expected to be in output document\n" +
176+
177+
"<p>";
178+
assertEquals(expectedJavadoc, actualJavadoc);
179+
}
180+
181+
182+
164183
}

0 commit comments

Comments
 (0)