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

(-)formatter/org/eclipse/jdt/internal/formatter/Scribe.java (-4 / +5 lines)
Lines 1798-1812 Link Here
1798
    		// Append next token inserting a new line if max line is reached
1798
    		// Append next token inserting a new line if max line is reached
1799
			if (lineHasTokens && !firstWord && lastColumn > maxColumn) {
1799
			if (lineHasTokens && !firstWord && lastColumn > maxColumn) {
1800
		    	String tokensString = tokensBuffer.toString().trim();
1800
		    	String tokensString = tokensBuffer.toString().trim();
1801
		    	int tokensStringLength = tokensString.length();
1801
				// not enough space on the line
1802
				// not enough space on the line
1802
				if (hasTextOnFirstLine == 1) {
1803
				if (hasTextOnFirstLine == 1) {
1803
					printBlockCommentHeaderLine(buffer);
1804
					printBlockCommentHeaderLine(buffer);
1804
				}
1805
				}
1805
				if ((this.indentationLevel+tokensString.length()+tokenLength) > maxColumn) {
1806
				if ((this.indentationLevel+tokensStringLength+tokenLength) > maxColumn) {
1806
					// there won't be enough room even if we break the line before the buffered tokens
1807
					// there won't be enough room even if we break the line before the buffered tokens
1807
					// So add the buffered tokens now
1808
					// So add the buffered tokens now
1808
					buffer.append(tokensString);
1809
					buffer.append(tokensBuffer);
1809
					this.column += tokensString.length();
1810
					this.column += tokensBuffer.length();
1810
					tokensBuffer.setLength(0);
1811
					tokensBuffer.setLength(0);
1811
					bufferHasNewLine = false;
1812
					bufferHasNewLine = false;
1812
					bufferHasTokens = true;
1813
					bufferHasTokens = true;
Lines 1820-1826 Link Here
1820
				}
1821
				}
1821
		    	if (tokensBuffer.length() > 0) {
1822
		    	if (tokensBuffer.length() > 0) {
1822
					buffer.append(tokensString);
1823
					buffer.append(tokensString);
1823
					this.column += tokensString.length();
1824
					this.column += tokensStringLength;
1824
					tokensBuffer.setLength(0);
1825
					tokensBuffer.setLength(0);
1825
		    	}
1826
		    	}
1826
				buffer.append(this.scanner.source, tokenStart, tokenLength);
1827
				buffer.append(this.scanner.source, tokenStart, tokenLength);
(-)src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java (+45 lines)
Lines 3531-3534 Link Here
3531
		"}\n"
3531
		"}\n"
3532
	);
3532
	);
3533
}
3533
}
3534
3535
/**
3536
 * @bug 297546: [formatter] Formatter removes blank after @see if reference is wrapped
3537
 * @test Verify that space after the @see tag is not removed while formatting
3538
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=297546"
3539
 */
3540
public void testBug297546() {
3541
	String source = 
3542
		"package org.eclipse.jdt.core;\n" + 
3543
		"public class TestClass implements TestInterface {\n" + 
3544
		"\n" + 
3545
		"	/* (non-Javadoc)\n" + 
3546
		"	 * @see org.eclipse.jdt.core.TestInterface#testMethod(org.eclipse.jdt.core.TestInterface)\n" + 
3547
		"	 */\n" + 
3548
		"	public void testMethod(TestInterface aLongNameForAParam) {\n" + 
3549
		"		// do nothing\n" + 
3550
		"	}\n" + 
3551
		"\n" + 
3552
		"	\n" + 
3553
		"}\n" + 
3554
		"interface TestInterface {\n" + 
3555
		"	void testMethod(TestInterface aLongNameForAParam);\n" + 
3556
		"}\n";
3557
	formatSource(source,
3558
		"package org.eclipse.jdt.core;\n" + 
3559
		"\n" + 
3560
		"public class TestClass implements TestInterface {\n" + 
3561
		"\n" + 
3562
		"	/*\n" + 
3563
		"	 * (non-Javadoc)\n" + 
3564
		"	 * \n" + 
3565
		"	 * @see org.eclipse.jdt.core.TestInterface#testMethod(org.eclipse.jdt.core.\n" + 
3566
		"	 * TestInterface)\n" + 
3567
		"	 */\n" + 
3568
		"	public void testMethod(TestInterface aLongNameForAParam) {\n" + 
3569
		"		// do nothing\n" + 
3570
		"	}\n" + 
3571
		"\n" + 
3572
		"}\n" + 
3573
		"\n" + 
3574
		"interface TestInterface {\n" + 
3575
		"	void testMethod(TestInterface aLongNameForAParam);\n" + 
3576
		"}\n"
3577
	);
3578
}
3534
}
3579
}

Return to bug 297546