SourceKitten icon indicating copy to clipboard operation
SourceKitten copied to clipboard

sourcekitten complete on Linux not doing what I expected

Open dpkirchner opened this issue 2 years ago • 1 comments

I'm trying to figure out how to use sourcekitten to parse an app's source and provide useful code completions. I found an old issue (https://github.com/jpsim/SourceKitten/issues/113) but I'm not sure it's still relevant. Here's what I'm trying (copied from an old post that referenced issue 113, https://forums.swift.org/t/sorting-filtering-results/12588):

$ sourcekitten complete --text "import Foundation; let x = UR" --offset 28 '' | jq -r .
[
  {
    "context": "source.codecompletion.context.thisclass",
    "typeName": "_",
    "kind": "source.lang.swift.keyword",
    "sourcetext": ".self",
    "name": "self",
    "numBytesToErase": 0,
    "descriptionKey": "self"
  }
]

The good news is it doesn't return nothing, but it doesn't return what I expected either. I was hoping it'd return something that indicates UR could be completed with URI from the Foundation module. Am I doing something wrong, and/or are most of the completions still handled by Xcode itself?

I'm running this on Linux. I'm on sourcekitten version 0.34.1 and my toolchain is Swift version 5.9.1-RELEASE.

dpkirchner avatar Dec 05 '23 19:12 dpkirchner

As I mentioned in the Swift forums thread, SourceKit's API for completions is really counter-intuitive. Maybe asking the folks who work on SourceKit at Apple will lead you to a more satisfying solution.

jpsim avatar Dec 14 '23 04:12 jpsim