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

Commit c064e24

Browse files
committed
Remove explicit dependency on Yams
1 parent 24cf9c6 commit c064e24

File tree

8 files changed

+3
-183
lines changed

8 files changed

+3
-183
lines changed

Package.pins

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@
3030
"reason": null,
3131
"repositoryURL": "https://github.com/RLovelett/SourceKit.git",
3232
"version": "1.0.2"
33-
},
34-
{
35-
"package": "Yams",
36-
"reason": null,
37-
"repositoryURL": "https://github.com/jpsim/Yams.git",
38-
"version": "0.1.4"
3933
}
4034
],
4135
"version": 1

Package.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ let package = Package(
55
targets: [
66
Target(name: "BaseProtocol"),
77
Target(name: "SourceKitter"),
8-
Target(name: "YamlConvertable"),
9-
Target(name: "LanguageServerProtocol", dependencies: ["YamlConvertable", "BaseProtocol", "SourceKitter"]),
8+
Target(name: "LanguageServerProtocol", dependencies: ["BaseProtocol", "SourceKitter"]),
109
Target(name: "LanguageServer", dependencies: ["LanguageServerProtocol", "BaseProtocol"])
1110
],
1211
dependencies: [
1312
.Package(url: "https://github.com/RLovelett/SourceKit.git", majorVersion: 1),
14-
.Package(url: "https://github.com/jpsim/Yams.git", Version(0, 1, 4)),
1513
.Package(url: "https://github.com/thoughtbot/Argo.git", majorVersion: 4),
1614
.Package(url: "https://github.com/edwardaux/Ogra.git", majorVersion: 4),
1715
.Package(url: "https://github.com/thoughtbot/Curry.git", majorVersion: 3)

Sources/LanguageServerProtocol/Types/SwiftModule.swift

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import Argo
1010
import Curry
1111
import Foundation
1212
import Runes
13-
import YamlConvertable
14-
import Yams
1513

1614
/// A module, typically defined and managed by [SwiftPM](), that manages the sources and the compiler arguments
1715
/// that should be sent to SourceKit.
@@ -89,30 +87,3 @@ extension SwiftModule : Equatable {
8987
}
9088

9189
}
92-
93-
extension SwiftModule : YamlConvertable {
94-
95-
/// - TODO: This really should really be part of `YamlConvertable`. Unfortunately the generic version of this
96-
/// causes the compiler to die.
97-
/// e.g., this signature
98-
/// static func decodeAndFilterFailed<T: YamlConvertable>(_ yaml: Node) -> Decoded<[T]> where T == T.DecodedType {
99-
static func decodeAndFilterFailed(_ yaml: Node) -> Decoded<[SwiftModule]> {
100-
switch yaml {
101-
case .mapping(let o):
102-
// return .typeMismatch(expected: "Array", actual: "")
103-
return pure(o.flatMap({ SwiftModule.decode($0.1).value }))
104-
default:
105-
return .typeMismatch(expected: "Array", actual: "")
106-
}
107-
}
108-
109-
110-
static func decode(_ yaml: Node) -> Decoded<SwiftModule> {
111-
let name = flatReduce(["module-name"], initial: yaml, combine: convertedYAML).flatMap(String.decode)
112-
let sources = flatReduce(["sources"], initial: yaml, combine: convertedYAML).flatMap(Array<URL>.decode)
113-
let otherArguments = flatReduce(["other-args"], initial: yaml, combine: convertedYAML).flatMap(Array<String>.decode)
114-
115-
return curry(SwiftModule.init) <^> name <*> sources <*> otherArguments
116-
}
117-
118-
}

Sources/LanguageServerProtocol/Types/Workspace.swift

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import Argo
1010
import Foundation
1111
import os.log
1212
import SourceKitter
13-
import YamlConvertable
14-
import Yams
1513

1614
@available(macOS 10.12, *)
1715
private let log = OSLog(subsystem: "me.lovelett.langserver-swift", category: "Workspace")
@@ -46,21 +44,7 @@ public struct Workspace {
4644
init(inDirectory: URL) {
4745
sourceKitSession = SourceKit.Session()
4846
root = inDirectory
49-
let llbuild = root.appendingPathComponent(".build", isDirectory: true)
50-
.appendingPathComponent("debug", isDirectory: false)
51-
.appendingPathExtension("yaml")
52-
let yamlModules: Decoded<[SwiftModule]> = Decoded<Node>.fromOptional(
53-
(try? String(contentsOf: llbuild, encoding: .utf8))
54-
.flatMap({ try? Node(string: $0) }))
55-
.flatMap({ flatReduce(["commands"], initial: $0, combine: convertedYAML) })
56-
.flatMap(SwiftModule.decodeAndFilterFailed)
57-
58-
switch yamlModules {
59-
case .success(let a) where !a.isEmpty:
60-
modules = Set(a)
61-
default:
62-
modules = [SwiftModule(root)]
63-
}
47+
modules = []
6448
}
6549

6650
/// A description to the client of the types of services this language server provides.
@@ -102,25 +86,7 @@ public struct Workspace {
10286
// MARK: - Language Server Protocol methods
10387

10488
public mutating func receive(notification parameters: DidChangeWatchedFilesParams) {
105-
let x: [SwiftModule] = parameters.changes
106-
.filter({ $0.uri.pathExtension == "yaml" })
107-
.flatMap({ try? String(contentsOf: $0.uri) })
108-
.flatMap({ try? Node(string: $0) })
109-
.flatMap({ flatReduce(["commands"], initial: $0, combine: convertedYAML).flatMap(SwiftModule.decodeAndFilterFailed).value })
110-
.flatMap({ $0 })
111-
let moduleChanges = Set<SwiftModule>(x)
112-
113-
// Remove any missing modules
114-
modules = modules.intersection(moduleChanges)
115-
116-
// for changedModule in moduleChanges {
117-
// if let index = modules.index(of: changedModule) {
118-
// var oldModule = modules[index]
119-
// oldModule
120-
// } else {
121-
// modules
122-
// }
123-
// }
89+
12490
}
12591

12692
/// Notify the `Workspace` that the client has opened a document in the workspace.

Sources/YamlConvertable/Extensions/StandardTypesRyan.swift

Lines changed: 0 additions & 54 deletions
This file was deleted.

Sources/YamlConvertable/Functions/convertedYAML.swift

Lines changed: 0 additions & 21 deletions
This file was deleted.

Sources/YamlConvertable/Protocols/YamlConvertable.swift

Lines changed: 0 additions & 18 deletions
This file was deleted.

Tests/LanguageServerProtocolTests/Types/SwiftModuleTests.swift

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,8 @@
88

99
import Argo
1010
@testable import LanguageServerProtocol
11-
@testable import YamlConvertable
12-
import Yams
1311
import XCTest
1412

1513
class SwiftModuleTests: XCTestCase {
1614

17-
func testYamlLoading() {
18-
let fixture = getFixture("debug.yaml", in: "ValidLayouts/Simple/.build")!
19-
let str = try! String(contentsOf: fixture, encoding: .utf8)
20-
let yaml = try! Node(string: str)
21-
let foo: Decoded<Node> = flatReduce(["commands"], initial: yaml, combine: convertedYAML)
22-
let bar: Decoded<[SwiftModule]> = foo.flatMap(SwiftModule.decodeAndFilterFailed)
23-
switch bar {
24-
case .success(let modules):
25-
XCTAssertEqual(modules.count, 1)
26-
case .failure(let error):
27-
XCTFail(error.description)
28-
}
29-
}
30-
3115
}

0 commit comments

Comments
 (0)