Skip to content

Commit 22a4941

Browse files
author
josh
committed
Fix merge conflicts (Toolchain, SwiftPMWorkspace, SwiftLanguageServer)
2 parents 3ef53f3 + 1a076bb commit 22a4941

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1796
-724
lines changed

Editors/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ You will need the path to the `sourcekit-lsp` executable and the Swift toolchain
6868
}
6969
```
7070

71+
## Emacs
72+
73+
There is an Emacs client for SourceKit-LSP in the [main Emacs LSP repository](https://github.com/emacs-lsp/lsp-sourcekit).
74+
7175
## Other Editors
7276

7377
SourceKit-LSP should work with any editor that supports the [Language Server Protocol](https://microsoft.github.io/language-server-protocol/)

Editors/vscode/package-lock.json

Lines changed: 467 additions & 138 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editors/vscode/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
"vscode-languageclient": "^4.0.0"
3232
},
3333
"devDependencies": {
34+
"@types/node": "^8.10.25",
3435
"typescript": "^2.6.1",
35-
"vscode": "^1.1.21",
36-
"vsce": "^1.52.0",
37-
"@types/node": "^8.10.25"
36+
"vsce": "^1.53.2",
37+
"vscode": "^1.1.22"
3838
},
3939
"contributes": {
4040
"configuration": {

Package.resolved

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ let package = Package(
3838
.target(
3939
name: "SKSwiftPMWorkspace",
4040
dependencies: ["SwiftPM", "SKCore"]),
41+
.testTarget(
42+
name: "SKSwiftPMWorkspaceTests",
43+
dependencies: ["SKSwiftPMWorkspace", "SKTestSupport"]),
4144

4245
// Csourcekitd: C modules wrapper for sourcekitd.
4346
.target(

README.md

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ SourceKit-LSP is an implementation of the [Language Server Protocol](https://mic
77

88
SourceKit-LSP is under heavy development! The best way to try it out is to build it from source. You will also need a Swift development toolchain and an editor that supports LSP.
99

10-
1. Install the `swift-DEVELOPMENT-SNAPSHOT-2018-11-01-a` toolchain snapshot from https://swift.org/download/. Set the environment variable `SOURCEKIT_TOOLCHAIN_PATH` to the absolute path to the toolchain or otherwise configure your editor to use this toolchain. See [Toolchains](#toolchains) for more information.
10+
1. Install the `swift-DEVELOPMENT-SNAPSHOT-2018-12-02-a` toolchain snapshot from https://swift.org/download/#snapshots. Set the environment variable `SOURCEKIT_TOOLCHAIN_PATH` to the absolute path to the toolchain or otherwise configure your editor to use this toolchain. See [Toolchains](#toolchains) for more information.
1111

1212
2. Build the language server executable `sourcekit-lsp` using `swift build`. See [Building](#building-sourcekit-lsp) for more information.
1313

@@ -45,13 +45,35 @@ $ swift package generate-xcodeproj --xcconfig-overrides overrides.xcconfig
4545
$ open SourceKitLSP.xcodeproj
4646
```
4747

48+
## Debugging
49+
50+
You can attach LLDB to SourceKit-LSP and set breakpoints to debug. You may want to instruct LLDB to wait for the sourcekit-lsp process to launch and then start your editor, which will typically launch
51+
SourceKit-LSP as soon as you open a Swift file:
52+
53+
54+
```sh
55+
$ lldb -w -n sourcekit-lsp
56+
```
57+
58+
If you are using the Xcode project, go to Debug, Attach to Process by PID or Name.
59+
60+
### Print SourceKit Logs
61+
62+
You can configure SourceKit-LSP to print log information from SourceKit to stderr by setting the following environment variable:
63+
64+
```sh
65+
SOURCEKIT_LOGGING="N"
66+
```
67+
68+
Where "N" configures the log verbosity and is one of the following numbers: 0 (error), 1 (warning), 2 (info), or 3 (debug).
69+
4870
## Toolchains
4971

5072
SourceKit-LSP depends on tools such as `sourcekitd` and `clangd`, which it loads at runtime from an installed toolchain.
5173

5274
### Recommended Toolchain
5375

54-
Use the `swift-DEVELOPMENT-SNAPSHOT-2018-11-01-a` toolchain snapshot from https://swift.org/download/#snapshots. It can be found under "Older Snapshots" as "November 1, 2018". SourceKit-LSP is still early in its development and we are actively adding functionality to the toolchain to support it.
76+
Use the `swift-DEVELOPMENT-SNAPSHOT-2018-12-02-a` toolchain snapshot from https://swift.org/download/#snapshots. SourceKit-LSP is still early in its development and we are actively adding functionality to the toolchain to support it.
5577

5678
### Selecting the Toolchain
5779

@@ -94,9 +116,6 @@ SourceKit-LSP is still in early development, so you may run into rough edges wit
94116

95117
### Caveats
96118

