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

(-)src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java (-1 / +304 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 3125-3128 Link Here
3125
		"}\n"
3125
		"}\n"
3126
	);
3126
	);
3127
}
3127
}
3128
3129
/**
3130
 * @bug 254998: [formatter] wrong type comment format during code generation
3131
 * @test Ensure that the comment formatter works well on the given test case
3132
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=254998"
3133
 */
3134
public void testBug254998() throws JavaModelException {
3135
	this.formatterPrefs.comment_format_javadoc_comment = false;
3136
	this.formatterPrefs.comment_format_block_comment = false;
3137
	this.formatterPrefs.comment_format_line_comment = false;
3138
	this.formatterPrefs.comment_format_header = true;
3139
	String source = 
3140
		"/**\n" + 
3141
		" * Test for\n" + 
3142
		" * bug 254998\n" + 
3143
		" */\n" + 
3144
		"package javadoc;\n" + 
3145
		"\n" + 
3146
		"/**\n" + 
3147
		" * Test for\n" + 
3148
		" * bug 254998\n" + 
3149
		" */\n" + 
3150
		"public class Test {\n" + 
3151
		"\n" + 
3152
		"}\n";
3153
	formatSource(source,
3154
		"/**\n" + 
3155
		" * Test for bug 254998\n" + 
3156
		" */\n" + 
3157
		"package javadoc;\n" + 
3158
		"\n" + 
3159
		"/**\n" + 
3160
		" * Test for\n" + 
3161
		" * bug 254998\n" + 
3162
		" */\n" + 
3163
		"public class Test {\n" + 
3164
		"\n" + 
3165
		"}\n"
3166
	);
3167
}
3168
public void testBug254998b() throws JavaModelException {
3169
	this.formatterPrefs.comment_format_javadoc_comment = false;
3170
	this.formatterPrefs.comment_format_block_comment = false;
3171
	this.formatterPrefs.comment_format_line_comment = false;
3172
	this.formatterPrefs.comment_format_header = true;
3173
	String source = 
3174
		"/*\n" + 
3175
		" * Test for\n" + 
3176
		" * bug 254998\n" + 
3177
		" */\n" + 
3178
		"package block;\n" + 
3179
		"\n" + 
3180
		"/*\n" + 
3181
		" * Test for\n" + 
3182
		" * bug 254998\n" + 
3183
		" */\n" + 
3184
		"public class Test {\n" + 
3185
		"/*\n" + 
3186
		" * Test for\n" + 
3187
		" * bug 254998\n" + 
3188
		" */\n" + 
3189
		"}\n";
3190
	formatSource(source,
3191
		"/*\n" + 
3192
		" * Test for bug 254998\n" + 
3193
		" */\n" + 
3194
		"package block;\n" + 
3195
		"\n" + 
3196
		"/*\n" + 
3197
		" * Test for bug 254998\n" + 
3198
		" */\n" + 
3199
		"public class Test {\n" + 
3200
		"	/*\n" + 
3201
		"	 * Test for\n" + 
3202
		"	 * bug 254998\n" + 
3203
		"	 */\n" + 
3204
		"}\n"
3205
	);
3206
}
3207
public void testBug254998c() throws JavaModelException {
3208
	this.formatterPrefs.comment_format_javadoc_comment = false;
3209
	this.formatterPrefs.comment_format_block_comment = false;
3210
	this.formatterPrefs.comment_format_line_comment = false;
3211
	this.formatterPrefs.comment_format_header = true;
3212
	String source = 
3213
		"//		Test		for		bug		254998\n" + 
3214
		"package line;\n" + 
3215
		"\n" + 
3216
		"//		Test		for		bug		254998\n" + 
3217
		"public class Test {\n" + 
3218
		"//		Test		for		bug		254998\n" + 
3219
		"}\n";
3220
	formatSource(source,
3221
		"// Test for bug 254998\n" + 
3222
		"package line;\n" + 
3223
		"\n" + 
3224
		"// Test for bug 254998\n" + 
3225
		"public class Test {\n" + 
3226
		"	//		Test		for		bug		254998\n" + 
3227
		"}\n"
3228
	);
3229
}
3230
3231
/**
3232
 * @bug 260274: [formatter] * character is removed while formatting block comments
3233
 * @test Ensure that the comment formatter keep '*' characters while formatting block comments
3234
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=260274"
3235
 */
