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

(-)compiler/org/eclipse/jdt/internal/compiler/parser/diagnose/LexStream.java (-1 / +15 lines)
Lines 223-229 Link Here
223
		
223
		
224
		String source = new String(scanner.source);
224
		String source = new String(scanner.source);
225
		if(currentIndex < 0) {
225
		if(currentIndex < 0) {
226
			res.append(source);
226
			int previousEnd = -1;
227
			for (int i = 0; i < intervalStartToSkip.length; i++) {
228
				int intervalStart = intervalStartToSkip[i];
229
				int intervalEnd = intervalEndToSkip[i];
230
				
231
				res.append(source.substring(previousEnd + 1, intervalStart));
232
				res.append('<');
233
				res.append('@');
234
				res.append(source.substring(intervalStart, intervalEnd + 1));
235
				res.append('@');
236
				res.append('>');
237
				
238
				previousEnd = intervalEnd;
239
			}
240
			res.append(source.substring(previousEnd + 1));
227
		} else {
241
		} else {
228
			Token token = token(currentIndex);
242
			Token token = token(currentIndex);
229
			int curtokKind = token.kind;
243
			int curtokKind = token.kind;
(-)compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredMethod.java (+9 lines)
Lines 445-450 Link Here
445
		}
445
		}
446
		return this;
446
		return this;
447
	}
447
	}
448
	if(this.parent != null && this.parent instanceof RecoveredType) {
449
		int modifiers = ((RecoveredType)this.parent).typeDeclaration.modifiers;
450
		if (TypeDeclaration.kind(modifiers) == TypeDeclaration.INTERFACE_DECL) {
451
			if (!this.foundOpeningBrace) {
452
				this.updateSourceEndIfNecessary(braceStart - 1, braceStart - 1);
453
				return this.parent.updateOnClosingBrace(braceStart, braceEnd);
454
			}
455
		}
456
	}
448
	return super.updateOnClosingBrace(braceStart, braceEnd);
457
	return super.updateOnClosingBrace(braceStart, braceEnd);
