View | Details | Raw Unified | Return to bug 334652
Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/JavadocContents.java (-20 / +7 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2009, 2010 IBM Corporation and others.
2
 * Copyright (c) 2009, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 13-19 Link Here
13
import org.eclipse.jdt.core.Flags;
13
import org.eclipse.jdt.core.Flags;
14
import org.eclipse.jdt.core.IField;
14
import org.eclipse.jdt.core.IField;
15
import org.eclipse.jdt.core.IJavaModelStatusConstants;
15
import org.eclipse.jdt.core.IJavaModelStatusConstants;
16
import org.eclipse.jdt.core.IJavaProject;
17
import org.eclipse.jdt.core.IMethod;
16
import org.eclipse.jdt.core.IMethod;
18
import org.eclipse.jdt.core.IType;
17
import org.eclipse.jdt.core.IType;
19
import org.eclipse.jdt.core.JavaModelException;
18
import org.eclipse.jdt.core.JavaModelException;
Lines 378-408 Link Here
378
		IType declaringType = this.type;
377
		IType declaringType = this.type;
379
		if (declaringType.isMember()) {
378
		if (declaringType.isMember()) {
380
			int depth = 0;
379
			int depth = 0;
381
			final String packageFragmentName = declaringType.getPackageFragment().getElementName();
382
			// might need to remove a part of the signature corresponding to the synthetic argument
380
			// might need to remove a part of the signature corresponding to the synthetic argument
383
			final IJavaProject javaProject = declaringType.getJavaProject();
381
			if (!Flags.isStatic(declaringType.getFlags())) {
384
			char[][] typeNames = CharOperation.splitOn('.', typeQualifiedName.toCharArray());
382
				depth++;
385
			if (!Flags.isStatic(declaringType.getFlags())) depth++;
386
			StringBuffer typeName = new StringBuffer();
387
			for (int i = 0, max = typeNames.length; i < max; i++) {
388
				if (typeName.length() == 0) {
389
					typeName.append(typeNames[i]);
390
				} else {
391
					typeName.append('.').append(typeNames[i]);
392
				}
393
				IType resolvedType = javaProject.findType(packageFragmentName, String.valueOf(typeName));
394
				if (resolvedType != null && resolvedType.isMember() && !Flags.isStatic(resolvedType.getFlags())) depth++;
395
			}
383
			}
396
			if (depth != 0) {
384
			if (depth != 0) {
385
				// depth is 1
397
				int indexOfOpeningParen = anchor.indexOf('(');
386
				int indexOfOpeningParen = anchor.indexOf('(');
398
				if (indexOfOpeningParen == -1) return null;
387
				if (indexOfOpeningParen == -1) return null;
399
				int index = indexOfOpeningParen;
388
				int index = indexOfOpeningParen;
400
				indexOfOpeningParen++;
389
				indexOfOpeningParen++;
401
				for (int i = 0; i < depth; i++) {
390
				int indexOfComma = anchor.indexOf(',', index);
402
					int indexOfComma = anchor.indexOf(',', index);
391
				if (indexOfComma != -1) {
403
					if (indexOfComma != -1) {
392
					index = indexOfComma + 2;
404
						index = indexOfComma + 2;
405
					}
406
				}
393
				}
407
				anchor = anchor.substring(0, indexOfOpeningParen) + anchor.substring(index);
394
				anchor = anchor.substring(0, indexOfOpeningParen) + anchor.substring(index);
408
			}
395
			}
(-)src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java (-2 / +147 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 43-49 Link Here
43
	private static final String DEFAULT_DOC_FOLDER = "doc";
43
	private static final String DEFAULT_DOC_FOLDER = "doc";
44
44
45
	static {
45
	static {
46
//		TESTS_NAMES = new String[] { "test010" };
46
//		TESTS_NAMES = new String[] { "testBug334652_4" };
47
//		TESTS_NUMBERS = new int[] { 24 };
47
//		TESTS_NUMBERS = new int[] { 24 };
48
//		TESTS_RANGE = new int[] { 169, 180 };
48
//		TESTS_RANGE = new int[] { 169, 180 };
49
	}
49
	}
Lines 783-786 Link Here
783
			this.project.setOptions(options);
783
			this.project.setOptions(options);
784
		}
784
		}
785
	}
785
	}
