View | Details | Raw Unified | Return to bug 140980 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java (+354 lines)
Lines 7093-7098 Link Here
7093
		expectedFullUnitToString,
7093
		expectedFullUnitToString,
7094
		expectedCompletionDietUnitToString, testName);
7094
		expectedCompletionDietUnitToString, testName);
7095
}
7095
}
7096
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=154811
7097
public void test117_2() {
7098
	String s = 
7099
		"public class X {\n" + 
7100
		"	void foo1() {\n" + 
7101
		"		class Y  {\n" + 
7102
		"		}\n" + 
7103
		"		void foo2() {\n" + 
7104
		"		}\n" + 
7105
		"		class Z { \n" + 
7106
		"		}\n" + 
7107
		"	}\n" + 
7108
		"} \n";
7109
		
7110
	String expectedDietUnitToString = null;
7111
	String expectedDietPlusBodyUnitToString = null;
7112
	String expectedDietPlusBodyPlusStatementsRecoveryUnitToString = null;
7113
	String expectedFullUnitToString = null;
7114
	String expectedCompletionDietUnitToString = null;
7115
	
7116
	expectedDietUnitToString = 
7117
		"public class X {\n" + 
7118
		"  public X() {\n" + 
7119
		"  }\n" + 
7120
		"  void foo1() {\n" + 
7121
		"  }\n" + 
7122
		"}\n";
7123
7124
	expectedDietPlusBodyUnitToString = 
7125
		"public class X {\n" + 
7126
		"  public X() {\n" + 
7127
		"    super();\n" + 
7128
		"  }\n" + 
7129
		"  void foo1() {\n" + 
7130
		"  }\n" + 
7131
		"}\n";
7132
	
7133
	expectedDietPlusBodyPlusStatementsRecoveryUnitToString =
7134
		"public class X {\n" + 
7135
		"  public X() {\n" + 
7136
		"    super();\n" + 
7137
		"  }\n" + 
7138
		"  void foo1() {\n" + 
7139
		"    class Y {\n" + 
7140
		"      Y() {\n" + 
7141
		"        super();\n" + 
7142
		"      }\n" + 
7143
		"    }\n" + 
7144
		"    new foo2() {\n" + 
7145
		"    };\n" + 
7146
		"    class Z {\n" + 
7147
		"      Z() {\n" + 
7148
		"        super();\n" + 
7149
		"      }\n" + 
7150
		"    }\n" + 
7151
		"  }\n" + 
7152
		"}\n";
7153
	
7154
	expectedFullUnitToString =
7155
		"public class X {\n" + 
7156
		"  class Z {\n" + 
7157
		"    Z() {\n" + 
7158
		"    }\n" + 
7159
		"  }\n" + 
7160
		"  public X() {\n" + 
7161
		"  }\n" + 
7162
		"  void foo1() {\n" + 
7163
		"  }\n" + 
7164
		"  void foo2() {\n" + 
7165
		"  }\n" + 
7166
		"}\n";
7167
	
7168
	expectedCompletionDietUnitToString = 
7169
		expectedDietUnitToString;
7170
	
7171
	String testName = "test foreach toString";
7172
	checkParse(
7173
		s.toCharArray(),
7174
		expectedDietUnitToString,
7175
		expectedDietPlusBodyUnitToString,
7176
		expectedDietPlusBodyPlusStatementsRecoveryUnitToString,		
7177
		expectedFullUnitToString,
7178
		expectedCompletionDietUnitToString, testName);
7179
}
7096
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=162056
7180
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=162056
7097
public void test118() {
7181
public void test118() {
7098
	String s = 
7182
	String s = 
Lines 7234-7237 Link Here
7234
		expectedFullUnitToString,
7318
		expectedFullUnitToString,
7235
		expectedCompletionDietUnitToString, testName);
7319
		expectedCompletionDietUnitToString, testName);