449
}
458
}
450
/*
459
/*
(-)src/org/eclipse/jdt/core/tests/compiler/parser/StatementRecoveryTest.java (+50 lines)
Lines 3537-3540 Link Here
3537
		expectedFullWithStatementRecoveryUnitToString,
3537
		expectedFullWithStatementRecoveryUnitToString,
3538
		testName);
3538
		testName);
3539
}
3539
}
3540
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=80339
3541
public void test0043() {
3542
3543
	String s = 
3544
		"package a;											\n"
3545
			+ "public interface Test {						\n"
3546
			+ "  public void myMethod()						\n"
3547
			+ "}											\n";
3548
3549
	String expectedDietUnitToString = 
3550
		"package a;\n" + 
3551
		"public interface Test {\n" + 
3552
		"  public void myMethod() {\n" + 
3553
		"  }\n" + 
3554
		"}\n";
3555
	
3556
	String expectedDietWithStatementRecoveryUnitToString =
3557
		expectedDietUnitToString;
3558
	
3559
	String expectedDietPlusBodyUnitToString = 
3560
		"package a;\n" + 
3561
		"public interface Test {\n" + 
3562
		"  public void myMethod() {\n" + 
3563
		"  }\n" + 
3564
		"}\n";
3565
3566
	String expectedDietPlusBodyWithStatementRecoveryUnitToString = 
3567
		"package a;\n" + 
3568
		"public interface Test {\n" + 
3569
		"  public void myMethod() {\n" + 
3570
		"  }\n" + 
3571
		"}\n";
3572
	
3573
	String expectedFullUnitToString =
3574
		expectedDietUnitToString;
3575
	
3576
	String expectedFullWithStatementRecoveryUnitToString =
3577
		expectedDietUnitToString;
3578
	
3579
	String testName = "<test>";
3580
	checkParse(
3581
		s.toCharArray(),
3582
		expectedDietUnitToString,
3583
		expectedDietWithStatementRecoveryUnitToString,
3584
		expectedDietPlusBodyUnitToString,
3585
		expectedDietPlusBodyWithStatementRecoveryUnitToString,
3586
		expectedFullUnitToString,
3587
		expectedFullWithStatementRecoveryUnitToString,
3588
		testName);
3589
}
3540
}
3590
}
(-)src/org/eclipse/jdt/core/tests/compiler/parser/SyntaxErrorTest.java (+52 lines)
Lines 374-377 Link Here
374
		expectedSyntaxErrorDiagnosis,
374
		expectedSyntaxErrorDiagnosis,
375
		testName);
375
		testName);
376
}
376
}
377
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=80339
378
public void test11() {
379
380
	String s = 
381
		"package a;										\n"+
382
		"public interface Test {						\n"+
383
		"  public void myMethod()						\n"+
384
		"}												\n"; 	
385
386
	String expectedSyntaxErrorDiagnosis =
387
		"----------\n"+
388
		"1. ERROR in <test> (at line 3)\n"+
389
		"	public void myMethod()						\n"+
390
		"	                     ^\n"+
391
		"Syntax error, insert \";\" to complete MethodDeclaration\n"+
392
		"----------\n";
393
394
	String testName = "<test>";
395
	checkParse(
396
		s.toCharArray(),
397
		expectedSyntaxErrorDiagnosis,
398
		testName);
399
}
400
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=80339
401
public void test12() {
402
403
	String s = 
404
		"package a;										\n"+
405
		"public interface Test {						\n"+
406
		"  public void myMethod()						\n"+
407
		"    System.out.println();						\n"+
408
		"}												\n"; 	
409
410
	String expectedSyntaxErrorDiagnosis =
411
		"----------\n"+
412
		"1. ERROR in <test> (at line 3)\n"+
413
		"	public void myMethod()						\n"+
414
		"	                     ^\n"+
415
		"Syntax error on token \")\", { expected after this token\n"+
416
		"----------\n"+
417
		"2. ERROR in <test> (at line 5)\n"+
418
		"	}												\n"+
419
		"	^\n"+
420
		"Syntax error, insert \"}\" to complete InterfaceBody\n"+
421
		"----------\n";
422
423
	String testName = "<test>";
424
	checkParse(
425
		s.toCharArray(),
426
		expectedSyntaxErrorDiagnosis,
427
		testName);
428
}
377
}
429
}
(-)src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java (+81 lines)
Lines 6869-6872 Link Here
6869
		expectedFullUnitToString,
6869
		expectedFullUnitToString,
6870
		expectedCompletionDietUnitToString, testName);
6870
		expectedCompletionDietUnitToString, testName);
6871
}
6871
}
6872
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=80339
6873
public void test115() {
6874
	String s = 
6875
		"public interface Test {\n"+
6876
		"  public void myMethod()\n"+
6877
		"}\n";
6878
		
6879
	String expectedDietUnitToString = 
6880
		"public interface Test {\n" + 
6881
		"  public void myMethod() {\n" + 
6882
		"  }\n" + 
6883
		"}\n";
6884
6885
	String expectedDietPlusBodyUnitToString = 
6886
		"public interface Test {\n" + 
6887
		"  public void myMethod() {\n" + 
6888
		"  }\n" + 
6889
		"}\n";
6890
	
6891
	String expectedDietPlusBodyPlusStatementsRecoveryUnitToString =
6892
		"public interface Test {\n" + 
6893
		"  public void myMethod() {\n" + 
6894
		"  }\n" + 
6895
		"}\n";
6896
	
6897
	String expectedFullUnitToString = expectedDietUnitToString;
6898
	
6899
	String expectedCompletionDietUnitToString = 
6900
		expectedDietUnitToString;
6901
	
6902
	String testName = "test foreach toString";
6903
	checkParse(
6904
		s.toCharArray(),
6905
		expectedDietUnitToString,
6906
		expectedDietPlusBodyUnitToString,
6907
		expectedDietPlusBodyPlusStatementsRecoveryUnitToString,		
6908
		expectedFullUnitToString,
6909
		expectedCompletionDietUnitToString, testName);
6910
}
6911
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=80339
6912
public void test116() {
6913
	String s = 
6914
		"public interface Test {\n"+
6915
		"  public void myMethod()\n"+
6916
		"    System.out.println();\n"+
6917
		"}\n";
6918
		
6919
	String expectedDietUnitToString = 
6920
		"public interface Test {\n" + 
6921
		"  public void myMethod() {\n" + 
6922
		"  }\n" + 
6923
		"}\n";
6924
6925
	String expectedDietPlusBodyUnitToString = 
6926
		"public interface Test {\n" + 
6927
		"  public void myMethod() {\n" + 
6928
		"    System.out.println();\n" + 
6929
		"  }\n" + 
6930
		"}\n";
6931
	
6932
	String expectedDietPlusBodyPlusStatementsRecoveryUnitToString =
6933
		"public interface Test {\n" + 
6934
		"  public void myMethod() {\n" + 
6935
		"    System.out.println();\n" + 
6936
		"  }\n" + 
6937
		"}\n";
6938
	
6939
	String expectedFullUnitToString = expectedDietUnitToString;
6940
	
6941
	String expectedCompletionDietUnitToString = 
6942
		expectedDietUnitToString;
6943
	
6944
	String testName = "test foreach toString";
6945
	checkParse(
6946
		s.toCharArray(),
6947
		expectedDietUnitToString,
6948
		expectedDietPlusBodyUnitToString,
6949
		expectedDietPlusBodyPlusStatementsRecoveryUnitToString,		
6950
		expectedFullUnitToString,
6951
		expectedCompletionDietUnitToString, testName);
6952
}
6872
}
6953
}

Return to bug 80339