# Extracting ranges of simple statements using SourceKit

**URL:** <https://forums.swift.org/t/extracting-ranges-of-simple-statements-using-sourcekit/7355>\
**Category:** Using Swift\
**Created:** [January 3, 2018, 8:52pm UTC](https://forums.swift.org/t/extracting-ranges-of-simple-statements-using-sourcekit/7355 "2018-01-03T20:52:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jared\_Khan](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jared_khan/32/2435_2.png) [@Jared\_Khan](https://forums.swift.org/u/Jared_Khan)\
**Post date:** [January 3, 2018, 8:52pm UTC](https://forums.swift.org/t/extracting-ranges-of-simple-statements-using-sourcekit/7355/1 "2018-01-03T20:52:27Z")

</div>

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