7236
}
7320
}
7321
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=140980
7322
public void test120() {
7323
	String s = 
7324
		"public class X {\n" + 
7325
		"  void foo() {\n" + 
7326
		"    #\n" + 
7327
		"    try {\n" + 
7328
		"      System.out.println(); \n" + 
7329
		"    } catch (Exception e) {\n" + 
7330
		"    }\n" + 
7331
		"    class Z {}\n" + 
7332
		" }\n" + 
7333
		"}\n";
7334
		
7335
	String expectedDietUnitToString = 
7336
		"public class X {\n" + 
7337
		"  public X() {\n" + 
7338
		"  }\n" + 
7339
		"  void foo() {\n" + 
7340
		"  }\n" + 
7341
		"}\n";
7342
7343
	String expectedDietPlusBodyUnitToString = 
7344
		"public class X {\n" + 
7345
		"  public X() {\n" + 
7346
		"    super();\n" + 
7347
		"  }\n" + 
7348
		"  void foo() {\n" + 
7349
		"  }\n" + 
7350
		"}\n";
7351
	
7352
	String expectedDietPlusBodyPlusStatementsRecoveryUnitToString =
7353
		"public class X {\n" + 
7354
		"  public X() {\n" + 
7355
		"    super();\n" + 
7356
		"  }\n" + 
7357
		"  void foo() {\n" + 
7358
		"    try \n" + 
7359
		"      {\n" + 
7360
		"        System.out.println();\n" + 
7361
		"      }\n" + 
7362
		"    catch (Exception e)       {\n" + 
7363
		"      }\n" + 
7364
		"    class Z {\n" + 
7365
		"      Z() {\n" + 
7366
		"        super();\n" + 
7367
		"      }\n" + 
7368
		"    }\n" + 
7369
		"  }\n" + 
7370
		"}\n";
7371
	
7372
	String expectedFullUnitToString = expectedDietUnitToString;
7373
	
7374
	String expectedCompletionDietUnitToString = 
7375
		expectedDietUnitToString;
7376
	
7377
	String testName = "test foreach toString";
7378
	checkParse(
7379
		s.toCharArray(),
7380
		expectedDietUnitToString,
7381
		expectedDietPlusBodyUnitToString,
7382
		expectedDietPlusBodyPlusStatementsRecoveryUnitToString,		
7383
		expectedFullUnitToString,
7384
		expectedCompletionDietUnitToString, testName);
7385
}
7386
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=140980
7387
public void test121() {
7388
	String s = 
7389
		"public class X {\n" + 
7390
		"  void foo() {\n" + 
7391
		"    #\n" + 
7392
		"    try {\n" + 
7393
		"      System.out.println(); \n" + 
7394
		"    } catch (Exception e) {\n" + 
7395
		"      class Z {}\n" + 
7396
		"    }\n" + 
7397
		" }\n" + 
7398
		"}\n";
7399
		
7400
	String expectedDietUnitToString = 
7401
		"public class X {\n" + 
7402
		"  public X() {\n" + 
7403
		"  }\n" + 
7404
		"  void foo() {\n" + 
7405
		"  }\n" + 
7406
		"}\n";
7407
7408
	String expectedDietPlusBodyUnitToString = 
7409
		"public class X {\n" + 
7410
		"  public X() {\n" + 
7411
		"    super();\n" + 
7412
		"  }\n" + 
7413
		"  void foo() {\n" + 
7414
		"  }\n" + 
7415
		"}\n";
7416
	
7417
	String expectedDietPlusBodyPlusStatementsRecoveryUnitToString =
7418
		"public class X {\n" + 
7419
		"  public X() {\n" + 
7420
		"    super();\n" + 
7421
		"  }\n" + 
7422
		"  void foo() {\n" + 
7423
		"    try \n" + 
7424
		"      {\n" + 
7425
		"        System.out.println();\n" + 
7426
		"      }\n" + 
7427
		"    catch (Exception e)       {\n" + 
7428
		"        class Z {\n" + 
7429
		"          Z() {\n" + 
7430
		"            super();\n" + 
7431
		"          }\n" + 
7432
		"        }\n" + 
7433
		"      }\n" + 
7434
		"  }\n" + 
7435
		"}\n";
7436
	
7437
	String expectedFullUnitToString = expectedDietUnitToString;
7438
	
7439
	String expectedCompletionDietUnitToString = 
7440
		expectedDietUnitToString;
7441
	
7442
	String testName = "test foreach toString";
7443
	checkParse(
7444
		s.toCharArray(),
7445
		expectedDietUnitToString,
7446
		expectedDietPlusBodyUnitToString,
7447
		expectedDietPlusBodyPlusStatementsRecoveryUnitToString,		
7448
		expectedFullUnitToString,
7449
		expectedCompletionDietUnitToString, testName);
7450
}
7451
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=140980
7452
public void test122() {
7453
	String s = 
7454
		"public class Test\n" + 
7455
		"{\n" + 
7456
		"  public void func1()\n" + 
7457
		"  {\n" + 
7458
		"    try\n" + 
7459
		"    {\n" + 
7460
		"    catch ( Exception exception)\n" + 
7461
		"    {\n" + 
7462
		"      exception.printStackTrace();\n" + 
7463
		"    }\n" + 
7464
		"  }\n" + 
7465
		"\n" + 
7466
		"  class Clazz\n" + 
7467
		"  {\n" + 
7468
		"  }\n" + 
7469
		"}\n" + 
7470
		"\n";
7471
		
7472
	String expectedDietUnitToString = 
7473
		"public class Test {\n" + 
7474
		"  public Test() {\n" + 
7475
		"  }\n" + 
7476
		"  public void func1() {\n" + 
7477
		"  }\n" + 
7478
		"}\n";
7479
7480
	String expectedDietPlusBodyUnitToString = 
7481
		"public class Test {\n" + 
7482
		"  public Test() {\n" + 
7483
		"    super();\n" + 
7484
		"  }\n" + 
7485
		"  public void func1() {\n" + 
7486
		"  }\n" + 
7487
		"}\n";
7488
	
7489
	String expectedDietPlusBodyPlusStatementsRecoveryUnitToString =
7490
		"public class Test {\n" + 
7491
		"  public Test() {\n" + 
7492
		"    super();\n" + 
7493
		"  }\n" + 
7494
		"  public void func1() {\n" + 
7495
		"    try \n" + 
7496
		"      {\n" + 
7497
		"      }\n" + 
7498
		"    catch (Exception exception)       {\n" + 
7499
		"        exception.printStackTrace();\n" + 
7500
		"      }\n" + 
7501
		"    class Clazz {\n" + 
7502
		"      Clazz() {\n" + 
7503
		"        super();\n" + 
7504
		"      }\n" + 
7505
		"    }\n" + 
7506
		"  }\n" + 
7507
		"}\n";
7508
	
7509
	String expectedFullUnitToString = expectedDietUnitToString;
7510
	
7511
	String expectedCompletionDietUnitToString = 
7512
		expectedDietUnitToString;
7513
	
7514
	String testName = "test foreach toString";
7515
	checkParse(
7516
		s.toCharArray(),
7517
		expectedDietUnitToString,
7518
		expectedDietPlusBodyUnitToString,
7519
		expectedDietPlusBodyPlusStatementsRecoveryUnitToString,		
7520
		expectedFullUnitToString,
7521
		expectedCompletionDietUnitToString, testName);
7522
}
7523
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=140980
7524
public void test123() {
7525
	String s = 
7526
		"public class SwitchBug {\n" + 
7527
		"       void aMethod() {\n" + 
7528
		"               int i=0;\n" + 
7529
		"               try {\n" + 
7530
		"                        switch( i ) {\n" + 
7531
		"                } catch( Exception ex ) {\n" + 
7532
		"                }\n" + 
7533
		"        }\n" + 
7534
		"        class Nested {\n" + 
7535
		"        }\n" + 
7536
		"}\n";
7537
		
7538
	String expectedDietUnitToString = 
7539
		"public class SwitchBug {\n" + 
7540
		"  public SwitchBug() {\n" + 
7541
		"  }\n" + 
7542
		"  void aMethod() {\n" + 
7543
		"  }\n" + 
7544
		"}\n";
7545
7546
	String expectedDietPlusBodyUnitToString = 
7547
		"public class SwitchBug {\n" + 
7548
		"  public SwitchBug() {\n" + 
7549
		"    super();\n" + 
7550
		"  }\n" + 
7551
		"  void aMethod() {\n" + 
7552
		"  }\n" + 
7553
		"}\n";
7554
	
7555
	String expectedDietPlusBodyPlusStatementsRecoveryUnitToString =
7556
		"public class SwitchBug {\n" + 
7557
		"  public SwitchBug() {\n" + 
7558
		"    super();\n" + 
7559
		"  }\n" + 
7560
		"  void aMethod() {\n" + 
7561
		"    int i = 0;\n" + 
7562
		"    try \n" + 
7563
		"      {\n" + 
7564
		"        switch (i) {\n" + 
7565
		"        }\n" + 
7566
		"      }\n" + 
7567
		"    catch (Exception ex)       {\n" + 
7568
		"      }\n" + 
7569
		"    class Nested {\n" + 
7570
		"      Nested() {\n" + 
7571
		"        super();\n" + 
7572
		"      }\n" + 
7573
		"    }\n" + 
7574
		"  }\n" + 
7575
		"}\n";
7576
	
7577
	String expectedFullUnitToString = expectedDietUnitToString;
7578
	
7579
	String expectedCompletionDietUnitToString = 
7580
		expectedDietUnitToString;
7581
	
7582
	String testName = "test foreach toString";
7583
	checkParse(
7584
		s.toCharArray(),
7585
		expectedDietUnitToString,
7586
		expectedDietPlusBodyUnitToString,
7587
		expectedDietPlusBodyPlusStatementsRecoveryUnitToString,		
7588
		expectedFullUnitToString,
7589
		expectedCompletionDietUnitToString, testName);
7590
}
7237
}
7591
}
(-)compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java (-34 / +106 lines)
Lines 58-63 Link Here
58
	public static short check_table[] = null;
58
	public static short check_table[] = null;
59
	public static final int CurlyBracket = 2;
59
	public static final int CurlyBracket = 2;
60
	private static final boolean DEBUG = false;
60
	private static final boolean DEBUG = false;
61
	private static final boolean DEBUG_AUTOMATON = false;
61
	private static final String EOF_TOKEN = "$eof" ; //$NON-NLS-1$
62
	private static final String EOF_TOKEN = "$eof" ; //$NON-NLS-1$
62
	private static final String ERROR_TOKEN = "$error" ; //$NON-NLS-1$
63
	private static final String ERROR_TOKEN = "$error" ; //$NON-NLS-1$
63
	//expression stack
64
	//expression stack
Lines 189-194 Link Here
189
	protected TypeDeclaration[] recoveredTypes;
190
	protected TypeDeclaration[] recoveredTypes;
190
	protected int recoveredTypePtr;
191
	protected int recoveredTypePtr;
191
	protected int nextTypeStart;
192
	protected int nextTypeStart;
193
	protected TypeDeclaration pendingRecoveredType;
192
	
194
	
193
	public RecoveryScanner recoveryScanner;
195
	public RecoveryScanner recoveryScanner;
194
	
196
	
Lines 1052-1057 Link Here
1052
			}
1054
			}
1053
		}