3236
public void testBug260274() throws JavaModelException {
3237
	String source = 
3238
		"class X {\n" + 
3239
		"/*\n" + 
3240
		" * The formatter should NOT remove * character\n" + 
3241
		" * in block comments!\n" + 
3242
		" */\n" + 
3243
		"}\n";
3244
	formatSource(source,
3245
		"class X {\n" + 
3246
		"	/*\n" + 
3247
		"	 * The formatter should NOT remove * character in block comments!\n" + 
3248
		"	 */\n" + 
3249
		"}\n"
3250
	);
3251
}
3252
public void testBug260274b() throws JavaModelException {
3253
	String source = 
3254
		"class X {\n" + 
3255
		"/*\n" + 
3256
		" * The formatter should keep \'*\' characters\n" + 
3257
		" * in block comments!\n" + 
3258
		" */\n" + 
3259
		"}\n";
3260
	formatSource(source,
3261
		"class X {\n" + 
3262
		"	/*\n" + 
3263
		"	 * The formatter should keep \'*\' characters in block comments!\n" + 
3264
		"	 */\n" + 
3265
		"}\n"
3266
	);
3267
}
3268
public void testBug260274c() throws JavaModelException {
3269
	this.formatterPrefs.join_lines_in_comments = false;
3270
	String source = 
3271
		"class X {\n" + 
3272
		"/* *********************************************\n" + 
3273
		" * Test \n" + 
3274
		" */\n" + 
3275
		"}\n";
3276
	formatSource(source,
3277
		"class X {\n" + 
3278
		"	/* *********************************************\n" + 
3279
		"	 * Test\n" + 
3280
		"	 */\n" + 
3281
		"}\n"
3282
	);
3283
}
3284
public void testBug260274d() throws JavaModelException {
3285
	String source = 
3286
		"class X {\n" + 
3287
		"/* *********************************************\n" + 
3288
		" * Test \n" + 
3289
		" */\n" + 
3290
		"}\n";
3291
	formatSource(source,
3292
		"class X {\n" + 
3293
		"	/* *********************************************\n" + 
3294
		"	 * Test\n" + 
3295
		"	 */\n" + 
3296
		"}\n"
3297
	);
3298
}
3299
public void testBug260274e() throws JavaModelException {
3300
	String source = 
3301
		"class X {\n" + 
3302
		"/*\n" + 
3303
		" * **************************************************\n" + 
3304
		" * **********  Test  **********  Test  **************\n" + 
3305
		" * **************************************************\n" + 
3306
		" */\n" + 
3307
		"}\n";
3308
	formatSource(source,
3309
		"class X {\n" + 
3310
		"	/*\n" + 
3311
		"	 * **************************************************\n" + 
3312
		"	 * ********** Test ********** Test **************\n" + 
3313
		"	 * **************************************************\n" + 
3314
		"	 */\n" + 
3315
		"}\n"
3316
	);
3317
}
3318
public void testBug260274f() throws JavaModelException {
3319
	String source = 
3320
		"class X {\n" + 
3321
		"/* *****************************************************************************\n" + 
3322
		" * Action that allows changing the model providers sort order.\n" + 
3323
		" */\n" + 
3324
		"void foo() {\n" + 
3325
		"}\n" + 
3326
		"}\n";
3327
	formatSource(source,
3328
		"class X {\n" + 
3329
		"	/* *****************************************************************************\n" + 
3330
		"	 * Action that allows changing the model providers sort order.\n" + 
3331
		"	 */\n" + 
3332
		"	void foo() {\n" + 
3333
		"	}\n" + 
3334
		"}\n"
3335
	);
3336
}
3337
public void testBug260274g() throws JavaModelException {
3338
	String source = 
3339
		"class X {\n" + 
3340
		"/*\n" + 
3341
		" * **********************************************************************************\n" + 
3342
		" * **********************************************************************************\n" + 
3343
		" * **********************************************************************************\n" + 
3344
		" * The code below was added to track the view with focus\n" + 
3345
		" * in order to support save actions from a view. Remove this\n" + 
3346
		" * experimental code if the decision is to not allow views to \n" + 
3347
		" * participate in save actions (see bug 10234) \n" + 
3348
		" */\n" + 
3349
		"}\n";
3350
	formatSource(source,
3351
		"class X {\n" + 
3352
		"	/*\n" + 
3353
		"	 * **********************************************************************************\n" + 
3354
		"	 * **********************************************************************************\n" + 
3355
		"	 * **********************************************************************************\n" + 
3356
		"	 * The code below was added to track the view with focus in order to support\n" + 
3357
		"	 * save actions from a view. Remove this experimental code if the decision\n" + 
3358
		"	 * is to not allow views to participate in save actions (see bug 10234)\n" + 
3359
		"	 */\n" + 
3360
		"}\n"
3361
	);
3362
}
3363
public void testBug260274h() throws JavaModelException {
3364
	String source = 
3365
		"class X {\n" + 
3366
		"    /**\n" + 
3367
		"	 * @see #spacing(Point)\n" + 
3368
		"	 * * @see #spacing(int, int)\n" + 
3369
		"	 */\n" + 
3370
		"    public void foo() {\n" + 
3371
		"    }\n" + 
3372
		"}\n";
3373
	formatSource(source,
3374
		"class X {\n" + 
3375
		"	/**\n" + 
3376
		"	 * @see #spacing(Point) * @see #spacing(int, int)\n" + 
3377
		"	 */\n" + 
3378
		"	public void foo() {\n" + 
3379
		"	}\n" + 
3380
		"}\n"
3381
	);
3382
}
3383
3384
/**
3385
 * @bug 260276: [formatter] Inconsistent formatting of one-line block comment
3386
 * @test Ensure that the comment formatter has a consistent behavior while formatting one-line block comment
3387
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=260276"
3388
 */
