Lines 113-128
Link Here
|
113 |
// Run test cases subset |
113 |
// Run test cases subset |
114 |
COPY_DIR = false; |
114 |
COPY_DIR = false; |
115 |
System.err.println("WARNING: only subset of tests will be executed!!!"); |
115 |
System.err.println("WARNING: only subset of tests will be executed!!!"); |
116 |
suite.addTest(new ASTConverterJavadocTest("testBug93880_15a")); |
116 |
suite.addTest(new ASTConverterJavadocTest("testBug100041")); |
117 |
suite.addTest(new ASTConverterJavadocTest("testBug93880_15b")); |
|
|
118 |
suite.addTest(new ASTConverterJavadocTest("testBug93880_15c")); |
119 |
suite.addTest(new ASTConverterJavadocTest("testBug93880_15d")); |
120 |
suite.addTest(new ASTConverterJavadocTest("testBug93880_15e")); |
121 |
suite.addTest(new ASTConverterJavadocTest("testBug93880_14a")); |
122 |
suite.addTest(new ASTConverterJavadocTest("testBug93880_14b")); |
123 |
suite.addTest(new ASTConverterJavadocTest("testBug93880_14c")); |
124 |
suite.addTest(new ASTConverterJavadocTest("testBug93880_14d")); |
125 |
suite.addTest(new ASTConverterJavadocTest("testBug93880_14e")); |
126 |
return suite; |
117 |
return suite; |
127 |
} |
118 |
} |
128 |
|
119 |
|
Lines 2822-2826
Link Here
|
2822 |
parser.setSource(source.toCharArray()); |
2813 |
parser.setSource(source.toCharArray()); |
2823 |
parser.createAST(null); |
2814 |
parser.createAST(null); |
2824 |
} |
2815 |
} |
2825 |
|
2816 |
|
|
|
2817 |
/** |
2818 |
* Bug 100041: [javadoc] Infinit loop in DocCommentParser |
2819 |
* @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=100041" |
2820 |
*/ |
2821 |
public void testBug100041() throws JavaModelException { |
2822 |
workingCopies = new ICompilationUnit[1]; |
2823 |
workingCopies[0] = getWorkingCopy("/Converter15/src/javadoc/b100041/X.java", |
2824 |
"package javadoc.b100041;\n" + |
2825 |
"class X {\n" + |
2826 |
" static Object object;\n" + |
2827 |
" static void foo() {\n" + |
2828 |
" /**\n" + |
2829 |
" * javadoc comment.\n" + |
2830 |
" */\n" + |
2831 |
" if (object instanceof String) {\n" + |
2832 |
" final String clr = null;\n" + |
2833 |
" }\n" + |
2834 |
" }\n" + |
2835 |
"}" |
2836 |
); |
2837 |
CompilationUnit compilUnit = verifyComments(workingCopies[0]); |
2838 |
if (docCommentSupport.equals(JavaCore.ENABLED)) { |
2839 |
// Get comment |
2840 |
List unitComments = compilUnit.getCommentList(); |
2841 |
assertEquals("Wrong number of comments", 1, unitComments.size()); |
2842 |
Comment comment = (Comment) unitComments.get(0); |
2843 |
int commentStart = comment.getStartPosition(); |
2844 |
int commentEnd = commentStart+comment.getLength(); |
2845 |
|
2846 |
// Get local variable declaration |
2847 |
ASTNode node = getASTNode(compilUnit, 0, 1, 0); |
2848 |
assertEquals("Expected if statement for node: "+node, ASTNode.IF_STATEMENT, node.getNodeType()); |
2849 |
IfStatement ifStatement = (IfStatement) node; |
2850 |
assertTrue("Invalid start position for IfStatement: "+ifStatement, ifStatement.getStartPosition() > commentEnd); |
2851 |
Statement statement = ifStatement.getThenStatement(); |
2852 |
assertEquals("Expected block for node: "+statement, ASTNode.BLOCK, statement.getNodeType()); |
2853 |
Block block = (Block) statement; |
2854 |
assertTrue("Invalid start position for Block: "+block, block.getStartPosition() > commentEnd); |
2855 |
List statements = block.statements(); |
2856 |
assertEquals("Invalid number of statements for block: "+block, 1, statements.size()); |
2857 |
statement = (Statement) statements.get(0); |
2858 |
assertEquals("Expected variable declaration statement for node: "+statement, ASTNode.VARIABLE_DECLARATION_STATEMENT, statement.getNodeType()); |
2859 |
VariableDeclarationStatement varDecl = (VariableDeclarationStatement) statement; |
2860 |
assertTrue("Invalid start position for : VariableDeclarationStatement"+varDecl, varDecl.getStartPosition() > commentEnd); |
2861 |
} |
2862 |
} |
2863 |
public void testBug100041b() throws JavaModelException { |
2864 |
workingCopies = new ICompilationUnit[1]; |
2865 |
workingCopies[0] = getWorkingCopy("/Converter15/src/javadoc/b100041/X.java", |
2866 |
"package javadoc.b100041;\n" + |
2867 |
"class X {\n" + |
2868 |
" static Object object;\n" + |
2869 |
" static void foo() {\n" + |
2870 |
" /**\n" + |
2871 |
" * javadoc comment.\n" + |
2872 |
" */\n" + |
2873 |
" if (object instanceof String)\n" + |
2874 |
" return;\n" + |
2875 |
" }\n" + |
2876 |
"}" |
2877 |
); |
2878 |
CompilationUnit compilUnit = verifyComments(workingCopies[0]); |
2879 |
if (docCommentSupport.equals(JavaCore.ENABLED)) { |
2880 |
// Get comment |
2881 |
List unitComments = compilUnit.getCommentList(); |
2882 |
assertEquals("Wrong number of comments", 1, unitComments.size()); |
2883 |
Comment comment = (Comment) unitComments.get(0); |
2884 |
int commentStart = comment.getStartPosition(); |
2885 |
int commentEnd = commentStart+comment.getLength(); |
2886 |
|
2887 |
// Get local variable declaration |
2888 |
ASTNode node = getASTNode(compilUnit, 0, 1, 0); |
2889 |
assertEquals("Expected if statement for node: "+node, ASTNode.IF_STATEMENT, node.getNodeType()); |
2890 |
IfStatement ifStatement = (IfStatement) node; |
2891 |
assertTrue("Invalid start position for IfStatement: "+ifStatement, ifStatement.getStartPosition() > commentEnd); |
2892 |
Statement statement = ifStatement.getThenStatement(); |
2893 |
assertEquals("Expected block for node: "+statement, ASTNode.RETURN_STATEMENT, statement.getNodeType()); |
2894 |
ReturnStatement returnStatement = (ReturnStatement) statement; |
2895 |
assertTrue("Invalid start position for Block: "+returnStatement, returnStatement.getStartPosition() > commentEnd); |
2896 |
} |
2897 |
} |
2898 |
public void testBug100041c() throws JavaModelException { |
2899 |
workingCopies = new ICompilationUnit[1]; |
2900 |
workingCopies[0] = getWorkingCopy("/Converter15/src/javadoc/b100041/Z.java", |
2901 |
"package javadoc.b100041;\n" + |
2902 |
"public class Z {\n" + |
2903 |
" /** C1 */\n" + |
2904 |
" class Z1 {}\n" + |
2905 |
" /** C2 */\n" + |
2906 |
" Z1 z1;\n" + |
2907 |
" /** C3 */\n" + |
2908 |
" public static void foo(Object object) {\n" + |
2909 |
" /** C4 */\n" + |
2910 |
" class ZZ {\n" + |
2911 |
" /** C5 */\n" + |
2912 |
" ZZ zz;\n" + |
2913 |
" /** C6 */\n" + |
2914 |
" public void bar() {}\n" + |
2915 |
" }\n" + |
2916 |
" }\n" + |
2917 |
"}\n" |
2918 |
); |
2919 |
CompilationUnit compilUnit = verifyComments(workingCopies[0]); |
2920 |
if (docCommentSupport.equals(JavaCore.ENABLED)) { |
2921 |
// Get comments |
2922 |
List unitComments = compilUnit.getCommentList(); |
2923 |
int size = unitComments.size(); |
2924 |
assertEquals("Wrong number of comments", 6, size); |
2925 |
Javadoc[] javadocs = new Javadoc[size]; |
2926 |
Iterator iterator = unitComments.iterator(); |
2927 |
for (int i=0; i<size; i++) { |
2928 |
Comment comment = (Comment) iterator.next(); |
2929 |
assertEquals("Expect javadoc for comment: "+comment, ASTNode.JAVADOC, comment.getNodeType()); |
2930 |
javadocs[i] = (Javadoc) comment; |
2931 |
} |
2932 |
|
2933 |
// Verify member type declaration start |
2934 |
ASTNode node = getASTNode(compilUnit, 0, 0); |
2935 |
assertEquals("Expected type declaration for node: "+node, ASTNode.TYPE_DECLARATION, node.getNodeType()); |
2936 |
TypeDeclaration typeDeclaration = (TypeDeclaration) node; |
2937 |
int javadocStart = javadocs[0].getStartPosition(); |
2938 |
assertEquals("Invalid start position for TypeDeclaration: "+typeDeclaration, typeDeclaration.getStartPosition(), javadocStart); |
2939 |
|
2940 |
// Verify field declaration start |
2941 |
node = getASTNode(compilUnit, 0, 1); |
2942 |
assertEquals("Expected field declaration for node: "+node, ASTNode.FIELD_DECLARATION, node.getNodeType()); |
2943 |
FieldDeclaration fieldDeclaration = (FieldDeclaration) node; |
2944 |
javadocStart = javadocs[1].getStartPosition(); |
2945 |
assertEquals("Invalid start position for FieldDeclaration: "+fieldDeclaration, fieldDeclaration.getStartPosition(), javadocStart); |
2946 |
|
2947 |
// Verify method declaration start |
2948 |
node = getASTNode(compilUnit, 0, 2); |
2949 |
assertEquals("Expected method declaration for node: "+node, ASTNode.METHOD_DECLARATION, node.getNodeType()); |
2950 |
MethodDeclaration methodDeclaration = (MethodDeclaration) node; |
2951 |
javadocStart = javadocs[2].getStartPosition(); |
2952 |
assertEquals("Invalid start position for MethodDeclaration: "+methodDeclaration, methodDeclaration.getStartPosition(), javadocStart); |
2953 |
|
2954 |
// Verify local type declaration start |
2955 |
node = getASTNode(compilUnit, 0, 2, 0); |
2956 |
assertEquals("Expected type declaration for node: "+node, ASTNode.TYPE_DECLARATION_STATEMENT, node.getNodeType()); |
2957 |
typeDeclaration = (TypeDeclaration) ((TypeDeclarationStatement) node).getDeclaration(); |
2958 |
javadocStart = javadocs[3].getStartPosition(); |
2959 |
assertEquals("Invalid start position for TypeDeclaration: "+typeDeclaration, typeDeclaration.getStartPosition(), javadocStart); |
2960 |
|
2961 |
// Verify field declaration start |
2962 |
List bodyDeclarations = typeDeclaration.bodyDeclarations(); |
2963 |
node = (ASTNode) bodyDeclarations.get(0); |
2964 |
assertEquals("Expected field declaration for node: "+node, ASTNode.FIELD_DECLARATION, node.getNodeType()); |
2965 |
fieldDeclaration = (FieldDeclaration) node; |
2966 |
javadocStart = javadocs[4].getStartPosition(); |
2967 |
assertEquals("Invalid start position for FieldDeclaration: "+fieldDeclaration, fieldDeclaration.getStartPosition(), javadocStart); |
2968 |
|
2969 |
// Verify method declaration start |
2970 |
node = (ASTNode) bodyDeclarations.get(1); |
2971 |
assertEquals("Expected method declaration for node: "+node, ASTNode.METHOD_DECLARATION, node.getNodeType()); |
2972 |
methodDeclaration = (MethodDeclaration) node; |
2973 |
javadocStart = javadocs[5].getStartPosition(); |
2974 |
assertEquals("Invalid start position for MethodDeclaration: "+methodDeclaration, methodDeclaration.getStartPosition(), javadocStart); |
2975 |
} |
2976 |
} |
2826 |
} |
2977 |
} |