mirror of
https://github.com/github/semantic.git
synced 2024-12-01 09:15:01 +03:00
Merge branch 'master' into improve-memory-usage
This commit is contained in:
commit
9f9dc4feab
@ -70,6 +70,7 @@ isErrorSummary _ = False
|
|||||||
data DiffInfo = LeafInfo { categoryName :: Text, termName :: Text, sourceSpan :: SourceSpan }
|
data DiffInfo = LeafInfo { categoryName :: Text, termName :: Text, sourceSpan :: SourceSpan }
|
||||||
| BranchInfo { branches :: [ DiffInfo ], categoryName :: Text, branchType :: Branch }
|
| BranchInfo { branches :: [ DiffInfo ], categoryName :: Text, branchType :: Branch }
|
||||||
| ErrorInfo { errorSpan :: SourceSpan, termName :: Text }
|
| ErrorInfo { errorSpan :: SourceSpan, termName :: Text }
|
||||||
|
| HideInfo -- Hide/Strip from summary output entirely.
|
||||||
deriving (Eq, Show)
|
deriving (Eq, Show)
|
||||||
|
|
||||||
data Branch = BIndexed | BFixed | BCommented deriving (Show, Eq, Generic)
|
data Branch = BIndexed | BFixed | BCommented deriving (Show, Eq, Generic)
|
||||||
@ -147,6 +148,7 @@ determiner _ = "the"
|
|||||||
toLeafInfos :: DiffInfo -> [JSONSummary Doc SourceSpan]
|
toLeafInfos :: DiffInfo -> [JSONSummary Doc SourceSpan]
|
||||||
toLeafInfos err@ErrorInfo{..} = pure $ ErrorSummary (pretty err) errorSpan
|
toLeafInfos err@ErrorInfo{..} = pure $ ErrorSummary (pretty err) errorSpan
|
||||||
toLeafInfos BranchInfo{..} = branches >>= toLeafInfos
|
toLeafInfos BranchInfo{..} = branches >>= toLeafInfos
|
||||||
|
toLeafInfos HideInfo = []
|
||||||
toLeafInfos leaf = pure . flip JSONSummary (sourceSpan leaf) $ case leaf of
|
toLeafInfos leaf = pure . flip JSONSummary (sourceSpan leaf) $ case leaf of
|
||||||
(LeafInfo "number" termName _) -> squotes $ toDoc termName
|
(LeafInfo "number" termName _) -> squotes $ toDoc termName
|
||||||
(LeafInfo "boolean" termName _) -> squotes $ toDoc termName
|
(LeafInfo "boolean" termName _) -> squotes $ toDoc termName
|
||||||
@ -242,7 +244,8 @@ termToDiffInfo blob term = case unwrap term of
|
|||||||
S.Indexed children -> BranchInfo (termToDiffInfo' <$> children) (toCategoryName term) BIndexed
|
S.Indexed children -> BranchInfo (termToDiffInfo' <$> children) (toCategoryName term) BIndexed
|
||||||
S.Fixed children -> BranchInfo (termToDiffInfo' <$> children) (toCategoryName term) BFixed
|
S.Fixed children -> BranchInfo (termToDiffInfo' <$> children) (toCategoryName term) BFixed
|
||||||
S.AnonymousFunction _ _ -> LeafInfo "anonymous function" (toTermName' term) (getField $ extract term)
|
S.AnonymousFunction _ _ -> LeafInfo "anonymous function" (toTermName' term) (getField $ extract term)
|
||||||
Commented cs leaf -> BranchInfo (termToDiffInfo' <$> cs <> maybeToList leaf) (toCategoryName term) BCommented
|
S.Comment _ -> HideInfo
|
||||||
|
S.Commented cs leaf -> BranchInfo (termToDiffInfo' <$> cs <> maybeToList leaf) (toCategoryName term) BCommented
|
||||||
S.Error _ -> ErrorInfo (getField $ extract term) (toTermName' term)
|
S.Error _ -> ErrorInfo (getField $ extract term) (toTermName' term)
|
||||||
_ -> LeafInfo (toCategoryName term) (toTermName' term) (getField $ extract term)
|
_ -> LeafInfo (toCategoryName term) (toTermName' term) (getField $ extract term)
|
||||||
where toTermName' = toTermName blob
|
where toTermName' = toTermName blob
|
||||||
@ -347,3 +350,4 @@ instance P.Pretty DiffInfo where
|
|||||||
pretty LeafInfo{..} = squotes (string $ toSL termName) <+> string (toSL categoryName)
|
pretty LeafInfo{..} = squotes (string $ toSL termName) <+> string (toSL categoryName)
|
||||||
pretty BranchInfo{..} = mconcat $ punctuate (string "," P.<> space) (pretty <$> branches)
|
pretty BranchInfo{..} = mconcat $ punctuate (string "," P.<> space) (pretty <$> branches)
|
||||||
pretty ErrorInfo{..} = squotes (string $ toSL termName) <+> "at" <+> (string . toSL $ displayStartEndPos errorSpan)
|
pretty ErrorInfo{..} = squotes (string $ toSL termName) <+> "at" <+> (string . toSL $ displayStartEndPos errorSpan)
|
||||||
|
pretty HideInfo = ""
|
||||||
|
@ -49,6 +49,7 @@ termConstructor source sourceSpan name range children
|
|||||||
("case", [ expr, body ]) -> S.Case expr body
|
("case", [ expr, body ]) -> S.Case expr body
|
||||||
("object", _) -> S.Object $ foldMap toTuple children
|
("object", _) -> S.Object $ foldMap toTuple children
|
||||||
("pair", _) -> S.Fixed children
|
("pair", _) -> S.Fixed children
|
||||||
|
("comment", _) -> S.Comment . toText $ slice range source
|
||||||
("if_statement", [ expr, clause1, clause2 ]) -> S.If expr clause1 (Just clause2)
|
("if_statement", [ expr, clause1, clause2 ]) -> S.If expr clause1 (Just clause2)
|
||||||
("if_statement", [ expr, clause ]) -> S.If expr clause Nothing
|
("if_statement", [ expr, clause ]) -> S.If expr clause Nothing
|
||||||
("while_statement", [ expr, body ]) -> S.While expr body
|
("while_statement", [ expr, body ]) -> S.While expr body
|
||||||
|
@ -1,25 +1,7 @@
|
|||||||
[{
|
[{
|
||||||
"testCaseDescription": "javascript-comment-insert-test",
|
"testCaseDescription": "javascript-comment-insert-test",
|
||||||
"expectedResult": {
|
"expectedResult": {
|
||||||
"changes": {
|
"changes": {},
|
||||||
"comment.js": [
|
|
||||||
{
|
|
||||||
"span": {
|
|
||||||
"insert": {
|
|
||||||
"start": [
|
|
||||||
1,
|
|
||||||
1
|
|
||||||
],
|
|
||||||
"end": [
|
|
||||||
1,
|
|
||||||
22
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"summary": "Added the '// This is a property' comment"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"errors": {}
|
"errors": {}
|
||||||
},
|
},
|
||||||
"filePaths": [
|
"filePaths": [
|
||||||
@ -32,40 +14,7 @@
|
|||||||
,{
|
,{
|
||||||
"testCaseDescription": "javascript-comment-replacement-insert-test",
|
"testCaseDescription": "javascript-comment-replacement-insert-test",
|
||||||
"expectedResult": {
|
"expectedResult": {
|
||||||
"changes": {
|
"changes": {},
|
||||||
"comment.js": [
|
|
||||||
{
|
|
||||||
"span": {
|
|
||||||
"insert": {
|
|
||||||
"start": [
|
|
||||||
1,
|
|
||||||
1
|
|
||||||
],
|
|
||||||
"end": [
|
|
||||||
3,
|
|
||||||
3
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"summary": "Added the '/*\n * This is a method\n*/' comment"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"span": {
|
|
||||||
"insert": {
|
|
||||||
"start": [
|
|
||||||
4,
|
|
||||||
1
|
|
||||||
],
|
|
||||||
"end": [
|
|
||||||
4,
|
|
||||||
22
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"summary": "Added the '// This is a property' comment"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"errors": {}
|
"errors": {}
|
||||||
},
|
},
|
||||||
"filePaths": [
|
"filePaths": [
|
||||||
@ -78,37 +27,7 @@
|
|||||||
,{
|
,{
|
||||||
"testCaseDescription": "javascript-comment-delete-insert-test",
|
"testCaseDescription": "javascript-comment-delete-insert-test",
|
||||||
"expectedResult": {
|
"expectedResult": {
|
||||||
"changes": {
|
"changes": {},
|
||||||
"comment.js": [
|
|
||||||
{
|
|
||||||
"span": {
|
|
||||||
"replace": [
|
|
||||||
{
|
|
||||||
"start": [
|
|
||||||
1,
|
|
||||||
1
|
|
||||||
],
|
|
||||||
"end": [
|
|
||||||
3,
|
|
||||||
3
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"start": [
|
|
||||||
1,
|
|
||||||
1
|
|
||||||
],
|
|
||||||
"end": [
|
|
||||||
1,
|
|
||||||
22
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"summary": "Replaced the '/*\n * This is a method\n*/' comment with the '// This is a property' comment"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"errors": {}
|
"errors": {}
|
||||||
},
|
},
|
||||||
"filePaths": [
|
"filePaths": [
|
||||||
@ -121,37 +40,7 @@
|
|||||||
,{
|
,{
|
||||||
"testCaseDescription": "javascript-comment-replacement-test",
|
"testCaseDescription": "javascript-comment-replacement-test",
|
||||||
"expectedResult": {
|
"expectedResult": {
|
||||||
"changes": {
|
"changes": {},
|
||||||
"comment.js": [
|
|
||||||
{
|
|
||||||
"span": {
|
|
||||||
"replace": [
|
|
||||||
{
|
|
||||||
"start": [
|
|
||||||
1,
|
|
||||||
1
|
|
||||||
],
|
|
||||||
"end": [
|
|
||||||
1,
|
|
||||||
22
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"start": [
|
|
||||||
1,
|
|
||||||
1
|
|
||||||
],
|
|
||||||
"end": [
|
|
||||||
3,
|
|
||||||
3
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"summary": "Replaced the '// This is a property' comment with the '/*\n * This is a method\n*/' comment"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"errors": {}
|
"errors": {}
|
||||||
},
|
},
|
||||||
"filePaths": [
|
"filePaths": [
|
||||||
@ -164,55 +53,7 @@
|
|||||||
,{
|
,{
|
||||||
"testCaseDescription": "javascript-comment-delete-replacement-test",
|
"testCaseDescription": "javascript-comment-delete-replacement-test",
|
||||||
"expectedResult": {
|
"expectedResult": {
|
||||||
"changes": {
|
"changes": {},
|
||||||
"comment.js": [
|
|
||||||
{
|
|
||||||
"span": {
|
|
||||||
"delete": {
|
|
||||||
"start": [
|
|
||||||
1,
|
|
||||||
1
|
|
||||||
],
|
|
||||||
"end": [
|
|
||||||
3,
|
|
||||||
3
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"summary": "Deleted the '/*\n * This is a method\n*/' comment"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"span": {
|
|
||||||
"delete": {
|
|
||||||
"start": [
|
|
||||||
4,
|
|
||||||
1
|
|
||||||
],
|
|
||||||
"end": [
|
|
||||||
4,
|
|
||||||
22
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"summary": "Deleted the '// This is a property' comment"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"span": {
|
|
||||||
"insert": {
|
|
||||||
"start": [
|
|
||||||
2,
|
|
||||||
1
|
|
||||||
],
|
|
||||||
"end": [
|
|
||||||
4,
|
|
||||||
3
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"summary": "Added the '/*\n * This is a method\n*/' comment"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"errors": {}
|
"errors": {}
|
||||||
},
|
},
|
||||||
"filePaths": [
|
"filePaths": [
|
||||||
@ -225,25 +66,7 @@
|
|||||||
,{
|
,{
|
||||||
"testCaseDescription": "javascript-comment-delete-test",
|
"testCaseDescription": "javascript-comment-delete-test",
|
||||||
"expectedResult": {
|
"expectedResult": {
|
||||||
"changes": {
|
"changes": {},
|
||||||
"comment.js": [
|
|
||||||
{
|
|
||||||
"span": {
|
|
||||||
"delete": {
|
|
||||||
"start": [
|
|
||||||
1,
|
|
||||||
1
|
|
||||||
],
|
|
||||||
"end": [
|
|
||||||
1,
|
|
||||||
22
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"summary": "Deleted the '// This is a property' comment"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"errors": {}
|
"errors": {}
|
||||||
},
|
},
|
||||||
"filePaths": [
|
"filePaths": [
|
||||||
@ -256,25 +79,7 @@
|
|||||||
,{
|
,{
|
||||||
"testCaseDescription": "javascript-comment-delete-rest-test",
|
"testCaseDescription": "javascript-comment-delete-rest-test",
|
||||||
"expectedResult": {
|
"expectedResult": {
|
||||||
"changes": {
|
"changes": {},
|
||||||
"comment.js": [
|
|
||||||
{
|
|
||||||
"span": {
|
|
||||||
"delete": {
|
|
||||||
"start": [
|
|
||||||
1,
|
|
||||||
1
|
|
||||||
],
|
|
||||||
"end": [
|
|
||||||
3,
|
|
||||||
3
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"summary": "Deleted the '/*\n * This is a method\n*/' comment"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"errors": {}
|
"errors": {}
|
||||||
},
|
},
|
||||||
"filePaths": [
|
"filePaths": [
|
||||||
|
Loading…
Reference in New Issue
Block a user