Lines 22-35
Link Here
|
22 |
|
22 |
|
23 |
import org.eclipse.jdt.core.compiler.CharOperation; |
23 |
import org.eclipse.jdt.core.compiler.CharOperation; |
24 |
import org.eclipse.jdt.core.compiler.InvalidInputException; |
24 |
import org.eclipse.jdt.core.compiler.InvalidInputException; |
|
|
25 |
import org.eclipse.jdt.internal.compiler.ASTVisitor; |
25 |
import org.eclipse.jdt.internal.compiler.CompilationResult; |
26 |
import org.eclipse.jdt.internal.compiler.CompilationResult; |
26 |
import org.eclipse.jdt.internal.compiler.ast.*; |
27 |
import org.eclipse.jdt.internal.compiler.ast.*; |
27 |
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; |
28 |
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; |
28 |
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; |
29 |
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; |
29 |
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; |
30 |
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; |
30 |
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext; |
31 |
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext; |
|
|
32 |
import org.eclipse.jdt.internal.compiler.lookup.BlockScope; |
33 |
import org.eclipse.jdt.internal.compiler.lookup.ClassScope; |
31 |
import org.eclipse.jdt.internal.compiler.lookup.Binding; |
34 |
import org.eclipse.jdt.internal.compiler.lookup.Binding; |
32 |
import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers; |
35 |
import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers; |
|
|
36 |
import org.eclipse.jdt.internal.compiler.lookup.MethodScope; |
33 |
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; |
37 |
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; |
34 |
import org.eclipse.jdt.internal.compiler.lookup.TypeIds; |
38 |
import org.eclipse.jdt.internal.compiler.lookup.TypeIds; |
35 |
import org.eclipse.jdt.internal.compiler.parser.diagnose.DiagnoseParser; |
39 |
import org.eclipse.jdt.internal.compiler.parser.diagnose.DiagnoseParser; |
Lines 76-81
Link Here
|
76 |
|
80 |
|
77 |
public static byte rhs[] = null; |
81 |
public static byte rhs[] = null; |
78 |
|
82 |
|
|
|
83 |
public static int[] reverse_index = null; |
84 |
public static char[] recovery_templates_index = null; |
85 |
public static char[] recovery_templates = null; |
86 |
public static char[] statements_recovery_filter = null; |
87 |
|
79 |
public static long rules_compliance[] = null; |
88 |
public static long rules_compliance[] = null; |
80 |
|
89 |
|
81 |
public static final int RoundBracket = 0; |
90 |
public static final int RoundBracket = 0; |
Lines 171-176
Link Here
|
171 |
public boolean reportOnlyOneSyntaxError = false; |
180 |
public boolean reportOnlyOneSyntaxError = false; |
172 |
public boolean reportSyntaxErrorIsRequired = true; |
181 |
public boolean reportSyntaxErrorIsRequired = true; |
173 |
protected boolean restartRecovery; |
182 |
protected boolean restartRecovery; |
|
|
183 |
|
184 |
// statement recovery |
185 |
// public boolean statementRecoveryEnabled = true; |
186 |
protected boolean methodRecoveryActivated = false; |
187 |
protected boolean statementRecoveryActivated = false; |
188 |
protected TypeDeclaration[] recoveredTypes; |
189 |
protected int recoveredTypePtr; |
190 |
protected int nextTypeStart; |
191 |
|
192 |
public RecoveryScanner recoveryScanner; |
193 |
|
174 |
//scanner token |
194 |
//scanner token |
175 |
public Scanner scanner; |
195 |
public Scanner scanner; |
176 |
protected int[] stack = new int[StackIncrement]; |
196 |
protected int[] stack = new int[StackIncrement]; |
Lines 298-303
Link Here
|
298 |
Collections.sort(entries); |
318 |
Collections.sort(entries); |
299 |
buildFile(file, entries); |
319 |
buildFile(file, entries); |
300 |
} |
320 |
} |
|
|
321 |
private static void buildFilesForRecoveryTemplates( |
322 |
String indexFilename, |
323 |
String templatesFilename, |
324 |
char[] newTerminalIndex, |
325 |
char[] newNonTerminalIndex, |
326 |
String[] newName, |
327 |
char[] newLhs, |
328 |
String[] tokens) throws IOException { |
329 |
|
330 |
int[] newReverse = computeReverseTable(newTerminalIndex, newNonTerminalIndex, newName); |
331 |
|
332 |
char[] newRecoveyTemplatesIndex = new char[newNonTerminalIndex.length]; |
333 |
char[] newRecoveyTemplates = new char[newNonTerminalIndex.length]; |
334 |
int newRecoveyTemplatesPtr = 0; |
335 |
|
336 |
for (int i = 0; i < tokens.length; i = i + 3) { |
337 |
if("3".equals(tokens[i])) { //$NON-NLS-1$ |
338 |
int length = newRecoveyTemplates.length; |
339 |
if(length == newRecoveyTemplatesPtr + 1) { |
340 |
System.arraycopy(newRecoveyTemplates, 0, newRecoveyTemplates = new char[length * 2], 0, length); |
341 |
} |
342 |
newRecoveyTemplates[newRecoveyTemplatesPtr++] = 0; |
343 |
|
344 |
int index = newLhs[Integer.parseInt(tokens[i + 1])]; |
345 |
|
346 |
newRecoveyTemplatesIndex[index] = (char)newRecoveyTemplatesPtr; |
347 |
|
348 |
String token = tokens[i + 2].trim(); |
349 |
java.util.StringTokenizer st = new java.util.StringTokenizer(new String(token), " "); //$NON-NLS-1$ |
350 |
String[] terminalNames = new String[st.countTokens()]; |
351 |
int t = 0; |
352 |
while (st.hasMoreTokens()) { |
353 |
terminalNames[t++] = st.nextToken(); |
354 |
} |
355 |
|
356 |
for (int j = 0; j < terminalNames.length; j++) { |
357 |
int symbol = getSymbol(terminalNames[j], newName, newReverse); |
358 |
if(symbol > -1) { |
359 |
length = newRecoveyTemplates.length; |
360 |
if(length == newRecoveyTemplatesPtr + 1) { |
361 |
System.arraycopy(newRecoveyTemplates, 0, newRecoveyTemplates = new char[length * 2], 0, length); |
362 |
} |
363 |
newRecoveyTemplates[newRecoveyTemplatesPtr++] = (char)symbol; |
364 |
} |
365 |
} |
366 |
} |
367 |
} |
368 |
newRecoveyTemplates[newRecoveyTemplatesPtr++] = 0; |
369 |
System.arraycopy(newRecoveyTemplates, 0, newRecoveyTemplates = new char[newRecoveyTemplatesPtr], 0, newRecoveyTemplatesPtr); |
370 |
|
371 |
buildFileForTable(indexFilename, newRecoveyTemplatesIndex); |
372 |
buildFileForTable(templatesFilename, newRecoveyTemplates); |
373 |
} |
374 |
private static void buildFilesForStatementsRecoveryFilter( |
375 |
String filename, |
376 |
char[] newNonTerminalIndex, |
377 |
char[] newLhs, |
378 |
String[] tokens) throws IOException { |
379 |
|
380 |
char[] newStatementsRecoveryFilter = new char[newNonTerminalIndex.length]; |
381 |
|
382 |
for (int i = 0; i < tokens.length; i = i + 3) { |
383 |
if("4".equals(tokens[i])) { //$NON-NLS-1$ |
384 |
int index = newLhs[Integer.parseInt(tokens[i + 1])]; |
385 |
|
386 |
newStatementsRecoveryFilter[index] = 1; |
387 |
} |
388 |
} |
389 |
buildFileForTable(filename, newStatementsRecoveryFilter); |
390 |
} |
301 |
private static void buildFileForCompliance( |
391 |
private static void buildFileForCompliance( |
302 |
String file, |
392 |
String file, |
303 |
int length, |
393 |
int length, |
Lines 450-456
Link Here
|
450 |
buildFileOfIntFor(prefix + (++i) + ".rsc", "asr", tokens); //$NON-NLS-2$ //$NON-NLS-1$ |
540 |
buildFileOfIntFor(prefix + (++i) + ".rsc", "asr", tokens); //$NON-NLS-2$ //$NON-NLS-1$ |
451 |
buildFileOfIntFor(prefix + (++i) + ".rsc", "nasb", tokens); //$NON-NLS-2$ //$NON-NLS-1$ |
541 |
buildFileOfIntFor(prefix + (++i) + ".rsc", "nasb", tokens); //$NON-NLS-2$ //$NON-NLS-1$ |
452 |
buildFileOfIntFor(prefix + (++i) + ".rsc", "nasr", tokens); //$NON-NLS-2$ //$NON-NLS-1$ |
542 |
buildFileOfIntFor(prefix + (++i) + ".rsc", "nasr", tokens); //$NON-NLS-2$ //$NON-NLS-1$ |
453 |
buildFileOfIntFor(prefix + (++i) + ".rsc", "terminal_index", tokens); //$NON-NLS-2$ //$NON-NLS-1$ |
543 |
char[] newTerminalIndex = buildFileOfIntFor(prefix + (++i) + ".rsc", "terminal_index", tokens); //$NON-NLS-2$ //$NON-NLS-1$ |
454 |
char[] newNonTerminalIndex = buildFileOfIntFor(prefix + (++i) + ".rsc", "non_terminal_index", tokens); //$NON-NLS-1$ //$NON-NLS-2$ |
544 |
char[] newNonTerminalIndex = buildFileOfIntFor(prefix + (++i) + ".rsc", "non_terminal_index", tokens); //$NON-NLS-1$ //$NON-NLS-2$ |
455 |
buildFileOfIntFor(prefix + (++i) + ".rsc", "term_action", tokens); //$NON-NLS-2$ //$NON-NLS-1$ |
545 |
buildFileOfIntFor(prefix + (++i) + ".rsc", "term_action", tokens); //$NON-NLS-2$ //$NON-NLS-1$ |
456 |
|
546 |
|
Lines 475-481
Link Here
|
475 |
System.out.println(Messages.parser_incorrectPath); |
565 |
System.out.println(Messages.parser_incorrectPath); |
476 |
return; |
566 |
return; |
477 |
} |
567 |
} |
478 |
st = new java.util.StringTokenizer(new String(contents), "\t\n\r=#"); //$NON-NLS-1$ |
568 |
st = new java.util.StringTokenizer(new String(contents), "\t\n\r#"); //$NON-NLS-1$ |
479 |
tokens = new String[st.countTokens()]; |
569 |
tokens = new String[st.countTokens()]; |
480 |
j = 0; |
570 |
j = 0; |
481 |
while (st.hasMoreTokens()) { |
571 |
while (st.hasMoreTokens()) { |
Lines 485-490
Link Here
|
485 |
buildFileForCompliance(prefix + (++i) + ".rsc", newRhs.length, tokens);//$NON-NLS-1$ |
575 |
buildFileForCompliance(prefix + (++i) + ".rsc", newRhs.length, tokens);//$NON-NLS-1$ |
486 |
buildFileForReadableName(READABLE_NAMES_FILE+".properties", newLhs, newNonTerminalIndex, newName, tokens);//$NON-NLS-1$ |
576 |
buildFileForReadableName(READABLE_NAMES_FILE+".properties", newLhs, newNonTerminalIndex, newName, tokens);//$NON-NLS-1$ |
487 |
|
577 |
|
|
|
578 |
buildFilesForRecoveryTemplates( |
579 |
prefix + (++i) + ".rsc", //$NON-NLS-1$ |
580 |
prefix + (++i) + ".rsc", //$NON-NLS-1$ |
581 |
newTerminalIndex, |
582 |
newNonTerminalIndex, |
583 |
newName, |
584 |
newLhs, |
585 |
tokens); |
586 |
|
587 |
buildFilesForStatementsRecoveryFilter( |
588 |
prefix + (++i) + ".rsc", //$NON-NLS-1$ |
589 |
newNonTerminalIndex, |
590 |
newLhs, |
591 |
tokens); |
592 |
|
593 |
|
488 |
System.out.println(Messages.parser_moveFiles); |
594 |
System.out.println(Messages.parser_moveFiles); |
489 |
} |
595 |
} |
490 |
public static int in_symbol(int state) { |
596 |
public static int in_symbol(int state) { |
Lines 526-531
Link Here
|
526 |
|
632 |
|
527 |
readableName = readReadableNameTable(READABLE_NAMES_FILE_NAME); |
633 |
readableName = readReadableNameTable(READABLE_NAMES_FILE_NAME); |
528 |
|
634 |
|
|
|
635 |
reverse_index = computeReverseTable(terminal_index, non_terminal_index, name); |
636 |
|
637 |
recovery_templates_index = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$ |
638 |
recovery_templates = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$ |
639 |
|
640 |
statements_recovery_filter = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$ |
641 |
|
529 |
base_action = lhs; |
642 |
base_action = lhs; |
530 |
} |
643 |
} |
531 |
public static int nasi(int state) { |
644 |
public static int nasi(int state) { |
Lines 537-542
Link Here
|
537 |
protected static int original_state(int state) { |
650 |
protected static int original_state(int state) { |
538 |
return -base_check(state); |
651 |
return -base_check(state); |
539 |
} |
652 |
} |
|
|
653 |
protected static int[] computeReverseTable(char[] newTerminalIndex, char[] newNonTerminalIndex, String[] newName) { |
654 |
int[] newReverseTable = new int[newName.length]; |
655 |
for (int j = 0; j < newName.length; j++) { |
656 |
found : { |
657 |
for (int k = 0; k < newTerminalIndex.length; k++) { |
658 |
if(newTerminalIndex[k] == j) { |
659 |
newReverseTable[j] = k; |
660 |
break found; |
661 |
} |
662 |
} |
663 |
for (int k = 0; k < newNonTerminalIndex.length; k++) { |
664 |
if(newNonTerminalIndex[k] == j) { |
665 |
newReverseTable[j] = -k; |
666 |
break found; |
667 |
} |
668 |
} |
669 |
} |
670 |
} |
671 |
return newReverseTable; |
672 |
} |
673 |
|
674 |
private static int getSymbol(String terminalName, String[] newName, int[] newReverse) { |
675 |
for (int j = 0; j < newName.length; j++) { |
676 |
if(terminalName.equals(newName[j])) { |
677 |
return newReverse[j]; |
678 |
} |
679 |
} |
680 |
return -1; |
681 |
} |
682 |
|
540 |
protected static byte[] readByteTable(String filename) throws java.io.IOException { |
683 |
protected static byte[] readByteTable(String filename) throws java.io.IOException { |
541 |
|
684 |
|
542 |
//files are located at Parser.class directory |
685 |
//files are located at Parser.class directory |
Lines 703-708
Link Here
|
703 |
|
846 |
|
704 |
// javadoc support |
847 |
// javadoc support |
705 |
this.javadocParser = new JavadocParser(this); |
848 |
this.javadocParser = new JavadocParser(this); |
|
|
849 |
|
850 |
// this.statementRecoveryEnabled = this.options.performStatementsRecovery; |
706 |
} |
851 |
} |
707 |
protected void annotationRecoveryCheckPoint(int start, int end) { |
852 |
protected void annotationRecoveryCheckPoint(int start, int end) { |
708 |
if(this.lastCheckPoint > start && this.lastCheckPoint < end) { |
853 |
if(this.lastCheckPoint > start && this.lastCheckPoint < end) { |
Lines 768-773
Link Here
|
768 |
if (this.referenceContext instanceof AbstractMethodDeclaration){ |
913 |
if (this.referenceContext instanceof AbstractMethodDeclaration){ |
769 |
element = new RecoveredMethod((AbstractMethodDeclaration) this.referenceContext, null, 0, this); |
914 |
element = new RecoveredMethod((AbstractMethodDeclaration) this.referenceContext, null, 0, this); |
770 |
this.lastCheckPoint = ((AbstractMethodDeclaration) this.referenceContext).bodyStart; |
915 |
this.lastCheckPoint = ((AbstractMethodDeclaration) this.referenceContext).bodyStart; |
|
|
916 |
if(this.statementRecoveryActivated) { |
917 |
element = element.add(new Block(0), 0); |
918 |
} |
771 |
} else { |
919 |
} else { |
772 |
/* Initializer bodies are parsed in the context of the type declaration, we must thus search it inside */ |
920 |
/* Initializer bodies are parsed in the context of the type declaration, we must thus search it inside */ |
773 |
if (this.referenceContext instanceof TypeDeclaration){ |
921 |
if (this.referenceContext instanceof TypeDeclaration){ |
Lines 845-850
Link Here
|
845 |
element = element.add(importRef, 0); |
993 |
element = element.add(importRef, 0); |
846 |
this.lastCheckPoint = importRef.declarationSourceEnd + 1; |
994 |
this.lastCheckPoint = importRef.declarationSourceEnd + 1; |
847 |
} |
995 |
} |
|
|
996 |
if(this.statementRecoveryActivated) { |
997 |
if(node instanceof Block) { |
998 |
Block block = (Block) node; |
999 |
element = element.add(block, 0); |
1000 |
this.lastCheckPoint = block.sourceEnd + 1; |
1001 |
} else if(node instanceof LocalDeclaration) { |
1002 |
LocalDeclaration statement = (LocalDeclaration) node; |
1003 |
element = element.add(statement, 0); |
1004 |
this.lastCheckPoint = statement.sourceEnd + 1; |
1005 |
} else if(node instanceof Expression) { |
1006 |
Expression statement = (Expression) node; |
1007 |
element = element.add(statement, 0); |
1008 |
if(statement.statementEnd != -1) { |
1009 |
this.lastCheckPoint = statement.statementEnd + 1; |
1010 |
} else { |
1011 |
this.lastCheckPoint = statement.sourceEnd + 1; |
1012 |
} |
1013 |
} else if(node instanceof Statement) { |
1014 |
Statement statement = (Statement) node; |
1015 |
element = element.add(statement, 0); |
1016 |
this.lastCheckPoint = statement.sourceEnd + 1; |
1017 |
} |
1018 |
} |
848 |
} |
1019 |
} |
849 |
return element; |
1020 |
return element; |
850 |
} |
1021 |
} |
Lines 1133-1139
Link Here
|
1133 |
annotationTypeDeclaration.javadoc = this.javadoc; |
1304 |
annotationTypeDeclaration.javadoc = this.javadoc; |
1134 |
this.javadoc = null; |
1305 |
this.javadoc = null; |
1135 |
pushOnAstStack(annotationTypeDeclaration); |
1306 |
pushOnAstStack(annotationTypeDeclaration); |
1136 |
if(options.sourceLevel < ClassFileConstants.JDK1_5 && |
1307 |
if(!this.statementRecoveryActivated && |
|
|
1308 |
options.sourceLevel < ClassFileConstants.JDK1_5 && |
1137 |
this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) { |
1309 |
this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) { |
1138 |
this.problemReporter().invalidUsageOfAnnotationDeclarations(annotationTypeDeclaration); |
1310 |
this.problemReporter().invalidUsageOfAnnotationDeclarations(annotationTypeDeclaration); |
1139 |
} |
1311 |
} |
Lines 2421-2427
Link Here
|
2421 |
protected void consumeEmptyClassMemberDeclaration() { |
2593 |
protected void consumeEmptyClassMemberDeclaration() { |
2422 |
// ClassMemberDeclaration ::= ';' |
2594 |
// ClassMemberDeclaration ::= ';' |
2423 |
pushOnAstLengthStack(0); |
2595 |
pushOnAstLengthStack(0); |
2424 |
problemReporter().superfluousSemicolon(this.endPosition+1, this.endStatementPosition); |
2596 |
if(!this.statementRecoveryActivated) problemReporter().superfluousSemicolon(this.endPosition+1, this.endStatementPosition); |
2425 |
flushCommentsDefinedPriorTo(this.endStatementPosition); |
2597 |
flushCommentsDefinedPriorTo(this.endStatementPosition); |
2426 |
} |
2598 |
} |
2427 |
protected void consumeEmptyMethodHeaderDefaultValue() { |
2599 |
protected void consumeEmptyMethodHeaderDefaultValue() { |
Lines 2489-2495
Link Here
|
2489 |
protected void consumeEmptyTypeDeclaration() { |
2661 |
protected void consumeEmptyTypeDeclaration() { |
2490 |
// TypeDeclaration ::= ';' |
2662 |
// TypeDeclaration ::= ';' |
2491 |
pushOnAstLengthStack(0); |
2663 |
pushOnAstLengthStack(0); |
2492 |
problemReporter().superfluousSemicolon(this.endPosition+1, this.endStatementPosition); |
2664 |
if(!this.statementRecoveryActivated) problemReporter().superfluousSemicolon(this.endPosition+1, this.endStatementPosition); |
2493 |
flushCommentsDefinedPriorTo(this.endStatementPosition); |
2665 |
flushCommentsDefinedPriorTo(this.endStatementPosition); |
2494 |
} |
2666 |
} |
2495 |
protected void consumeEnhancedForStatementHeaderInit(boolean hasModifiers) { |
2667 |
protected void consumeEnhancedForStatementHeaderInit(boolean hasModifiers) { |
Lines 2539-2544
Link Here
|
2539 |
localDeclaration, |
2711 |
localDeclaration, |
2540 |
this.intStack[this.intPtr--]); |
2712 |
this.intStack[this.intPtr--]); |
2541 |
pushOnAstStack(iteratorForStatement); |
2713 |
pushOnAstStack(iteratorForStatement); |
|
|
2714 |
|
2715 |
iteratorForStatement.sourceEnd = localDeclaration.declarationSourceEnd; |
2542 |
} |
2716 |
} |
2543 |
protected void consumeEnhancedForStatementHeader(){ |
2717 |
protected void consumeEnhancedForStatementHeader(){ |
2544 |
// EnhancedForStatementHeader ::= EnhancedForStatementHeaderInit ':' Expression ')' |
2718 |
// EnhancedForStatementHeader ::= EnhancedForStatementHeaderInit ':' Expression ')' |
Lines 2547-2553
Link Here
|
2547 |
this.expressionLengthPtr--; |
2721 |
this.expressionLengthPtr--; |
2548 |
final Expression collection = this.expressionStack[this.expressionPtr--]; |
2722 |
final Expression collection = this.expressionStack[this.expressionPtr--]; |
2549 |
statement.collection = collection; |
2723 |
statement.collection = collection; |
2550 |
if(options.sourceLevel < ClassFileConstants.JDK1_5 && |
2724 |
statement.sourceEnd = this.rParenPos; |
|
|
2725 |
|
2726 |
if(!this.statementRecoveryActivated && |
2727 |
options.sourceLevel < ClassFileConstants.JDK1_5 && |
2551 |
this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) { |
2728 |
this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) { |
2552 |
this.problemReporter().invalidUsageOfForeachStatements(statement.elementVariable, collection); |
2729 |
this.problemReporter().invalidUsageOfForeachStatements(statement.elementVariable, collection); |
2553 |
} |
2730 |
} |
Lines 2986-2992
Link Here
|
2986 |
|
3163 |
|
2987 |
this.listLength = 0; // will be updated when reading super-interfaces |
3164 |
this.listLength = 0; // will be updated when reading super-interfaces |
2988 |
|
3165 |
|
2989 |
if(options.sourceLevel < ClassFileConstants.JDK1_5 && |
3166 |
if(!this.statementRecoveryActivated && |
|
|
3167 |
options.sourceLevel < ClassFileConstants.JDK1_5 && |
2990 |
this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) { |
3168 |
this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) { |
2991 |
//TODO this code will be never run while 'enum' is an identifier in 1.3 scanner |
3169 |
//TODO this code will be never run while 'enum' is an identifier in 1.3 scanner |
2992 |
this.problemReporter().invalidUsageOfEnumDeclarations(enumDeclaration); |
3170 |
this.problemReporter().invalidUsageOfEnumDeclarations(enumDeclaration); |
Lines 3146-3152
Link Here
|
3146 |
protected void consumeExpressionStatement() { |
3324 |
protected void consumeExpressionStatement() { |
3147 |
// ExpressionStatement ::= StatementExpression ';' |
3325 |
// ExpressionStatement ::= StatementExpression ';' |
3148 |
this.expressionLengthPtr--; |
3326 |
this.expressionLengthPtr--; |
3149 |
pushOnAstStack(this.expressionStack[this.expressionPtr--]); |
3327 |
Expression expression = this.expressionStack[this.expressionPtr--]; |
|
|
3328 |
expression.statementEnd = this.endStatementPosition; |
3329 |
pushOnAstStack(expression); |
3150 |
} |
3330 |
} |
3151 |
protected void consumeFieldAccess(boolean isSuperAccess) { |
3331 |
protected void consumeFieldAccess(boolean isSuperAccess) { |
3152 |
// FieldAccess ::= Primary '.' 'Identifier' |
3332 |
// FieldAccess ::= Primary '.' 'Identifier' |
Lines 3290-3299
Link Here
|
3290 |
this.listLength++; |
3470 |
this.listLength++; |
3291 |
|
3471 |
|
3292 |
if(isVarArgs) { |
3472 |
if(isVarArgs) { |
3293 |
if (options.sourceLevel < ClassFileConstants.JDK1_5 && |
3473 |
if (!this.statementRecoveryActivated && |
|
|
3474 |
options.sourceLevel < ClassFileConstants.JDK1_5 && |
3294 |
this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) { |
3475 |
this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) { |
3295 |
this.problemReporter().invalidUsageOfVarargs(arg); |
3476 |
this.problemReporter().invalidUsageOfVarargs(arg); |
3296 |
} else if (extendedDimensions > 0) { |
3477 |
} else if (!this.statementRecoveryActivated && |
|
|
3478 |
extendedDimensions > 0) { |
3297 |
this.problemReporter().illegalExtendedDimensions(arg); |
3479 |
this.problemReporter().illegalExtendedDimensions(arg); |
3298 |
} |
3480 |
} |
3299 |
} |
3481 |
} |
Lines 3570-3576
Link Here
|
3570 |
protected void consumeInvalidAnnotationTypeDeclaration() { |
3752 |
protected void consumeInvalidAnnotationTypeDeclaration() { |
3571 |
// BlockStatement ::= AnnotationTypeDeclaration |
3753 |
// BlockStatement ::= AnnotationTypeDeclaration |
3572 |
TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr]; |
3754 |
TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr]; |
3573 |
problemReporter().illegalLocalTypeDeclaration(typeDecl); |
3755 |
if(!this.statementRecoveryActivated) problemReporter().illegalLocalTypeDeclaration(typeDecl); |
3574 |
// remove the ast node created in interface header |
3756 |
// remove the ast node created in interface header |
3575 |
this.astPtr--; |
3757 |
this.astPtr--; |
3576 |
pushOnAstLengthStack(-1); |
3758 |
pushOnAstLengthStack(-1); |
Lines 3623-3629
Link Here
|
3623 |
// BlockStatement ::= InvalidInterfaceDeclaration |
3805 |
// BlockStatement ::= InvalidInterfaceDeclaration |
3624 |
//InterfaceDeclaration ::= Modifiersopt 'interface' 'Identifier' ExtendsInterfacesopt InterfaceHeader InterfaceBody |
3806 |
//InterfaceDeclaration ::= Modifiersopt 'interface' 'Identifier' ExtendsInterfacesopt InterfaceHeader InterfaceBody |
3625 |
TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr]; |
3807 |
TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr]; |
3626 |
problemReporter().illegalLocalTypeDeclaration(typeDecl); |
3808 |
if(!this.statementRecoveryActivated) problemReporter().illegalLocalTypeDeclaration(typeDecl); |
3627 |
// remove the ast node created in interface header |
3809 |
// remove the ast node created in interface header |
3628 |
this.astPtr--; |
3810 |
this.astPtr--; |
3629 |
pushOnAstLengthStack(-1); |
3811 |
pushOnAstLengthStack(-1); |
Lines 3632-3638
Link Here
|
3632 |
protected void consumeInvalidEnumDeclaration() { |
3814 |
protected void consumeInvalidEnumDeclaration() { |
3633 |
// BlockStatement ::= EnumDeclaration |
3815 |
// BlockStatement ::= EnumDeclaration |
3634 |
TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr]; |
3816 |
TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr]; |
3635 |
problemReporter().illegalLocalTypeDeclaration(typeDecl); |
3817 |
if(!this.statementRecoveryActivated) problemReporter().illegalLocalTypeDeclaration(typeDecl); |
3636 |
// remove the ast node created in interface header |
3818 |
// remove the ast node created in interface header |
3637 |
this.astPtr--; |
3819 |
this.astPtr--; |
3638 |
pushOnAstLengthStack(-1); |
3820 |
pushOnAstLengthStack(-1); |
Lines 3668-3674
Link Here
|
3668 |
md.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition); |
3850 |
md.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition); |
3669 |
|
3851 |
|
3670 |
// report the problem and continue the parsing - narrowing the problem onto the method |
3852 |
// report the problem and continue the parsing - narrowing the problem onto the method |
3671 |
problemReporter().abstractMethodNeedingNoBody(md); |
3853 |
if(!this.statementRecoveryActivated) problemReporter().abstractMethodNeedingNoBody(md); |
3672 |
} |
3854 |
} |
3673 |
protected void consumeLabel() { |
3855 |
protected void consumeLabel() { |
3674 |
// Do nothing |
3856 |
// Do nothing |
Lines 3728-3734
Link Here
|
3728 |
markerAnnotation = new MarkerAnnotation(typeReference, this.intStack[this.intPtr--]); |
3910 |
markerAnnotation = new MarkerAnnotation(typeReference, this.intStack[this.intPtr--]); |
3729 |
markerAnnotation.declarationSourceEnd = markerAnnotation.sourceEnd; |
3911 |
markerAnnotation.declarationSourceEnd = markerAnnotation.sourceEnd; |
3730 |
pushOnExpressionStack(markerAnnotation); |
3912 |
pushOnExpressionStack(markerAnnotation); |
3731 |
if(options.sourceLevel < ClassFileConstants.JDK1_5 && |
3913 |
if(!this.statementRecoveryActivated && |
|
|
3914 |
options.sourceLevel < ClassFileConstants.JDK1_5 && |
3732 |
this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) { |
3915 |
this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) { |
3733 |
this.problemReporter().invalidUsageOfAnnotation(markerAnnotation); |
3916 |
this.problemReporter().invalidUsageOfAnnotation(markerAnnotation); |
3734 |
} |
3917 |
} |
Lines 4244-4250
Link Here
|
4244 |
annotationRecoveryCheckPoint(normalAnnotation.sourceStart, normalAnnotation.declarationSourceEnd); |
4427 |
annotationRecoveryCheckPoint(normalAnnotation.sourceStart, normalAnnotation.declarationSourceEnd); |
4245 |
} |
4428 |
} |
4246 |
|
4429 |
|
4247 |
if(options.sourceLevel < ClassFileConstants.JDK1_5 && |
4430 |
if(!this.statementRecoveryActivated && |
|
|
4431 |
options.sourceLevel < ClassFileConstants.JDK1_5 && |
4248 |
this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) { |
4432 |
this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) { |
4249 |
this.problemReporter().invalidUsageOfAnnotation(normalAnnotation); |
4433 |
this.problemReporter().invalidUsageOfAnnotation(normalAnnotation); |
4250 |
} |
4434 |
} |
Lines 4261-4267
Link Here
|
4261 |
this.expressionLengthPtr--; |
4445 |
this.expressionLengthPtr--; |
4262 |
} |
4446 |
} |
4263 |
protected void consumeOnlyTypeArguments() { |
4447 |
protected void consumeOnlyTypeArguments() { |
4264 |
if(options.sourceLevel < ClassFileConstants.JDK1_5 && |
4448 |
if(!this.statementRecoveryActivated && |
|
|
4449 |
options.sourceLevel < ClassFileConstants.JDK1_5 && |
4265 |
this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) { |
4450 |
this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) { |
4266 |
int length = this.genericsLengthStack[this.genericsLengthPtr]; |
4451 |
int length = this.genericsLengthStack[this.genericsLengthPtr]; |
4267 |
this.problemReporter().invalidUsageOfTypeArguments( |
4452 |
this.problemReporter().invalidUsageOfTypeArguments( |
Lines 6259-6265
Link Here
|
6259 |
annotationRecoveryCheckPoint(singleMemberAnnotation.sourceStart, singleMemberAnnotation.declarationSourceEnd); |
6444 |
annotationRecoveryCheckPoint(singleMemberAnnotation.sourceStart, singleMemberAnnotation.declarationSourceEnd); |
6260 |
} |
6445 |
} |
6261 |
|
6446 |
|
6262 |
if(options.sourceLevel < ClassFileConstants.JDK1_5 && |
6447 |
if(!this.statementRecoveryActivated && |
|
|
6448 |
options.sourceLevel < ClassFileConstants.JDK1_5 && |
6263 |
this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) { |
6449 |
this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) { |
6264 |
this.problemReporter().invalidUsageOfAnnotation(singleMemberAnnotation); |
6450 |
this.problemReporter().invalidUsageOfAnnotation(singleMemberAnnotation); |
6265 |
} |
6451 |
} |
Lines 6291-6297
Link Here
|
6291 |
//this.endPosition is just before the ; |
6477 |
//this.endPosition is just before the ; |
6292 |
impt.declarationSourceStart = this.intStack[this.intPtr--]; |
6478 |
impt.declarationSourceStart = this.intStack[this.intPtr--]; |
6293 |
|
6479 |
|
6294 |
if(this.options.sourceLevel < ClassFileConstants.JDK1_5 && |
6480 |
if(!this.statementRecoveryActivated && |
|
|
6481 |
this.options.sourceLevel < ClassFileConstants.JDK1_5 && |
6295 |
this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) { |
6482 |
this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) { |
6296 |
impt.modifiers = ClassFileConstants.AccDefault; // convert the static import reference to a non-static importe reference |
6483 |
impt.modifiers = ClassFileConstants.AccDefault; // convert the static import reference to a non-static importe reference |
6297 |
this.problemReporter().invalidUsageOfStaticImports(impt); |
6484 |
this.problemReporter().invalidUsageOfStaticImports(impt); |
Lines 6660-6666
Link Here
|
6660 |
//this.endPosition is just before the ; |
6847 |
//this.endPosition is just before the ; |
6661 |
impt.declarationSourceStart = this.intStack[this.intPtr--]; |
6848 |
impt.declarationSourceStart = this.intStack[this.intPtr--]; |
6662 |
|
6849 |
|
6663 |
if(options.sourceLevel < ClassFileConstants.JDK1_5 && |
6850 |
if(!this.statementRecoveryActivated && |
|
|
6851 |
options.sourceLevel < ClassFileConstants.JDK1_5 && |
6664 |
this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) { |
6852 |
this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) { |
6665 |
impt.modifiers = ClassFileConstants.AccDefault; // convert the static import reference to a non-static importe reference |
6853 |
impt.modifiers = ClassFileConstants.AccDefault; // convert the static import reference to a non-static importe reference |
6666 |
this.problemReporter().invalidUsageOfStaticImports(impt); |
6854 |
this.problemReporter().invalidUsageOfStaticImports(impt); |
Lines 6762-6773
Link Here
|
6762 |
if (this.scanner.useAssertAsAnIndentifier && |
6950 |
if (this.scanner.useAssertAsAnIndentifier && |
6763 |
this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) { |
6951 |
this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) { |
6764 |
long positions = this.identifierPositionStack[this.identifierPtr]; |
6952 |
long positions = this.identifierPositionStack[this.identifierPtr]; |
6765 |
problemReporter().useAssertAsAnIdentifier((int) (positions >>> 32), (int) positions); |
6953 |
if(!this.statementRecoveryActivated) problemReporter().useAssertAsAnIdentifier((int) (positions >>> 32), (int) positions); |
6766 |
} |
6954 |
} |
6767 |
if (this.scanner.useEnumAsAnIndentifier && |
6955 |
if (this.scanner.useEnumAsAnIndentifier && |
6768 |
this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) { |
6956 |
this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) { |
6769 |
long positions = this.identifierPositionStack[this.identifierPtr]; |
6957 |
long positions = this.identifierPositionStack[this.identifierPtr]; |
6770 |
problemReporter().useEnumAsAnIdentifier((int) (positions >>> 32), (int) positions); |
6958 |
if(!this.statementRecoveryActivated) problemReporter().useEnumAsAnIdentifier((int) (positions >>> 32), (int) positions); |
6771 |
} |
6959 |
} |
6772 |
break; |
6960 |
break; |
6773 |
case TokenNameinterface : |
6961 |
case TokenNameinterface : |
Lines 7091-7097
Link Here
|
7091 |
concatGenericsLists(); |
7279 |
concatGenericsLists(); |
7092 |
intPtr--; |
7280 |
intPtr--; |
7093 |
|
7281 |
|
7094 |
if(options.sourceLevel < ClassFileConstants.JDK1_5 && |
7282 |
if(!this.statementRecoveryActivated && |
|
|
7283 |
options.sourceLevel < ClassFileConstants.JDK1_5 && |
7095 |
this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) { |
7284 |
this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) { |
7096 |
int length = this.genericsLengthStack[this.genericsLengthPtr]; |
7285 |
int length = this.genericsLengthStack[this.genericsLengthPtr]; |
7097 |
this.problemReporter().invalidUsageOfTypeArguments( |
7286 |
this.problemReporter().invalidUsageOfTypeArguments( |
Lines 7202-7208
Link Here
|
7202 |
} |
7391 |
} |
7203 |
|
7392 |
|
7204 |
|
7393 |
|
7205 |
if(options.sourceLevel < ClassFileConstants.JDK1_5&& |
7394 |
if(!this.statementRecoveryActivated && |
|
|
7395 |
options.sourceLevel < ClassFileConstants.JDK1_5&& |
7206 |
this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) { |
7396 |
this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) { |
7207 |
int length = this.genericsLengthStack[this.genericsLengthPtr]; |
7397 |
int length = this.genericsLengthStack[this.genericsLengthPtr]; |
7208 |
this.problemReporter().invalidUsageOfTypeParameters( |
7398 |
this.problemReporter().invalidUsageOfTypeParameters( |
Lines 7298-7304
Link Here
|
7298 |
if (!post) { |
7488 |
if (!post) { |
7299 |
this.intPtr--; |
7489 |
this.intPtr--; |
7300 |
} |
7490 |
} |
7301 |
problemReporter().invalidUnaryExpression(leftHandSide); |
7491 |
if(!this.statementRecoveryActivated) problemReporter().invalidUnaryExpression(leftHandSide); |
7302 |
} |
7492 |
} |
7303 |
} |
7493 |
} |
7304 |
protected void consumeVariableDeclarators() { |
7494 |
protected void consumeVariableDeclarators() { |
Lines 7678-7691
Link Here
|
7678 |
|
7868 |
|
7679 |
this.lastAct = act; |
7869 |
this.lastAct = act; |
7680 |
|
7870 |
|
7681 |
if (this.currentElement != null){ |
7871 |
if(this.statementRecoveryActivated) { |
7682 |
this.currentElement.topElement().updateParseTree(); |
7872 |
RecoveredElement recoveredElement = this.buildInitialRecoveryState(); |
|
|
7873 |
recoveredElement.topElement().updateParseTree(); |
7874 |
if(this.hasError) this.resetStacks(); |
7875 |
} else if (this.currentElement != null){ |
7683 |
if (VERBOSE_RECOVERY){ |
7876 |
if (VERBOSE_RECOVERY){ |
7684 |
System.out.print(Messages.parser_syntaxRecovery); |
7877 |
System.out.print(Messages.parser_syntaxRecovery); |
7685 |
System.out.println("--------------------------"); //$NON-NLS-1$ |
7878 |
System.out.println("--------------------------"); //$NON-NLS-1$ |
7686 |
System.out.println(this.compilationUnit); |
7879 |
System.out.println(this.compilationUnit); |
7687 |
System.out.println("----------------------------------"); //$NON-NLS-1$ |
7880 |
System.out.println("----------------------------------"); //$NON-NLS-1$ |
7688 |
} |
7881 |
} |
|
|
7882 |
this.currentElement.topElement().updateParseTree(); |
7689 |
} else { |
7883 |
} else { |
7690 |
if (this.diet & VERBOSE_RECOVERY){ |
7884 |
if (this.diet & VERBOSE_RECOVERY){ |
7691 |
System.out.print(Messages.parser_regularParse); |
7885 |
System.out.print(Messages.parser_regularParse); |
Lines 7696-7702
Link Here
|
7696 |
} |
7890 |
} |
7697 |
persistLineSeparatorPositions(); |
7891 |
persistLineSeparatorPositions(); |
7698 |
for (int i = 0; i < this.scanner.foundTaskCount; i++){ |
7892 |
for (int i = 0; i < this.scanner.foundTaskCount; i++){ |
7699 |
problemReporter().task( |
7893 |
if(!this.statementRecoveryActivated) problemReporter().task( |
7700 |
new String(this.scanner.foundTaskTags[i]), |
7894 |
new String(this.scanner.foundTaskTags[i]), |
7701 |
new String(this.scanner.foundTaskMessages[i]), |
7895 |
new String(this.scanner.foundTaskMessages[i]), |
7702 |
this.scanner.foundTaskPriorities[i] == null ? null : new String(this.scanner.foundTaskPriorities[i]), |
7896 |
this.scanner.foundTaskPriorities[i] == null ? null : new String(this.scanner.foundTaskPriorities[i]), |
Lines 8187-8193
Link Here
|
8187 |
ArrayInitializer arrayInitializer = (ArrayInitializer) this.expressionStack[this.expressionPtr--]; |
8381 |
ArrayInitializer arrayInitializer = (ArrayInitializer) this.expressionStack[this.expressionPtr--]; |
8188 |
this.expressionLengthPtr -- ; |
8382 |
this.expressionLengthPtr -- ; |
8189 |
// report a syntax error and abort parsing |
8383 |
// report a syntax error and abort parsing |
8190 |
problemReporter().arrayConstantsOnlyInArrayInitializers(arrayInitializer.sourceStart, arrayInitializer.sourceEnd); |
8384 |
if(!this.statementRecoveryActivated) problemReporter().arrayConstantsOnlyInArrayInitializers(arrayInitializer.sourceStart, arrayInitializer.sourceEnd); |
8191 |
} |
8385 |
} |
8192 |
public void initialize() { |
8386 |
public void initialize() { |
8193 |
this.initialize(false); |
8387 |
this.initialize(false); |
Lines 8281-8286
Link Here
|
8281 |
if (this.diet && (this.dietInt == 0)) |
8475 |
if (this.diet && (this.dietInt == 0)) |
8282 |
this.scanner.diet = true; |
8476 |
this.scanner.diet = true; |
8283 |
} |
8477 |
} |
|
|
8478 |
private void jumpOverType(){ |
8479 |
if (this.recoveredTypes != null && this.nextTypeStart > -1 && this.nextTypeStart < this.scanner.currentPosition) { |
8480 |
TypeDeclaration typeDeclaration = this.recoveredTypes[this.recoveredTypePtr]; |
8481 |
boolean isAnonymous = typeDeclaration.allocation != null; |
8482 |
|
8483 |
int end = this.scanner.eofPosition; |
8484 |
this.scanner.resetTo(typeDeclaration.declarationSourceEnd + 1, end - 1); |
8485 |
if(!isAnonymous) { |
8486 |
pushOnAstStack(typeDeclaration); |
8487 |
if(this.astLengthPtr > 0) { |
8488 |
concatNodeLists(); |
8489 |
} |
8490 |
|
8491 |
if(this.currentElement != null) { |
8492 |
this.currentElement = this.currentElement.add(typeDeclaration, 0); |
8493 |
} |
8494 |
|
8495 |
try { |
8496 |
this.currentToken = this.scanner.getNextToken(); |
8497 |
} catch(InvalidInputException e){ |
8498 |
if (!this.hasReportedError){ |
8499 |
this.problemReporter().scannerError(this, e.getMessage()); |
8500 |
this.hasReportedError = true; |
8501 |
} |
8502 |
this.lastCheckPoint = this.scanner.currentPosition; |
8503 |
} |
8504 |
} else { |
8505 |
if(this.astPtr > -1 && this.astStack[this.astPtr] instanceof TypeDeclaration) { |
8506 |
this.astStack[astPtr] = typeDeclaration; |
8507 |
this.expressionStack[this.expressionPtr] = typeDeclaration.allocation; |
8508 |
} |
8509 |
this.currentToken = TokenNameRBRACE; |
8510 |
} |
8511 |
|
8512 |
if(++this.recoveredTypePtr < this.recoveredTypes.length) { |
8513 |
TypeDeclaration nextTypeDeclaration = this.recoveredTypes[this.recoveredTypePtr]; |
8514 |
this.nextTypeStart = |
8515 |
nextTypeDeclaration.allocation == null |
8516 |
? nextTypeDeclaration.declarationSourceStart |
8517 |
: nextTypeDeclaration.bodyStart; |
8518 |
} else { |
8519 |
this.nextTypeStart = Integer.MAX_VALUE; |
8520 |
} |
8521 |
} |
8522 |
} |
8284 |
protected void markEnclosingMemberWithLocalType() { |
8523 |
protected void markEnclosingMemberWithLocalType() { |
8285 |
if (this.currentElement != null) return; // this is already done in the recovery code |
8524 |
if (this.currentElement != null) return; // this is already done in the recovery code |
8286 |
for (int i = this.astPtr; i >= 0; i--) { |
8525 |
for (int i = this.astPtr; i >= 0; i--) { |
Lines 8485-8490
Link Here
|
8485 |
protected void parse() { |
8724 |
protected void parse() { |
8486 |
if (DEBUG) System.out.println("-- ENTER INSIDE PARSE METHOD --"); //$NON-NLS-1$ |
8725 |
if (DEBUG) System.out.println("-- ENTER INSIDE PARSE METHOD --"); //$NON-NLS-1$ |
8487 |
boolean isDietParse = this.diet; |
8726 |
boolean isDietParse = this.diet; |
|
|
8727 |
boolean jumpOverTypeAfterReduce = false; |
8488 |
int oldFirstToken = getFirstToken(); |
8728 |
int oldFirstToken = getFirstToken(); |
8489 |
this.hasError = false; |
8729 |
this.hasError = false; |
8490 |
|
8730 |
|
Lines 8533-8539
Link Here
|
8533 |
} |
8773 |
} |
8534 |
this.lastCheckPoint = this.scanner.currentPosition; |
8774 |
this.lastCheckPoint = this.scanner.currentPosition; |
8535 |
this.restartRecovery = true; |
8775 |
this.restartRecovery = true; |
8536 |
} |
8776 |
} |
|
|
8777 |
if(this.statementRecoveryActivated) { |
8778 |
jumpOverTypeAfterReduce = true; |
8779 |
} |
8537 |
act -= ERROR_ACTION; |
8780 |
act -= ERROR_ACTION; |
8538 |
|
8781 |
|
8539 |
} else { |
8782 |
} else { |
Lines 8550-8555
Link Here
|
8550 |
this.lastCheckPoint = this.scanner.currentPosition; |
8793 |
this.lastCheckPoint = this.scanner.currentPosition; |
8551 |
this.restartRecovery = true; |
8794 |
this.restartRecovery = true; |
8552 |
} |
8795 |
} |
|
|
8796 |
if(this.statementRecoveryActivated) { |
8797 |
this.jumpOverType(); |
8798 |
} |
8553 |
continue ProcessTerminals; |
8799 |
continue ProcessTerminals; |
8554 |
} |
8800 |
} |
8555 |
break ProcessTerminals; |
8801 |
break ProcessTerminals; |
Lines 8560-8565
Link Here
|
8560 |
consumeRule(act); |
8806 |
consumeRule(act); |
8561 |
this.stateStackTop -= (rhs[act] - 1); |
8807 |
this.stateStackTop -= (rhs[act] - 1); |
8562 |
act = ntAction(this.stack[this.stateStackTop], lhs[act]); |
8808 |
act = ntAction(this.stack[this.stateStackTop], lhs[act]); |
|
|
8809 |
if(this.statementRecoveryActivated && act > NUM_RULES) { |
8810 |
if(jumpOverTypeAfterReduce) { |
8811 |
this.jumpOverType(); |
8812 |
jumpOverTypeAfterReduce = false; |
8813 |
} |
8814 |
} |
8563 |
} while (act <= NUM_RULES); |
8815 |
} while (act <= NUM_RULES); |
8564 |
} |
8816 |
} |
8565 |
endParse(act); |
8817 |
endParse(act); |
Lines 8568-8577
Link Here
|
8568 |
if (tags != null) { |
8820 |
if (tags != null) { |
8569 |
this.compilationUnit.nlsTags = tags; |
8821 |
this.compilationUnit.nlsTags = tags; |
8570 |
} |
8822 |
} |
|
|
8823 |
|
8571 |
this.scanner.checkNonExternalizedStringLiterals = false; |
8824 |
this.scanner.checkNonExternalizedStringLiterals = false; |
8572 |
if (this.reportSyntaxErrorIsRequired && this.hasError) { |
8825 |
if (this.reportSyntaxErrorIsRequired && this.hasError && !this.statementRecoveryActivated) { |
8573 |
reportSyntaxErrors(isDietParse, oldFirstToken); |
8826 |
if(!this.options.performStatementsRecovery) { |
8574 |
} |
8827 |
reportSyntaxErrors(isDietParse, oldFirstToken); |
|
|
8828 |
} else { |
8829 |
RecoveryScannerData data = this.referenceContext.compilationResult().recoveryScannerData; |
8830 |
|
8831 |
if(this.recoveryScanner == null) { |
8832 |
this.recoveryScanner = new RecoveryScanner(this.scanner, data); |
8833 |
} else { |
8834 |
this.recoveryScanner.setData(data); |
8835 |
} |
8836 |
|
8837 |
this.recoveryScanner.setSource(scanner.source); |
8838 |
this.recoveryScanner.lineEnds = this.scanner.lineEnds; |
8839 |
this.recoveryScanner.linePtr = this.scanner.linePtr; |
8840 |
|
8841 |
reportSyntaxErrors(isDietParse, oldFirstToken); |
8842 |
|
8843 |
if(data == null) { |
8844 |
this.referenceContext.compilationResult().recoveryScannerData = |
8845 |
this.recoveryScanner.getData(); |
8846 |
} |
8847 |
|
8848 |
if (this.methodRecoveryActivated) { |
8849 |
this.methodRecoveryActivated = false; |
8850 |
this.recoverStatements(); |
8851 |
this.methodRecoveryActivated = true; |
8852 |
|
8853 |
this.lastAct = ERROR_ACTION; |
8854 |
} |
8855 |
} |
8856 |
} |
8857 |
|
8575 |
if (DEBUG) System.out.println("-- EXIT FROM PARSE METHOD --"); //$NON-NLS-1$ |
8858 |
if (DEBUG) System.out.println("-- EXIT FROM PARSE METHOD --"); //$NON-NLS-1$ |
8576 |
} |
8859 |
} |
8577 |
public void parse(ConstructorDeclaration cd, CompilationUnitDeclaration unit) { |
8860 |
public void parse(ConstructorDeclaration cd, CompilationUnitDeclaration unit) { |
Lines 8583-8588
Link Here
|
8583 |
|
8866 |
|
8584 |
//convert bugs into parse error |
8867 |
//convert bugs into parse error |
8585 |
|
8868 |
|
|
|
8869 |
boolean oldMethodRecoveryActivated = this.methodRecoveryActivated; |
8870 |
if(this.options.performStatementsRecovery) { |
8871 |
this.methodRecoveryActivated = true; |
8872 |
} |
8873 |
|
8586 |
initialize(); |
8874 |
initialize(); |
8587 |
goForBlockStatementsopt(); |
8875 |
goForBlockStatementsopt(); |
8588 |
if (recordLineSeparator) { |
8876 |
if (recordLineSeparator) { |
Lines 8601-8606
Link Here
|
8601 |
this.lastAct = ERROR_ACTION; |
8889 |
this.lastAct = ERROR_ACTION; |
8602 |
} finally { |
8890 |
} finally { |
8603 |
this.nestedMethod[this.nestedType]--; |
8891 |
this.nestedMethod[this.nestedType]--; |
|
|
8892 |
if(this.options.performStatementsRecovery) { |
8893 |
this.methodRecoveryActivated = oldMethodRecoveryActivated; |
8894 |
} |
8604 |
} |
8895 |
} |
8605 |
|
8896 |
|
8606 |
checkNonNLSAfterBodyEnd(cd.declarationSourceEnd); |
8897 |
checkNonNLSAfterBodyEnd(cd.declarationSourceEnd); |
Lines 8613-8619
Link Here
|
8613 |
//statements |
8904 |
//statements |
8614 |
cd.explicitDeclarations = this.realBlockStack[this.realBlockPtr--]; |
8905 |
cd.explicitDeclarations = this.realBlockStack[this.realBlockPtr--]; |
8615 |
int length; |
8906 |
int length; |
8616 |
if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) { |
8907 |
if (astLengthPtr > -1 && (length = this.astLengthStack[this.astLengthPtr--]) != 0) { |
8617 |
this.astPtr -= length; |
8908 |
this.astPtr -= length; |
8618 |
if (this.astStack[this.astPtr + 1] instanceof ExplicitConstructorCall) |
8909 |
if (this.astStack[this.astPtr + 1] instanceof ExplicitConstructorCall) |
8619 |
//avoid a isSomeThing that would only be used here BUT what is faster between two alternatives ? |
8910 |
//avoid a isSomeThing that would only be used here BUT what is faster between two alternatives ? |
Lines 8747-8752
Link Here
|
8747 |
|
9038 |
|
8748 |
//convert bugs into parse error |
9039 |
//convert bugs into parse error |
8749 |
|
9040 |
|
|
|
9041 |
boolean oldMethodRecoveryActivated = this.methodRecoveryActivated; |
9042 |
if(this.options.performStatementsRecovery) { |
9043 |
this.methodRecoveryActivated = true; |
9044 |
} |
9045 |
|
8750 |
initialize(); |
9046 |
initialize(); |
8751 |
goForBlockStatementsopt(); |
9047 |
goForBlockStatementsopt(); |
8752 |
this.nestedMethod[this.nestedType]++; |
9048 |
this.nestedMethod[this.nestedType]++; |
Lines 8762-8767
Link Here
|
8762 |
this.lastAct = ERROR_ACTION; |
9058 |
this.lastAct = ERROR_ACTION; |
8763 |
} finally { |
9059 |
} finally { |
8764 |
this.nestedMethod[this.nestedType]--; |
9060 |
this.nestedMethod[this.nestedType]--; |
|
|
9061 |
if(this.options.performStatementsRecovery) { |
9062 |
this.methodRecoveryActivated = oldMethodRecoveryActivated; |
9063 |
} |
8765 |
} |
9064 |
} |
8766 |
|
9065 |
|
8767 |
checkNonNLSAfterBodyEnd(initializer.declarationSourceEnd); |
9066 |
checkNonNLSAfterBodyEnd(initializer.declarationSourceEnd); |
Lines 8773-8779
Link Here
|
8773 |
//refill statements |
9072 |
//refill statements |
8774 |
initializer.block.explicitDeclarations = this.realBlockStack[this.realBlockPtr--]; |
9073 |
initializer.block.explicitDeclarations = this.realBlockStack[this.realBlockPtr--]; |
8775 |
int length; |
9074 |
int length; |
8776 |
if ((length = this.astLengthStack[this.astLengthPtr--]) > 0) { |
9075 |
if (astLengthPtr > -1 && (length = this.astLengthStack[this.astLengthPtr--]) > 0) { |
8777 |
System.arraycopy(this.astStack, (this.astPtr -= length) + 1, initializer.block.statements = new Statement[length], 0, length); |
9076 |
System.arraycopy(this.astStack, (this.astPtr -= length) + 1, initializer.block.statements = new Statement[length], 0, length); |
8778 |
} else { |
9077 |
} else { |
8779 |
// check whether this block at least contains some comment in it |
9078 |
// check whether this block at least contains some comment in it |
Lines 8801-8806
Link Here
|
8801 |
if ((md.modifiers & ExtraCompilerModifiers.AccSemicolonBody) != 0) |
9100 |
if ((md.modifiers & ExtraCompilerModifiers.AccSemicolonBody) != 0) |
8802 |
return; |
9101 |
return; |
8803 |
|
9102 |
|
|
|
9103 |
boolean oldMethodRecoveryActivated = this.methodRecoveryActivated; |
9104 |
if(this.options.performStatementsRecovery) { |
9105 |
this.methodRecoveryActivated = true; |
9106 |
this.rParenPos = md.sourceEnd; |
9107 |
} |
8804 |
initialize(); |
9108 |
initialize(); |
8805 |
goForBlockStatementsopt(); |
9109 |
goForBlockStatementsopt(); |
8806 |
this.nestedMethod[this.nestedType]++; |
9110 |
this.nestedMethod[this.nestedType]++; |
Lines 8817-8822
Link Here
|
8817 |
this.lastAct = ERROR_ACTION; |
9121 |
this.lastAct = ERROR_ACTION; |
8818 |
} finally { |
9122 |
} finally { |
8819 |
this.nestedMethod[this.nestedType]--; |
9123 |
this.nestedMethod[this.nestedType]--; |
|
|
9124 |
if(this.options.performStatementsRecovery) { |
9125 |
this.methodRecoveryActivated = oldMethodRecoveryActivated; |
9126 |
} |
8820 |
} |
9127 |
} |
8821 |
|
9128 |
|
8822 |
checkNonNLSAfterBodyEnd(md.declarationSourceEnd); |
9129 |
checkNonNLSAfterBodyEnd(md.declarationSourceEnd); |
Lines 8828-8834
Link Here
|
8828 |
//refill statements |
9135 |
//refill statements |
8829 |
md.explicitDeclarations = this.realBlockStack[this.realBlockPtr--]; |
9136 |
md.explicitDeclarations = this.realBlockStack[this.realBlockPtr--]; |
8830 |
int length; |
9137 |
int length; |
8831 |
if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) { |
9138 |
if (astLengthPtr > -1 && (length = this.astLengthStack[this.astLengthPtr--]) != 0) { |
8832 |
System.arraycopy( |
9139 |
System.arraycopy( |
8833 |
this.astStack, |
9140 |
this.astStack, |
8834 |
(this.astPtr -= length) + 1, |
9141 |
(this.astPtr -= length) + 1, |
Lines 8871-8877
Link Here
|
8871 |
return null; |
9178 |
return null; |
8872 |
} |
9179 |
} |
8873 |
int astLength; |
9180 |
int astLength; |
8874 |
if ((astLength = this.astLengthStack[this.astLengthPtr--]) != 0) { |
9181 |
if (astLengthPtr > -1 && (astLength = this.astLengthStack[this.astLengthPtr--]) != 0) { |
8875 |
ASTNode[] result = new ASTNode[astLength]; |
9182 |
ASTNode[] result = new ASTNode[astLength]; |
8876 |
this.astPtr -= astLength; |
9183 |
this.astPtr -= astLength; |
8877 |
System.arraycopy(this.astStack, this.astPtr + 1, result, 0, astLength); |
9184 |
System.arraycopy(this.astStack, this.astPtr + 1, result, 0, astLength); |
Lines 8929-8939
Link Here
|
8929 |
|
9236 |
|
8930 |
return this.expressionStack[this.expressionPtr]; |
9237 |
return this.expressionStack[this.expressionPtr]; |
8931 |
} |
9238 |
} |
|
|
9239 |
public void parseStatements(ReferenceContext rc, int start, int end, TypeDeclaration[] types, CompilationUnitDeclaration unit) { |
9240 |
boolean oldStatementRecoveryEnabled = this.statementRecoveryActivated; |
9241 |
this.statementRecoveryActivated = true; |
9242 |
|
9243 |
initialize(); |
9244 |
|
9245 |
goForBlockStatementsopt(); |
9246 |
this.nestedMethod[this.nestedType]++; |
9247 |
pushOnRealBlockStack(0); |
9248 |
|
9249 |
pushOnAstLengthStack(0); |
9250 |
|
9251 |
this.referenceContext = rc; |
9252 |
this.compilationUnit = unit; |
9253 |
|
9254 |
if(types != null && types.length > 0) { |
9255 |
this.recoveredTypes = types; |
9256 |
this.recoveredTypePtr = 0; |
9257 |
this.nextTypeStart = |
9258 |
this.recoveredTypes[0].allocation == null |
9259 |
? this.recoveredTypes[0].declarationSourceStart |
9260 |
: this.recoveredTypes[0].bodyStart; |
9261 |
} else { |
9262 |
this.recoveredTypes = null; |
9263 |
this.recoveredTypePtr = -1; |
9264 |
this.nextTypeStart = -1; |
9265 |
} |
9266 |
|
9267 |
this.scanner.resetTo(start, end); |
9268 |
// reset the scanner to parser from { down to } |
9269 |
|
9270 |
this.lastCheckPoint = this.scanner.initialPosition; |
9271 |
|
9272 |
|
9273 |
this.stateStackTop = -1; |
9274 |
|
9275 |
try { |
9276 |
parse(); |
9277 |
} catch (AbortCompilation ex) { |
9278 |
this.lastAct = ERROR_ACTION; |
9279 |
} finally { |
9280 |
this.nestedMethod[this.nestedType]--; |
9281 |
this.recoveredTypes = null; |
9282 |
this.statementRecoveryActivated = oldStatementRecoveryEnabled; |
9283 |
} |
9284 |
|
9285 |
checkNonNLSAfterBodyEnd(end); |
9286 |
} |
8932 |
public void persistLineSeparatorPositions() { |
9287 |
public void persistLineSeparatorPositions() { |
8933 |
if (this.scanner.recordLineSeparator) { |
9288 |
if (this.scanner.recordLineSeparator) { |
8934 |
this.compilationUnit.compilationResult.lineSeparatorPositions = this.scanner.getLineEnds(); |
9289 |
this.compilationUnit.compilationResult.lineSeparatorPositions = this.scanner.getLineEnds(); |
8935 |
} |
9290 |
} |
8936 |
} |
9291 |
} |
|
|
9292 |
/* |
9293 |
* Prepares the state of the parser to go for BlockStatements. |
9294 |
*/ |
9295 |
protected void prepareForBlockStatements() { |
9296 |
this.nestedMethod[this.nestedType = 0] = 1; |
9297 |
this.variablesCounter[this.nestedType] = 0; |
9298 |
this.realBlockStack[this.realBlockPtr = 1] = 0; |
9299 |
} |
8937 |
/** |
9300 |
/** |
8938 |
* Returns this parser's problem reporter initialized with its reference context. |
9301 |
* Returns this parser's problem reporter initialized with its reference context. |
8939 |
* Also it is assumed that a problem is going to be reported, so initializes |
9302 |
* Also it is assumed that a problem is going to be reported, so initializes |
Lines 9121-9126
Link Here
|
9121 |
} |
9484 |
} |
9122 |
this.realBlockStack[this.realBlockPtr] = i; |
9485 |
this.realBlockStack[this.realBlockPtr] = i; |
9123 |
} |
9486 |
} |
|
|
9487 |
protected void recoverStatements() { |
9488 |
class MethodVisitor extends ASTVisitor { |
9489 |
public ASTVisitor typeVisitor; |
9490 |
|
9491 |
TypeDeclaration enclosingType; // used only for initializer |
9492 |
|
9493 |
TypeDeclaration[] types = new TypeDeclaration[0]; |
9494 |
int typePtr = -1; |
9495 |
public boolean visit(ConstructorDeclaration constructorDeclaration, ClassScope scope) { |
9496 |
typePtr = -1; |
9497 |
return true; |
9498 |
} |
9499 |
public boolean visit(Initializer initializer, MethodScope scope) { |
9500 |
typePtr = -1; |
9501 |
return true; |
9502 |
} |
9503 |
public boolean visit(MethodDeclaration methodDeclaration,ClassScope scope) { |
9504 |
typePtr = -1; |
9505 |
return true; |
9506 |
} |
9507 |
public boolean visit(TypeDeclaration typeDeclaration, BlockScope scope) { |
9508 |
return this.visit(typeDeclaration); |
9509 |
} |
9510 |
public boolean visit(TypeDeclaration typeDeclaration, ClassScope scope) { |
9511 |
return this.visit(typeDeclaration); |
9512 |
} |
9513 |
private boolean visit(TypeDeclaration typeDeclaration) { |
9514 |
if(this.types.length <= ++this.typePtr) { |
9515 |
int length = this.typePtr; |
9516 |
System.arraycopy(this.types, 0, this.types = new TypeDeclaration[length * 2 + 1], 0, length); |
9517 |
} |
9518 |
this.types[this.typePtr] = typeDeclaration; |
9519 |
return false; |
9520 |
} |
9521 |
public void endVisit(ConstructorDeclaration constructorDeclaration, ClassScope scope) { |
9522 |
this.endVisitMethod(constructorDeclaration, scope); |
9523 |
} |
9524 |
public void endVisit(MethodDeclaration methodDeclaration, ClassScope scope) { |
9525 |
this.endVisitMethod(methodDeclaration, scope); |
9526 |
} |
9527 |
private void endVisitMethod(AbstractMethodDeclaration methodDeclaration, ClassScope scope) { |
9528 |
TypeDeclaration[] foundTypes = null; |
9529 |
int length = 0; |
9530 |
if(this.typePtr > -1) { |
9531 |
length = this.typePtr + 1; |
9532 |
foundTypes = new TypeDeclaration[length]; |
9533 |
System.arraycopy(this.types, 0, foundTypes, 0, length); |
9534 |
} |
9535 |
ReferenceContext oldContext = Parser.this.referenceContext; |
9536 |
Parser.this.recoveryScanner.resetTo(methodDeclaration.bodyStart, methodDeclaration.bodyEnd); |
9537 |
Scanner oldScanner = Parser.this.scanner; |
9538 |
Parser.this.scanner = Parser.this.recoveryScanner; |
9539 |
Parser.this.parseStatements( |
9540 |
methodDeclaration, |
9541 |
methodDeclaration.bodyStart, |
9542 |
methodDeclaration.bodyEnd, |
9543 |
foundTypes, |
9544 |
compilationUnit); |
9545 |
Parser.this.scanner = oldScanner; |
9546 |
Parser.this.referenceContext = oldContext; |
9547 |
|
9548 |
for (int i = 0; i < length; i++) { |
9549 |
foundTypes[i].traverse(typeVisitor, scope); |
9550 |
} |
9551 |
} |
9552 |
public void endVisit(Initializer initializer, MethodScope scope) { |
9553 |
TypeDeclaration[] foundTypes = null; |
9554 |
int length = 0; |
9555 |
if(this.typePtr > -1) { |
9556 |
length = this.typePtr + 1; |
9557 |
foundTypes = new TypeDeclaration[length]; |
9558 |
System.arraycopy(this.types, 0, foundTypes, 0, length); |
9559 |
} |
9560 |
ReferenceContext oldContext = Parser.this.referenceContext; |
9561 |
Parser.this.recoveryScanner.resetTo(initializer.bodyStart, initializer.bodyEnd); |
9562 |
Scanner oldScanner = Parser.this.scanner; |
9563 |
Parser.this.scanner = Parser.this.recoveryScanner; |
9564 |
Parser.this.parseStatements( |
9565 |
this.enclosingType, |
9566 |
initializer.bodyStart, |
9567 |
initializer.bodyEnd, |
9568 |
foundTypes, |
9569 |
compilationUnit); |
9570 |
Parser.this.scanner = oldScanner; |
9571 |
Parser.this.referenceContext = oldContext; |
9572 |
|
9573 |
for (int i = 0; i < length; i++) { |
9574 |
foundTypes[i].traverse(typeVisitor, scope); |
9575 |
} |
9576 |
} |
9577 |
} |
9578 |
class TypeVisitor extends ASTVisitor { |
9579 |
public MethodVisitor methodVisitor; |
9580 |
|
9581 |
TypeDeclaration[] types = new TypeDeclaration[0]; |
9582 |
int typePtr = -1; |
9583 |
|
9584 |
public void endVisit(TypeDeclaration typeDeclaration, BlockScope scope) { |
9585 |
endVisitType(); |
9586 |
} |
9587 |
public void endVisit(TypeDeclaration typeDeclaration, ClassScope scope) { |
9588 |
endVisitType(); |
9589 |
} |
9590 |
private void endVisitType() { |
9591 |
this.typePtr--; |
9592 |
} |
9593 |
public boolean visit(TypeDeclaration typeDeclaration, BlockScope scope) { |
9594 |
return this.visit(typeDeclaration); |
9595 |
} |
9596 |
public boolean visit(TypeDeclaration typeDeclaration, ClassScope scope) { |
9597 |
return this.visit(typeDeclaration); |
9598 |
} |
9599 |
private boolean visit(TypeDeclaration typeDeclaration) { |
9600 |
if(this.types.length <= ++this.typePtr) { |
9601 |
int length = this.typePtr; |
9602 |
System.arraycopy(this.types, 0, this.types = new TypeDeclaration[length * 2 + 1], 0, length); |
9603 |
} |
9604 |
this.types[this.typePtr] = typeDeclaration; |
9605 |
return true; |
9606 |
} |
9607 |
public boolean visit(ConstructorDeclaration constructorDeclaration, ClassScope scope) { |
9608 |
if(constructorDeclaration.isDefaultConstructor()) return false; |
9609 |
|
9610 |
constructorDeclaration.traverse(methodVisitor, scope); |
9611 |
return false; |
9612 |
} |
9613 |
public boolean visit(Initializer initializer, MethodScope scope) { |
9614 |
methodVisitor.enclosingType = this.types[typePtr]; |
9615 |
initializer.traverse(methodVisitor, scope); |
9616 |
return false; |
9617 |
} |
9618 |
public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) { |
9619 |
methodDeclaration.traverse(methodVisitor, scope); |
9620 |
return false; |
9621 |
} |
9622 |
} |
9623 |
|
9624 |
MethodVisitor methodVisitor = new MethodVisitor(); |
9625 |
TypeVisitor typeVisitor = new TypeVisitor(); |
9626 |
methodVisitor.typeVisitor = typeVisitor; |
9627 |
typeVisitor.methodVisitor = methodVisitor; |
9628 |
|
9629 |
if(this.referenceContext instanceof AbstractMethodDeclaration) { |
9630 |
((AbstractMethodDeclaration)this.referenceContext).traverse(methodVisitor, (ClassScope)null); |
9631 |
} else if(this.referenceContext instanceof TypeDeclaration) { |
9632 |
TypeDeclaration typeContext = (TypeDeclaration)this.referenceContext; |
9633 |
|
9634 |
int length = typeContext.fields.length; |
9635 |
for (int i = 0; i < length; i++) { |
9636 |
final FieldDeclaration fieldDeclaration = typeContext.fields[i]; |
9637 |
switch(fieldDeclaration.getKind()) { |
9638 |
case AbstractVariableDeclaration.INITIALIZER: |
9639 |
methodVisitor.enclosingType = typeContext; |
9640 |
((Initializer) fieldDeclaration).traverse(methodVisitor, (MethodScope)null); |
9641 |
break; |
9642 |
} |
9643 |
} |
9644 |
} |
9645 |
} |
9646 |
|
9124 |
public void recoveryExitFromVariable() { |
9647 |
public void recoveryExitFromVariable() { |
9125 |
if(this.currentElement != null && this.currentElement.parent != null) { |
9648 |
if(this.currentElement != null && this.currentElement.parent != null) { |
9126 |
if(this.currentElement instanceof RecoveredLocalVariable) { |
9649 |
if(this.currentElement instanceof RecoveredLocalVariable) { |
Lines 9202-9217
Link Here
|
9202 |
int end = this.scanner.eofPosition <= Integer.MAX_VALUE ? this.scanner.eofPosition - 1 : this.scanner.eofPosition; |
9725 |
int end = this.scanner.eofPosition <= Integer.MAX_VALUE ? this.scanner.eofPosition - 1 : this.scanner.eofPosition; |
9203 |
if(isDietParse) { |
9726 |
if(isDietParse) { |
9204 |
TypeDeclaration[] types = this.compilationUnit.types; |
9727 |
TypeDeclaration[] types = this.compilationUnit.types; |
9205 |
|
|
|
9206 |
int[][] intervalToSkip = org.eclipse.jdt.internal.compiler.parser.diagnose.RangeUtil.computeDietRange(types); |
9728 |
int[][] intervalToSkip = org.eclipse.jdt.internal.compiler.parser.diagnose.RangeUtil.computeDietRange(types); |
9207 |
DiagnoseParser diagnoseParser = new DiagnoseParser(this, oldFirstToken, start, end, intervalToSkip[0], intervalToSkip[1], intervalToSkip[2], this.options); |
9729 |
DiagnoseParser diagnoseParser = new DiagnoseParser(this, oldFirstToken, start, end, intervalToSkip[0], intervalToSkip[1], intervalToSkip[2], this.options); |
9208 |
diagnoseParser.diagnoseParse(); |
9730 |
diagnoseParser.diagnoseParse(false); |
9209 |
|
9731 |
|
9210 |
reportSyntaxErrorsForSkippedMethod(types); |
9732 |
reportSyntaxErrorsForSkippedMethod(types); |
9211 |
this.scanner.resetTo(start, end); |
9733 |
this.scanner.resetTo(start, end); |
9212 |
} else { |
9734 |
} else { |
9213 |
DiagnoseParser diagnoseParser = new DiagnoseParser(this, oldFirstToken, start, end, this.options); |
9735 |
DiagnoseParser diagnoseParser = new DiagnoseParser(this, oldFirstToken, start, end, this.options); |
9214 |
diagnoseParser.diagnoseParse(); |
9736 |
diagnoseParser.diagnoseParse(this.options.performStatementsRecovery); |
9215 |
} |
9737 |
} |
9216 |
} |
9738 |
} |
9217 |
private void reportSyntaxErrorsForSkippedMethod(TypeDeclaration[] types){ |
9739 |
private void reportSyntaxErrorsForSkippedMethod(TypeDeclaration[] types){ |
Lines 9229-9238
Link Here
|
9229 |
if(method.errorInSignature) { |
9751 |
if(method.errorInSignature) { |
9230 |
if(method.isAnnotationMethod()) { |
9752 |
if(method.isAnnotationMethod()) { |
9231 |
DiagnoseParser diagnoseParser = new DiagnoseParser(this, TokenNameQUESTION, method.declarationSourceStart, method.declarationSourceEnd, this.options); |
9753 |
DiagnoseParser diagnoseParser = new DiagnoseParser(this, TokenNameQUESTION, method.declarationSourceStart, method.declarationSourceEnd, this.options); |
9232 |
diagnoseParser.diagnoseParse(); |
9754 |
diagnoseParser.diagnoseParse(this.options.performStatementsRecovery); |
9233 |
} else { |
9755 |
} else { |
9234 |
DiagnoseParser diagnoseParser = new DiagnoseParser(this, TokenNameDIVIDE, method.declarationSourceStart, method.declarationSourceEnd, this.options); |
9756 |
DiagnoseParser diagnoseParser = new DiagnoseParser(this, TokenNameDIVIDE, method.declarationSourceStart, method.declarationSourceEnd, this.options); |
9235 |
diagnoseParser.diagnoseParse(); |
9757 |
diagnoseParser.diagnoseParse(this.options.performStatementsRecovery); |
9236 |
} |
9758 |
} |
9237 |
|
9759 |
|
9238 |
} |
9760 |
} |
Lines 9247-9253
Link Here
|
9247 |
Initializer initializer = (Initializer)fields[j]; |
9769 |
Initializer initializer = (Initializer)fields[j]; |
9248 |
if(initializer.errorInSignature){ |
9770 |
if(initializer.errorInSignature){ |
9249 |
DiagnoseParser diagnoseParser = new DiagnoseParser(this, TokenNameRIGHT_SHIFT, initializer.declarationSourceStart, initializer.declarationSourceEnd, this.options); |
9771 |
DiagnoseParser diagnoseParser = new DiagnoseParser(this, TokenNameRIGHT_SHIFT, initializer.declarationSourceStart, initializer.declarationSourceEnd, this.options); |
9250 |
diagnoseParser.diagnoseParse(); |
9772 |
diagnoseParser.diagnoseParse(this.options.performStatementsRecovery); |
9251 |
} |
9773 |
} |
9252 |
} |
9774 |
} |
9253 |
} |
9775 |
} |
Lines 9292-9315
Link Here
|
9292 |
* decide which grammar goal is activated. |
9814 |
* decide which grammar goal is activated. |
9293 |
*/ |
9815 |
*/ |
9294 |
protected boolean resumeAfterRecovery() { |
9816 |
protected boolean resumeAfterRecovery() { |
9295 |
|
9817 |
if(!this.methodRecoveryActivated && !this.statementRecoveryActivated) { |
9296 |
// reset internal stacks |
9818 |
|
9297 |
this.resetStacks(); |
9819 |
// reset internal stacks |
9298 |
this.resetModifiers(); |
9820 |
this.resetStacks(); |
|
|
9821 |
this.resetModifiers(); |
9822 |
|
9823 |
/* attempt to move checkpoint location */ |
9824 |
if (!this.moveRecoveryCheckpoint()) { |
9825 |
return false; |
9826 |
} |
9299 |
|
9827 |
|
9300 |
/* attempt to move checkpoint location */ |
9828 |
// only look for headers |
9301 |
if (!this.moveRecoveryCheckpoint()) { |
9829 |
if (this.referenceContext instanceof CompilationUnitDeclaration){ |
|
|
9830 |
goForHeaders(); |
9831 |
this.diet = true; // passed this point, will not consider method bodies |
9832 |
return true; |
9833 |
} |
9834 |
|
9835 |
// does not know how to restart |
9302 |
return false; |
9836 |
return false; |
9303 |
} |
9837 |
} else if(!this.statementRecoveryActivated) { |
9304 |
|
9838 |
|
9305 |
// only look for headers |
9839 |
// reset internal stacks |
9306 |
if (this.referenceContext instanceof CompilationUnitDeclaration){ |
9840 |
this.resetStacks(); |
|
|
9841 |
this.resetModifiers(); |
9842 |
|
9843 |
/* attempt to move checkpoint location */ |
9844 |
if (!this.moveRecoveryCheckpoint()) { |
9845 |
return false; |
9846 |
} |
9847 |
|
9848 |
// only look for headers |
9307 |
goForHeaders(); |
9849 |
goForHeaders(); |
9308 |
this.diet = true; // passed this point, will not consider method bodies |
|
|
9309 |
return true; |
9850 |
return true; |
|
|
9851 |
} else { |
9852 |
return false; |
9310 |
} |
9853 |
} |
9311 |
// does not know how to restart |
|
|
9312 |
return false; |
9313 |
} |
9854 |
} |
9314 |
protected boolean resumeOnSyntaxError() { |
9855 |
protected boolean resumeOnSyntaxError() { |
9315 |
this.checkExternalizeStrings = false; |
9856 |
this.checkExternalizeStrings = false; |
Lines 9335-9340
Link Here
|
9335 |
/* attempt to reset state in order to resume to parse loop */ |
9876 |
/* attempt to reset state in order to resume to parse loop */ |
9336 |
return this.resumeAfterRecovery(); |
9877 |
return this.resumeAfterRecovery(); |
9337 |
} |
9878 |
} |
|
|
9879 |
public void setStatementsRecovery(boolean enabled) { |
9880 |
this.options.performStatementsRecovery = enabled; |
9881 |
} |
9338 |
public String toString() { |
9882 |
public String toString() { |
9339 |
|
9883 |
|
9340 |
|
9884 |
|