0001 // 0002 // SourceLocation.swift 0003 // SourceKitten 0004 // 0005 // Created by JP Simard on 10/27/15. 0006 // Copyright © 2015 SourceKitten. All rights reserved. 0007 // 0008 0009 #if SWIFT_PACKAGE 0010 import Clang_C 0011 #endif 0012 import Foundation 0013 0014 public struct SourceLocation{ 0015 let file
Clang+SourceKitten.swift:45 func location() -> SourceLocation {Clang+SourceKitten.swift:46 return SourceLocation(clangLocation: clang_getCursorLocation(self))Clang+SourceKitten.swift:49 func extent() -> (start: SourceLocation, end: SourceLocation) {Clang+SourceKitten.swift:49 func extent() -> (start: SourceLocation, end: SourceLocation) {Clang+SourceKitten.swift:51 let start = SourceLocation(clangLocation: clang_getRangeStart(extent))Clang+SourceKitten.swift:52 let end = SourceLocation(clangLocation: clang_getRangeEnd(extent))SourceDeclaration.swift:34 let location: SourceLocationSourceDeclaration.swift:35 let extent: (start: SourceLocation, end: SourceLocation)SourceDeclaration.swift:35 let extent: (start: SourceLocation, end: SourceLocation)SourceLocation.swift:20 public func rangeToEndLocation(end: SourceLocation) -> NSRange {SourceLocation.swift:25 extension SourceLocation {SourceLocation.swift:39 extension SourceLocation: Comparable {}SourceLocation.swift:41 public func ==(lhs: SourceLocation, rhs: SourceLocation) -> Bool {SourceLocation.swift:41 public func ==(lhs: SourceLocation, rhs: SourceLocation) -> Bool {SourceLocation.swift:50 public func <(lhs: SourceLocation, rhs: SourceLocation) -> Bool {SourceLocation.swift:50 public func <(lhs: SourceLocation, rhs: SourceLocation) -> Bool {String+SourceKitten.swift:381 public func substringWithSourceRange(start: SourceLocation, end: SourceLocation) -> String? {String+SourceKitten.swift:381 public func substringWithSourceRange(start: SourceLocation, end: SourceLocation) -> String? {String+SourceKitten.swift:414 let location = SourceLocation(file: filename,: String 0016 let line
Clang+SourceKitten.swift:83 let contents = try! NSString(contentsOfFile: cursorExtent.start.file, encoding: NSUTF8StringEncoding)ClangTranslationUnit.swift:67 .groupBy { $0.location.file }JSONOutput.swift:78 set(.FilePath, decl.location.file)JSONOutput.swift:79 set(.DocFile, decl.location.file)SourceDeclaration.swift:16 guard let path = declarations.first?.location.file, let file = File(path: path) else {SourceLocation.swift:42 return lhs.file.compare(rhs.file) == .OrderedSame &&SourceLocation.swift:42 return lhs.file.compare(rhs.file) == .OrderedSame &&SourceLocation.swift:52 switch lhs.file.compare(rhs.file) {SourceLocation.swift:52 switch lhs.file.compare(rhs.file) {: UInt32 0017 let column
JSONOutput.swift:80 set(.DocLine, Int(decl.location.line))JSONOutput.swift:86 set(.ParsedScopeStart, Int(decl.extent.start.line))JSONOutput.swift:87 set(.ParsedScopeEnd, Int(decl.extent.end.line))SourceLocation.swift:43 lhs.line == rhs.line &&SourceLocation.swift:43 lhs.line == rhs.line &&: UInt32 0018 let offset
JSONOutput.swift:81 set(.DocColumn, Int(decl.location.column))SourceLocation.swift:44 lhs.column == rhs.column &&SourceLocation.swift:44 lhs.column == rhs.column &&: UInt32 0019 0020 public func rangeToEndLocation
SourceLocation.swift:21 return NSRange(location: Int(offset), length: Int(end.offset - offset))SourceLocation.swift:21 return NSRange(location: Int(offset), length: Int(end.offset - offset))SourceLocation.swift:21 return NSRange(location: Int(offset), length: Int(end.offset - offset))SourceLocation.swift:45 lhs.offset == rhs.offsetSourceLocation.swift:45 lhs.offset == rhs.offsetSourceLocation.swift:62 return lhs.offset < rhs.offsetSourceLocation.swift:62 return lhs.offset < rhs.offsetString+SourceKitten.swift:382 return substringWithByteRange(start: Int(start.offset), length: Int(end.offset - start.offset))String+SourceKitten.swift:382 return substringWithByteRange(start: Int(start.offset), length: Int(end.offset - start.offset))String+SourceKitten.swift:382 return substringWithByteRange(start: Int(start.offset), length: Int(end.offset - start.offset))(end: SourceLocation) -> NSRange { 0021 return NSRange(location: Int(offset), length: Int(end.offset - offset)) 0022 } 0023 } 0024 0025 extension SourceLocation { 0026 init
SourceDeclaration.swift:45 return extent.start.rangeToEndLocation(extent.end)(clangLocation: CXSourceLocation) { 0027 var cxfile = CXFile() 0028 var line: UInt32 = 0 0029 var column: UInt32 = 0 0030 var offset: UInt32 = 0 0031 clang_getSpellingLocation(clangLocation, &cxfile, &line, &column, &offset) 0032 self.init(file: clang_getFileName(cxfile).str() ?? "<none>", 0033 line: line, column: column, offset: offset) 0034 } 0035 } 0036 0037 // MARK: Comparable 0038 0039 extension SourceLocation: Comparable {} 0040 0041 public func ==(lhs: SourceLocation, rhs: SourceLocation) -> Bool { 0042 return lhs.file.compare(rhs.file) == .OrderedSame && 0043 lhs.line == rhs.line && 0044 lhs.column == rhs.column && 0045 lhs.offset == rhs.offset 0046 } 0047 0048 /// A [strict total order](http://en.wikipedia.org/wiki/Total_order#Strict_total_order) 0049 /// over instances of `Self`. 0050 public func <(lhs: SourceLocation, rhs: SourceLocation) -> Bool { 0051 // Sort by file path. 0052 switch lhs.file.compare(rhs.file) { 0053 case .OrderedDescending: 0054 return false 0055 case .OrderedAscending: 0056 return true 0057 case .OrderedSame: 0058 break 0059 } 0060 0061 // Then offset. 0062 return lhs.offset < rhs.offset 0063 } 0064
Clang+SourceKitten.swift:46 return SourceLocation(clangLocation: clang_getCursorLocation(self))Clang+SourceKitten.swift:51 let start = SourceLocation(clangLocation: clang_getRangeStart(extent))Clang+SourceKitten.swift:52 let end = SourceLocation(clangLocation: clang_getRangeEnd(extent))