mirror of
https://github.com/github/semantic.git
synced 2024-12-22 22:31:36 +03:00
Add trailing statement support for new tree-sitter trailing productions
This commit is contained in:
parent
14fe319ade
commit
b90bb8913b
@ -16,7 +16,7 @@ functions :: [Text]
|
|||||||
functions = [ "arrow_function", "generator_function", "function" ]
|
functions = [ "arrow_function", "generator_function", "function" ]
|
||||||
|
|
||||||
forStatements :: [Text]
|
forStatements :: [Text]
|
||||||
forStatements = [ "for_statement", "for_of_statement", "for_in_statement" ]
|
forStatements = [ "for_statement", "for_of_statement", "for_in_statement", "trailing_for_statement", "trailing_for_of_statement", "trailing_for_in_statement" ]
|
||||||
|
|
||||||
termConstructor
|
termConstructor
|
||||||
:: Source Char -- ^ The source that the term occurs within.
|
:: Source Char -- ^ The source that the term occurs within.
|
||||||
@ -29,6 +29,7 @@ termConstructor source sourceSpan name range children
|
|||||||
| name == "ERROR" = withDefaultInfo (S.Error children)
|
| name == "ERROR" = withDefaultInfo (S.Error children)
|
||||||
| otherwise = withDefaultInfo $ case (name, children) of
|
| otherwise = withDefaultInfo $ case (name, children) of
|
||||||
("return_statement", _) -> S.Return (listToMaybe children)
|
("return_statement", _) -> S.Return (listToMaybe children)
|
||||||
|
("trailing_return_statement", _) -> S.Return (listToMaybe children)
|
||||||
("assignment", [ identifier, value ]) -> S.Assignment identifier value
|
("assignment", [ identifier, value ]) -> S.Assignment identifier value
|
||||||
("assignment", _ ) -> S.Error children
|
("assignment", _ ) -> S.Error children
|
||||||
("math_assignment", [ identifier, value ]) -> S.MathAssignment identifier value
|
("math_assignment", [ identifier, value ]) -> S.MathAssignment identifier value
|
||||||
@ -52,6 +53,7 @@ termConstructor source sourceSpan name range children
|
|||||||
("var_assignment", [ x, y ]) -> S.VarAssignment x y
|
("var_assignment", [ x, y ]) -> S.VarAssignment x y
|
||||||
("var_assignment", _ ) -> S.Error children
|
("var_assignment", _ ) -> S.Error children
|
||||||
("var_declaration", _) -> S.Indexed $ toVarDecl <$> children
|
("var_declaration", _) -> S.Indexed $ toVarDecl <$> children
|
||||||
|
("trailing_var_declaration", _) -> S.Indexed $ toVarDecl <$> children
|
||||||
("switch_statement", expr : rest) -> S.Switch expr rest
|
("switch_statement", expr : rest) -> S.Switch expr rest
|
||||||
("switch_statement", _ ) -> S.Error children
|
("switch_statement", _ ) -> S.Error children
|
||||||
("case", [ expr, body ]) -> S.Case expr [body]
|
("case", [ expr, body ]) -> S.Case expr [body]
|
||||||
@ -60,13 +62,21 @@ termConstructor source sourceSpan name range children
|
|||||||
("pair", _) -> S.Fixed children
|
("pair", _) -> S.Fixed children
|
||||||
("comment", _) -> S.Comment . toText $ slice range source
|
("comment", _) -> S.Comment . toText $ slice range source
|
||||||
("if_statement", expr : rest ) -> S.If expr rest
|
("if_statement", expr : rest ) -> S.If expr rest
|
||||||
|
("trailing_if_statement", expr : rest ) -> S.If expr rest
|
||||||
("if_statement", _ ) -> S.Error children
|
("if_statement", _ ) -> S.Error children
|
||||||
|
("trailing_if_statement", _ ) -> S.Error children
|
||||||
("while_statement", expr : rest ) -> S.While expr rest
|
("while_statement", expr : rest ) -> S.While expr rest
|
||||||
|
("trailing_while_statement", expr : rest ) -> S.While expr rest
|
||||||
("while_statement", _ ) -> S.Error children
|
("while_statement", _ ) -> S.Error children
|
||||||
|
("trailing_while_statement", _ ) -> S.Error children
|
||||||
("do_statement", [ expr, body ]) -> S.DoWhile expr body
|
("do_statement", [ expr, body ]) -> S.DoWhile expr body
|
||||||
|
("trailing_do_statement", [ expr, body ]) -> S.DoWhile expr body
|
||||||
("do_statement", _ ) -> S.Error children
|
("do_statement", _ ) -> S.Error children
|
||||||
|
("trailing_do_statement", _ ) -> S.Error children
|
||||||
("throw_statement", [ expr ]) -> S.Throw expr
|
("throw_statement", [ expr ]) -> S.Throw expr
|
||||||
|
("trailing_throw_statement", [ expr ]) -> S.Throw expr
|
||||||
("throw_statment", _ ) -> S.Error children
|
("throw_statment", _ ) -> S.Error children
|
||||||
|
("trailing_throw_statment", _ ) -> S.Error children
|
||||||
("new_expression", [ expr ]) -> S.Constructor expr
|
("new_expression", [ expr ]) -> S.Constructor expr
|
||||||
("new_expression", _ ) -> S.Error children
|
("new_expression", _ ) -> S.Error children
|
||||||
("try_statement", _) -> case children of
|
("try_statement", _) -> case children of
|
||||||
@ -114,6 +124,7 @@ categoryForJavaScriptProductionName :: Text -> Category
|
|||||||
categoryForJavaScriptProductionName name = case name of
|
categoryForJavaScriptProductionName name = case name of
|
||||||
"object" -> Object
|
"object" -> Object
|
||||||
"expression_statement" -> ExpressionStatements
|
"expression_statement" -> ExpressionStatements
|
||||||
|
"trailing_expression_statement" -> ExpressionStatements
|
||||||
"this_expression" -> Identifier
|
"this_expression" -> Identifier
|
||||||
"null" -> Identifier
|
"null" -> Identifier
|
||||||
"undefined" -> Identifier
|
"undefined" -> Identifier
|
||||||
@ -125,13 +136,18 @@ categoryForJavaScriptProductionName name = case name of
|
|||||||
"delete_op" -> Operator -- delete operator, e.g. delete x[2].
|
"delete_op" -> Operator -- delete operator, e.g. delete x[2].
|
||||||
"type_op" -> Operator -- type operator, e.g. typeof Object.
|
"type_op" -> Operator -- type operator, e.g. typeof Object.
|
||||||
"void_op" -> Operator -- void operator, e.g. void 2.
|
"void_op" -> Operator -- void operator, e.g. void 2.
|
||||||
|
"for_statement" -> For
|
||||||
|
"trailing_for_statement" -> For
|
||||||
"for_in_statement" -> For
|
"for_in_statement" -> For
|
||||||
|
"trailing_for_in_statement" -> For
|
||||||
"for_of_statement" -> For
|
"for_of_statement" -> For
|
||||||
|
"trailing_for_of_statement" -> For
|
||||||
"new_expression" -> Constructor
|
"new_expression" -> Constructor
|
||||||
"class" -> Class
|
"class" -> Class
|
||||||
"catch" -> Catch
|
"catch" -> Catch
|
||||||
"finally" -> Finally
|
"finally" -> Finally
|
||||||
"if_statement" -> If
|
"if_statement" -> If
|
||||||
|
"trailing_if_statement" -> If
|
||||||
"empty_statement" -> Empty
|
"empty_statement" -> Empty
|
||||||
"program" -> Program
|
"program" -> Program
|
||||||
"ERROR" -> Error
|
"ERROR" -> Error
|
||||||
@ -155,17 +171,21 @@ categoryForJavaScriptProductionName name = case name of
|
|||||||
"template_string" -> TemplateString
|
"template_string" -> TemplateString
|
||||||
"var_assignment" -> VarAssignment
|
"var_assignment" -> VarAssignment
|
||||||
"var_declaration" -> VarDecl
|
"var_declaration" -> VarDecl
|
||||||
|
"trailing_var_declaration" -> VarDecl
|
||||||
"switch_statement" -> Switch
|
"switch_statement" -> Switch
|
||||||
"math_assignment" -> MathAssignment
|
"math_assignment" -> MathAssignment
|
||||||
"case" -> Case
|
"case" -> Case
|
||||||
"true" -> Boolean
|
"true" -> Boolean
|
||||||
"false" -> Boolean
|
"false" -> Boolean
|
||||||
"ternary" -> Ternary
|
"ternary" -> Ternary
|
||||||
"for_statement" -> For
|
|
||||||
"while_statement" -> While
|
"while_statement" -> While
|
||||||
|
"trailing_while_statement" -> While
|
||||||
"do_statement" -> DoWhile
|
"do_statement" -> DoWhile
|
||||||
|
"trailing_do_statement" -> DoWhile
|
||||||
"return_statement" -> Return
|
"return_statement" -> Return
|
||||||
|
"trailing_return_statement" -> Return
|
||||||
"throw_statement" -> Throw
|
"throw_statement" -> Throw
|
||||||
|
"trailing_throw_statement" -> Throw
|
||||||
"try_statement" -> Try
|
"try_statement" -> Try
|
||||||
"method_definition" -> Method
|
"method_definition" -> Method
|
||||||
"comment" -> Comment
|
"comment" -> Comment
|
||||||
|
Loading…
Reference in New Issue
Block a user