Skip to content

Upgrade SwiftPM dependency to master branch #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.DS_Store
default.profraw
Package.resolved
/.build
/Packages
/*.xcodeproj
Expand Down
34 changes: 34 additions & 0 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let package = Package(
products: [
],
dependencies: [
.package(url: "https://github.com/apple/swift-package-manager.git", "0.3.0"..<"0.4.0"),
.package(url: "https://github.com/apple/swift-package-manager.git", .branch("master")),
.package(url: "https://github.com/apple/indexstore-db.git", .branch("master")),
],
targets: [
Expand Down
4 changes: 2 additions & 2 deletions Sources/LanguageServerProtocol/Diagnostic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public enum DiagnosticCode: Hashable {
public struct Diagnostic: Codable, Hashable {

/// The primary position/range of the diagnostic.
public var range: Range<Position>
public var range: PositionRange

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

public init(range: Range<Position>, severity: DiagnosticSeverity?, code: DiagnosticCode? = nil, source: String?, message: String, relatedInformation: [DiagnosticRelatedInformation]? = nil) {
self.range = range
self.range = PositionRange(range)
self.severity = severity
self.code = code
self.source = source
Expand Down
4 changes: 2 additions & 2 deletions Sources/LanguageServerProtocol/DocumentHighlight.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ public enum DocumentHighlightKind: Int, Codable, Hashable {
public struct DocumentHighlight: ResponseType, Hashable {

/// The location of the highlight.
public var range: Range<Position>
public var range: PositionRange

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

public init(range: Range<Position>, kind: DocumentHighlightKind?) {
self.range = range
self.range = PositionRange(range)
self.kind = kind
}
}
9 changes: 3 additions & 6 deletions Sources/LanguageServerProtocol/Location.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,18 @@
/// Range within a particular document.
///
/// For a location where the document is implied, use `Position` or `Range<Position>`.
public struct Location {
public struct Location: Hashable {

public var url: URL

public var range: Range<Position>
public var range: PositionRange

public init(url: URL, range: Range<Position>) {
self.url = url
self.range = range
self.range = PositionRange(range)
}
}

extension Location: Equatable {}
extension Location: Hashable {}

// Encode using the key "uri" to match LSP.
extension Location: Codable {
private enum CodingKeys: String, CodingKey {
Expand Down
6 changes: 3 additions & 3 deletions Sources/LanguageServerProtocol/Messages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public struct HoverResponse: ResponseType, Hashable {

public var contents: MarkupContent

public var range: Range<Position>?
public var range: PositionRange?

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

public init(contents: MarkupContent, range: Range<Position>?, usr: String?, definition: Location?) {
self.contents = contents
self.range = range
self.range = range.map { PositionRange($0) }
self.usr = usr
self.definition = definition
}
Expand Down Expand Up @@ -378,7 +378,7 @@ public struct DocumentRangeFormatting: TextDocumentRequest, Hashable {

public var textDocument: TextDocumentIdentifier

public var range: Range<Position>
public var range: PositionRange

public var options: FormattingOptions
}
Expand Down
30 changes: 1 addition & 29 deletions Sources/LanguageServerProtocol/Position.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//===----------------------------------------------------------------------===//

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

/// Line number within a document (zero-based).
public var line: Int
Expand All @@ -25,8 +25,6 @@ public struct Position {
}
}

extension Position: Equatable {}
extension Position: Hashable {}
extension Position: Codable {
private enum CodingKeys: String, CodingKey {
case line
Expand All @@ -39,29 +37,3 @@ extension Position: Comparable {
return (lhs.line, lhs.utf16index) < (rhs.line, rhs.utf16index)
}
}

// Encode Range<Position> using the keys "start" and "end" to match the LSP protocol for "Range".
extension Range: Codable where Bound == Position {
private enum CodingKeys: String, CodingKey {
case lowerBound = "start"
case upperBound = "end"
}

/// Create a range for a single position.
public init(_ pos: Position) {
self = pos ..< pos
}

public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
let lowerBound = try values.decode(Position.self, forKey: .lowerBound)
let upperBound = try values.decode(Position.self, forKey: .upperBound)
self = lowerBound ..< upperBound
}

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(lowerBound, forKey: .lowerBound)
try container.encode(upperBound, forKey: .upperBound)
}
}
47 changes: 47 additions & 0 deletions Sources/LanguageServerProtocol/PositionRange.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

/// Half-open range of Positions `[start, end)` within a text document, for use in LSP messages.
///
/// It is generally preferred to work with Range<Position> directly, but when passing values in LSP
/// messages, use PositionRange to provide the correct (de)serialization.
public struct PositionRange: Hashable {

/// The `lowerBound` of the range (inclusive).
public var lowerBound: Position

/// The `upperBound` of the range (exclusive).
public var upperBound: Position

/// The equivalent range expressed as a `Swift.Range`.
public var asRange: Range<Position> { return lowerBound..<upperBound}

public init(_ range: Range<Position>) {
self.lowerBound = range.lowerBound
self.upperBound = range.upperBound
}
}

extension PositionRange: Codable {
private enum CodingKeys: String, CodingKey {
case lowerBound = "start"
case upperBound = "end"
}
}

extension Range where Bound == Position {

/// Create a range for a single position.
public init(_ pos: Position) {
self = pos ..< pos
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
/// 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.
public struct TextDocumentContentChangeEvent: Codable, Hashable {

public var range: Range<Position>?
public var range: PositionRange?

public var rangeLength: Int?

public var text: String

public init(range: Range<Position>? = nil, rangeLength: Int? = nil, text: String) {
self.range = range
self.range = range.map { PositionRange($0) }
self.rangeLength = rangeLength
self.text = text
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/LanguageServerProtocol/TextEdit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
public struct TextEdit: Codable, Hashable {

/// The range of text to be replaced.
var range: Range<Position>
var range: PositionRange

/// The new text.
var newText: String

public init(range: Range<Position>, newText: String) {
self.range = range
self.range = PositionRange(range)
self.newText = newText
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import SKSupport
struct MessageHeader: Hashable {
static let contentLengthKey: [UInt8] = [UInt8]("Content-Length".utf8)
static let separator: [UInt8] = [UInt8]("\r\n".utf8)
static let colon: UInt8 = ":".utf8.only!
static let colon: UInt8 = ":".utf8.spm_only!
static let invalidKeyBytes: [UInt8] = [colon] + separator

var contentLength: Int? = nil
Expand Down
2 changes: 1 addition & 1 deletion Sources/SKCore/FallbackBuildSettingsProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public final class FallbackBuildSettingsProvider: BuildSettingsProvider {

lazy var sdkpath: AbsolutePath? = {
if case .darwin? = Platform.currentPlatform {
if let str = try? Process.checkNonZeroExit(args: "/usr/bin/xcrun", "--show-sdk-path", "--sdk", "macosx"), let path = try? AbsolutePath(validating: str.chomp()) {
if let str = try? Process.checkNonZeroExit(args: "/usr/bin/xcrun", "--show-sdk-path", "--sdk", "macosx"), let path = try? AbsolutePath(validating: str.spm_chomp()) {
return path
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/SKCore/ToolchainRegistry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ extension ToolchainRegistry {
]

var currentXcodeDeveloperPath: AbsolutePath? {
if let str = try? Process.checkNonZeroExit(args: "/usr/bin/xcode-select", "-p"), let path = try? AbsolutePath(validating: str.chomp()) {
if let str = try? Process.checkNonZeroExit(args: "/usr/bin/xcode-select", "-p"), let path = try? AbsolutePath(validating: str.spm_chomp()) {
return path
}
return nil
Expand Down
15 changes: 0 additions & 15 deletions Sources/SKSupport/Result.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,3 @@ extension Result {
}
}
}

extension Result: Equatable where Value: Equatable, ErrorType: Equatable {

@inlinable
public static func ==(lhs: Result, rhs: Result) -> Bool {
switch (lhs, rhs) {
case (.success(let lhs), .success(let rhs)):
return lhs == rhs
case (.failure(let lhs), .failure(let rhs)):
return lhs == rhs
default:
return false
}
}
}
2 changes: 2 additions & 0 deletions Sources/SKSupport/dlopen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ public struct DLOpenFlags: RawRepresentable, OptionSet {
// Platform-specific flags.
#if os(macOS)
public static let first: DLOpenFlags = DLOpenFlags(rawValue: RTLD_FIRST)
public static let deepBind: DLOpenFlags = DLOpenFlags(rawValue: 0)
#else
public static let first: DLOpenFlags = DLOpenFlags(rawValue: 0)
public static let deepBind: DLOpenFlags = DLOpenFlags(rawValue: RTLD_DEEPBIND)
#endif

public var rawValue: Int32
Expand Down
Loading