| Summary: | Content assist throws error and fails | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [ECD] Orion | Reporter: | Mark Macdonald <mamacdon> | ||||
| Component: | JS Tools | Assignee: | Michael Rennie <Michael_Rennie> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | Michael_Rennie | ||||
| Version: | 5.0 | ||||||
| Target Milestone: | 6.0 M1 | ||||||
| Hardware: | PC | ||||||
| OS: | Windows 7 | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
Mark Macdonald
A bit more debugging. The trouble starts in typeEnvironment.scope(target), which is incorrectly returning undefined.
When that happens, 'target' has this shape:
> { "type": "Identifier",
> "name": "parentId",
> "range": [5741, 5749],
> "extras": {
> "inferredTypeObj": {
> "type": "UnionType",
> "elements": [
> { "type": "NameExpression",
> "name": "String"
> },
> { "type": "NameExpression",
> "name": "Element"
> }
> ]
> }
> }
> }
"UnionType" is not one of the inferredTypeObj types handled in scope(). Control reaches the end of the function (which shouldn't happen) so we get 'undefined'.
Here is a condensed snippet that causes the problem:
var foo = {
/**
* @param {String|Object} union
*/
bar: function(union) {
union = typeof union === "string" ? union : (union.id || union);
}
};
Put the cursor after 'union' in the assignment and activate content assist.
Looks like we don't properly handle the UnionType from doctrine, as noted in comment #1
(In reply to Michael Rennie from comment #2) > Here is a condensed snippet that causes the problem: An even more condensed snippet: /** * @param {String|Object} union */ function f(union) { union = union ? union.id : 'baz'; } I opened bug 431053 to track the work of actually making union types work properly. For now I committed a fix to stop it from blowing up when a union type is encountered. Pushed to: http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=fd758a579051a8ea5f17965b8df87fa891893ec3 |