nathankot / company-sourcekit

Completion for Swift projects via SourceKit with the help of SourceKitten
207 stars 16 forks source link

Completion of symbols in current module #14

Open wiruzx opened 8 years ago

wiruzx commented 8 years ago
import Foundation

let x = "Hello"

func test(x: String) -> String {
    return x + " World"
}

let y = te // Completion doesn't work

But if we write

let y = Temp.te // Completion works perfectly

where Temp is module name

nathankot commented 8 years ago

It seems that just like #13 it's running into an issue where sourcekit returns never-ending gibberish for completions that don't have a . or ( or import.

I'm not sure if it's because we're sending the wrong offset to sourcekit or if sourcekittendaemon is sending the wrong flags.

This is how it currently works:

let y = te|
#         ^ Offset: 11, Prefix: ""
#           Results: gibberish

It probably should work like this but even after manually sending the offset it's still getting gibberish:

let y = |te
#       ^ Offset: 9, Prefix: "te"
#         Results: gibberish

I've tried to see how XCode does it using export SOURCEKIT_LOGGING=3 && /Applications/Xcode.app/Contents/MacOS/Xcode but things were too slow with the logging on and I've run out of time today :)