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

Cross-module definition doesn't work #52

@chrismwendt

Description

@chrismwendt

2018-05-31 13 15 09

This happens because the framework path for the project is not getting passed to the swift compiler.

$ swift --help
...
  -F <value>              Add directory to framework search path
...

With -F, cursorinfo across modules works (I'm on bebf0d1):

cat <<EOF | sourcekitd-repl
{
  key.request: source.request.cursorinfo,
  key.compilerargs: [
    "-sdk",
    "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk",
    "-F",
    "/Users/chrismwendt/Library/Developer/Xcode/DerivedData/langserver-swift-decoewqzatmxuugoqscoirgsoekn/Build/Products/Debug",
    "/Users/chrismwendt/langserver-swift/Sources/LanguageServer/main.swift",
  ],
  key.offset: 368,
  key.sourcefile: "/Users/chrismwendt/langserver-swift/Sources/LanguageServer/main.swift",
}
EOF

And returns:

{
  key.kind: source.lang.swift.ref.class,
  key.name: "RequestBuffer",
  key.usr: "s:12BaseProtocol13RequestBufferC",
  key.typename: "RequestBuffer.Type",
  key.annotated_decl: "<Declaration>class RequestBuffer</Declaration>",
  key.fully_annotated_decl: "<decl.class><syntaxtype.keyword>class</syntaxtype.keyword> <decl.name>RequestBuffer</decl.name></decl.class>",
  key.typeusr: "_T012BaseProtocol13RequestBufferCmD",
  key.modulename: "BaseProtocol"
}

The correct path can be obtained by running this build command (similar to the one listed in the README:

$ xcodebuild -project langserver-swift.xcodeproj -scheme langserver-swift -showBuildSettings | grep "TARGET_BUILD_DIR"
   TARGET_BUILD_DIR = /Users/chrismwendt/Library/Developer/Xcode/DerivedData/langserver-swift-decoewqzatmxuugoqscoirgsoekn/Build/Products/Debug

The -scheme langserver-swift can be obtained with swift package dump-package | jq -r .name, but it's probably not safe to assume that there is a scheme with the same name as the package.

I'm thinking about running those commands and passing it to the compiler at https://github.com/chrismwendt/langserver-swift/blob/bebf0d10c51c8c0fa71d557b4fcf90fb92e64615/Sources/LanguageServerProtocol/Types/Server.swift#L179

@RLovelett Does this approach make sense?

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions