VSCode handling of responses with a ".swiftmodule"

Hi.

I'm seeing references to "XYZ.swiftmodule" in sourcekit-lsp responses that have negative line/col information.

With vscode running on Linux (5.2 or master branch of sourcekit-lsp) that seems to break some of the behaviour around 'Go to Definition/Implementation'.

I've tried two workarounds:
(1) Filter out ".swiftmodule" completely. This is the best solution for vscode, it works as I would expect. It finds a primary location and jumps to it.
(2) Limit the line/col to >= 0 values. vscode now presents 2 definitions, one location in a .swift source file but another in a .swiftmodule thing that it doesn't know how to handle. It's somewhat random as to the order of these and it just doesn't work as I would expect.

Some questions: are we supposed to be seeing ".swiftmodule" in the responses? Shouldn't SourceKit filter those out if it finds a real definition? Can returning swiftmodule not be put on a capabilities flag so that vscode (and other language servers) don't present weird looking definitions while allowing xcode to do what it needs? I'm jumping ahead and assuming it's based on the same code!

On a related note, since Xcode 11.x, I've noticed that it jumps into some generated "swiftmodule" rather than going directly to the source code implementation in the same project. I'm assuming this is all connected but it's not pleasant behaviour for xcode either.

Thanks!

Example response:

[Trace - 6:37:10 AM] Received response 'textDocument/implementation - (35)' in 8ms.
Result: [
    {
        "range": {
            "end": {
                "character": -1,
                "line": -1
            },
            "start": {
                "line": -1,
                "character": -1
            }
        },
        "uri": "file:///...../SomeModule.swiftmodule"
    },
    {
        "range": {
            "end": {
                "line": 48,
                "character": 34
            },
            "start": {
                "line": 48,
                "character": 34
            }
        },
        "uri": "file:///...../SourceFile.swift"
    }
]

We should do this in sourcekit-lsp. Please file a bug (bugs.swift.org) so that we can keep track of this. This should be relatively easy to fix. We should also fix "implementation" and "declaration" requests while we're at it.

The current behaviour is undesirable and is just what falls out of the implementation. We want to eventually have the ability to show a generated interface for modules that we do not have source code (e.g. like the Swift stdlib, or SDK modules), but that doesn't exist right now in SourceKit-LSP and we should not be offering invalid locations to jump to.

On a related note, since Xcode 11.x, I've noticed that it jumps into some generated "swiftmodule" rather than going directly to the source code implementation in the same project. I'm assuming this is all connected but it's not pleasant behaviour for xcode either.

If you're seeing behaviour you don't like from Xcode, please file a bug on feedbackassistant.apple.com with any details you can provide about how to reproduce it.