Lines 189-194
Link Here
|
189 |
protected TypeDeclaration[] recoveredTypes; |
189 |
protected TypeDeclaration[] recoveredTypes; |
190 |
protected int recoveredTypePtr; |
190 |
protected int recoveredTypePtr; |
191 |
protected int nextTypeStart; |
191 |
protected int nextTypeStart; |
|
|
192 |
protected TypeDeclaration pendingRecoveredType; |
192 |
|
193 |
|
193 |
public RecoveryScanner recoveryScanner; |
194 |
public RecoveryScanner recoveryScanner; |
194 |
|
195 |
|
Lines 1023-1028
Link Here
|
1023 |
} |
1024 |
} |
1024 |
} |
1025 |
} |
1025 |
} |
1026 |
} |
|
|
1027 |
|
1028 |
if (this.statementRecoveryActivated) { |
1029 |
if (this.pendingRecoveredType != null && |
1030 |
this.scanner.startPosition - 1 <= this.pendingRecoveredType.declarationSourceEnd) { |
1031 |
// Add the pending type to the AST if this type isn't already added in the AST. |
1032 |
element = element.add(this.pendingRecoveredType, 0); |
1033 |
this.lastCheckPoint = this.pendingRecoveredType.declarationSourceEnd + 1; |
1034 |
this.pendingRecoveredType = null; |
1035 |
} |
1036 |
} |
1037 |
|
1026 |
return element; |
1038 |
return element; |
1027 |
} |
1039 |
} |
1028 |
|
1040 |
|
Lines 1458-1463
Link Here
|
1458 |
this.expressionStack[this.expressionPtr] , |
1470 |
this.expressionStack[this.expressionPtr] , |
1459 |
this.expressionStack[this.expressionPtr+1], |
1471 |
this.expressionStack[this.expressionPtr+1], |
1460 |
this.scanner.startPosition - 1); |
1472 |
this.scanner.startPosition - 1); |
|
|
1473 |
|
1474 |
if (this.pendingRecoveredType != null) { |
1475 |
// Used only in statements recovery. |
1476 |
// This is not a real assignment but a placeholder for an existing anonymous type. |
1477 |
// The assignment must be replace by the anonymous type. |
1478 |
if (this.pendingRecoveredType.allocation != null && |
1479 |
this.scanner.startPosition - 1 <= this.pendingRecoveredType.declarationSourceEnd) { |
1480 |
this.expressionStack[this.expressionPtr] = this.pendingRecoveredType.allocation; |
1481 |
this.pendingRecoveredType = null; |
1482 |
return; |
1483 |
} |
1484 |
this.pendingRecoveredType = null; |
1485 |
} |
1461 |
} |
1486 |
} |
1462 |
protected void consumeAssignmentOperator(int pos) { |
1487 |
protected void consumeAssignmentOperator(int pos) { |
1463 |
// AssignmentOperator ::= '=' |
1488 |
// AssignmentOperator ::= '=' |
Lines 6557-6562
Link Here
|
6557 |
// break pushs a position on this.intStack in case there is no label |
6582 |
// break pushs a position on this.intStack in case there is no label |
6558 |
|
6583 |
|
6559 |
pushOnAstStack(new BreakStatement(null, this.intStack[this.intPtr--], this.endPosition)); |
6584 |
pushOnAstStack(new BreakStatement(null, this.intStack[this.intPtr--], this.endPosition)); |
|
|
6585 |
|
6586 |
if (this.pendingRecoveredType != null) { |
6587 |
// Used only in statements recovery. |
6588 |
// This is not a real break statement but a placeholder for an existing local type. |
6589 |
// The break statement must be replace by the local type. |
6590 |
if (this.pendingRecoveredType.allocation == null && |
6591 |
this.endPosition <= this.pendingRecoveredType.declarationSourceEnd) { |
6592 |
this.astStack[this.astPtr] = this.pendingRecoveredType; |
6593 |
this.pendingRecoveredType = null; |
6594 |
return; |
6595 |
} |
6596 |
this.pendingRecoveredType = null; |
6597 |
} |
6560 |
} |
6598 |
} |
6561 |
protected void consumeStatementBreakWithLabel() { |
6599 |
protected void consumeStatementBreakWithLabel() { |
6562 |
// BreakStatement ::= 'break' Identifier ';' |
6600 |
// BreakStatement ::= 'break' Identifier ';' |
Lines 8515-8552
Link Here
|
8515 |
int end = this.scanner.eofPosition; |
8553 |
int end = this.scanner.eofPosition; |
8516 |
this.scanner.resetTo(typeDeclaration.declarationSourceEnd + 1, end - 1); |
8554 |
this.scanner.resetTo(typeDeclaration.declarationSourceEnd + 1, end - 1); |
8517 |
if(!isAnonymous) { |
8555 |
if(!isAnonymous) { |
8518 |
pushOnAstStack(typeDeclaration); |
8556 |
((RecoveryScanner)this.scanner).setPendingTokens(new int[]{TokenNameSEMICOLON, TokenNamebreak}); |
8519 |
if(this.astLengthPtr > 0) { |
|
|
8520 |
concatNodeLists(); |
8521 |
} |
8522 |
|
8523 |
if(this.currentElement != null) { |
8524 |
this.currentElement = this.currentElement.add(typeDeclaration, 0); |
8525 |
} |
8526 |
|
8527 |
try { |
8528 |
this.currentToken = this.scanner.getNextToken(); |
8529 |
} catch(InvalidInputException e){ |
8530 |
if (!this.hasReportedError){ |
8531 |
this.problemReporter().scannerError(this, e.getMessage()); |
8532 |
this.hasReportedError = true; |
8533 |
} |
8534 |
this.lastCheckPoint = this.scanner.currentPosition; |
8535 |
} |
8536 |
} else { |
8557 |
} else { |
8537 |
if(this.astPtr > -1 && this.astStack[this.astPtr] instanceof TypeDeclaration) { |
8558 |
((RecoveryScanner)this.scanner).setPendingTokens(new int[]{TokenNameIdentifier, TokenNameEQUAL, TokenNameIdentifier}); |
8538 |
this.astStack[astPtr] = typeDeclaration; |
8559 |
} |
8539 |
this.expressionStack[this.expressionPtr] = typeDeclaration.allocation; |
8560 |
|
8540 |
} |
8561 |
this.pendingRecoveredType = typeDeclaration; |
8541 |
this.currentToken = TokenNameRBRACE; |
8562 |
|
|
|
8563 |
try { |
8564 |
this.currentToken = this.scanner.getNextToken(); |
8565 |
} catch(InvalidInputException e){ |
8566 |
// it's impossible because we added pending tokens before |
8542 |
} |
8567 |
} |
8543 |
|
8568 |
|
8544 |
if(++this.recoveredTypePtr < this.recoveredTypes.length) { |
8569 |
if(++this.recoveredTypePtr < this.recoveredTypes.length) { |
8545 |
TypeDeclaration nextTypeDeclaration = this.recoveredTypes[this.recoveredTypePtr]; |
8570 |
TypeDeclaration nextTypeDeclaration = this.recoveredTypes[this.recoveredTypePtr]; |
8546 |
this.nextTypeStart = |
8571 |
this.nextTypeStart = |
8547 |
nextTypeDeclaration.allocation == null |
8572 |
nextTypeDeclaration.allocation == null |
8548 |
? nextTypeDeclaration.declarationSourceStart |
8573 |
? nextTypeDeclaration.declarationSourceStart |
8549 |
: nextTypeDeclaration.bodyStart; |
8574 |
: nextTypeDeclaration.allocation.sourceStart; |
8550 |
} else { |
8575 |
} else { |
8551 |
this.nextTypeStart = Integer.MAX_VALUE; |
8576 |
this.nextTypeStart = Integer.MAX_VALUE; |
8552 |
} |
8577 |
} |
Lines 8757-8763
Link Here
|
8757 |
protected void parse() { |
8782 |
protected void parse() { |
8758 |
if (DEBUG) System.out.println("-- ENTER INSIDE PARSE METHOD --"); //$NON-NLS-1$ |
8783 |
if (DEBUG) System.out.println("-- ENTER INSIDE PARSE METHOD --"); //$NON-NLS-1$ |
8759 |
boolean isDietParse = this.diet; |
8784 |
boolean isDietParse = this.diet; |
8760 |
boolean jumpOverTypeAfterReduce = false; |
|
|
8761 |
int oldFirstToken = getFirstToken(); |
8785 |
int oldFirstToken = getFirstToken(); |
8762 |
this.hasError = false; |
8786 |
this.hasError = false; |
8763 |
|
8787 |
|
Lines 8808-8814
Link Here
|
8808 |
this.restartRecovery = true; |
8832 |
this.restartRecovery = true; |
8809 |
} |
8833 |
} |
8810 |
if(this.statementRecoveryActivated) { |
8834 |
if(this.statementRecoveryActivated) { |
8811 |
jumpOverTypeAfterReduce = true; |
8835 |
this.jumpOverType(); |
8812 |
} |
8836 |
} |
8813 |
act -= ERROR_ACTION; |
8837 |
act -= ERROR_ACTION; |
8814 |
|
8838 |
|
Lines 8839-8850
Link Here
|
8839 |
consumeRule(act); |
8863 |
consumeRule(act); |
8840 |
this.stateStackTop -= (rhs[act] - 1); |
8864 |
this.stateStackTop -= (rhs[act] - 1); |
8841 |
act = ntAction(this.stack[this.stateStackTop], lhs[act]); |
8865 |
act = ntAction(this.stack[this.stateStackTop], lhs[act]); |
8842 |
if(this.statementRecoveryActivated && act > NUM_RULES) { |
|
|
8843 |
if(jumpOverTypeAfterReduce) { |
8844 |
this.jumpOverType(); |
8845 |
jumpOverTypeAfterReduce = false; |
8846 |
} |
8847 |
} |
8848 |
} while (act <= NUM_RULES); |
8866 |
} while (act <= NUM_RULES); |
8849 |
} |
8867 |
} |
8850 |
endParse(act); |
8868 |
endParse(act); |
Lines 9292-9304
Link Here
|
9292 |
this.referenceContext = rc; |
9310 |
this.referenceContext = rc; |
9293 |
this.compilationUnit = unit; |
9311 |
this.compilationUnit = unit; |
9294 |
|
9312 |
|
|
|
9313 |
this.pendingRecoveredType = null; |
9314 |
|
9295 |
if(types != null && types.length > 0) { |
9315 |
if(types != null && types.length > 0) { |
9296 |
this.recoveredTypes = types; |
9316 |
this.recoveredTypes = types; |
9297 |
this.recoveredTypePtr = 0; |
9317 |
this.recoveredTypePtr = 0; |
9298 |
this.nextTypeStart = |
9318 |
this.nextTypeStart = |
9299 |
this.recoveredTypes[0].allocation == null |
9319 |
this.recoveredTypes[0].allocation == null |
9300 |
? this.recoveredTypes[0].declarationSourceStart |
9320 |
? this.recoveredTypes[0].declarationSourceStart |
9301 |
: this.recoveredTypes[0].bodyStart; |
9321 |
: this.recoveredTypes[0].allocation.sourceStart; |
9302 |
} else { |
9322 |
} else { |
9303 |
this.recoveredTypes = null; |
9323 |
this.recoveredTypes = null; |
9304 |
this.recoveredTypePtr = -1; |
9324 |
this.recoveredTypePtr = -1; |
Lines 9900-9905
Link Here
|
9900 |
if (this.currentElement == null){ |
9920 |
if (this.currentElement == null){ |
9901 |
// Reset javadoc before restart parsing after recovery |
9921 |
// Reset javadoc before restart parsing after recovery |
9902 |
this.javadoc = null; |
9922 |
this.javadoc = null; |
|
|
9923 |
|
9924 |
if (this.statementRecoveryActivated) return false; |
9903 |
|
9925 |
|
9904 |
// build some recovered elements |
9926 |
// build some recovered elements |
9905 |
this.currentElement = buildInitialRecoveryState(); |
9927 |
this.currentElement = buildInitialRecoveryState(); |