Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ public void testBug394382() throws JavaModelException {
} catch(JavaModelException e) {
assertTrue("Should not happen", false);
}
assertNotNull("Shouldhave a javadoc", javadoc); //$NON-NLS-1$
assertNotNull("Should have a javadoc", javadoc); //$NON-NLS-1$
String encodedContents = new String (Util.getResourceContentsAsCharArray(sourceFile, encoding));
char[] charArray = encodedContents.toCharArray();
encodedContents = new String(CharOperation.remove(charArray, '\r'));
Expand All @@ -1122,10 +1122,12 @@ public void testBug398272() throws JavaModelException {
}
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=426058
public void testBug426058() throws JavaModelException {
public void testBug426058() throws Exception {
IClasspathEntry[] oldClasspath = this.project.getRawClasspath();
String oldEncoding = this.project.getProject().getDefaultCharset();
try {
String encoding = "UTF-8";
this.project.getProject().setDefaultCharset("ISO-8859-1", null);
IResource resource = this.project.getProject().findMember("/UTF8doc2/"); //$NON-NLS-1$
assertNotNull("doc folder cannot be null", resource); //$NON-NLS-1$
URI locationURI = resource.getLocationURI();
Expand Down Expand Up @@ -1168,7 +1170,7 @@ public void testBug426058() throws JavaModelException {
} catch(JavaModelException e) {
assertTrue("Should not happen", false);
}
assertNotNull("Shouldhave a javadoc", javadoc); //$NON-NLS-1$
assertNotNull("Should have a javadoc", javadoc); //$NON-NLS-1$
String encodedContents = new String (Util.getResourceContentsAsCharArray(sourceFile, encoding));
char[] charArray = encodedContents.toCharArray();
encodedContents = new String(CharOperation.remove(charArray, '\r'));
Expand All @@ -1177,7 +1179,76 @@ public void testBug426058() throws JavaModelException {
assertTrue("Sources should be decoded the same way", encodedContents.equals(javadoc));
}
finally {
this.project.setRawClasspath(oldClasspath, null);
try {
this.project.getProject().setDefaultCharset(oldEncoding, null);
} finally {
this.project.setRawClasspath(oldClasspath, null);
}
}
}
public void testAttachedJavadocWithModernMetaCharset() throws Exception {
IClasspathEntry[] oldClasspath = this.project.getRawClasspath();
String oldEncoding = this.project.getProject().getDefaultCharset();
try {
String encoding = "UTF-8";
this.project.getProject().setDefaultCharset("ISO-8859-1", null);
IResource resource = this.project.getProject().findMember("/UTF8doc3/"); //$NON-NLS-1$
assertNotNull("doc folder cannot be null", resource); //$NON-NLS-1$
URI locationURI = resource.getLocationURI();
assertNotNull("doc folder cannot be null", locationURI); //$NON-NLS-1$
URL docUrl = null;
try {
docUrl = locationURI.toURL();
} catch (MalformedURLException e) {
assertTrue("Should not happen", false); //$NON-NLS-1$
} catch(IllegalArgumentException e) {
assertTrue("Should not happen", false); //$NON-NLS-1$
}
IClasspathAttribute attribute = JavaCore.newClasspathAttribute(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, docUrl.toExternalForm());
IClasspathEntry newEntry = JavaCore.newLibraryEntry(new Path("/AttachedJavadocProject/lib/bug394382.jar"), null, null, new IAccessRule[]{}, new IClasspathAttribute[] { attribute }, false ); //$NON-NLS-1$
IClasspathEntry[] newClasspath = new IClasspathEntry[oldClasspath.length + 1];
System.arraycopy(oldClasspath, 0, newClasspath, 0, oldClasspath.length);
newClasspath[oldClasspath.length] = newEntry;
this.project.setRawClasspath(newClasspath, null);
waitForAutoBuild();

IPackageFragmentRoot[] roots = this.project.getAllPackageFragmentRoots();
IPackageFragmentRoot packageRoot = null;
for(int i=0; i < roots.length; i++) {
IPath path = roots[i].getPath();
if (path.segment(path.segmentCount() - 1).equals("bug394382.jar")) {
packageRoot = roots[i];
}
}

assertNotNull("Should not be null", packageRoot);
IPackageFragment packageFragment = packageRoot.getPackageFragment("p"); //$NON-NLS-1$
assertNotNull("Should not be null", packageFragment); //$NON-NLS-1$
IOrdinaryClassFile classFile = packageFragment.getOrdinaryClassFile("TestBug394382.class"); //$NON-NLS-1$
assertNotNull(classFile);
IType type = classFile.getType();
IFile sourceFile = (IFile) this.project.getProject().findMember("UTF8doc3/p/TestBug394382.txt");
assertNotNull("source file cannot be null", sourceFile); //$NON-NLS-1$
String javadoc = null;
Comment thread
chagong marked this conversation as resolved.
try {
javadoc = type.getAttachedJavadoc(new NullProgressMonitor());
} catch(JavaModelException e) {
assertTrue("Should not happen", false);
}
assertNotNull("Should have a javadoc", javadoc); //$NON-NLS-1$
String encodedContents = new String (Util.getResourceContentsAsCharArray(sourceFile, encoding));
char[] charArray = encodedContents.toCharArray();
encodedContents = new String(CharOperation.remove(charArray, '\r'));
charArray = javadoc.toCharArray();
javadoc = new String(CharOperation.remove(charArray, '\r'));
assertEquals("Sources should be decoded the same way", encodedContents, javadoc);
}
finally {
try {
this.project.getProject().setDefaultCharset(oldEncoding, null);
} finally {
this.project.setRawClasspath(oldClasspath, null);
}
}
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=403154
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,255 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<title>TestBug394382</title>
<meta name="viewport" content="width=device-width">
<meta name="x" data-charset="ISO-8859-1">
<meta charset="UTF-8" />
<link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="TestBug394382";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../p/package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../deprecated-list.html">Deprecated</a></li>
<li><a href="../index-all.html">Index</a></li>
<li><a href="../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev Class</li>
<li>Next Class</li>
</ul>
<ul class="navList">
<li><a href="../index.html?p/TestBug394382.html" target="_top">Frames</a></li>
<li><a href="TestBug394382.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">p</div>
<h2 title="Class TestBug394382" class="title">Class TestBug394382</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li>p.TestBug394382</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>public class <span class="strong">TestBug394382</span>
extends java.lang.Object</pre>
<div class="block">こんにちは世界 ! This class <code>TestBug394382</code> is to test bug 426058</div>
<dl><dt><span class="strong">See Also:</span></dt><dd><code>https://bugs.eclipse.org/bugs/show_bug.cgi?id=394382</code></dd></dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor_summary">
<!-- -->
</a>
<h3>Constructor Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colOne" scope="col">Constructor and Description</th>
</tr>
<tr class="altColor">
<td class="colOne"><code><strong><a href="../p/TestBug394382.html#TestBug394382()">TestBug394382</a></strong>()</code>&nbsp;</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method_summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span>Methods</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static void</code></td>
<td class="colLast"><code><strong><a href="../p/TestBug394382.html#main(java.lang.String[])">main</a></strong>(java.lang.String[]&nbsp;args)</code>&nbsp;</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods_inherited_from_class_java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.Object</h3>
<code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor_detail">
<!-- -->
</a>
<h3>Constructor Detail</h3>
<a name="TestBug394382()">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>TestBug394382</h4>
<pre>public&nbsp;TestBug394382()</pre>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method_detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="main(java.lang.String[])">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>main</h4>
<pre>public static&nbsp;void&nbsp;main(java.lang.String[]&nbsp;args)</pre>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../p/package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../deprecated-list.html">Deprecated</a></li>
<li><a href="../index-all.html">Index</a></li>
<li><a href="../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev Class</li>
<li>Next Class</li>
</ul>
<ul class="navList">
<li><a href="../index.html?p/TestBug394382.html" target="_top">Frames</a></li>
<li><a href="TestBug394382.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="block">こんにちは世界 ! This class <code>TestBug394382</code> is to test bug 426058</div>
<dl><dt><span class="strong">See Also:</span></dt><dd><code>https://bugs.eclipse.org/bugs/show_bug.cgi?id=394382</code></dd></dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
Loading