1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 10:15:55 +03:00

parse function calls

This commit is contained in:
joshvera 2016-10-31 18:22:10 -04:00
parent 19f42de32c
commit 3b3c800193
5 changed files with 362 additions and 44 deletions

View File

@ -40,6 +40,7 @@ termConstructor source sourceSpan name range children = case (name, children) of
withDefaultInfo $ S.VarAssignment identifier' exprs
_ -> withCategory Error (S.Error [varSpec])
withDefaultInfo $ S.VarDecl assignment'
("call_expression", [id]) -> withDefaultInfo $ S.FunctionCall id []
(_, []) -> withDefaultInfo . S.Leaf $ toText (slice range source)
_ -> withDefaultInfo $ S.Indexed children
where

View File

@ -3,6 +3,52 @@
"expectedResult": {
"changes": {
"assignment.go": [
{
"span": {
"insert": {
"start": [
3,
1
],
"end": [
3,
17
]
}
},
"summary": "Added the 'foo' variable"
}
]
},
"errors": {}
},
"filePaths": [
"assignment.go"
],
"sha1": "582a80bbfeebb20dc528c5d5dd913c5616cdff63",
"gitDir": "test/corpus/repos/go",
"sha2": "ce3eb61f573f5a7fe1caa454548166cc31d12f3b"
}
,{
"testCaseDescription": "go-assignment-replacement-insert-test",
"expectedResult": {
"changes": {
"assignment.go": [
{
"span": {
"insert": {
"start": [
3,
1
],
"end": [
3,
25
]
}
},
"summary": "Added the 'bar' variable"
},
{
"span": {
"insert": {
@ -25,40 +71,9 @@
"filePaths": [
"assignment.go"
],
"sha1": "78d912e517fdbf5bf094f2eb42416144c7bd6ba9",
"sha1": "ce3eb61f573f5a7fe1caa454548166cc31d12f3b",
"gitDir": "test/corpus/repos/go",
"sha2": "ff2abe6f392b3a3f417414c99e0a7811141099a9"
}
,{
"testCaseDescription": "go-assignment-replacement-insert-test",
"expectedResult": {
"changes": {
"assignment.go": [
{
"span": {
"insert": {
"start": [
3,
1
],
"end": [
3,
25
]
}
},
"summary": "Added the 'bar' variable"
}
]
},
"errors": {}
},
"filePaths": [
"assignment.go"
],
"sha1": "ff2abe6f392b3a3f417414c99e0a7811141099a9",
"gitDir": "test/corpus/repos/go",
"sha2": "df134e07646f72dc3ff1ec894939535affd3092e"
"sha2": "61a954ded45fc9e72d04ed6f4735fa32fcd8fab5"
}
,{
"testCaseDescription": "go-assignment-delete-insert-test",
@ -129,9 +144,9 @@
"filePaths": [
"assignment.go"
],
"sha1": "df134e07646f72dc3ff1ec894939535affd3092e",
"sha1": "61a954ded45fc9e72d04ed6f4735fa32fcd8fab5",
"gitDir": "test/corpus/repos/go",
"sha2": "49901a2846858582a91f28591f7967dd204393af"
"sha2": "43c4dff47db90e11a09449ddaf178b0934537699"
}
,{
"testCaseDescription": "go-assignment-replacement-test",
@ -202,9 +217,9 @@
"filePaths": [
"assignment.go"
],
"sha1": "49901a2846858582a91f28591f7967dd204393af",
"sha1": "43c4dff47db90e11a09449ddaf178b0934537699",
"gitDir": "test/corpus/repos/go",
"sha2": "72213d2d55fa6da918d3cc41fbdbd2086c189475"
"sha2": "666700adb23c91a72262f061316ad818c0fa9db1"
}
,{
"testCaseDescription": "go-assignment-delete-replacement-test",
@ -263,9 +278,9 @@
"filePaths": [
"assignment.go"
],
"sha1": "72213d2d55fa6da918d3cc41fbdbd2086c189475",
"sha1": "666700adb23c91a72262f061316ad818c0fa9db1",
"gitDir": "test/corpus/repos/go",
"sha2": "575d58f20f3db393100c105c4da36ae6b0241450"
"sha2": "daa3d539ef1783cbf4184afa0d8f960d10dcad97"
}
,{
"testCaseDescription": "go-assignment-delete-test",
@ -294,9 +309,9 @@
"filePaths": [
"assignment.go"
],
"sha1": "575d58f20f3db393100c105c4da36ae6b0241450",
"sha1": "daa3d539ef1783cbf4184afa0d8f960d10dcad97",
"gitDir": "test/corpus/repos/go",
"sha2": "b9de00e181133fbf542d11d16422e766b5a13cb9"
"sha2": "e671e9f6f4fce4d324c5810c6abb5548305e732e"
}
,{
"testCaseDescription": "go-assignment-delete-rest-test",
@ -325,7 +340,7 @@
"filePaths": [
"assignment.go"
],
"sha1": "b9de00e181133fbf542d11d16422e766b5a13cb9",
"sha1": "e671e9f6f4fce4d324c5810c6abb5548305e732e",
"gitDir": "test/corpus/repos/go",
"sha2": "731af5545c9fec2ed851817a3f6212443652b27c"
"sha2": "12c47b44d2e91782a6f049e094c836b5415aed72"
}]

View File

@ -0,0 +1,295 @@
[{
"testCaseDescription": "go-function call-insert-test",
"expectedResult": {
"changes": {
"function-call.go": [
{
"span": {
"insert": {
"start": [
3,
1
],
"end": [
3,
4
]
}
},
"summary": "Added the 'a()' function call"
}
]
},
"errors": {}
},
"filePaths": [
"function-call.go"
],
"sha1": "12c47b44d2e91782a6f049e094c836b5415aed72",
"gitDir": "test/corpus/repos/go",
"sha2": "860ccbe1c3bdeb0c47e32a8e90fa181a9a1cc149"
}
,{
"testCaseDescription": "go-function call-replacement-insert-test",
"expectedResult": {
"changes": {
"function-call.go": [
{
"span": {
"replace": [
{
"start": [
1,
1
],
"end": [
4,
1
]
},
{
"start": [
1,
1
],
"end": [
1,
13
]
}
]
},
"summary": "Replaced the 'main' module statement with the 'main' module statement"
}
]
},
"errors": {}
},
"filePaths": [
"function-call.go"
],
"sha1": "860ccbe1c3bdeb0c47e32a8e90fa181a9a1cc149",
"gitDir": "test/corpus/repos/go",
"sha2": "04cd5977a1e11d1ccc0c7bb98e3336b35ad8ec0e"
}
,{
"testCaseDescription": "go-function call-delete-insert-test",
"expectedResult": {
"changes": {
"function-call.go": [
{
"span": {
"replace": [
{
"start": [
3,
1
],
"end": [
3,
2
]
},
{
"start": [
3,
1
],
"end": [
3,
2
]
}
]
},
"summary": "Replaced the 'b' identifier with the 'a' identifier in the a() function call"
}
]
},
"errors": {}
},
"filePaths": [
"function-call.go"
],
"sha1": "04cd5977a1e11d1ccc0c7bb98e3336b35ad8ec0e",
"gitDir": "test/corpus/repos/go",
"sha2": "1256ed562694230c35ae859e74de43be61431232"
}
,{
"testCaseDescription": "go-function call-replacement-test",
"expectedResult": {
"changes": {
"function-call.go": [
{
"span": {
"replace": [
{
"start": [
3,
1
],
"end": [
3,
2
]
},
{
"start": [
3,
1
],
"end": [
3,
2
]
}
]
},
"summary": "Replaced the 'a' identifier with the 'b' identifier in the b() function call"
}
]
},
"errors": {}
},
"filePaths": [
"function-call.go"
],
"sha1": "1256ed562694230c35ae859e74de43be61431232",
"gitDir": "test/corpus/repos/go",
"sha2": "4ed01c4bcffcdf6103f3449dd11af9e3d13729b1"
}
,{
"testCaseDescription": "go-function call-delete-replacement-test",
"expectedResult": {
"changes": {
"function-call.go": [
{
"span": {
"delete": {
"start": [
3,
1
],
"end": [
3,
4
]
}
},
"summary": "Deleted the 'b()' function call"
},
{
"span": {
"delete": {
"start": [
4,
1
],
"end": [
4,
4
]
}
},
"summary": "Deleted the 'a()' function call"
},
{
"span": {
"insert": {
"start": [
4,
1
],
"end": [
4,
4
]
}
},
"summary": "Added the 'b()' function call"
}
]
},
"errors": {}
},
"filePaths": [
"function-call.go"
],
"sha1": "4ed01c4bcffcdf6103f3449dd11af9e3d13729b1",
"gitDir": "test/corpus/repos/go",
"sha2": "2bf409a84ead1ad41e539e77632caeb2bad6cc7d"
}
,{
"testCaseDescription": "go-function call-delete-test",
"expectedResult": {
"changes": {
"function-call.go": [
{
"span": {
"replace": [
{
"start": [
1,
1
],
"end": [
1,
13
]
},
{
"start": [
1,
1
],
"end": [
4,
1
]
}
]
},
"summary": "Replaced the 'main' module statement with the 'main' module statement"
}
]
},
"errors": {}
},
"filePaths": [
"function-call.go"
],
"sha1": "2bf409a84ead1ad41e539e77632caeb2bad6cc7d",
"gitDir": "test/corpus/repos/go",
"sha2": "01d6f80865616cf2f9c611e208da3eaa9449dedb"
}
,{
"testCaseDescription": "go-function call-delete-rest-test",
"expectedResult": {
"changes": {
"function-call.go": [
{
"span": {
"delete": {
"start": [
3,
1
],
"end": [
3,
4
]
}
},
"summary": "Deleted the 'b()' function call"
}
]
},
"errors": {}
},
"filePaths": [
"function-call.go"
],
"sha1": "01d6f80865616cf2f9c611e208da3eaa9449dedb",
"gitDir": "test/corpus/repos/go",
"sha2": "1dc12f3dd339cd009052043fcf2d1516d52173a3"
}]

View File

@ -11,6 +11,13 @@
"insert": "var foo int = 42",
"testCaseFilePath": "test/corpus/diff-summaries/go/assignment.json",
"replacement": "var bar string = \"hello\""
},
{
"syntax": "function call",
"repoFilePath": "function-call.go",
"insert": "a()",
"testCaseFilePath": "test/corpus/diff-summaries/go/function-call.json",
"replacement": "b()"
}
]
}

@ -1 +1 @@
Subproject commit d3fa479c4d82673363dbcee77472346afb069504
Subproject commit 1dc12f3dd339cd009052043fcf2d1516d52173a3