Bug 33213 - Same error reported more than once?
Summary: Same error reported more than once?
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.0 M2   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-02-26 05:18 EST by Erich Gamma CLA
Modified: 2003-07-16 04:14 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Erich Gamma CLA 2003-02-26 05:18:08 EST
For the following code 

public class Foo1 {

	public static void main(String[] args)  /** mising { **/
	}
}

The problems below are reported. 

Notice that the "Syntax error on token "}", "{" expected" is reported twice.
This is confusing, but if it this is an issue for this particluar scenario 
only, then it isn't critical.

Kind	Status	Priority	Description	Resource	In Folder
	Location
Error			Syntax error on token "}", "{" expected	Foo1.java
	JUnit/junit/samples	line 18
Error			Unmatched bracket	Foo1.java
	JUnit/junit/samples	line 18
Error			Syntax error on token "}", "{" expected	Foo1.java
	JUnit/junit/samples	line 18
Error			Unmatched bracket	Foo1.java
	JUnit/junit/samples	line 19
Comment 1 Philipe Mulet CLA 2003-02-26 05:31:58 EST
Suspecting this is a consequence of our dual parsing story with recovery.
Comment 2 David Audel CLA 2003-03-07 11:39:38 EST
Parser needs subtle modifications to fix this problem.
Will consider for 2.2.
Comment 3 David Audel CLA 2003-03-07 11:47:18 EST
A possible fix is to modify Parser#parse() with the following code:

protected void parse() {
	...
	ProcessTerminals : for (;;) {
		...

		if (act == ERROR_ACTION || restartRecovery) {
			int errorPos = scanner.currentPosition;
			if (!hasReportedError){	
				if(referenceContext instanceof 
AbstractMethodDeclaration){
					if(errorPos != lastDietErrorPos
						|| (errorPos > 
((AbstractMethodDeclaration)referenceContext).bodyStart)
						&& (errorPos < 
((AbstractMethodDeclaration)referenceContext).bodyEnd + 1)) {
						this.reportSyntaxError
(ERROR_ACTION, currentToken, stateStackTop);
						hasReportedError = true;
					}
				} else {
					this.reportSyntaxError(ERROR_ACTION, 
currentToken, stateStackTop);
					hasReportedError = true;
					lastDietErrorPos = errorPos;
				}
			}
			...
		}
		...
	}
	endParse(act);
}


and to initialize the new field in goForCompilationUnit()

public void goForCompilationUnit(){
	//tells the scanner to go for compilation unit parsing

	lastDietErrorPos = -1; // new field
	firstToken = TokenNamePLUS_PLUS ;
	scanner.linePtr = -1;	
	scanner.foundTaskCount = 0;
	scanner.recordLineSeparator = true;
	scanner.currentLine= null;
}
Comment 4 Philipe Mulet CLA 2003-04-02 06:42:18 EST
reopen
Comment 5 David Audel CLA 2003-07-01 06:40:16 EDT
Fixed.
Comment 6 David Audel CLA 2003-07-16 04:14:23 EDT
Verified.