| Summary: | [content assist] Insert of assist proposal fails inside nested object literal | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [WebTools] JSDT | Reporter: | Chris Jaun <cmjaun> | ||||||
| Component: | General | Assignee: | Project Inbox <jsdt.javascript-inbox> | ||||||
| Status: | RESOLVED FIXED | QA Contact: | Chris Jaun <cmjaun> | ||||||
| Severity: | normal | ||||||||
| Priority: | P3 | CC: | houghtoj, hyukmin0530.kwon, jaeheung.kim, kgurals | ||||||
| Version: | 3.2 | Flags: | cmjaun:
review+
|
||||||
| Target Milestone: | 3.5.1 | ||||||||
| Hardware: | PC | ||||||||
| OS: | Windows XP | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
Can be reproduced with a simple statement:
var ptt = {};
(p*)
attempt content assist on the *
The error seems to be in updateSourcePosition() in the parser which changes the start location of the completionNode to the (.
Created attachment 215614 [details]
proposed patch
This patch adjusts the replacement position of the completion proposal.
The start position of ast node includes parentheses('('). For example the start position of '(p)' expression is set to '(' not 'p'.
As Chris said, the position is determined while parsing by updateSourcePosition(). And Content Assist for '(p)' fails because AbstractJavaCompletionProposal.validate() checks the prefix of ast node with the proposal which are '(p' and 'p' respectively.
I'm not sure whether updateSourcePosition() is wrong or not. But ASTConverter which converts internal AST to public AST is handling this issue explicitly by introducing ParenthesizedExpression node. So the proposed patch handles this issue at the use site(content assist) not at the generation site(parser).
This patch sets the new replacement position of the proposal by searching actual start position backward from the cursor position.
Created attachment 215615 [details]
testcase
I have reviewed this patch and recommend that it be included in 3.5.1. Chris, can you officially review it. Wooyoung, Eclipse is putting in some updated policies regarding accepting patches. See point #1 and #2 in the Bugzilla section at this link: http://wiki.eclipse.org/Development_Resources/Handling_Git_Contributions If you haven't yet, you need to sign the Contributor License Agreement for us to pull in your patch. Thanks, Chris Pushed to 3.5.1 and master. |
1. Create a JS file in a JS Project. 2. Add the following... var point = new Object(); point.x = 2.3; point.y = -1.2; var square = {"upperLeft": {x:point.x, y:point.y}, 'upperRight': {x:(p)} }; 3. Attempt content assist directly after the 'p'. A list of proposals pops up, including the proposal for "point". 4. Double click to select the proposal. Nothing is inserted.