Fix flow plugin when flow+arrow+spread used together

The fix includes creating a new method on the parser called `parseArrow`.
This new function by default only checks if current position matches an
arrow. If it does returns the `node` otherwise `undefined`.
The flow plugin can then extend this function and correctly parse the typeAnnotation
and add it to the node.

With this change, in the flow plugin there is no need anymore to extend
`parseParenAndDistinguishExpression` and the arrow handling in `parseParenItem`
could also be removed, because it is all handled now in `parseArrow`.

Some existing tests were failing, because `extra->parentesized` is now missing,
but this is correct as it is now inline with parsing without flow annotation. No extra
is added for arrow function without type annotations.

In the expression-parser `this.next()` was replaced by a more specific
`this.expect(tt.parenL)`.
This commit is contained in:
Daniel Tschinder
2016-03-12 14:04:53 +01:00
parent 8b150813f5
commit d15a2310cd
13 changed files with 793 additions and 74 deletions

View File

@@ -171,10 +171,6 @@
"raw": "' world'"
},
"value": " world"
},
"extra": {
"parenthesized": true,
"parenStart": 12
}
}
],