786
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=334652
787
	public void testBug334652() throws CoreException, IOException {
788
		IClasspathEntry[] entries = this.project.getRawClasspath();
789
790
		try {
791
			IClasspathAttribute attribute =
792
					JavaCore.newClasspathAttribute(
793
							IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME,
794
							"jar:platform:/resource/AttachedJavadocProject/bug334652_doc.zip!/NoJavaDocForInnerClass/doc");
795
					IClasspathEntry newEntry = JavaCore.newLibraryEntry(new Path("/AttachedJavadocProject/bug334652.jar"), null, null, null, new IClasspathAttribute[] { attribute}, false);
796
			this.project.setRawClasspath(new IClasspathEntry[]{newEntry}, null);
797
			this.project.getResolvedClasspath(false);
798
799
			IPackageFragmentRoot jarRoot = this.project.getPackageFragmentRoot(getFile("/AttachedJavadocProject/bug334652.jar"));
800
			final IType type = jarRoot.getPackageFragment("com.test").getClassFile("PublicAbstractClass$InnerFinalException.class").getType();
801
			IMethod method = type.getMethod("InnerFinalException", new String[] { "Lcom.test.PublicAbstractClass;", "Ljava.lang.String;", "Ljava.lang.String;"});
802
			assertNotNull(method);
803
			assertTrue("Does not exist", method.exists());
804
805
			String javadoc = method.getAttachedJavadoc(null);
806
			assertNotNull(javadoc);
807
			assertEquals("Wrong contents", "<H3>\r\n" + 
808
					"PublicAbstractClass.InnerFinalException</H3>\r\n" + 
809
					"<PRE>\r\n" + 
810
					"public <B>PublicAbstractClass.InnerFinalException</B>(java.lang.String&nbsp;property,\r\n" + 
811
					"                                               java.lang.String&nbsp;msg)</PRE>\r\n" + 
812
					"<DL>\r\n" + 
813
					"<DD>javadoc for InnerFinalException(String property, String msg)\r\n" + 
814
					"<P>\r\n" + 
815
					"<DL>\r\n" + 
816
					"<DT><B>Parameters:</B><DD><CODE>property</CODE> - the property argument<DD><CODE>msg</CODE> - the message argument</DL>\r\n" + 
817
					"</DL>\r\n", javadoc);
818
		} finally {
819
			this.project.setRawClasspath(entries, null);
820
		}
821
	}
822
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=334652
823
	public void testBug334652_2() throws CoreException, IOException {
824
		IClasspathEntry[] entries = this.project.getRawClasspath();
825
826
		try {
827
			IClasspathAttribute attribute =
828
					JavaCore.newClasspathAttribute(
829
							IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME,
830
							"jar:platform:/resource/AttachedJavadocProject/bug334652(2)_doc.zip!/doc");
831
					IClasspathEntry newEntry = JavaCore.newLibraryEntry(new Path("/AttachedJavadocProject/bug334652(2).jar"), null, null, null, new IClasspathAttribute[] { attribute}, false);
832
			this.project.setRawClasspath(new IClasspathEntry[]{newEntry}, null);
833
			this.project.getResolvedClasspath(false);
834
835
			IPackageFragmentRoot jarRoot = this.project.getPackageFragmentRoot(getFile("/AttachedJavadocProject/bug334652(2).jar"));
836
			final IType type = jarRoot.getPackageFragment("com.test").getClassFile("PublicAbstractClass$InnerFinalException.class").getType();
837
			IMethod method = type.getMethod("InnerFinalException", new String[] { "Ljava.lang.String;", "Ljava.lang.String;"});
838
			assertNotNull(method);
839
			assertTrue("Does not exist", method.exists());
840
841
			String javadoc = method.getAttachedJavadoc(null);
842
			assertNotNull(javadoc);
843
			assertEquals("Wrong contents", "<H3>\r\n" + 
844
					"PublicAbstractClass.InnerFinalException</H3>\r\n" + 
845
					"<PRE>\r\n" + 
846
					"public <B>PublicAbstractClass.InnerFinalException</B>(java.lang.String&nbsp;property,\r\n" + 
847
					"                                               java.lang.String&nbsp;msg)</PRE>\r\n" + 
848
					"<DL>\r\n" + 
849
					"<DD>javadoc for InnerFinalException(String property, String msg)\r\n" + 
850
					"<P>\r\n" + 
851
					"<DL>\r\n" + 
852
					"<DT><B>Parameters:</B><DD><CODE>property</CODE> - the property argument<DD><CODE>msg</CODE> - the message argument</DL>\r\n" + 
853
					"</DL>\r\n", javadoc);
854
		} finally {
855
			this.project.setRawClasspath(entries, null);
856
		}
857
	}
