Skip to content
This repository was archived by the owner on Dec 17, 2018. It is now read-only.

Fix some cross-module definition calls #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chrismwendt
Copy link
Collaborator

Before:

2018-06-01 01 17 07

After:

2018-06-01 01 18 02

Admittedly, this doesn't work in all cases (e.g. the call to SourceKit.CodeComplete in #52), which is pretty ironic because that's the case that I tried to fix 😒

If anyone has any tips for figuring out what arguments to pass to swift to get it to resolve these properly, that would be very helpful, because so far my best strategy is Try Random Combinations And Hope It Works ™️

@RLovelett RLovelett self-requested a review June 1, 2018 13:13
Copy link
Owner

@RLovelett RLovelett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are not changes per-se but I'd like to at least understand the behavior before we merge this. The devil you know and all that.

return result.value

// TODO This doesn't work in all cases https://github.com/RLovelett/langserver-swift/issues/52
let interModuleResult = SourceKit.CursorInfo(source: source.text, source: at.textDocument.uri, offset: offset, args: module.arguments + modules.flatMap { $0.sources.keys.map { $0.path } })
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I get that this likely works in this case. It does not seem to generalize well. Can you confirm how this would handle a case where you have two modules, e.g., ModuleA and ModuleB, both define a protocol/struct/class of the same name?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this: I copied RequestBuffer.swift from the BaseProtocol module to the LanguageServerProtocol module, then when I did a go-to-def on main.swift:11 RequestBuffer(), it took me to the RequestBuffer in LanguageServerProtocol. I have no idea if that was an arbitrary choice by SourceKit, or if the order of the command line arguments mattered, or what.

@chrismwendt
Copy link
Collaborator Author

I probably don't actually understand this much more than you do. My guess is that providing more .swift files to the compiler helps it find definitions of classes/structs/protocols.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants