Skip to content

textDocument/definition on a reference to a project package opens .swiftinterface file instead #2693

Description

@jansorg

Swift version

Swift version 6.5-dev (LLVM 18d2bfb70c14d89, Swift c13d82e5987aecb)

Platform

Linux

Editor

Visual Studio Code, latest Swift plugin version

Description

Navigating via textDocument/definition on a reference to a package of the local workspace opens a .swiftinterface representation of that package.
IMHO, instead, it should either reference the source folder of the package or reject the request.

I have not researched if a folder is a valid response to textDocument/definition.

In an ideal world, the folder would be returned and a rename request would rename references to the package, the directory and update the setup in the Package.swift file. But that's probably out-of-scope for SourceKit LSP.

I originally noticed this with a cloned https://github.com/swiftlang/swift-subprocess, but created a small example to reproduce the problem.

Thank you for your hard work!

Steps to Reproduce

  1. Clone https://github.com/jansorg/sourcekit-lsp-bug-demo
  2. Open Tests/swift_sourcekit_demoTests/swift_sourcekit_demoTests.swift
  3. Ctrl+Click on package reference (swift_sourcekit_demo, line 5)

Now VSCode (via SourceKit LSP) opens a .swiftinterface. Depending on previous work, it's either empty or not.
In my tests it was usually empty

Logging

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions