Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 333445 - Content Assist in Query Editor fails on Complex Nested Queries
Summary: Content Assist in Query Editor fails on Complex Nested Queries
Status: CLOSED FIXED
Alias: None
Product: EMF
Classification: Modeling
Component: Query2 (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-03 22:31 EST by Animesh Kumar CLA
Modified: 2011-04-25 02:13 EDT (History)
2 users (show)

See Also:


Attachments
Sample Query which was used (316 bytes, text/plain)
2011-01-03 23:06 EST, Animesh Kumar CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Animesh Kumar CLA 2011-01-03 22:31:56 EST
Build Identifier: 

Whenever a complex nested query is written(say as having 4 or more nesting), the content assists fails and starts giving a Null Pointer Exception in the code for content assist in EMF Generated Code of String Syntax UI plugin. 
After the failing of content assist, the Query cannot be typed manually also as it gives an error saying the from Clause must have a Class only (though there are Classes only in the from Clause).
The most surprising thing is, that query editor runs (executes) the same Query(Any Complex nested query with 4 or more nests) without any problem, if it is copied from some external source and pasted in the Query Editor.

Reproducible: Always
Comment 1 Animesh Kumar CLA 2011-01-03 23:06:34 EST
Created attachment 185981 [details]
Sample Query which was used

Sample Query which was used when it gave an error.
Comment 2 manasa CLA 2011-02-21 00:56:02 EST
This is actually caused by a bug in org.antlr.runtime.BaseRecognizer.pushFollow(BitSet).The exact issue is, BaseRecognizer.following[99] is null. 

/** Push a rule's follow set using our own hardcoded stack */
protected void pushFollow(BitSet fset) {
   if ( (_fsp +1)>=following.length ) {
      BitSet[] f = new BitSet[following.length*2];
      System.arraycopy(following, 0, f, 0, following.length-1);
      following = f;
   }
   following[++_fsp] = fset;
}

The problem is the length parameter of
System.arraycopy. They do not copy the last element of the original array when
growing, and sofollowing[99] is null. When this method is overrided in .ui project's parser, the error no more occurs.

This bug is fixed in xtext version 1.0.2 which will be released in a couple of days, as Query2 uses xtext Version 1.0.1, we will have to wait until it is released to migrate to the 1.0.2 version. Hence I reduce the priority of the bug.

Please find details below.
http://www.eclipse.org/forums/index.php?t=rview&goto=655318#msg_655318

Thanks & Regards,
Manasa
Comment 3 Animesh Kumar CLA 2011-02-21 01:25:53 EST
Hi,
I have updated the Severity of the bug to minor.
(In reply to comment #2)
> This is actually caused by a bug in
> org.antlr.runtime.BaseRecognizer.pushFollow(BitSet).The exact issue is,
> BaseRecognizer.following[99] is null. 
> 
> /** Push a rule's follow set using our own hardcoded stack */
> protected void pushFollow(BitSet fset) {
>    if ( (_fsp +1)>=following.length ) {
>       BitSet[] f = new BitSet[following.length*2];
>       System.arraycopy(following, 0, f, 0, following.length-1);
>       following = f;
>    }
>    following[++_fsp] = fset;
> }
> 
> The problem is the length parameter of
> System.arraycopy. They do not copy the last element of the original array when
> growing, and sofollowing[99] is null. When this method is overrided in .ui
> project's parser, the error no more occurs.
> 
> This bug is fixed in xtext version 1.0.2 which will be released in a couple of
> days, as Query2 uses xtext Version 1.0.1, we will have to wait until it is
> released to migrate to the 1.0.2 version. Hence I reduce the priority of the
> bug.
> 
> Please find details below.
> http://www.eclipse.org/forums/index.php?t=rview&goto=655318#msg_655318
> 
> Thanks & Regards,
> Manasa
Comment 4 manasa CLA 2011-04-25 02:11:45 EDT
Issue has been tested with the xtext 1.0.2  updated IDE.
NPE no more reproducible with latest content.
Please close the bug.