Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 28544 Details for
Bug 110172
[plan] API to extract the Javadoc on org.eclipse.jdt.core.IMember
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Regression tests
patch_110172_tests.txt (text/plain), 14.98 KB, created by
Olivier Thomann
on 2005-10-20 15:34:16 EDT
(
hide
)
Description:
Regression tests
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2005-10-20 15:34:16 EDT
Size:
14.98 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.model >Index: workspace/AttachSourceTests/.classpath >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/.classpath,v >retrieving revision 1.8 >diff -u -r1.8 .classpath >--- workspace/AttachSourceTests/.classpath 21 Sep 2004 15:57:01 -0000 1.8 >+++ workspace/AttachSourceTests/.classpath 20 Oct 2005 19:32:46 -0000 >@@ -8,6 +8,7 @@ > <classpathentry kind="lib" path="test2.jar"/> > <classpathentry kind="lib" path="test4.jar"/> > <classpathentry kind="lib" path="test5.jar"/> >+ <classpathentry kind="lib" path="test6.jar"/> > <classpathentry kind="lib" path="lib"/> > <classpathentry kind="src" path="src" output="src"/> > <classpathentry kind="var" path="JCL_LIB"/> >Index: src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java,v >retrieving revision 1.36 >diff -u -r1.36 CompilationUnitTests.java >--- src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java 13 Oct 2005 09:07:59 -0000 1.36 >+++ src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java 20 Oct 2005 19:32:46 -0000 >@@ -82,7 +82,7 @@ > // All specified tests which do not belong to the class are skipped... > static { > // TESTS_PREFIX = "testBug"; >-// TESTS_NAMES = new String[] { "testGetChildrenForCategory02" }; >+// TESTS_NAMES = new String[] { "test110172" }; > // TESTS_NUMBERS = new int[] { 13 }; > // TESTS_RANGE = new int[] { 16, -1 }; > } >@@ -1006,4 +1006,137 @@ > deleteFile("/P/src/X.java"); > } > } >+public void test110172() throws CoreException { >+ try { >+ String source = >+ "/**\n" + >+ " * Class X javadoc \n" + >+ " */\n" + >+ "public class X {\n" + >+ " /**\n" + >+ " * Javadoc for initializer\n" + >+ " */\n" + >+ " static {\n" + >+ " }\n" + >+ " \n" + >+ " /**\n" + >+ " * Javadoc for field f \n" + >+ " */\n" + >+ " public int f;\n" + >+ " \n" + >+ " /**\n" + >+ " * Javadoc for method foo\n" + >+ " */\n" + >+ " public void foo(int i, long l, String s) {\n" + >+ " }\n" + >+ " \n" + >+ " /**\n" + >+ " * Javadoc for member type A\n" + >+ " */\n" + >+ " public class A {\n" + >+ " }\n" + >+ "\n" + >+ " /**\n" + >+ " * Javadoc for constructor X(int)\n" + >+ " */\n" + >+ " X(int i) {\n" + >+ " }\n" + >+ " \n" + >+ " /**\n" + >+ " * Javadoc for f3\n" + >+ " */\n" + >+ " /*\n" + >+ " * Not a javadoc comment\n" + >+ " */\n" + >+ " /**\n" + >+ " * Real javadoc for f3\n" + >+ " */\n" + >+ " public String f3;\n" + >+ " \n" + >+ " public int f2;\n" + >+ " \n" + >+ " public void foo2() {\n" + >+ " }\n" + >+ " \n" + >+ " public class B {\n" + >+ " }\n" + >+ "\n" + >+ " X() {\n" + >+ " }\n" + >+ " \n" + >+ " {\n" + >+ " }\n" + >+ "}"; >+ createFile("/P/src/X.java", source); >+ IType type = getCompilationUnit("/P/src/X.java").getType("X"); >+ IJavaElement[] members = type.getChildren(); >+ final int length = members.length; >+ assertEquals("Wrong number", 11, length); >+ for (int i = 0; i < length; i++) { >+ final IJavaElement element = members[i]; >+ assertTrue(element instanceof IMember); >+ final ISourceRange javadocRange = ((IMember) element).getJavadocRange(); >+ final String elementName = element.getElementName(); >+ if ("f".equals(elementName)) { >+ assertNotNull("No javadoc source range", javadocRange); >+ final int start = javadocRange.getOffset(); >+ final int end = javadocRange.getLength() + start - 1; >+ String javadocSource = source.substring(start, end); >+ assertTrue("Wrong javadoc", javadocSource.indexOf("field f") != -1); >+ } else if ("foo".equals(elementName)) { >+ assertNotNull("No javadoc source range", javadocRange); >+ final int start = javadocRange.getOffset(); >+ final int end = javadocRange.getLength() + start - 1; >+ String javadocSource = source.substring(start, end); >+ assertTrue("Wrong javadoc", javadocSource.indexOf("method foo") != -1); >+ } else if ("A".equals(elementName)) { >+ assertNotNull("No javadoc source range", javadocRange); >+ final int start = javadocRange.getOffset(); >+ final int end = javadocRange.getLength() + start - 1; >+ String javadocSource = source.substring(start, end); >+ assertTrue("Wrong javadoc", javadocSource.indexOf("member type A") != -1); >+ } else if ("X".equals(elementName)) { >+ // need treatment for the two constructors >+ assertTrue("Not an IMethod", element instanceof IMethod); >+ IMethod method = (IMethod) element; >+ switch(method.getNumberOfParameters()) { >+ case 0 : >+ assertNull("Has a javadoc source range", javadocRange); >+ break; >+ case 1: >+ assertNotNull("No javadoc source range", javadocRange); >+ final int start = javadocRange.getOffset(); >+ final int end = javadocRange.getLength() + start - 1; >+ String javadocSource = source.substring(start, end); >+ assertTrue("Wrong javadoc", javadocSource.indexOf("constructor") != -1); >+ } >+ } else if ("f3".equals(elementName)) { >+ assertNotNull("No javadoc source range", javadocRange); >+ final int start = javadocRange.getOffset(); >+ final int end = javadocRange.getLength() + start - 1; >+ String javadocSource = source.substring(start, end); >+ assertTrue("Wrong javadoc", javadocSource.indexOf("Real") != -1); >+ } else if ("f2".equals(elementName)) { >+ assertNull("Has a javadoc source range", javadocRange); >+ } else if ("foo2".equals(elementName)) { >+ assertNull("Has a javadoc source range", javadocRange); >+ } else if ("B".equals(elementName)) { >+ assertNull("Has a javadoc source range", javadocRange); >+ } else if (element instanceof IInitializer) { >+ IInitializer initializer = (IInitializer) element; >+ if (Flags.isStatic(initializer.getFlags())) { >+ assertNotNull("No javadoc source range", javadocRange); >+ final int start = javadocRange.getOffset(); >+ final int end = javadocRange.getLength() + start - 1; >+ String javadocSource = source.substring(start, end); >+ assertTrue("Wrong javadoc", javadocSource.indexOf("initializer") != -1); >+ } else { >+ assertNull("Has a javadoc source range", javadocRange); >+ } >+ } >+ } >+ } finally { >+ deleteFile("/P/src/X.java"); >+ } >+} > } >Index: src/org/eclipse/jdt/core/tests/model/AttachSourceTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachSourceTests.java,v >retrieving revision 1.36 >diff -u -r1.36 AttachSourceTests.java >--- src/org/eclipse/jdt/core/tests/model/AttachSourceTests.java 8 Jun 2005 09:03:20 -0000 1.36 >+++ src/org/eclipse/jdt/core/tests/model/AttachSourceTests.java 20 Oct 2005 19:32:46 -0000 >@@ -21,8 +21,6 @@ > import org.eclipse.core.runtime.Path; > import org.eclipse.jdt.core.*; > import org.eclipse.jdt.core.dom.*; >-import org.eclipse.jdt.core.dom.AST; >-import org.eclipse.jdt.core.dom.ASTNode; > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; > import org.eclipse.jdt.internal.core.JarPackageFragmentRoot; > import org.eclipse.jdt.internal.core.util.Util; >@@ -34,6 +32,15 @@ > * - don't hardcode positions > */ > public class AttachSourceTests extends ModifyingResourceTests { >+ static { >+// TESTS_NAMES = new String[] { "testRootPath13" }; >+// TESTS_NUMBERS = new int[] { 5 }; >+// TESTS_RANGE = new int[] { 169, 180 }; >+ } >+ >+ public static Test suite() { >+ return buildTestSuite(AttachSourceTests.class); >+ } > > /** @deprecated using deprecated code */ > private static final int AST_INTERNAL_JLS2 = AST.JLS2; >@@ -45,9 +52,6 @@ > public AttachSourceTests(String name) { > super(name); > } >-public static Test suite() { >- return new Suite(AttachSourceTests.class); >-} > public ASTNode runConversion(IClassFile classFile, boolean resolveBindings) { > ASTParser parser = ASTParser.newParser(AST_INTERNAL_JLS2); > parser.setSource(classFile); >@@ -868,5 +872,84 @@ > attachSource(root, null, null); // detach source > root.close(); > } >- >+/** >+ * http://bugs.eclipse.org/bugs/show_bug.cgi?id=110172 >+ */ >+public void testRootPath13() throws JavaModelException { >+ IJavaProject project = this.getJavaProject("/AttachSourceTests"); >+ IPackageFragmentRoot root = project.getPackageFragmentRoot(this.getFile("/AttachSourceTests/test6.jar")); >+ assertTrue("Root doesn't exist", root.exists()); >+ attachSource(root, "/AttachSourceTests/test6src.zip", null); >+ >+ try { >+ // check the javadoc source range in a class file >+ IClassFile cf = root.getPackageFragment("p1.p2").getClassFile("X.class"); >+ assertNotNull(cf); >+ final String source = cf.getSource(); >+ assertNotNull("No source", source); >+ IJavaElement[] children = cf.getChildren(); >+ assertEquals("Wrong number of children", 1, children.length); >+ IJavaElement element = children[0]; >+ assertTrue("Not a type", element instanceof IType); >+ IType type = (IType) element; >+ IJavaElement[] members = type.getChildren(); >+ final int length = members.length; >+ assertEquals("Wrong number", 9, length); >+ for (int i = 0; i < length; i++) { >+ element = members[i]; >+ assertTrue(element instanceof IMember); >+ final ISourceRange javadocRange = ((IMember) element).getJavadocRange(); >+ final String elementName = element.getElementName(); >+ if ("f".equals(elementName)) { >+ assertNotNull("No javadoc source range", javadocRange); >+ final int start = javadocRange.getOffset(); >+ final int end = javadocRange.getLength() + start - 1; >+ String javadocSource = source.substring(start, end); >+ assertTrue("Wrong javadoc", javadocSource.indexOf("field f") != -1); >+ } else if ("foo".equals(elementName)) { >+ assertNotNull("No javadoc source range", javadocRange); >+ final int start = javadocRange.getOffset(); >+ final int end = javadocRange.getLength() + start - 1; >+ String javadocSource = source.substring(start, end); >+ assertTrue("Wrong javadoc", javadocSource.indexOf("method foo") != -1); >+ } else if ("A".equals(elementName)) { >+ assertNotNull("No javadoc source range", javadocRange); >+ final int start = javadocRange.getOffset(); >+ final int end = javadocRange.getLength() + start - 1; >+ String javadocSource = source.substring(start, end); >+ assertTrue("Wrong javadoc", javadocSource.indexOf("member type A") != -1); >+ } else if ("X".equals(elementName)) { >+ // need treatment for the two constructors >+ assertTrue("Not an IMethod", element instanceof IMethod); >+ IMethod method = (IMethod) element; >+ switch(method.getNumberOfParameters()) { >+ case 0 : >+ assertNull("Has a javadoc source range", javadocRange); >+ break; >+ case 1: >+ assertNotNull("No javadoc source range", javadocRange); >+ final int start = javadocRange.getOffset(); >+ final int end = javadocRange.getLength() + start - 1; >+ String javadocSource = source.substring(start, end); >+ assertTrue("Wrong javadoc", javadocSource.indexOf("constructor") != -1); >+ } >+ } else if ("f3".equals(elementName)) { >+ assertNotNull("No javadoc source range", javadocRange); >+ final int start = javadocRange.getOffset(); >+ final int end = javadocRange.getLength() + start - 1; >+ String javadocSource = source.substring(start, end); >+ assertTrue("Wrong javadoc", javadocSource.indexOf("Real") != -1); >+ } else if ("f2".equals(elementName)) { >+ assertNull("Has a javadoc source range", javadocRange); >+ } else if ("foo2".equals(elementName)) { >+ assertNull("Has a javadoc source range", javadocRange); >+ } else if ("B".equals(elementName)) { >+ assertNull("Has a javadoc source range", javadocRange); >+ } >+ } >+ } finally { >+ attachSource(root, null, null); // detach source >+ root.close(); >+ } >+} > } >Index: workspace/AttachSourceTests/test6src.zip >=================================================================== >RCS file: workspace/AttachSourceTests/test6src.zip >diff -N workspace/AttachSourceTests/test6src.zip >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/AttachSourceTests/test6src.zip 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,13 @@ >+PK >+¨nT3p1/PK >+¨nT3p1/p2/PK >+¨pT3??Dt p1/p2/X.java 1o0 g?ünLPTT2fJ»uèÐ.¬c§n >+gÁ%R[õ¿×¨Q%?Nw÷½{<¼Tò¤Áßßùj'rE!r(àÑɾÞåEQAl"÷ç³ >+O¿E >+D?'^5Ø?m-Yéìîa@³$62?á?}f°±ÚÁÀ8(µ-?Ù?ìgMoPÄtÑÚ¡¿vÛ¸ >+¼RgCÕ¯§¾nh7Ý}z >+û¥üÈþ*rKCaÛSwVê:ZY'¡ztö¿³MLÉãg$?éW)lÝÒd×^´tik!ÅßÁq-§< >+¾÷®V«çY @êùáùPK >+¨nT3íAp1/PK >+¨nT3íA!p1/p2/PK >+¨pT3??Dt ¤?Ep1/p2/X.javaPKw >Index: workspace/AttachSourceTests/test6.jar >=================================================================== >RCS file: workspace/AttachSourceTests/test6.jar >diff -N workspace/AttachSourceTests/test6.jar >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/AttachSourceTests/test6.jar 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,26 @@ >+PK >+rqT3 META-INF/þÊPK >+qqT3òC¿^jMETA-INF/MANIFEST.MFóMÌËLK-.Ñ >+K-*ÎÌϳR0Ô3àårÌCq,HLÎHU%ÍôLy¹RKRSt?*AêMôâ >+,u4Kó|3ò+KRs<óõ4y¹x¹PK >+CoT3p1/PK >+CoT3p1/p2/PK >+qT3!qp1/p2/X$A.class=?MKÃ@ßibbÓøU¿õ$ôÐVhT¼)B)BÐC%ôºÝnJ >+þ,"xðø£ÄÙÊÂ̼³ïì>óû÷ý` >+Bsq,®IgèÂ&lÏÄR¡_§x&àSUt.ØÖÞ®ÇïºÊR%l¸UZw¿»rô"=Ê^¤¾?ul¬n/j°åc >+çPiù¸Ç2q* í0KD\]7m@h +TðÆÙ2Oä½2g20ÜLð µÌG©( >+Y¸8"¸õ?8ãÏ-^÷4] ÒÄÍcu?Àë¡Õ?ÿÄæ«Ï N±ÃѯjmìV÷{UÜÇAÕ5oâôPK >+qT3zgåqp1/p2/X$B.class=?MKÃ@ßIbbÓøU¿½ =´o!è¡zÝÄÅnIIRÁåAþ8»²03ïì;»Ïüþ}ÿâÄEh-.ÂÅe8í<8í¹xa&òð1Ë´&¸õLUÝs¶F?÷ëÉ{^ÏdR6ܨ\Õ· ·rôc3.¥Aulì^?n?°` >+.çHåòaùÈòI$$t¢"Y,J¥uÓt4¡PÀË2wJ;ÜéPs3Á}Ërª#×hSþÜæåyOMÀÙ&&Ôh>«+X|ð öàì¬,?Ñ?©}t°kî÷LÜÇ?éê7qúPK >+qT3êVr} >+p1/p2/X.classuPÉNÂP=?©Rë, ÎÓ5¡8$BbRBt¡!l©)ÕÿreâÂð£ç=¨;{îÉýø|{Pƶö¸o>V̶Àô½ýlíß?{§ ÍHôª³ÍÀUºþíT½ (¬ÆoÈNK Un?©¦ë;O'¼¶;#)®íµìÐuÜLEwn_ ÛÅñpiAã,sìúntJlÉÚiéHbÁ@EJ)©D]úUðv?sWÒfÚe)NÀ°|ß ëÝï;} >+k<_Ú>#ýÍV?6@j>.ÉF1³ªN1Ó1No°²hi9}¡K`>Ã?Ç$ý.áru >+ÓÊfâ99nÈl$.Çí £¥w_Qø¡ÖUsàME¾éÓ1½À"1Õ:ñ¢0b5CÜ÷bUý£áGXR~+³ÌV9_§ÉÏnA|PK >+rqT3 íAMETA-INF/þÊPK >+qqT3òC¿^j¤?+META-INF/MANIFEST.MFPK >+CoT3íA»p1/PK >+CoT3íAÜp1/p2/PK >+qT3!q¤?p1/p2/X$A.classPK >+qT3zgåq¤?@p1/p2/X$B.classPK >+qT3êVr} >+¤?p1/p2/X.classPK'
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 110172
:
27701
|
28542
| 28544