1055
		}
1054
	}
1056
	}
1057
	
1058
	if (this.statementRecoveryActivated) {
1059
		if (this.pendingRecoveredType != null &&
1060
				this.scanner.startPosition - 1 <= this.pendingRecoveredType.declarationSourceEnd) {
1061
			// Add the pending type to the AST if this type isn't already added in the AST.
1062
			element = element.add(this.pendingRecoveredType, 0);				
1063
			this.lastCheckPoint = this.pendingRecoveredType.declarationSourceEnd + 1;
1064
			this.pendingRecoveredType = null;
1065
		}
1066
	}
1055
	return element;
1067
	return element;
1056
}
1068
}
1057
1069
Lines 1487-1492 Link Here
1487
				this.expressionStack[this.expressionPtr] ,
1499
				this.expressionStack[this.expressionPtr] ,
1488
				this.expressionStack[this.expressionPtr+1],
1500
				this.expressionStack[this.expressionPtr+1],
1489
				this.scanner.startPosition - 1);
1501
				this.scanner.startPosition - 1);
1502
				
1503
	if (this.pendingRecoveredType != null) {
1504
		// Used only in statements recovery.
1505
		// This is not a real assignment but a placeholder for an existing anonymous type.
1506
		// The assignment must be replace by the anonymous type.
1507
		if (this.pendingRecoveredType.allocation != null &&
1508
				this.scanner.startPosition - 1 <= this.pendingRecoveredType.declarationSourceEnd) {
1509
			this.expressionStack[this.expressionPtr] = this.pendingRecoveredType.allocation;
1510
			this.pendingRecoveredType = null;
1511
			return;
1512
		}
1513
		this.pendingRecoveredType = null;
1514
	}
