View | Details | Raw Unified | Return to bug 143026 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/rewrite/describing/LineCommentOffsetsTest.java (-2 / +57 lines)
Lines 11-16 Link Here
11
package org.eclipse.jdt.core.tests.rewrite.describing;
11
package org.eclipse.jdt.core.tests.rewrite.describing;
12
12
13
import java.util.HashSet;
13
import java.util.HashSet;
14
import java.util.List;
14
15
15
import junit.framework.Test;
16
import junit.framework.Test;
16
import junit.framework.TestSuite;
17
import junit.framework.TestSuite;
Lines 453-459 Link Here
453
		assertEqualString(preview, buf.toString());
454
		assertEqualString(preview, buf.toString());
454
	}
455
	}
455
	
456
	
456
	/* not yet working
457
	public void testBug128422() throws Exception {
457
	public void testBug128422() throws Exception {
458
		
458
		
459
		IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null);
459
		IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null);
Lines 495-501 Link Here
495
		buf.append("  }\n");	
495
		buf.append("  }\n");	
496
		buf.append("}\n");	
496
		buf.append("}\n");	
497
		assertEqualString(preview, buf.toString());
497
		assertEqualString(preview, buf.toString());
498
	}*/
498
	}
499
	
500
	public void testBug128422b() throws Exception {
501
		
502
		IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null);
503
		StringBuffer buf= new StringBuffer();
504
		buf.append("package test1;\n");
505
		buf.append("public class E {\n");
506
		buf.append("  void foo() {\n");
507
		buf.append("    foo(); //comment\n");
508
		buf.append("    foo();\n");
509
		buf.append("  }\n");	
510
		buf.append("}\n");	
511
		ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
512
		
513
		CompilationUnit astRoot= createAST3(cu);
514
		ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST());
515
		
516
		AST ast= astRoot.getAST();
517
		
518
		assertTrue("Parse errors", (astRoot.getFlags() & ASTNode.MALFORMED) == 0);
519
		TypeDeclaration type= findTypeDeclaration(astRoot, "E");
520
		MethodDeclaration method= (MethodDeclaration) type.bodyDeclarations().get(0);
521
		List statements= method.getBody().statements();
522
		ASTNode copy= rewrite.createCopyTarget((ASTNode) statements.get(0));
523
		
524
		Block newBlock= ast.newBlock();
525
		newBlock.statements().add(newStatement(ast));
526
		newBlock.statements().add(copy);
527
		newBlock.statements().add(newStatement(ast));
528
		
529
		rewrite.getListRewrite(method.getBody(), Block.STATEMENTS_PROPERTY).insertLast(newBlock, null);
530
531
		String preview= evaluateRewrite(cu, rewrite);
532
		
533
		buf= new StringBuffer();
534
		buf.append("package test1;\n");
535
		buf.append("public class E {\n");
536
		buf.append("  void foo() {\n");
537
		buf.append("    foo(); //comment\n");
538
		buf.append("    foo();\n");
539
		buf.append("    {\n");
540
		buf.append("        bar();\n");
541
		buf.append("        foo(); //comment\n");
542
		buf.append("        bar();\n");
543
		buf.append("    }\n");
544
		buf.append("  }\n");	
545
		buf.append("}\n");	
546
		assertEqualString(preview, buf.toString());
547
	}
548
	
549
	private Statement newStatement(AST ast) {
550
		MethodInvocation inv= ast.newMethodInvocation();
551
		inv.setName(ast.newSimpleName("bar"));
552
		return ast.newExpressionStatement(inv);
553
	}
499
	
554
	
500
	public void testCommentAtEnd() throws Exception {
555
	public void testCommentAtEnd() throws Exception {
501
		
556
		

Return to bug 143026