Lines 22-27
Link Here
|
22 |
import org.eclipse.core.runtime.CoreException; |
22 |
import org.eclipse.core.runtime.CoreException; |
23 |
import org.eclipse.core.runtime.IPath; |
23 |
import org.eclipse.core.runtime.IPath; |
24 |
import org.eclipse.core.runtime.NullProgressMonitor; |
24 |
import org.eclipse.core.runtime.NullProgressMonitor; |
|
|
25 |
import org.eclipse.core.runtime.Path; |
25 |
import org.eclipse.jdt.core.IClassFile; |
26 |
import org.eclipse.jdt.core.IClassFile; |
26 |
import org.eclipse.jdt.core.IClasspathAttribute; |
27 |
import org.eclipse.jdt.core.IClasspathAttribute; |
27 |
import org.eclipse.jdt.core.IClasspathEntry; |
28 |
import org.eclipse.jdt.core.IClasspathEntry; |
Lines 34-39
Link Here
|
34 |
import org.eclipse.jdt.core.IType; |
35 |
import org.eclipse.jdt.core.IType; |
35 |
import org.eclipse.jdt.core.JavaCore; |
36 |
import org.eclipse.jdt.core.JavaCore; |
36 |
import org.eclipse.jdt.core.JavaModelException; |
37 |
import org.eclipse.jdt.core.JavaModelException; |
|
|
38 |
import org.eclipse.jdt.internal.core.BinaryType; |
39 |
import org.eclipse.jdt.internal.core.JavaModelManager; |
40 |
import org.eclipse.jdt.internal.core.JavaModelManager.PerProjectInfo; |
37 |
|
41 |
|
38 |
public class AttachedJavadocTests extends ModifyingResourceTests { |
42 |
public class AttachedJavadocTests extends ModifyingResourceTests { |
39 |
private static final String DEFAULT_DOC_FOLDER = "doc"; |
43 |
private static final String DEFAULT_DOC_FOLDER = "doc"; |
Lines 718-721
Link Here
|
718 |
setJavadocLocationAttribute(DEFAULT_DOC_FOLDER); |
722 |
setJavadocLocationAttribute(DEFAULT_DOC_FOLDER); |
719 |
} |
723 |
} |
720 |
} |
724 |
} |
|
|
725 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=329671 |
726 |
public void testBug329671() throws CoreException, IOException { |
727 |
Map options = this.project.getOptions(true); |
728 |
Object timeout = options.get(JavaCore.TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC); |
729 |
options.put(JavaCore.TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC, "1"); //$NON-NLS-1$ |
730 |
this.project.setOptions(options); |
731 |
IClasspathEntry[] entries = this.project.getRawClasspath(); |
732 |
|
733 |
try { |
734 |
IClasspathAttribute attribute = |
735 |
JavaCore.newClasspathAttribute( |
736 |
IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, |
737 |
"jar:platform:/resource/AttachedJavadocProject/bug329671_doc.zip!/"); |
738 |
IClasspathEntry newEntry = JavaCore.newLibraryEntry(new Path("/AttachedJavadocProject/bug329671.jar"), null, null, null, new IClasspathAttribute[] { attribute}, false); |
739 |
this.project.setRawClasspath(new IClasspathEntry[]{newEntry}, null); |
740 |
this.project.getResolvedClasspath(false); |
741 |
|
742 |
IPackageFragmentRoot jarRoot = this.project.getPackageFragmentRoot(getFile("/AttachedJavadocProject/bug329671.jar")); |
743 |
final IType type = jarRoot.getPackageFragment("bug").getClassFile("X.class").getType(); |
744 |
IMethod method = type.getMethod("foo", new String[]{"Ljava.lang.Object;"}); |
745 |
assertNotNull(method); |
746 |
|
747 |
String[] paramNames = method.getParameterNames(); |
748 |
assertStringsEqual("Parameter names", new String[]{"arg0"}, paramNames); |
749 |
final PerProjectInfo projectInfo = JavaModelManager.getJavaModelManager().getPerProjectInfoCheckExistence(this.project.getProject()); |
750 |
final Object varThis = this; |
751 |
Thread thread = new Thread(){ |
752 |
public void run() { |
753 |
Object javadocContent = projectInfo.javadocCache.get(type); |
754 |
while(javadocContent == null || javadocContent == BinaryType.EMPTY_JAVADOC) { |
755 |
try { |
756 |
Thread.sleep(50); |
757 |
javadocContent = projectInfo.javadocCache.get(type); |
758 |
} catch (InterruptedException e) { |
759 |
} |
760 |
synchronized (varThis) { |
761 |
varThis.notify(); |
762 |
} |
763 |
} |
764 |
} |
765 |
}; |
766 |
thread.start(); |
767 |
synchronized (varThis) { |
768 |
try { |
769 |
varThis.wait(5000); |
770 |
} catch (InterruptedException e) { |
771 |
e.printStackTrace(); |
772 |
} |
773 |
} |
774 |
projectInfo.javadocCache.flush(); |
775 |
options.put(JavaCore.TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC, "5000"); //$NON-NLS-1$ |
776 |
this.project.setOptions(options); |
777 |
paramNames = method.getParameterNames(); |
778 |
assertStringsEqual("Parameter names", new String[]{"param"}, paramNames); |
779 |
} finally { |
780 |
this.project.setRawClasspath(entries, null); |
781 |
if (timeout != null) |
782 |
options.put(JavaCore.TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC, timeout); |
783 |
this.project.setOptions(options); |
784 |
} |
785 |
} |
721 |
} |
786 |
} |