SolaWing / xcode-build-server

a build server protocol implementation for integrate xcode with sourcekit-lsp
MIT License
283 stars 16 forks source link

Go to Reference works wierd #33

Closed fireplusteam closed 3 months ago

fireplusteam commented 3 months ago

Hi, thanks for the great work and server. Really awesome. By the way do you know why "Go To Reference" stops working if there's an error in a line of code. For example:

func callMethod() {
        let a = 10
        print("\(a),\(self.po)")
        someFunc(B: "", d: 10)
    }

    func someFunc(
        B: String,
        d: String  
    ) {
    }

in that case if I put the cursor to someFunc and try to "Go to reference" it doesn't work, However if I change the line to someFunc(B: "", d: "") it starts working immediately

SolaWing commented 3 months ago

I can not reproduce your problem. even your code compile failed, the reference works. what sourcekit-lsp version you use? may upgrade it fixes problem. also notice Sourcekit-LSP only update index after build

fireplusteam commented 3 months ago

Yes, I built it first, here is the sample project where it's reproducible for me:

example.zip

fireplusteam commented 3 months ago

I used builtin sourcekit-lsp which comes with xcode 15.0.1

SolaWing commented 3 months ago

This issue appears to only be reproduced when used as an instance method. There is no problem with global methods. It can also be reproduced in the Package.swift project. So you should post an issue to sourcekit-lsp, here is my test code:

struct Foo {
    func callMethod() {
        // let a = 10
        // print("\(a),\(self.po)")
        bla(B: "", d: 10)
    }

    func bla( // this cannot goto references
        B: String,
        d: String  
    ) {

    }
}
func callMethod() {
    // let a = 10
    // print("\(a),\(self.po)")
    bla(B: "", d: 10)
}

func bla( // this can goto references
    B: String,
    d: String  
) {

}