Dan2552/SublimeTextSwiftAutocomplete

init suggestions

Dan2552 opened this issue · 2 comments

GridPoint()
         ^

suggests correctly:

GridPoint(col: <Int>, row: <Int>, floor: <Int>)

but

let gridPoint = GridPoint()
                         ^

gets results as if no context

Not sure about this one:

$ cd /Users/dan2552/projects/SourceKittenSubl/test/data/MonkeyExample && sourcekitten complete --text 'Banana(' --offset 7 -- -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.2.sdk -target x86_64-apple-ios9.0 /Users/dan2552/projects/SourceKittenSubl/test/data/MonkeyExample/Banana.swift /Users/dan2552/projects/SourceKittenSubl/test/data/MonkeyExample/Monkey.swift | head -8
[{
  "descriptionKey" : "(color: String, flavor: Int)",
  "kind" : "source.lang.swift.decl.function.constructor",
  "name" : "color:flavor:)",
  "sourcetext" : "color: <#T##String#>, flavor: <#T##Int#>)",
  "typeName" : "Banana",
  "associatedUSRs" : "s:FV4main6BananacFT5colorSS6flavorSi_S0_",
  "moduleName" : "main",

$ cd /Users/dan2552/projects/SourceKittenSubl/test/data/MonkeyExample && sourcekitten complete --text 'let banana = Banana(' --offset 20 -- -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.2.sdk -target x86_64-apple-ios9.0 /Users/dan2552/projects/SourceKittenSubl/test/data/MonkeyExample/Banana.swift /Users/dan2552/projects/SourceKittenSubl/test/data/MonkeyExample/Monkey.swift | head -8
[{
  "descriptionKey" : "#colorLiteral(red: Float, green: Float, blue: Float, alpha: Float)",
  "kind" : "source.lang.swift.literal.color",
  "name" : "#colorLiteral(red:green:blue:alpha:)",
  "sourcetext" : "#colorLiteral(red: <#T##Float#>, green: <#T##Float#>, blue: <#T##Float#>, alpha: <#T##Float#>)",
  "typeName" : "",
  "context" : "source.codecompletion.context.none"
}, {

I made a branch (https://github.com/Dan2552/SourceKittenSubl/tree/attempt-to-fix-14) with a test

Weirdly, it looks like if the definition is in the same file it works ok:

struct Test {
    let a: String
}

let test = Test(