mirror of
https://github.com/github/semantic.git
synced 2024-12-23 06:41:45 +03:00
Merge remote-tracking branch 'origin/master' into different-eval-strategy
This commit is contained in:
commit
a9da8eb9df
@ -144,6 +144,8 @@ type Syntax = '[
|
|||||||
, TypeScript.Syntax.JsxClosingElement
|
, TypeScript.Syntax.JsxClosingElement
|
||||||
, TypeScript.Syntax.JsxExpression
|
, TypeScript.Syntax.JsxExpression
|
||||||
, TypeScript.Syntax.JsxAttribute
|
, TypeScript.Syntax.JsxAttribute
|
||||||
|
, TypeScript.Syntax.JsxFragment
|
||||||
|
, TypeScript.Syntax.JsxNamespaceName
|
||||||
, TypeScript.Syntax.OptionalParameter
|
, TypeScript.Syntax.OptionalParameter
|
||||||
, TypeScript.Syntax.RequiredParameter
|
, TypeScript.Syntax.RequiredParameter
|
||||||
, TypeScript.Syntax.RestParameter
|
, TypeScript.Syntax.RestParameter
|
||||||
@ -196,8 +198,8 @@ expression = handleError everything
|
|||||||
super,
|
super,
|
||||||
object,
|
object,
|
||||||
array,
|
array,
|
||||||
jsxElement,
|
jsxElement',
|
||||||
jsxSelfClosingElement,
|
jsxFragment,
|
||||||
class',
|
class',
|
||||||
anonymousClass,
|
anonymousClass,
|
||||||
function,
|
function,
|
||||||
@ -352,26 +354,44 @@ object = makeTerm <$> (symbol Object <|> symbol ObjectPattern) <*> children (Lit
|
|||||||
array :: Assignment
|
array :: Assignment
|
||||||
array = makeTerm <$> (symbol Array <|> symbol ArrayPattern) <*> children (Literal.Array <$> manyTerm (expression <|> spreadElement))
|
array = makeTerm <$> (symbol Array <|> symbol ArrayPattern) <*> children (Literal.Array <$> manyTerm (expression <|> spreadElement))
|
||||||
|
|
||||||
|
jsxElement' :: Assignment
|
||||||
|
jsxElement' = choice [ jsxElement, jsxSelfClosingElement ]
|
||||||
|
|
||||||
jsxElement :: Assignment
|
jsxElement :: Assignment
|
||||||
jsxElement = makeTerm <$> symbol Grammar.JsxElement <*> children (TypeScript.Syntax.JsxElement <$> term jsxOpeningElement' <*> manyTerm (jsxElement <|> jsxSelfClosingElement <|> jsxExpression' <|> jsxText) <*> term jsxClosingElement')
|
jsxElement = makeTerm <$> symbol Grammar.JsxElement <*> children (TypeScript.Syntax.JsxElement <$> term jsxOpeningElement' <*> manyTerm jsxChild <*> term jsxClosingElement')
|
||||||
|
|
||||||
|
jsxFragment :: Assignment
|
||||||
|
jsxFragment = makeTerm <$> symbol Grammar.JsxFragment <*> children (TypeScript.Syntax.JsxFragment <$> manyTerm jsxChild)
|
||||||
|
|
||||||
|
jsxChild :: Assignment
|
||||||
|
jsxChild = choice [ jsxElement', jsxExpression', jsxText ]
|
||||||
|
|
||||||
jsxSelfClosingElement :: Assignment
|
jsxSelfClosingElement :: Assignment
|
||||||
jsxSelfClosingElement = makeTerm <$> symbol Grammar.JsxSelfClosingElement <*> children (TypeScript.Syntax.JsxSelfClosingElement <$> term identifier <*> manyTerm (jsxAttribute <|> jsxExpression'))
|
jsxSelfClosingElement = makeTerm <$> symbol Grammar.JsxSelfClosingElement <*> children (TypeScript.Syntax.JsxSelfClosingElement <$> term jsxElementName <*> manyTerm jsxAttribute')
|
||||||
|
|
||||||
|
jsxAttribute' = jsxAttribute <|> jsxExpression'
|
||||||
|
|
||||||
jsxOpeningElement' :: Assignment
|
jsxOpeningElement' :: Assignment
|
||||||
jsxOpeningElement' = makeTerm <$> symbol Grammar.JsxOpeningElement <*> children (TypeScript.Syntax.JsxOpeningElement <$> term identifier <*> manyTerm (jsxAttribute <|> jsxExpression'))
|
jsxOpeningElement' = makeTerm <$> symbol Grammar.JsxOpeningElement <*> children (TypeScript.Syntax.JsxOpeningElement <$> term jsxElementName <*> manyTerm jsxAttribute')
|
||||||
|
|
||||||
|
jsxElementName :: Assignment
|
||||||
|
jsxElementName = choice [ identifier, nestedIdentifier, jsxNamespaceName ]
|
||||||
|
|
||||||
|
jsxNamespaceName :: Assignment
|
||||||
|
jsxNamespaceName = makeTerm <$> symbol Grammar.JsxNamespaceName <*> children (TypeScript.Syntax.JsxNamespaceName <$> identifier <*> identifier)
|
||||||
|
|
||||||
jsxExpression' :: Assignment
|
jsxExpression' :: Assignment
|
||||||
jsxExpression' = makeTerm <$> symbol Grammar.JsxExpression <*> children (TypeScript.Syntax.JsxExpression <$> term (expressions <|> spreadElement))
|
jsxExpression' = makeTerm <$> symbol Grammar.JsxExpression <*> children (TypeScript.Syntax.JsxExpression <$> term (expressions <|> spreadElement <|> emptyTerm))
|
||||||
|
|
||||||
jsxText :: Assignment
|
jsxText :: Assignment
|
||||||
jsxText = makeTerm <$> symbol Grammar.JsxText <*> (TypeScript.Syntax.JsxText <$> source)
|
jsxText = makeTerm <$> symbol Grammar.JsxText <*> (TypeScript.Syntax.JsxText <$> source)
|
||||||
|
|
||||||
jsxClosingElement' :: Assignment
|
jsxClosingElement' :: Assignment
|
||||||
jsxClosingElement' = makeTerm <$> symbol Grammar.JsxClosingElement <*> children (TypeScript.Syntax.JsxClosingElement <$> term identifier)
|
jsxClosingElement' = makeTerm <$> symbol Grammar.JsxClosingElement <*> children (TypeScript.Syntax.JsxClosingElement <$> term jsxElementName)
|
||||||
|
|
||||||
jsxAttribute :: Assignment
|
jsxAttribute :: Assignment
|
||||||
jsxAttribute = makeTerm <$> symbol Grammar.JsxAttribute <*> children (TypeScript.Syntax.JsxAttribute <$> term propertyIdentifier <*> term (number <|> string <|> jsxExpression'))
|
jsxAttribute = makeTerm <$> symbol Grammar.JsxAttribute <*> children (TypeScript.Syntax.JsxAttribute <$> term (propertyIdentifier <|> jsxNamespaceName) <*> (term jsxAttributeValue <|> emptyTerm))
|
||||||
|
where jsxAttributeValue = choice [ string, jsxExpression', jsxElement', jsxFragment ]
|
||||||
|
|
||||||
propertyIdentifier :: Assignment
|
propertyIdentifier :: Assignment
|
||||||
propertyIdentifier = makeTerm <$> symbol PropertyIdentifier <*> (Syntax.Identifier <$> source)
|
propertyIdentifier = makeTerm <$> symbol PropertyIdentifier <*> (Syntax.Identifier <$> source)
|
||||||
|
@ -493,3 +493,17 @@ data RestParameter a = RestParameter { _restParameterContext :: ![a], _restParam
|
|||||||
instance Eq1 RestParameter where liftEq = genericLiftEq
|
instance Eq1 RestParameter where liftEq = genericLiftEq
|
||||||
instance Ord1 RestParameter where liftCompare = genericLiftCompare
|
instance Ord1 RestParameter where liftCompare = genericLiftCompare
|
||||||
instance Show1 RestParameter where liftShowsPrec = genericLiftShowsPrec
|
instance Show1 RestParameter where liftShowsPrec = genericLiftShowsPrec
|
||||||
|
|
||||||
|
data JsxFragment a = JsxFragment [a]
|
||||||
|
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
|
||||||
|
|
||||||
|
instance Eq1 JsxFragment where liftEq = genericLiftEq
|
||||||
|
instance Ord1 JsxFragment where liftCompare = genericLiftCompare
|
||||||
|
instance Show1 JsxFragment where liftShowsPrec = genericLiftShowsPrec
|
||||||
|
|
||||||
|
data JsxNamespaceName a = JsxNamespaceName a a
|
||||||
|
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
|
||||||
|
|
||||||
|
instance Eq1 JsxNamespaceName where liftEq = genericLiftEq
|
||||||
|
instance Ord1 JsxNamespaceName where liftCompare = genericLiftCompare
|
||||||
|
instance Show1 JsxNamespaceName where liftShowsPrec = genericLiftShowsPrec
|
||||||
|
2
test/fixtures/typescript/jsx-elements.A.ts
vendored
2
test/fixtures/typescript/jsx-elements.A.ts
vendored
@ -1 +1,3 @@
|
|||||||
var a = <Text {...css(styles.titleText)}>{children}</Text>
|
var a = <Text {...css(styles.titleText)}>{children}</Text>
|
||||||
|
var b = <Foo.Text></Foo.Text>
|
||||||
|
var c = <Foo.Text foo bar="zed" />
|
||||||
|
@ -22,4 +22,16 @@
|
|||||||
(JsxExpression
|
(JsxExpression
|
||||||
(Identifier))
|
(Identifier))
|
||||||
(JsxClosingElement
|
(JsxClosingElement
|
||||||
(Identifier))))))
|
(Identifier)))))
|
||||||
|
{-(VariableDeclaration
|
||||||
|
{-(Assignment
|
||||||
|
{-(Empty)-}
|
||||||
|
{-(Identifier)-}
|
||||||
|
{-(JsxElement{-(JsxOpeningElement{-(NestedIdentifier{-(Identifier)-}{-(Identifier)-})-})-}{-(JsxClosingElement{-(NestedIdentifier{-(Identifier)-}{-(Identifier)-})-})-})-})
|
||||||
|
-})-}
|
||||||
|
{-(VariableDeclaration
|
||||||
|
{-(Assignment
|
||||||
|
{-(Empty)-}
|
||||||
|
{-(Identifier)-}
|
||||||
|
{-(JsxSelfClosingElement{-(NestedIdentifier{-(Identifier)-}{-(Identifier)-})-}{-(JsxAttribute{-(Identifier)-}{-(Empty)-})-}{-(JsxAttribute{-(Identifier)-}{-(TextElement)-})-})-}
|
||||||
|
)-})-})
|
||||||
|
@ -22,4 +22,14 @@
|
|||||||
(JsxExpression
|
(JsxExpression
|
||||||
(Identifier))
|
(Identifier))
|
||||||
(JsxClosingElement
|
(JsxClosingElement
|
||||||
(Identifier))))))
|
(Identifier)))))
|
||||||
|
{+(VariableDeclaration
|
||||||
|
{+(Assignment
|
||||||
|
{+(Empty)+}
|
||||||
|
{+(Identifier)+}
|
||||||
|
{+(JsxElement{+(JsxOpeningElement{+(NestedIdentifier{+(Identifier)+}{+(Identifier)+})+})+}{+(JsxClosingElement{+(NestedIdentifier{+(Identifier)+}{+(Identifier)+})+})+})+})+})+}
|
||||||
|
{+(VariableDeclaration
|
||||||
|
{+(Assignment
|
||||||
|
{+(Empty)+}
|
||||||
|
{+(Identifier)+}
|
||||||
|
{+(JsxSelfClosingElement{+(NestedIdentifier{+(Identifier)+}{+(Identifier)+})+}{+(JsxAttribute{+(Identifier)+}{+(Empty)+})+}{+(JsxAttribute{+(Identifier)+}{+(TextElement)+})+})+})+})+})
|
||||||
|
26
test/fixtures/typescript/jsx-elements.parseA.txt
vendored
26
test/fixtures/typescript/jsx-elements.parseA.txt
vendored
@ -16,4 +16,30 @@
|
|||||||
(JsxExpression
|
(JsxExpression
|
||||||
(Identifier))
|
(Identifier))
|
||||||
(JsxClosingElement
|
(JsxClosingElement
|
||||||
|
(Identifier)))))
|
||||||
|
(VariableDeclaration
|
||||||
|
(Assignment
|
||||||
|
(Empty)
|
||||||
|
(Identifier)
|
||||||
|
(JsxElement
|
||||||
|
(JsxOpeningElement
|
||||||
|
(NestedIdentifier
|
||||||
|
(Identifier) (Identifier)))
|
||||||
|
(JsxClosingElement
|
||||||
|
(NestedIdentifier
|
||||||
|
(Identifier)
|
||||||
(Identifier))))))
|
(Identifier))))))
|
||||||
|
(VariableDeclaration
|
||||||
|
(Assignment
|
||||||
|
(Empty)
|
||||||
|
(Identifier)
|
||||||
|
(JsxSelfClosingElement
|
||||||
|
(NestedIdentifier
|
||||||
|
(Identifier)
|
||||||
|
(Identifier))
|
||||||
|
(JsxAttribute
|
||||||
|
(Identifier)
|
||||||
|
(Empty))
|
||||||
|
(JsxAttribute
|
||||||
|
(Identifier)
|
||||||
|
(TextElement))))))
|
||||||
|
2
vendor/effects
vendored
2
vendor/effects
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 7b905b290f746c07f6a5486afd9fd881cfd30caf
|
Subproject commit 665d14c75881ddedb3aa6fa9ee0c46bfb898b3df
|
2
vendor/haskell-tree-sitter
vendored
2
vendor/haskell-tree-sitter
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 179099a20135bfcee635e469022c77f04df20b07
|
Subproject commit a7c77ef5459e4f610bd82ce203984f408bc106c2
|
Loading…
Reference in New Issue
Block a user