I have a main.swfit swift file like below:
import Foundation
func functest() {
print(123)
}
I can use sourcekitten structure to get function names:
sourcekitten structure --file main.swift | jq '."key.substructure"[] | select(."key.kind" == "source.lang.swift.decl.function.free") | ."key.name"'
and match the functions:
sourcekitten structure --file main.swift | jq '."key.substructure"[] | select(."key.kind" == "source.lang.swift.decl.function.free") '
the result:

but how to get source code ?
I want to implement a function given the function name( functest ) then return the source code
func functest() {
print(123)
}
I have a
main.swfitswift file like below:I can use sourcekitten structure to get function names:
and match the functions:
the result:

but how to get source code ?
I want to implement a function given the function name(
functest) then return the source code