Bug 196514 - Bunch of exception during code typing in JDT editor
Summary: Bunch of exception during code typing in JDT editor
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.4 M1   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-07-13 18:03 EDT by Alex Chapiro CLA
Modified: 2007-08-09 14:18 EDT (History)
2 users (show)

See Also:


Attachments
This is a file I edited when got the described error (1.84 KB, application/octet-stream)
2007-07-13 18:07 EDT, Alex Chapiro CLA
no flags Details
Proposed fix (6.86 KB, patch)
2007-07-19 04:09 EDT, David Audel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Chapiro CLA 2007-07-13 18:03:58 EDT
Build ID:  I20070621-1340

Steps To Reproduce:
1.I edited attached source java file. Accidentally I typed the following text:

main(new String0])
As a result I got bunch of traces in the log. 

More information:

(Error descriptions were different, but the line of code exception occured was one and the same)

java.lang.IllegalArgumentException
	at org.eclipse.jdt.core.dom.ASTNode.setSourceRange(ASTNode.java:2609)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:838)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1534)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1998)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1621)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2476)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:511)
	at org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations(ASTConverter.java:179)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2661)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1248)
	at org.eclipse.jdt.core.dom.AST.convertCompilationUnit(AST.java:278)
	at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.makeConsistent(ReconcileWorkingCopyOperation.java:207)
	at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:89)
	at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:720)
	at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:780)
	at org.eclipse.jdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:1169)
	at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy$1.run(JavaReconcilingStrategy.java:101)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
	at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:82)
	at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:149)
	at org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:86)
	at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile(JavaCompositeReconcilingStrategy.java:96)
	at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:75)
	at org.eclipse.jdt.internal.ui.text.JavaReconciler.process(JavaReconciler.java:378)
	at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:204)
Comment 1 Alex Chapiro CLA 2007-07-13 18:07:12 EDT
Created attachment 73778 [details]
This is a file I edited when got the described error
Comment 2 Olivier Thomann CLA 2007-07-15 11:02:41 EDT
David, the error seems to come from statement recovery.
Comment 3 David Audel CLA 2007-07-19 04:09:35 EDT
Created attachment 74117 [details]
Proposed fix

The ASTConverter try to retrieve the right bracket position. The converter search this bracket one character after the left bracket and in this case the right bracket is a recovered token with the same location as left bracket.
On other side the converter doesn't take into account interlinked bracket (eg a[b[0]].

The fix is to count brackets and to start the search at the left bracket location.
Comment 4 David Audel CLA 2007-07-19 04:12:20 EDT
Released for 3.4M1.

Tests added
  ASTConverterTestAST3_2#test0682() -> test0683()
Comment 5 Frederic Fusier CLA 2007-08-03 09:32:13 EDT
Verified for 3.4M1 using build I20070802-0800.
Comment 6 Jerome Lanneluc CLA 2007-08-09 11:03:46 EDT
It might be worth backporting to 3.3.1. David, what do you think ?
Comment 7 Dani Megert CLA 2007-08-09 14:18:06 EDT
+1 for 3.3.1.