[swift-users] Extracting ranges of simple statements using SourceKit

Jared Khan jaredkhan at me.com
Wed Jan 3 14:52:27 CST 2018


Hi all,

I’m working on a static program slicer for Swift for a research project. 

Given a source file, I need to extract the ranges of all simple statements (e.g `var x = 1`, `print(“hello”)`, `break`) and of the control flow structures. Thus far, I’ve been trying to do this using SourceKit (via SourceKitten).

The `index` call to SourceKit (and the structure call to SourceKitten) seems to give me a good summary of the control flow structure but not the simple statements or unstructured control flow statements like `continue` or `break`. 

I wonder if anybody could point me in the right direction to extracting the ranges of these things.

Best,
Jared Khan


More information about the swift-users mailing list