3389
public void testBug260276() throws JavaModelException {
3390
	String source = 
3391
		"class X {\n" + 
3392
		"/* a\n" + 
3393
		"comment */\n" + 
3394
		"}\n";
3395
	formatSource(source,
3396
		"class X {\n" + 
3397
		"	/*\n" + 
3398
		"	 * a comment\n" + 
3399
		"	 */\n" + 
3400
		"}\n"
3401
	);
3402
}
3403
public void testBug260276b() throws JavaModelException {
3404
	String source = 
3405
		"class X {\n" + 
3406
		"/* a\n" + 
3407
		" comment */\n" + 
3408
		"}\n";
3409
	formatSource(source,
3410
		"class X {\n" + 
3411
		"	/*\n" + 
3412
		"	 * a comment\n" + 
3413
		"	 */\n" + 
3414
		"}\n"
3415
	);
3416
}
3417
public void testBug260276c() throws JavaModelException {
3418
	String source = 
3419
		"class X {\n" + 
3420
		"/* a\n" + 
3421
		" * comment */\n" + 
3422
		"}\n";
3423
	formatSource(source,
3424
		"class X {\n" + 
3425
		"	/*\n" + 
3426
		"	 * a comment\n" + 
3427
		"	 */\n" + 
3428
		"}\n"
3429
	);
3430
}
3128
}
3431
}
(-)src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java (-2 / +7 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 222-228 Link Here
222
		String outputSource = expectedContents == null ? originalSource : expectedContents;
222
		String outputSource = expectedContents == null ? originalSource : expectedContents;
223
		assertLineEquals(actualContents, originalSource, outputSource, false /* do not check null */);
223
		assertLineEquals(actualContents, originalSource, outputSource, false /* do not check null */);
224
	}
224
	}
225
	
225
226
	void formatSource(String source) {
227
		// expect unchanged source after formatting
228
		formatSource(source, source);
229
	}
230
226
	void formatSource(String source, String formattedOutput) {
231
	void formatSource(String source, String formattedOutput) {
227
		formatSource(source, formattedOutput, CodeFormatter.K_COMPILATION_UNIT | CodeFormatter.F_INCLUDE_COMMENTS, 0, true /*repeat formatting twice*/);
232
		formatSource(source, formattedOutput, CodeFormatter.K_COMPILATION_UNIT | CodeFormatter.F_INCLUDE_COMMENTS, 0, true /*repeat formatting twice*/);
228
	}
233
	}
