mirror of
https://github.com/github/semantic.git
synced 2024-12-25 07:55:12 +03:00
Fix anonymous function parsing and summarizing
This commit is contained in:
parent
fde17ce24b
commit
3d7c8cf67d
@ -133,8 +133,7 @@ toLeafInfos err@ErrorInfo{} = pure (pretty err)
|
||||
-- Returns a text representing a specific term given a source and a term.
|
||||
toTermName :: forall leaf fields. (HasCategory leaf, HasField fields Category, HasField fields Range) => Source Char -> SyntaxTerm leaf fields -> Text
|
||||
toTermName source term = case unwrap term of
|
||||
S.AnonymousFunction maybeParams _ -> "anonymous" <> maybe "" toParams maybeParams <> " function"
|
||||
where toParams ps = " " <> termNameFromSource ps
|
||||
S.AnonymousFunction maybeParams _ -> "anonymous" <> maybe "" termNameFromSource maybeParams <> " function"
|
||||
S.Fixed children -> fromMaybe "branch" $ (toCategoryName . category) . extract <$> head children
|
||||
S.Indexed children -> fromMaybe "branch" $ (toCategoryName . category) . extract <$> head children
|
||||
Leaf leaf -> toCategoryName leaf
|
||||
|
@ -71,9 +71,7 @@ termConstructor source sourceSpan name range children
|
||||
_ | name `elem` operators -> S.Operator children
|
||||
_ | name `elem` functions -> case children of
|
||||
[ body ] -> S.AnonymousFunction Nothing body
|
||||
[ idOrParams, body] -> case unwrap idOrParams of
|
||||
S.Leaf _ -> S.Function idOrParams Nothing body
|
||||
_ -> S.AnonymousFunction (Just idOrParams) body
|
||||
[ params, body ] -> S.AnonymousFunction (Just params) body
|
||||
[ id, params, body ] -> S.Function id (Just params) body
|
||||
_ -> S.Indexed children
|
||||
(_, []) -> S.Leaf . toText $ slice range source
|
||||
|
@ -3,7 +3,7 @@
|
||||
"expectedResult": {
|
||||
"changes": {
|
||||
"anonymous-function.js": [
|
||||
"Added an anonymous (a,b) function"
|
||||
"Added an anonymous(a,b) function"
|
||||
]
|
||||
},
|
||||
"errors": {}
|
||||
@ -20,8 +20,8 @@
|
||||
"expectedResult": {
|
||||
"changes": {
|
||||
"anonymous-function.js": [
|
||||
"Added an anonymous (b,c) function",
|
||||
"Added an anonymous (a,b) function"
|
||||
"Added an anonymous(b,c) function",
|
||||
"Added an anonymous(a,b) function"
|
||||
]
|
||||
},
|
||||
"errors": {}
|
||||
@ -77,9 +77,9 @@
|
||||
"expectedResult": {
|
||||
"changes": {
|
||||
"anonymous-function.js": [
|
||||
"Deleted an anonymous (b,c) function",
|
||||
"Deleted an anonymous (a,b) function",
|
||||
"Added an anonymous (b,c) function"
|
||||
"Deleted an anonymous(b,c) function",
|
||||
"Deleted an anonymous(a,b) function",
|
||||
"Added an anonymous(b,c) function"
|
||||
]
|
||||
},
|
||||
"errors": {}
|
||||
@ -96,7 +96,7 @@
|
||||
"expectedResult": {
|
||||
"changes": {
|
||||
"anonymous-function.js": [
|
||||
"Deleted an anonymous (a,b) function"
|
||||
"Deleted an anonymous(a,b) function"
|
||||
]
|
||||
},
|
||||
"errors": {}
|
||||
@ -113,7 +113,7 @@
|
||||
"expectedResult": {
|
||||
"changes": {
|
||||
"anonymous-function.js": [
|
||||
"Deleted an anonymous (b,c) function"
|
||||
"Deleted an anonymous(b,c) function"
|
||||
]
|
||||
},
|
||||
"errors": {}
|
||||
|
@ -3,7 +3,7 @@
|
||||
"expectedResult": {
|
||||
"changes": {
|
||||
"anonymous-parameterless-function.js": [
|
||||
"Added an anonymous function"
|
||||
"Added an anonymous() function"
|
||||
]
|
||||
},
|
||||
"errors": {}
|
||||
@ -20,8 +20,8 @@
|
||||
"expectedResult": {
|
||||
"changes": {
|
||||
"anonymous-parameterless-function.js": [
|
||||
"Added an anonymous function",
|
||||
"Added an anonymous function"
|
||||
"Added an anonymous() function",
|
||||
"Added an anonymous() function"
|
||||
]
|
||||
},
|
||||
"errors": {}
|
||||
@ -72,9 +72,9 @@
|
||||
"expectedResult": {
|
||||
"changes": {
|
||||
"anonymous-parameterless-function.js": [
|
||||
"Deleted an anonymous function",
|
||||
"Deleted an anonymous function",
|
||||
"Added an anonymous function"
|
||||
"Deleted an anonymous() function",
|
||||
"Deleted an anonymous() function",
|
||||
"Added an anonymous() function"
|
||||
]
|
||||
},
|
||||
"errors": {}
|
||||
@ -91,7 +91,7 @@
|
||||
"expectedResult": {
|
||||
"changes": {
|
||||
"anonymous-parameterless-function.js": [
|
||||
"Deleted an anonymous function"
|
||||
"Deleted an anonymous() function"
|
||||
]
|
||||
},
|
||||
"errors": {}
|
||||
@ -108,7 +108,7 @@
|
||||
"expectedResult": {
|
||||
"changes": {
|
||||
"anonymous-parameterless-function.js": [
|
||||
"Deleted an anonymous function"
|
||||
"Deleted an anonymous() function"
|
||||
]
|
||||
},
|
||||
"errors": {}
|
||||
|
@ -3,7 +3,7 @@
|
||||
"expectedResult": {
|
||||
"changes": {
|
||||
"arrow-function.js": [
|
||||
"Added an anonymous (f, g) function"
|
||||
"Added an anonymous(f, g) function"
|
||||
]
|
||||
},
|
||||
"errors": {}
|
||||
@ -20,8 +20,8 @@
|
||||
"expectedResult": {
|
||||
"changes": {
|
||||
"arrow-function.js": [
|
||||
"Added an anonymous (f, g) function",
|
||||
"Added an anonymous (f, g) function"
|
||||
"Added an anonymous(f, g) function",
|
||||
"Added an anonymous(f, g) function"
|
||||
]
|
||||
},
|
||||
"errors": {}
|
||||
@ -72,9 +72,9 @@
|
||||
"expectedResult": {
|
||||
"changes": {
|
||||
"arrow-function.js": [
|
||||
"Deleted an anonymous (f, g) function",
|
||||
"Deleted an anonymous (f, g) function",
|
||||
"Added an anonymous (f, g) function"
|
||||
"Deleted an anonymous(f, g) function",
|
||||
"Deleted an anonymous(f, g) function",
|
||||
"Added an anonymous(f, g) function"
|
||||
]
|
||||
},
|
||||
"errors": {}
|
||||
@ -91,7 +91,7 @@
|
||||
"expectedResult": {
|
||||
"changes": {
|
||||
"arrow-function.js": [
|
||||
"Deleted an anonymous (f, g) function"
|
||||
"Deleted an anonymous(f, g) function"
|
||||
]
|
||||
},
|
||||
"errors": {}
|
||||
@ -108,7 +108,7 @@
|
||||
"expectedResult": {
|
||||
"changes": {
|
||||
"arrow-function.js": [
|
||||
"Deleted an anonymous (f, g) function"
|
||||
"Deleted an anonymous(f, g) function"
|
||||
]
|
||||
},
|
||||
"errors": {}
|
||||
|
@ -3,7 +3,7 @@
|
||||
"expectedResult": {
|
||||
"changes": {
|
||||
"function.js": [
|
||||
"Added an anonymous (arg1, arg2) function"
|
||||
"Added an anonymous(arg1, arg2) function"
|
||||
]
|
||||
},
|
||||
"errors": {}
|
||||
@ -20,8 +20,8 @@
|
||||
"expectedResult": {
|
||||
"changes": {
|
||||
"function.js": [
|
||||
"Added an anonymous (arg1, arg2) function",
|
||||
"Added an anonymous (arg1, arg2) function"
|
||||
"Added an anonymous(arg1, arg2) function",
|
||||
"Added an anonymous(arg1, arg2) function"
|
||||
]
|
||||
},
|
||||
"errors": {}
|
||||
@ -72,9 +72,9 @@
|
||||
"expectedResult": {
|
||||
"changes": {
|
||||
"function.js": [
|
||||
"Deleted an anonymous (arg1, arg2) function",
|
||||
"Deleted an anonymous (arg1, arg2) function",
|
||||
"Added an anonymous (arg1, arg2) function"
|
||||
"Deleted an anonymous(arg1, arg2) function",
|
||||
"Deleted an anonymous(arg1, arg2) function",
|
||||
"Added an anonymous(arg1, arg2) function"
|
||||
]
|
||||
},
|
||||
"errors": {}
|
||||
@ -91,7 +91,7 @@
|
||||
"expectedResult": {
|
||||
"changes": {
|
||||
"function.js": [
|
||||
"Deleted an anonymous (arg1, arg2) function"
|
||||
"Deleted an anonymous(arg1, arg2) function"
|
||||
]
|
||||
},
|
||||
"errors": {}
|
||||
@ -108,7 +108,7 @@
|
||||
"expectedResult": {
|
||||
"changes": {
|
||||
"function.js": [
|
||||
"Deleted an anonymous (arg1, arg2) function"
|
||||
"Deleted an anonymous(arg1, arg2) function"
|
||||
]
|
||||
},
|
||||
"errors": {}
|
||||
|
Loading…
Reference in New Issue
Block a user