1490
}
1515
}
1491
protected void consumeAssignmentOperator(int pos) {
1516
protected void consumeAssignmentOperator(int pos) {
1492
	// AssignmentOperator ::= '='
1517
	// AssignmentOperator ::= '='
Lines 6630-6635 Link Here
6630
	// break pushs a position on this.intStack in case there is no label
6655
	// break pushs a position on this.intStack in case there is no label
6631
6656
6632
	pushOnAstStack(new BreakStatement(null, this.intStack[this.intPtr--], this.endPosition));
6657
	pushOnAstStack(new BreakStatement(null, this.intStack[this.intPtr--], this.endPosition));
6658
	
6659
	if (this.pendingRecoveredType != null) {
6660
		// Used only in statements recovery.
6661
		// This is not a real break statement but a placeholder for an existing local type.
6662
		// The break statement must be replace by the local type.
6663
		if (this.pendingRecoveredType.allocation == null &&
6664
				this.endPosition <= this.pendingRecoveredType.declarationSourceEnd) {
6665
			this.astStack[this.astPtr] = this.pendingRecoveredType;
6666
			this.pendingRecoveredType = null;
6667
			return;
6668
		}
6669
		this.pendingRecoveredType = null;
6670
	}
6633
}
6671
}
6634
protected void consumeStatementBreakWithLabel() {
6672
protected void consumeStatementBreakWithLabel() {
6635
	// BreakStatement ::= 'break' Identifier ';'
6673
	// BreakStatement ::= 'break' Identifier ';'
Lines 8582-8625 Link Here
8582
}
8620
}
8583
private void jumpOverType(){
8621
private void jumpOverType(){
8584
	if (this.recoveredTypes != null && this.nextTypeStart > -1 && this.nextTypeStart < this.scanner.currentPosition) {
8622
	if (this.recoveredTypes != null && this.nextTypeStart > -1 && this.nextTypeStart < this.scanner.currentPosition) {
8623
		
8624
		if (DEBUG_AUTOMATON) {
8625
			System.out.println("Jump         -"); //$NON-NLS-1$
8626
		}
8627
		
8585
		TypeDeclaration typeDeclaration = this.recoveredTypes[this.recoveredTypePtr];
8628
		TypeDeclaration typeDeclaration = this.recoveredTypes[this.recoveredTypePtr];
8586
		boolean isAnonymous = typeDeclaration.allocation != null;
8629
		boolean isAnonymous = typeDeclaration.allocation != null;
8587
		
8630
		
8588
		int end = this.scanner.eofPosition;
8631
		int end = this.scanner.eofPosition;
8589
		this.scanner.resetTo(typeDeclaration.declarationSourceEnd + 1, end  - 1);
8632
		this.scanner.resetTo(typeDeclaration.declarationSourceEnd + 1, end  - 1);
8590
		if(!isAnonymous) {
8633
		if(!isAnonymous) {
8591
			pushOnAstStack(typeDeclaration);
8634
			((RecoveryScanner)this.scanner).setPendingTokens(new int[]{TokenNameSEMICOLON, TokenNamebreak});
8592
			if(this.astLengthPtr > 0) {
8593
				concatNodeLists();
8594
			}
8595
			
8596
			if(this.currentElement != null) {
8597
				this.currentElement = this.currentElement.add(typeDeclaration, 0);
8598
			}
8599
			
8600
			try {
8601
				this.currentToken = this.scanner.getNextToken();
8602
			} catch(InvalidInputException e){
8603
				if (!this.hasReportedError){
8604
					this.problemReporter().scannerError(this, e.getMessage());
8605
					this.hasReportedError = true;
8606
				}
8607
				this.lastCheckPoint = this.scanner.currentPosition;
8608
			}
8609
		} else {
8635
		} else {
8610
			if(this.astPtr > -1 && this.astStack[this.astPtr] instanceof TypeDeclaration) {
8636
			((RecoveryScanner)this.scanner).setPendingTokens(new int[]{TokenNameIdentifier, TokenNameEQUAL, TokenNameIdentifier});
8611
				this.astStack[astPtr] = typeDeclaration;
8637
		}
8612
				this.expressionStack[this.expressionPtr] = typeDeclaration.allocation;
8638
		
8613
			}
8639
		this.pendingRecoveredType = typeDeclaration;
8614
			this.currentToken = TokenNameRBRACE;
8640
		
8641
		try {
8642
			this.currentToken = this.scanner.getNextToken();
8643
		} catch(InvalidInputException e){
8644
			// it's impossible because we added pending tokens before
8615
		}
8645
		}
8616
		
8646
		
8617
		if(++this.recoveredTypePtr < this.recoveredTypes.length) {
8647
		if(++this.recoveredTypePtr < this.recoveredTypes.length) {
8618
			TypeDeclaration nextTypeDeclaration = this.recoveredTypes[this.recoveredTypePtr];
8648
			TypeDeclaration nextTypeDeclaration = this.recoveredTypes[this.recoveredTypePtr];
8619
			this.nextTypeStart =
8649
			this.nextTypeStart =
8620
				nextTypeDeclaration.allocation == null
8650
				nextTypeDeclaration.allocation == null
8621
					? nextTypeDeclaration.declarationSourceStart
8651
					? nextTypeDeclaration.declarationSourceStart 
8622
							: nextTypeDeclaration.bodyStart;
8652
							: nextTypeDeclaration.allocation.sourceStart;
8623
		} else {
8653
		} else {
8624
			this.nextTypeStart = Integer.MAX_VALUE;
8654
			this.nextTypeStart = Integer.MAX_VALUE;
8625
		}
8655
		}
Lines 8831-8838 Link Here
8831
// name[symbol_index[currentKind]]
8861
// name[symbol_index[currentKind]]
8832
protected void parse() {
8862
protected void parse() {
8833
	if (DEBUG) System.out.println("-- ENTER INSIDE PARSE METHOD --");  //$NON-NLS-1$
8863
	if (DEBUG) System.out.println("-- ENTER INSIDE PARSE METHOD --");  //$NON-NLS-1$
8864
	
8865
	if (DEBUG_AUTOMATON) {
8866
		System.out.println("- Start --------------------------------");  //$NON-NLS-1$
8867
	}
8868
	
8834
	boolean isDietParse = this.diet;
8869
	boolean isDietParse = this.diet;
8835
	boolean jumpOverTypeAfterReduce = false;
8836
	int oldFirstToken = getFirstToken();
8870
	int oldFirstToken = getFirstToken();
8837
	this.hasError = false;
8871
	this.hasError = false;
8838
	
8872
	
Lines 8852-8857 Link Here
8852
8886
8853
		act = tAction(act, this.currentToken);
8887
		act = tAction(act, this.currentToken);
8854
		if (act == ERROR_ACTION || this.restartRecovery) {
8888
		if (act == ERROR_ACTION || this.restartRecovery) {
8889
			
8890
			if (DEBUG_AUTOMATON) {
8891
				if (this.restartRecovery) {
8892
					System.out.println("Restart      - "); //$NON-NLS-1$
8893
				} else {
8894
					System.out.println("Error        - "); //$NON-NLS-1$
8895
				}
8896
			}
8897
			
8855
			int errorPos = this.scanner.currentPosition;
8898
			int errorPos = this.scanner.currentPosition;
8856
			if (!this.hasReportedError) {
8899
			if (!this.hasReportedError) {
8857
				this.hasError = true;
8900
				this.hasError = true;
Lines 8868-8874 Link Here
8868
		}
8911
		}
8869
		if (act <= NUM_RULES) {
8912
		if (act <= NUM_RULES) {
8870
			this.stateStackTop--;
8913
			this.stateStackTop--;
8871
8914
			
8915
			if (DEBUG_AUTOMATON) {
8916
				System.out.print("Reduce       - "); //$NON-NLS-1$
8917
			}
8918
			
8872
		} else if (act > ERROR_ACTION) { /* shift-reduce */
8919
		} else if (act > ERROR_ACTION) { /* shift-reduce */
8873
			consumeToken(this.currentToken);
8920
			consumeToken(this.currentToken);
8874
			if (this.currentElement != null) this.recoveryTokenCheck();
8921
			if (this.currentElement != null) this.recoveryTokenCheck();
Lines 8883-8892 Link Here
8883
				this.restartRecovery = true;
8930
				this.restartRecovery = true;
8884
			}				
8931
			}				
8885
			if(this.statementRecoveryActivated) {
8932
			if(this.statementRecoveryActivated) {
8886
				jumpOverTypeAfterReduce = true;
8933
				this.jumpOverType();
8887
			}
8934
			}
8888
			act -= ERROR_ACTION;
8935
			act -= ERROR_ACTION;
8889
			
8936
			
8937
			if (DEBUG_AUTOMATON) {
8938
				System.out.print("Shift/Reduce - (" + name[terminal_index[this.currentToken]]+") ");  //$NON-NLS-1$  //$NON-NLS-2$ 
8939
			}
8940
			
8890
		} else {
8941
		} else {
8891
		    if (act < ACCEPT_ACTION) { /* shift */
8942
		    if (act < ACCEPT_ACTION) { /* shift */
8892
				consumeToken(this.currentToken);
8943
				consumeToken(this.currentToken);
Lines 8904-8909 Link Here
8904
				if(this.statementRecoveryActivated) {
8955
				if(this.statementRecoveryActivated) {
8905
					this.jumpOverType();
8956
					this.jumpOverType();
8906
				}
8957
				}
8958
				if (DEBUG_AUTOMATON) {
8959
					System.out.println("Shift        - (" + name[terminal_index[this.currentToken]]+")");  //$NON-NLS-1$  //$NON-NLS-2$
8960
				}
8907
				continue ProcessTerminals;
8961
				continue ProcessTerminals;
8908
			}
8962
			}
8909
			break ProcessTerminals;
8963
			break ProcessTerminals;
Lines 8911-8927 Link Here
8911
			
8965
			
8912
		// ProcessNonTerminals : 
8966
		// ProcessNonTerminals : 
8913
		do { /* reduce */
8967
		do { /* reduce */
8968
			
8969
			if (DEBUG_AUTOMATON) {
8970
				System.out.println(name[non_terminal_index[lhs[act]]]);
8971
			}
8972
			
8914
			consumeRule(act);
8973
			consumeRule(act);
8915
			this.stateStackTop -= (rhs[act] - 1);
8974
			this.stateStackTop -= (rhs[act] - 1);
8916
			act = ntAction(this.stack[this.stateStackTop], lhs[act]);
8975
			act = ntAction(this.stack[this.stateStackTop], lhs[act]);
8917
			if(this.statementRecoveryActivated && act > NUM_RULES) {
8976
			
8918
				if(jumpOverTypeAfterReduce) {
8977
			if (DEBUG_AUTOMATON && act <= NUM_RULES) {
8919
					this.jumpOverType();
8978
				System.out.print("             - ");  //$NON-NLS-1$
8920
					jumpOverTypeAfterReduce = false;
8921
				}
8922
			}
8979
			}
8980
			
8923
		} while (act <= NUM_RULES);
8981
		} while (act <= NUM_RULES);
8982
		
8983
		if (DEBUG_AUTOMATON) {
8984
			System.out.println("----------------------------------------");  //$NON-NLS-1$
8985
		}
8986
	}
8987
	
8988
	if (DEBUG_AUTOMATON) {
8989
		System.out.println("- End ----------------------------------");  //$NON-NLS-1$
8924
	}
8990
	}
8991
	
8925
	endParse(act);
8992
	endParse(act);
8926
	// record all nls tags in the corresponding compilation unit
8993
	// record all nls tags in the corresponding compilation unit
8927
	final NLSTag[] tags = this.scanner.getNLSTags();
8994
	final NLSTag[] tags = this.scanner.getNLSTags();
Lines 9367-9379 Link Here
9367
	this.referenceContext = rc;
9434
	this.referenceContext = rc;
9368
	this.compilationUnit = unit;
9435
	this.compilationUnit = unit;
9369
	
9436
	
9437
	this.pendingRecoveredType = null;
9438
	
9370
	if(types != null && types.length > 0) {
9439
	if(types != null && types.length > 0) {
9371
		this.recoveredTypes = types;
9440
		this.recoveredTypes = types;
9372
		this.recoveredTypePtr = 0;
9441
		this.recoveredTypePtr = 0;
9373
		this.nextTypeStart =
9442
		this.nextTypeStart =
9374
			this.recoveredTypes[0].allocation == null
9443
			this.recoveredTypes[0].allocation == null
9375
				? this.recoveredTypes[0].declarationSourceStart
9444
				? this.recoveredTypes[0].declarationSourceStart
9376
						: this.recoveredTypes[0].bodyStart;
9445
						: this.recoveredTypes[0].allocation.sourceStart;
9377
	} else {
9446
	} else {
9378
		this.recoveredTypes = null;
9447
		this.recoveredTypes = null;
9379
		this.recoveredTypePtr = -1;
9448
		this.recoveredTypePtr = -1;
Lines 9976-9981 Link Here
9976
		// Reset javadoc before restart parsing after recovery
10045
		// Reset javadoc before restart parsing after recovery
9977
		this.javadoc = null;
10046
		this.javadoc = null;
9978
10047
10048
		// do not investigate deeper in statement recovery
10049
		if (this.statementRecoveryActivated) return false;
10050
		
9979
		// build some recovered elements
10051
		// build some recovered elements
9980
		this.currentElement = buildInitialRecoveryState(); 
10052
		this.currentElement = buildInitialRecoveryState(); 
9981
	}
10053
	}
(-)compiler/org/eclipse/jdt/internal/compiler/parser/RecoveryScanner.java (+5 lines)
Lines 233-236 Link Here
233
			this.data = data;
233
			this.data = data;
234
		}
234
		}
235
	}
235
	}
236
	
237
	public void setPendingTokens(int[] pendingTokens) {
238
		this.pendingTokens = pendingTokens;
239
		this.pendingTokensPtr = pendingTokens.length - 1;
240
	}
236
}
241
}

Return to bug 140980