Files
sourcekit-lsp/Sources/LanguageServerProtocol/Position.swift
Ben Langmuir 048d72b163 Upgrade SwiftPM dependency to master branch
We are tied to using a SwiftPM that matches the toolchain, so upgrade
from 0.3.0 to .branch("master") and add a pins file to manage updating
that dependency.

This was driven by changes that broke loading packages being developed
with newer version of SwiftPM when using the 0.3.0 tag of libSwiftPM.
However, the changes seem to work when going in the other direction, so
using the newer libSwiftPM hasn't caused any known regressions for using
older toolchain versions (not guarantteed and not tested extensively
though).

This fixes using the latest (November 13) toolchain snapshot on macOS.
On Linux there are other issues not specific to LSP.
2018-11-16 15:11:38 -08:00

40 lines
1.2 KiB
Swift

//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
/// Position within a text document, expressed as a zero-based line and column (utf-16 code unit offset).
public struct Position: Hashable {
/// Line number within a document (zero-based).
public var line: Int
/// UTF-16 code-unit offset from the start of a line (zero-based).
public var utf16index: Int
public init(line: Int, utf16index: Int) {
self.line = line
self.utf16index = utf16index
}
}
extension Position: Codable {
private enum CodingKeys: String, CodingKey {
case line
case utf16index = "character"
}
}
extension Position: Comparable {
public static func < (lhs: Position, rhs: Position) -> Bool {
return (lhs.line, lhs.utf16index) < (rhs.line, rhs.utf16index)
}
}