97-
* Indexing does not work on Linux (jump-to-definition, find references)
98-
* Should be fixed in the next Swift snapshot by [swift-clang#219](https://github.com/apple/swift-clang/pull/219)
99-
100119
* SwiftPM build settings are not updated automatically after files are added/removed.
101120
* **Workaround**: close and reopen the project after adding/removing files
102121

Sources/LanguageServerProtocol/Messages.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import Basic
1818
public let builtinRequests: [_RequestType.Type] = [
1919
InitializeRequest.self,
2020
Shutdown.self,
21+
WorkspaceFoldersRequest.self,
2122
CompletionRequest.self,
2223
HoverRequest.self,
2324
DefinitionRequest.self,
@@ -37,6 +38,7 @@ public let builtinNotifications: [NotificationType.Type] = [
3738
CancelRequest.self,
3839
LogMessage.self,
3940
DidChangeConfiguration.self,
41+
DidChangeWorkspaceFolders.self,
4042
DidOpenTextDocument.self,
4143
DidCloseTextDocument.self,
4244
DidChangeTextDocument.self,
@@ -172,6 +174,12 @@ public struct LogMessage: NotificationType, Hashable {
172174

173175
// MARK: - Workspace -
174176

177+
public struct WorkspaceFoldersRequest: RequestType, Hashable {
178+
public static let method: String = "workspace/workspaceFolders"
179+
180+
public typealias Response = [WorkspaceFolder]
181+
}
182+
175183
public struct DidChangeConfiguration: NotificationType {
176184
public static let method: String = "workspace/didChangeConfiguration"
177185

@@ -182,6 +190,16 @@ public struct DidChangeConfiguration: NotificationType {
182190
}
183191
}
184192

193+
public struct DidChangeWorkspaceFolders: NotificationType {
194+
public static let method: String = "workspace/didChangeWorkspaceFolders"
195+
196+
public var event: WorkspaceFoldersChangeEvent
197+
198+
public init(event: WorkspaceFoldersChangeEvent) {
199+
self.event = event
200+
}
201+
}
202+
185203
// MARK: - Text synchronization -
186204

187205
public struct DidOpenTextDocument: NotificationType, Hashable {

Sources/LanguageServerProtocol/WorkspaceFolder.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public struct WorkspaceFolder {
3030

3131
extension WorkspaceFolder: Equatable {}
3232
extension WorkspaceFolder: Hashable {}
33+
extension WorkspaceFolder: ResponseType {}
3334

3435
// Encode using the key "uri" to match LSP.
3536
extension WorkspaceFolder: Codable {
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
/// The workspace folder change event.
14+
public struct WorkspaceFoldersChangeEvent: Codable, Hashable {
15+
16+
/// The array of added workspace folders
17+
public var added: [WorkspaceFolder]?
18+
19+
/// The array of the removed workspace folders
20+
public var removed: [WorkspaceFolder]?
21+
22+
public init(added: [WorkspaceFolder]? = nil, removed: [WorkspaceFolder]? = nil) {
23+
self.added = added
24+
self.removed = removed
25+
}
26+
}

Sources/SKCore/BuildSystem.swift

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,26 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
import LanguageServerProtocol
14+
import Basic
1415

15-
/// Provider of build settings.
16-
public protocol BuildSettingsProvider {
16+
/// Provider of FileBuildSettings and other build-related information.
17+
///
18+
/// The primary role of the build system is to answer queries for FileBuildSettings and (TODO) to
19+
/// notify clients when they change. The BuildSystem is also the source of related informatino,
20+
/// such as where the index datastore is located.
21+
///
22+
/// For example, a SwiftPMWorkspace provides compiler arguments for the files contained in a
23+
/// SwiftPM package root directory.
24+
public protocol BuildSystem {
1725

18-
/// Returns the settings for the given url and language mode, if known.
19-
func settings(for: URL, language: Language) -> FileBuildSettings?
20-
21-
// TODO: notifications when settings change.
22-
}
26+
/// The path to the raw index store data, if any.
27+
var indexStorePath: AbsolutePath? { get }
2328

24-
/// Build settings for a single file.
25-
public struct FileBuildSettings {
29+
/// The path to put the index database, if any.
30+
var indexDatabasePath: AbsolutePath? { get }
2631

27-
/// The identifier of the toolchain that is preferred for compiling this file, if any.
28-
public var preferredToolchain: String? = nil
29-
30-
/// The compiler arguments to use for this file.
31-
public var compilerArguments: [String]
32-
33-
/// The working directory to resolve any relative paths in `compilerArguments`.
34-
public var workingDirectory: String? = nil
32+
/// Returns the settings for the given url and language mode, if known.
33+
func settings(for: URL, _ language: Language) -> FileBuildSettings?
3534

36-
public init(
37-
preferredToolchain: String? = nil,
38-
compilerArguments: [String],
39-
workingDirectory: String? = nil
40-
) {
41-
self.preferredToolchain = preferredToolchain
42-
self.compilerArguments = compilerArguments
43-
self.workingDirectory = workingDirectory
44-
}
35+
// TODO: notifications when settings change.
4536
}

0 commit comments

Comments
 (0)