858
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=334652
859
	public void testBug334652_3() throws CoreException, IOException {
860
		IClasspathEntry[] entries = this.project.getRawClasspath();
861
862
		try {
863
			IClasspathAttribute attribute =
864
					JavaCore.newClasspathAttribute(
865
							IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME,
866
							"jar:platform:/resource/AttachedJavadocProject/bug334652(3)_doc.zip!/doc");
867
					IClasspathEntry newEntry = JavaCore.newLibraryEntry(new Path("/AttachedJavadocProject/bug334652(3).jar"), null, null, null, new IClasspathAttribute[] { attribute}, false);
868
			this.project.setRawClasspath(new IClasspathEntry[]{newEntry}, null);
869
			this.project.getResolvedClasspath(false);
870
871
			IPackageFragmentRoot jarRoot = this.project.getPackageFragmentRoot(getFile("/AttachedJavadocProject/bug334652(3).jar"));
872
			final IType type = jarRoot.getPackageFragment("com.test").getClassFile("PublicAbstractClass$A$InnerFinalException.class").getType();
873
			IMethod method = type.getMethod("InnerFinalException", new String[] { "Lcom.test.PublicAbstractClass$A;", "Ljava.lang.String;", "Ljava.lang.String;"});
874
			assertNotNull(method);
875
			assertTrue("Does not exist", method.exists());
876
877
			String javadoc = method.getAttachedJavadoc(null);
878
			assertNotNull(javadoc);
879
			assertEquals("Wrong contents",
880
					"<H3>\r\n" + 
881
					"PublicAbstractClass.A.InnerFinalException</H3>\r\n" + 
882
					"<PRE>\r\n" + 
883
					"public <B>PublicAbstractClass.A.InnerFinalException</B>(java.lang.String&nbsp;property,\r\n" + 
884
					"                                                 java.lang.String&nbsp;msg)</PRE>\r\n" + 
885
					"<DL>\r\n" + 
886
					"<DD>javadoc for InnerFinalException(String property, String msg)\r\n" + 
887
					"<P>\r\n" + 
888
					"<DL>\r\n" + 
889
					"<DT><B>Parameters:</B><DD><CODE>property</CODE> - the property argument<DD><CODE>msg</CODE> - the message argument</DL>\r\n" + 
890
					"</DL>\r\n", javadoc);
891
		} finally {
892
			this.project.setRawClasspath(entries, null);
893
		}
894
	}
895
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=334652
896
	public void testBug334652_4() throws CoreException, IOException {
897
		IClasspathEntry[] entries = this.project.getRawClasspath();
898
899
		try {
900
			IClasspathAttribute attribute =
901
					JavaCore.newClasspathAttribute(
902
							IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME,
903
							"jar:platform:/resource/AttachedJavadocProject/bug334652(4)_doc.zip!/doc");
904
					IClasspathEntry newEntry = JavaCore.newLibraryEntry(new Path("/AttachedJavadocProject/bug334652(4).jar"), null, null, null, new IClasspathAttribute[] { attribute}, false);
905
			this.project.setRawClasspath(new IClasspathEntry[]{newEntry}, null);
906
			this.project.getResolvedClasspath(false);
907
908
			IPackageFragmentRoot jarRoot = this.project.getPackageFragmentRoot(getFile("/AttachedJavadocProject/bug334652(4).jar"));
909
			final IType type = jarRoot.getPackageFragment("com.test").getClassFile("PublicAbstractClass$A$InnerFinalException.class").getType();
910
			IMethod method = type.getMethod("InnerFinalException", new String[] { "Lcom.test.PublicAbstractClass$A;", "Ljava.lang.String;", "Ljava.lang.String;"});
911
			assertNotNull(method);
912
			assertTrue("Does not exist", method.exists());
913
914
			String javadoc = method.getAttachedJavadoc(null);
915
			assertNotNull(javadoc);
916
			assertEquals("Wrong contents", "<H3>\r\n" + 
917
					"PublicAbstractClass.A.InnerFinalException</H3>\r\n" + 
918
					"<PRE>\r\n" + 
919
					"public <B>PublicAbstractClass.A.InnerFinalException</B>(java.lang.String&nbsp;property,\r\n" + 
920
					"                                                 java.lang.String&nbsp;msg)</PRE>\r\n" + 
921
					"<DL>\r\n" + 
922
					"<DD>javadoc for InnerFinalException(String property, String msg)\r\n" + 
923
					"<P>\r\n" + 
924
					"<DL>\r\n" + 
925
					"<DT><B>Parameters:</B><DD><CODE>property</CODE> - the property argument<DD><CODE>msg</CODE> - the message argument</DL>\r\n" + 
926
					"</DL>\r\n", javadoc);
927
		} finally {
928
			this.project.setRawClasspath(entries, null);
929
		}
930
	}
786
}
931
}

Return to bug 334652