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

(-)formatter/org/eclipse/jdt/internal/formatter/Scribe.java (+6 lines)
Lines 2379-2384 Link Here
2379
					case TerminalTokens.TokenNameCOMMENT_JAVADOC :
2379
					case TerminalTokens.TokenNameCOMMENT_JAVADOC :
2380
						if (this.editsEnabled && foundTaskCount > previousFoundTaskCount) {
2380
						if (this.editsEnabled && foundTaskCount > previousFoundTaskCount) {
2381
							setEditsEnabled(foundTaskCount, previousFoundTaskCount);
2381
							setEditsEnabled(foundTaskCount, previousFoundTaskCount);
2382
							if (!this.editsEnabled && this.editsIndex > 1) {
2383
								OptimizedReplaceEdit currentEdit = this.edits[this.editsIndex-1];
2384
								if (this.scanner.startPosition == currentEdit.offset+currentEdit.length) {
2385
									printNewLinesBeforeDisablingComment();
2386
								}
2387
							}
2382
							previousFoundTaskCount = foundTaskCount;
2388
							previousFoundTaskCount = foundTaskCount;
2383
						}
2389
						}
2384
						if (trailing > NO_TRAILING_COMMENT) {
2390
						if (trailing > NO_TRAILING_COMMENT) {
(-)src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java (+42 lines)
Lines 14-19 Link Here
14
import org.eclipse.core.runtime.Path;
14
import org.eclipse.core.runtime.Path;
15
import org.eclipse.jdt.core.JavaModelException;
15
import org.eclipse.jdt.core.JavaModelException;
16
import org.eclipse.jdt.core.formatter.CodeFormatter;
16
import org.eclipse.jdt.core.formatter.CodeFormatter;
17
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
17
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
18
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
18
import org.eclipse.jdt.internal.formatter.DefaultCodeFormatterOptions;
19
import org.eclipse.jdt.internal.formatter.DefaultCodeFormatterOptions;
19
20
Lines 6239-6242 Link Here
6239
	    "}\n");
6240
	    "}\n");
6240
}
6241
}
6241
6242
6243
/**
6244
 * @bug 305281: [formatter] Turning off formatting changes comment's formatting
6245
 * @test Verify that turning off formatting in a javadoc does not screw up its indentation
6246
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=305281"
6247
 */
6248
public void testBug305281() {
6249
	this.formatterPrefs = null;
6250
	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_DISABLING_TAG, "format: OFF");
6251
	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_ENABLING_TAG, "format: ON");
6252
	String source = 
6253
		"public class test {\n" + 
6254
		"\n" + 
6255
		"    /**\n" + 
6256
		"     * @param args\n" + 
6257
		"     * format: OFF\n" + 
6258
		"     */\n" + 
6259
		"    public static void main(String[] args) {\n" + 
6260
		"        do {\n" + 
6261
		"            } while (false);\n" + 
6262
		"        for (;;) {\n" + 
6263
		"        }\n" + 
6264
		"        // format: ON\n" + 
6265
		"    }\n" + 
6266
	    "}\n";
6267
	formatSource(source,
6268
		"public class test {\n" + 
6269
		"\n" + 
6270
		"	/**\n" + 
6271
		"     * @param args\n" + 
6272
		"     * format: OFF\n" + 
6273
		"     */\n" + 
6274
		"    public static void main(String[] args) {\n" + 
6275
		"        do {\n" + 
6276
		"            } while (false);\n" + 
6277
		"        for (;;) {\n" + 
6278
		"        }\n" + 
6279
		"        // format: ON\n" + 
6280
		"	}\n" + 
6281
	    "}\n");
6282
}
6283
6242
}
6284
}

Return to bug 305281