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 / +1 lines)
Lines 453-459 Link Here
453
		assertEqualString(preview, buf.toString());
453
		assertEqualString(preview, buf.toString());
454
	}
454
	}
455
	
455
	
456
	/* not yet working
457
	public void testBug128422() throws Exception {
456
	public void testBug128422() throws Exception {
458
		
457
		
459
		IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null);
458
		IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null);
Lines 495-501 Link Here
495
		buf.append("  }\n");	
494
		buf.append("  }\n");	
496
		buf.append("}\n");	
495
		buf.append("}\n");	
497
		assertEqualString(preview, buf.toString());
496
		assertEqualString(preview, buf.toString());
498
	}*/
497
	}
499
	
498
	
500
	public void testCommentAtEnd() throws Exception {
499
	public void testCommentAtEnd() throws Exception {
501
		
500
		
(-)dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteAnalyzer.java (+11 lines)
Lines 1061-1066 Link Here
1061
					TextEdit sourceEdit= getCopySourceEdit(copySource);
1061
					TextEdit sourceEdit= getCopySourceEdit(copySource);
1062
					doTextCopy(sourceEdit, insertOffset, srcIndentLevel, destIndentString, editGroup);
1062
					doTextCopy(sourceEdit, insertOffset, srcIndentLevel, destIndentString, editGroup);
1063
					currPos= offset + curr.length; // continue to insert after the replaced string
1063
					currPos= offset + curr.length; // continue to insert after the replaced string
1064
					if (needsNewLineForLineComment(copySource.getNode(), formatted, currPos)) {
1065
						doTextInsert(insertOffset, getLineDelimiter(), editGroup);
1066
					}
1064
				} else if (data instanceof StringPlaceholderData) { // replace with a placeholder
1067
				} else if (data instanceof StringPlaceholderData) { // replace with a placeholder
1065
					String code= ((StringPlaceholderData) data).code;
1068
					String code= ((StringPlaceholderData) data).code;
1066
					String str= this.formatter.changeIndent(code, 0, destIndentString); 
1069
					String str= this.formatter.changeIndent(code, 0, destIndentString); 
Lines 1076-1081 Link Here
1076
		}
1079
		}
1077
	}
1080
	}
1078
	
1081
	
1082
	private boolean needsNewLineForLineComment(ASTNode node, String formatted, int offset) {
1083
		if (!this.lineCommentEndOffsets.isEndOfLineComment(getExtendedEnd(node), this.content)) {
1084
			return false;
1085
		}
1086
		// copied code ends with a line comment, but doesn't contain the new line
1087
		return offset < formatted.length() && !IndentManipulation.isLineDelimiterChar(formatted.charAt(offset));
1088
	}
1089
	
1079
	private String getCurrentLine(String str, int pos) {
1090
	private String getCurrentLine(String str, int pos) {
1080
		for (int i= pos - 1; i>= 0; i--) {
1091
		for (int i= pos - 1; i>= 0; i--) {
1081
			char ch= str.charAt(i);
1092
			char ch= str.charAt(i);

Return to bug 143026