Skip to content

Commit 90b0b5e

Browse files
authored
Merge pull request swiftlang#10 from benlangmuir/swiftpm-update
Upgrade SwiftPM dependency to master branch
2 parents 4b77ff9 + 1def01e commit 90b0b5e

20 files changed

+121
-79
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
.DS_Store
22
default.profraw
3-
Package.resolved
43
/.build
54
/Packages
65
/*.xcodeproj

Package.resolved

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

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ let package = Package(
77
products: [
88
],
99
dependencies: [
10-
.package(url: "https://github.com/apple/swift-package-manager.git", "0.3.0"..<"0.4.0"),
10+
.package(url: "https://github.com/apple/swift-package-manager.git", .branch("master")),
1111
.package(url: "https://github.com/apple/indexstore-db.git", .branch("master")),
1212
],
1313
targets: [

Sources/LanguageServerProtocol/Diagnostic.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public enum DiagnosticCode: Hashable {
2525
public struct Diagnostic: Codable, Hashable {
2626

2727
/// The primary position/range of the diagnostic.
28-
public var range: Range<Position>
28+
public var range: PositionRange
2929

3030
/// Whether this is a warning, error, etc.
3131
public var severity: DiagnosticSeverity?
@@ -43,7 +43,7 @@ public struct Diagnostic: Codable, Hashable {
4343
public var relatedInformation: [DiagnosticRelatedInformation]?
4444

4545
public init(range: Range<Position>, severity: DiagnosticSeverity?, code: DiagnosticCode? = nil, source: String?, message: String, relatedInformation: [DiagnosticRelatedInformation]? = nil) {
46-
self.range = range
46+
self.range = PositionRange(range)
4747
self.severity = severity
4848
self.code = code
4949
self.source = source

Sources/LanguageServerProtocol/DocumentHighlight.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ public enum DocumentHighlightKind: Int, Codable, Hashable {
1919
public struct DocumentHighlight: ResponseType, Hashable {
2020

2121
/// The location of the highlight.
22-
public var range: Range<Position>
22+
public var range: PositionRange
2323

2424
/// What kind of reference this is. Default is `.text`.
2525
public var kind: DocumentHighlightKind?
2626

2727
public init(range: Range<Position>, kind: DocumentHighlightKind?) {
28-
self.range = range
28+
self.range = PositionRange(range)
2929
self.kind = kind
3030
}
3131
}

Sources/LanguageServerProtocol/Location.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,18 @@
1313
/// Range within a particular document.
1414
///
1515
/// For a location where the document is implied, use `Position` or `Range<Position>`.
16-
public struct Location {
16+
public struct Location: Hashable {
1717

1818
public var url: URL
1919

20-
public var range: Range<Position>
20+
public var range: PositionRange
2121

2222
public init(url: URL, range: Range<Position>) {
2323
self.url = url
24-
self.range = range
24+
self.range = PositionRange(range)
2525
}
2626
}
2727

28-
extension Location: Equatable {}
29-
extension Location: Hashable {}
30-
3128
// Encode using the key "uri" to match LSP.
3229
extension Location: Codable {
3330
private enum CodingKeys: String, CodingKey {

Sources/LanguageServerProtocol/Messages.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ public struct HoverResponse: ResponseType, Hashable {
309309

310310
public var contents: MarkupContent
311311

312-
public var range: Range<Position>?
312+
public var range: PositionRange?
313313

314314
/// Extension!
315315
public var usr: String?
@@ -319,7 +319,7 @@ public struct HoverResponse: ResponseType, Hashable {
319319

320320
public init(contents: MarkupContent, range: Range<Position>?, usr: String?, definition: Location?) {
321321
self.contents = contents
322-
self.range = range
322+
self.range = range.map { PositionRange($0) }
323323
self.usr = usr
324324
self.definition = definition
325325
}
@@ -378,7 +378,7 @@ public struct DocumentRangeFormatting: TextDocumentRequest, Hashable {
378378

379379
public var textDocument: TextDocumentIdentifier
380380

381-
public var range: Range<Position>
381+
public var range: PositionRange
382382

383383
public var options: FormattingOptions
384384
}

Sources/LanguageServerProtocol/Position.swift

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
/// Position within a text document, expressed as a zero-based line and column (utf-16 code unit offset).
14-
public struct Position {
14+
public struct Position: Hashable {
1515

1616
/// Line number within a document (zero-based).
1717
public var line: Int
@@ -25,8 +25,6 @@ public struct Position {
2525
}
2626
}
2727

28-
extension Position: Equatable {}
29-
extension Position: Hashable {}
3028
extension Position: Codable {
3129
private enum CodingKeys: String, CodingKey {
3230
case line
@@ -39,29 +37,3 @@ extension Position: Comparable {
3937
return (lhs.line, lhs.utf16index) < (rhs.line, rhs.utf16index)
4038
}
4139
}
42-
43-
// Encode Range<Position> using the keys "start" and "end" to match the LSP protocol for "Range".
44-
extension Range: Codable where Bound == Position {
45-
private enum CodingKeys: String, CodingKey {
46-
case lowerBound = "start"
47-
case upperBound = "end"
48-
}
49-
50-
/// Create a range for a single position.
51-
public init(_ pos: Position) {
52-
self = pos ..< pos
53-
}
54-
55-
public init(from decoder: Decoder) throws {
56-
let values = try decoder.container(keyedBy: CodingKeys.self)
57-
let lowerBound = try values.decode(Position.self, forKey: .lowerBound)
58-
let upperBound = try values.decode(Position.self, forKey: .upperBound)
59-
self = lowerBound ..< upperBound
60-
}
61-
62-
public func encode(to encoder: Encoder) throws {
63-
var container = encoder.container(keyedBy: CodingKeys.self)
64-
try container.encode(lowerBound, forKey: .lowerBound)
65-
try container.encode(upperBound, forKey: .upperBound)
66-
}
67-
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
/// Half-open range of Positions `[start, end)` within a text document, for use in LSP messages.
14+
///
15+
/// It is generally preferred to work with Range<Position> directly, but when passing values in LSP
16+
/// messages, use PositionRange to provide the correct (de)serialization.
17+
public struct PositionRange: Hashable {
18+
19+
/// The `lowerBound` of the range (inclusive).
20+
public var lowerBound: Position
21+
22+
/// The `upperBound` of the range (exclusive).
23+
public var upperBound: Position
24+
25+
/// The equivalent range expressed as a `Swift.Range`.
26+
public var asRange: Range<Position> { return lowerBound..<upperBound}
27+
28+
public init(_ range: Range<Position>) {
29+
self.lowerBound = range.lowerBound
30+
self.upperBound = range.upperBound
31+
}
32+
}
33+
34+
extension PositionRange: Codable {
35+
private enum CodingKeys: String, CodingKey {
36+
case lowerBound = "start"
37+
case upperBound = "end"
38+
}
39+
}
40+
41+
extension Range where Bound == Position {
42+
43+
/// Create a range for a single position.
44+
public init(_ pos: Position) {
45+
self = pos ..< pos
46+
}
47+
}

Sources/LanguageServerProtocol/TextDocumentContentChangeEvent.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
/// The `range.end` and `rangeLength` are potentially redundant. Based on https://github.com/Microsoft/language-server-protocol/issues/9, servers should be lenient and accept either.
1818
public struct TextDocumentContentChangeEvent: Codable, Hashable {
1919

20-
public var range: Range<Position>?
20+
public var range: PositionRange?
2121

2222
public var rangeLength: Int?
2323

2424
public var text: String
2525

2626
public init(range: Range<Position>? = nil, rangeLength: Int? = nil, text: String) {
27-
self.range = range
27+
self.range = range.map { PositionRange($0) }
2828
self.rangeLength = rangeLength
2929
self.text = text
3030
}

Sources/LanguageServerProtocol/TextEdit.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
public struct TextEdit: Codable, Hashable {
1515

1616
/// The range of text to be replaced.
17-
var range: Range<Position>
17+
var range: PositionRange
1818

1919
/// The new text.
2020
var newText: String
2121

2222
public init(range: Range<Position>, newText: String) {
23-
self.range = range
23+
self.range = PositionRange(range)
2424
self.newText = newText
2525
}
2626
}

Sources/LanguageServerProtocolJSONRPC/MessageSplitting.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import SKSupport
1616
struct MessageHeader: Hashable {
1717
static let contentLengthKey: [UInt8] = [UInt8]("Content-Length".utf8)
1818
static let separator: [UInt8] = [UInt8]("\r\n".utf8)
19-
static let colon: UInt8 = ":".utf8.only!
19+
static let colon: UInt8 = ":".utf8.spm_only!
2020
static let invalidKeyBytes: [UInt8] = [colon] + separator
2121

2222
var contentLength: Int? = nil

Sources/SKCore/FallbackBuildSettingsProvider.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public final class FallbackBuildSettingsProvider: BuildSettingsProvider {
1919

2020
lazy var sdkpath: AbsolutePath? = {
2121
if case .darwin? = Platform.currentPlatform {
22-
if let str = try? Process.checkNonZeroExit(args: "/usr/bin/xcrun", "--show-sdk-path", "--sdk", "macosx"), let path = try? AbsolutePath(validating: str.chomp()) {
22+
if let str = try? Process.checkNonZeroExit(args: "/usr/bin/xcrun", "--show-sdk-path", "--sdk", "macosx"), let path = try? AbsolutePath(validating: str.spm_chomp()) {
2323
return path
2424
}
2525
}

Sources/SKCore/ToolchainRegistry.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ extension ToolchainRegistry {
141141
]
142142

143143
var currentXcodeDeveloperPath: AbsolutePath? {
144-
if let str = try? Process.checkNonZeroExit(args: "/usr/bin/xcode-select", "-p"), let path = try? AbsolutePath(validating: str.chomp()) {
144+
if let str = try? Process.checkNonZeroExit(args: "/usr/bin/xcode-select", "-p"), let path = try? AbsolutePath(validating: str.spm_chomp()) {
145145
return path
146146
}
147147
return nil

Sources/SKSupport/Result.swift

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,3 @@ extension Result {
3434
}
3535
}
3636
}
37-
38-
extension Result: Equatable where Value: Equatable, ErrorType: Equatable {
39-
40-
@inlinable
41-
public static func ==(lhs: Result, rhs: Result) -> Bool {
42-
switch (lhs, rhs) {
43-
case (.success(let lhs), .success(let rhs)):
44-
return lhs == rhs
45-
case (.failure(let lhs), .failure(let rhs)):
46-
return lhs == rhs
47-
default:
48-
return false
49-
}
50-
}
51-
}

Sources/SKSupport/dlopen.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ public struct DLOpenFlags: RawRepresentable, OptionSet {
4747
// Platform-specific flags.
4848
#if os(macOS)
4949
public static let first: DLOpenFlags = DLOpenFlags(rawValue: RTLD_FIRST)
50+
public static let deepBind: DLOpenFlags = DLOpenFlags(rawValue: 0)
5051
#else
5152
public static let first: DLOpenFlags = DLOpenFlags(rawValue: 0)
53+
public static let deepBind: DLOpenFlags = DLOpenFlags(rawValue: RTLD_DEEPBIND)
5254
#endif
5355

5456
public var rawValue: Int32

0 commit comments

Comments
 (0)