Lines 23-34
Link Here
|
23 |
*/ |
23 |
*/ |
24 |
public class CodeSnippetParser extends Parser implements EvaluationConstants { |
24 |
public class CodeSnippetParser extends Parser implements EvaluationConstants { |
25 |
int codeSnippetStart, codeSnippetEnd; |
25 |
int codeSnippetStart, codeSnippetEnd; |
|
|
26 |
EvaluationContext evaluationContext; |
26 |
boolean hasRecoveredOnExpression; |
27 |
boolean hasRecoveredOnExpression; |
27 |
int problemCountBeforeRecovery = 0; |
|
|
28 |
int lastStatement = -1; // end of last top level statement |
28 |
int lastStatement = -1; // end of last top level statement |
29 |
int lineSeparatorLength; |
29 |
int lineSeparatorLength; |
30 |
|
30 |
|
31 |
EvaluationContext evaluationContext; |
31 |
int problemCountBeforeRecovery = 0; |
32 |
/** |
32 |
/** |
33 |
* Creates a new code snippet parser. |
33 |
* Creates a new code snippet parser. |
34 |
*/ |
34 |
*/ |
Lines 145-150
Link Here
|
145 |
/* recovery */ |
145 |
/* recovery */ |
146 |
recordLastStatementIfNeeded(); |
146 |
recordLastStatementIfNeeded(); |
147 |
} |
147 |
} |
|
|
148 |
protected void consumeEnhancedForStatement() { |
149 |
super.consumeEnhancedForStatement(); |
150 |
/* recovery */ |
151 |
recordLastStatementIfNeeded(); |
152 |
} |
148 |
protected void consumeExpressionStatement() { |
153 |
protected void consumeExpressionStatement() { |
149 |
super.consumeExpressionStatement(); |
154 |
super.consumeExpressionStatement(); |
150 |
/* recovery */ |
155 |
/* recovery */ |
Lines 245-250
Link Here
|
245 |
/* recovery */ |
250 |
/* recovery */ |
246 |
recordLastStatementIfNeeded(); |
251 |
recordLastStatementIfNeeded(); |
247 |
} |
252 |
} |
|
|
253 |
|
248 |
/** |
254 |
/** |
249 |
* In case emulating local variables, wrap the (recovered) statements inside a |
255 |
* In case emulating local variables, wrap the (recovered) statements inside a |
250 |
* try statement so as to achieve local state commiting (copy local vars back to fields). |
256 |
* try statement so as to achieve local state commiting (copy local vars back to fields). |
Lines 374-380
Link Here
|
374 |
m.receiver = new CodeSnippetSuperReference(m.sourceStart, this.endPosition, this.evaluationContext); |
380 |
m.receiver = new CodeSnippetSuperReference(m.sourceStart, this.endPosition, this.evaluationContext); |
375 |
pushOnExpressionStack(m); |
381 |
pushOnExpressionStack(m); |
376 |
} |
382 |
} |
377 |
|
|
|
378 |
protected void consumePrimaryNoNewArrayThis() { |
383 |
protected void consumePrimaryNoNewArrayThis() { |
379 |
// PrimaryNoNewArray ::= 'this' |
384 |
// PrimaryNoNewArray ::= 'this' |
380 |
|
385 |
|
Lines 679-684
Link Here
|
679 |
this.lastStatement = this.scanner.startPosition; |
684 |
this.lastStatement = this.scanner.startPosition; |
680 |
} |
685 |
} |
681 |
} |
686 |
} |
|
|
687 |
|
682 |
protected void reportSyntaxErrors(boolean isDietParse, int oldFirstToken) { |
688 |
protected void reportSyntaxErrors(boolean isDietParse, int oldFirstToken) { |
683 |
if (!isDietParse) { |
689 |
if (!isDietParse) { |
684 |
this.scanner.initialPosition = this.lastStatement; |
690 |
this.scanner.initialPosition = this.lastStatement; |
Lines 687-693
Link Here
|
687 |
} |
693 |
} |
688 |
super.reportSyntaxErrors(isDietParse, oldFirstToken); |
694 |
super.reportSyntaxErrors(isDietParse, oldFirstToken); |
689 |
} |
695 |
} |
690 |
|
|
|
691 |
/* |
696 |
/* |
692 |
* A syntax error was detected. If a method is being parsed, records the number of errors and |
697 |
* A syntax error was detected. If a method is being parsed, records the number of errors and |
693 |
* attempts to restart from the last statement by going for an expression. |
698 |
* attempts to restart from the last statement by going for an expression. |