(-)formatter/org/eclipse/jdt/internal/formatter/Scribe.java (-12 / +26 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 1223-1228 Link Here
1223
	private void printBlockComment(boolean isJavadoc) {
1223
	private void printBlockComment(boolean isJavadoc) {
1224
		int currentTokenStartPosition = this.scanner.getCurrentTokenStartPosition();
1224
		int currentTokenStartPosition = this.scanner.getCurrentTokenStartPosition();
1225
		int currentTokenEndPosition = this.scanner.getCurrentTokenEndPosition() + 1;
1225
		int currentTokenEndPosition = this.scanner.getCurrentTokenEndPosition() + 1;
1226
		boolean includesBlockComments = includesBlockComments();
1226
1227
1227
		this.scanner.resetTo(currentTokenStartPosition, currentTokenEndPosition - 1);
1228
		this.scanner.resetTo(currentTokenStartPosition, currentTokenEndPosition - 1);
1228
		int currentCharacter;
1229
		int currentCharacter;
Lines 1247-1253 Link Here
1247
		this.needSpace = false;
1248
		this.needSpace = false;
1248
		this.pendingSpace = false;
1249
		this.pendingSpace = false;
1249
1250
1250
		if (includesBlockComments()) {
1251
		if (includesBlockComments) {
1251
			if (printBlockComment(currentTokenStartPosition, currentTokenEndPosition)) {
1252
			if (printBlockComment(currentTokenStartPosition, currentTokenEndPosition)) {
1252
				return;
1253
				return;
1253
			}
1254
			}
Lines 1424-1429 Link Here
1424
		boolean hasMultiLines = false;
1425
		boolean hasMultiLines = false;
1425
		boolean hasTokens = false;
1426
		boolean hasTokens = false;
1426
		boolean bufferHasTokens = false;
1427
		boolean bufferHasTokens = false;
1428
		boolean lineHasTokens = false;
1427
		int hasTextOnFirstLine = 0;
1429
		int hasTextOnFirstLine = 0;
1428
		boolean firstWord = true;
1430
		boolean firstWord = true;
1429
		boolean clearBlankLines = this.formatter.preferences.comment_clear_blank_lines_in_block_comment;
1431
		boolean clearBlankLines = this.formatter.preferences.comment_clear_blank_lines_in_block_comment;
Lines 1445-1450 Link Here
1445
1447
1446
			// Look at specific tokens
1448
			// Look at specific tokens
1447
    		boolean insertSpace = (previousToken == TerminalTokens.TokenNameWHITESPACE) && (!firstWord || !hasTokens);
1449
    		boolean insertSpace = (previousToken == TerminalTokens.TokenNameWHITESPACE) && (!firstWord || !hasTokens);
1450
    		boolean isTokenStar = false;
1448
			switch (token) {
1451
			switch (token) {
1449
				case TerminalTokens.TokenNameWHITESPACE:
1452
				case TerminalTokens.TokenNameWHITESPACE:
1450
					if (tokensBuffer.length() > 0) {
1453
					if (tokensBuffer.length() > 0) {
Lines 1463-1469 Link Here
1463
					} else {
1466
					} else {
1464
						previousToken = token;
1467
						previousToken = token;
1465
					}
1468
					}
1466
					lineNumber = Util.getLineNumber(this.scanner.getCurrentTokenEndPosition(), this.lineEnds, scannerLine>1 ? scannerLine-2 : 0, this.maxLines);
1469
					lineNumber = Util.getLineNumber(this.scanner.currentPosition, this.lineEnds, scannerLine>1 ? scannerLine-2 : 0, this.maxLines);
1467
					if (lineNumber > scannerLine) {
1470
					if (lineNumber > scannerLine) {
1468
						hasMultiLines = true;
1471
						hasMultiLines = true;
1469
						newLine = true;
1472
						newLine = true;
Lines 1471-1478 Link Here
1471
					scannerLine = lineNumber;
1474
					scannerLine = lineNumber;
1472
					continue;
1475
					continue;
1473
				case TerminalTokens.TokenNameMULTIPLY:
1476
				case TerminalTokens.TokenNameMULTIPLY:
1477
					isTokenStar = true;
1478
					lineNumber = Util.getLineNumber(this.scanner.currentPosition, this.lineEnds, scannerLine>1 ? scannerLine-2 : 0, this.maxLines);
1479
					if (lineNumber == firstLine && previousToken == SKIP_FIRST_WHITESPACE_TOKEN) {
1480
						editStart = this.scanner.getCurrentTokenStartPosition();
1481
					}
1474
					previousToken = token;
1482
					previousToken = token;
1475
					lineNumber = Util.getLineNumber(this.scanner.getCurrentTokenEndPosition(), this.lineEnds, scannerLine>1 ? scannerLine-2 : 0, this.maxLines);
1476
					if (this.scanner.currentCharacter == '/') {
1483
					if (this.scanner.currentCharacter == '/') {
1477
						editEnd = this.scanner.startPosition - 1;
1484
						editEnd = this.scanner.startPosition - 1;
1478
						// Add remaining buffered tokens
1485
						// Add remaining buffered tokens
Lines 1491-1504 Link Here
1491
				    	this.scanner.getNextChar(); // reach the end of scanner
1498
				    	this.scanner.getNextChar(); // reach the end of scanner
1492
				    	continue;
1499
				    	continue;
1493
					}
1500
					}
1494
					scannerLine = lineNumber;
1501
					if (newLine) {
1495
					continue;
1502
						scannerLine = lineNumber;
1503
						newLine = false;
1504
						continue;
1505
					}
1506
					break;
1496
				case TerminalTokens.TokenNameMULTIPLY_EQUAL:
1507
				case TerminalTokens.TokenNameMULTIPLY_EQUAL:
1497
					if (newLine) {
1508
					if (newLine) {
1498
						this.scanner.resetTo(this.scanner.startPosition, currentTokenEndPosition-1);
1509
						this.scanner.resetTo(this.scanner.startPosition, currentTokenEndPosition-1);
1499
						this.scanner.getNextChar(); // consume the multiply
1510
						this.scanner.getNextChar(); // consume the multiply
1500
						previousToken = TerminalTokens.TokenNameMULTIPLY;
1511
						previousToken = TerminalTokens.TokenNameMULTIPLY;
1501
						scannerLine = Util.getLineNumber(this.scanner.getCurrentTokenEndPosition(), this.lineEnds, scannerLine>1 ? scannerLine-2 : 0, this.maxLines);
1512
						scannerLine = Util.getLineNumber(this.scanner.currentPosition, this.lineEnds, scannerLine>1 ? scannerLine-2 : 0, this.maxLines);
1502
						continue;
1513
						continue;
1503
					}
1514
					}
1504
					break;
1515
					break;
Lines 1524-1530 Link Here
1524
			// Look at gap and insert corresponding lines if necessary
1535
			// Look at gap and insert corresponding lines if necessary
1525
			int linesGap;
1536
			int linesGap;
1526
			int max;
1537
			int max;
1527
			lineNumber = Util.getLineNumber(this.scanner.getCurrentTokenEndPosition(), this.lineEnds, scannerLine>1 ? scannerLine-2 : 0, this.maxLines);
1538
			lineNumber = Util.getLineNumber(this.scanner.currentPosition, this.lineEnds, scannerLine>1 ? scannerLine-2 : 0, this.maxLines);
1528
			if (lastTextLine == -1) {
1539
			if (lastTextLine == -1) {
1529
				linesGap = lineNumber - firstLine;
1540
				linesGap = lineNumber - firstLine;
1530
				max = 0;
1541
				max = 0;
Lines 1534-1540 Link Here
1534
					// insert one blank line before root tags
1545
					// insert one blank line before root tags
1535
					linesGap = 2;
1546
					linesGap = 2;
1536
				}
1547
				}
1537
				max = joinLines ? 1 : 0;
1548
				max = joinLines && lineHasTokens ? 1 : 0;
1538
			}
1549
			}
1539
			if (linesGap > max) {
1550
			if (linesGap > max) {
1540
				if (clearBlankLines) {
1551
				if (clearBlankLines) {
Lines 1566-1577 Link Here
1566
				}
1577
				}
1567
				insertSpace = insertSpace && linesGap == 0;
1578
				insertSpace = insertSpace && linesGap == 0;
1568
			}
1579
			}
1580
    		if (newLine) lineHasTokens = false;
1569
1581
1570
			// Increment column
1582
			// Increment column
1571
			int tokenStart = this.scanner.getCurrentTokenStartPosition();
1583
			int tokenStart = this.scanner.getCurrentTokenStartPosition();
1572
    		int tokenLength = (this.scanner.atEnd() ? this.scanner.eofPosition : this.scanner.currentPosition) - tokenStart;
1584
    		int tokenLength = (this.scanner.atEnd() ? this.scanner.eofPosition : this.scanner.currentPosition) - tokenStart;
1573
    		hasTokens = true;
1585
    		hasTokens = true;
1574
    		if (hasTextOnFirstLine == 0) {
1586
    		if (!isTokenStar) lineHasTokens = true;
1587
    		if (hasTextOnFirstLine == 0 && !isTokenStar) {
1575
    			if (firstLine == lineNumber) {
1588
    			if (firstLine == lineNumber) {
1576
	    			hasTextOnFirstLine = 1;
1589
	    			hasTextOnFirstLine = 1;
1577
	    			this.column++; // include first space
1590
	    			this.column++; // include first space
Lines 1583-1589 Link Here
1583
    		if (insertSpace) lastColumn++;
1596
    		if (insertSpace) lastColumn++;
1584
1597
1585
    		// Append next token inserting a new line if max line is reached
1598
    		// Append next token inserting a new line if max line is reached
1586
			if (!firstWord && lastColumn > maxColumn) {
1599
			if (lineHasTokens && !firstWord && lastColumn > maxColumn) {
1587
		    	String tokensString = tokensBuffer.toString().trim();
1600
		    	String tokensString = tokensBuffer.toString().trim();
1588
				// not enough space on the line
1601
				// not enough space on the line
1589
				if (hasTextOnFirstLine == 1) {
1602
				if (hasTextOnFirstLine == 1) {
Lines 2045-2050 Link Here
2045
	private void printLineComment() {
2058
	private void printLineComment() {
2046
    	int currentTokenStartPosition = this.scanner.getCurrentTokenStartPosition();
2059
    	int currentTokenStartPosition = this.scanner.getCurrentTokenStartPosition();
2047
    	int currentTokenEndPosition = this.scanner.getCurrentTokenEndPosition() + 1;
2060
    	int currentTokenEndPosition = this.scanner.getCurrentTokenEndPosition() + 1;
2061
    	boolean includesLineComments = includesLineComments();
2048
    	boolean isNlsTag = false;
2062
    	boolean isNlsTag = false;
2049
    	if (CharOperation.indexOf(Scanner.TAG_PREFIX, this.scanner.source, true, currentTokenStartPosition, currentTokenEndPosition) != -1) {
2063
    	if (CharOperation.indexOf(Scanner.TAG_PREFIX, this.scanner.source, true, currentTokenStartPosition, currentTokenEndPosition) != -1) {
2050
    		this.nlsTagCounter = 0;
2064
    		this.nlsTagCounter = 0;
Lines 2068-2074 Link Here
2068
    	this.pendingSpace = false;
2082
    	this.pendingSpace = false;
2069
    	int previousStart = currentTokenStartPosition;
2083
    	int previousStart = currentTokenStartPosition;
2070
2084
2071
		if (!isNlsTag && includesLineComments()) {
2085
		if (!isNlsTag && includesLineComments) {
2072
			printLineComment(currentTokenStartPosition, currentTokenEndPosition-1);
2086
			printLineComment(currentTokenStartPosition, currentTokenEndPosition-1);
2073
		} else {
2087
		} else {
2074
			// do nothing!?
2088
			// do nothing!?
(-)compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java (-3 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 322-330 Link Here
322
						if (previousChar != '*') {
322
						if (previousChar != '*') {
323
							this.starPosition = previousPosition;
323
							this.starPosition = previousPosition;
324
							if (isDomParser || isFormatterParser) {
324
							if (isDomParser || isFormatterParser) {
325
								if (lineHasStar && !this.lineStarted) {
325
								if (lineHasStar) {
326
									this.lineStarted = true;
326
									this.lineStarted = true;
327
									this.textStart = previousPosition;
327
									if (this.textStart == -1) this.textStart = previousPosition;
328
								}
328
								}
329
								if (!this.lineStarted) {
329
								if (!this.lineStarted) {
330
									lineHasStar = true;
330
									lineHasStar = true;

Return to bug 254998