diff --git a/CHANGELOG.md b/CHANGELOG.md index 7da995be7..32fefe440 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,8 @@ ##### Breaking -* SourceKitten now requires Xcode 8.0 and Swift 3.0 to build. +* SourceKitten now requires Xcode 8.0 and Swift 3.0 to build. + APIs have been adapted to conform to the Swift 3 API Design Guidelines. [JP Simard](https://github.com/jpsim) [Norio Nomura](https://github.com/norio-nomura) diff --git a/Source/SourceKittenFramework/Clang+SourceKitten.swift b/Source/SourceKittenFramework/Clang+SourceKitten.swift index 65c864ff8..7ed0caa14 100644 --- a/Source/SourceKittenFramework/Clang+SourceKitten.swift +++ b/Source/SourceKittenFramework/Clang+SourceKitten.swift @@ -87,19 +87,19 @@ extension CXCursor { } func objCKind() -> ObjCDeclarationKind { - return ObjCDeclarationKind.fromClang(kind) + return ObjCDeclarationKind(kind) } func str() -> String? { let cursorExtent = extent() let contents = try! String(contentsOfFile: cursorExtent.start.file, encoding: .utf8) - return contents.substringWithSourceRange(cursorExtent.start, end: cursorExtent.end) + return contents.substringWithSourceRange(start: cursorExtent.start, end: cursorExtent.end) } func name() -> String { let spelling = clang_getCursorSpelling(self).str()! let type = objCKind() - if let usrString = usr(), spelling.isEmpty && type == .Enum { + if let usrString = usr(), spelling.isEmpty && type == .enum { // libClang considers enums declared like `typedef enum {} name;` rather than `NS_ENUM()` // to have a cursor spelling of "" (empty string). So we parse the USR to extract the actual name. let prefix = "c:@EA@" @@ -107,7 +107,7 @@ extension CXCursor { let index = usrString.index(usrString.startIndex, offsetBy: prefix.lengthOfBytes(using: .utf8)) return usrString.substring(from: index) - } else if type == .Category, let usrNSString = usr() as NSString? { + } else if type == .category, let usrNSString = usr() as NSString? { let ext = (usrNSString.range(of: "c:objc(ext)").location == 0) let regex = try! NSRegularExpression(pattern: "(\\w+)@(\\w+)", options: []) let range = NSRange(location: 0, length: usrNSString.length) @@ -119,9 +119,9 @@ extension CXCursor { } else { fatalError("Couldn't get category name") } - } else if type == .MethodInstance { + } else if type == .methodInstance { return "-" + spelling - } else if type == .MethodClass { + } else if type == .methodClass { return "+" + spelling } return spelling @@ -185,7 +185,7 @@ extension CXCursor { return commentBody } - func swiftDeclaration(_ compilerArguments: [String]) -> String? { + func swiftDeclaration(compilerArguments: [String]) -> String? { let file = location().file let swiftUUID: String if let uuid = interfaceUUIDMap[file] { @@ -194,16 +194,16 @@ extension CXCursor { swiftUUID = NSUUID().uuidString interfaceUUIDMap[file] = swiftUUID // Generate Swift interface, associating it with the UUID - _ = Request.Interface(file: file, uuid: swiftUUID).send() + _ = Request.interface(file: file, uuid: swiftUUID).send() } guard let usr = usr(), - let usrOffset = Request.FindUSR(file: swiftUUID, usr: usr).send()[SwiftDocKey.Offset.rawValue] as? Int64 else { + let usrOffset = Request.findUSR(file: swiftUUID, usr: usr).send()[SwiftDocKey.offset.rawValue] as? Int64 else { return nil } - let cursorInfo = Request.CursorInfo(file: swiftUUID, offset: usrOffset, arguments: compilerArguments).send() - guard let docsXML = cursorInfo[SwiftDocKey.FullXMLDocs.rawValue] as? String, + let cursorInfo = Request.cursorInfo(file: swiftUUID, offset: usrOffset, arguments: compilerArguments).send() + guard let docsXML = cursorInfo[SwiftDocKey.fullXMLDocs.rawValue] as? String, let swiftDeclaration = SWXMLHash.parse(docsXML).children.first?["Declaration"].element?.text else { return nil } @@ -245,7 +245,7 @@ extension CXComment { } fatalError("not text: \(child.kind())") } - return [.Para(paragraphString.stringByRemovingCommonLeadingWhitespaceFromLines(), kindString)] + return [.Para(paragraphString.removingCommonLeadingWhitespaceFromLines(), kindString)] } func kind() -> CXCommentKind { diff --git a/Source/SourceKittenFramework/ClangTranslationUnit.swift b/Source/SourceKittenFramework/ClangTranslationUnit.swift index c452984ec..bce4377ab 100644 --- a/Source/SourceKittenFramework/ClangTranslationUnit.swift +++ b/Source/SourceKittenFramework/ClangTranslationUnit.swift @@ -65,7 +65,7 @@ public struct ClangTranslationUnit { .distinct() .sorted() .groupBy { $0.location.file } - .map { insertMarks($0) } + .map { insertMarks(declarations: $0) } } /** @@ -77,8 +77,8 @@ public struct ClangTranslationUnit { - parameter path: Path to run `xcodebuild` from. Uses current path by default. */ public init?(headerFiles: [String], xcodeBuildArguments: [String], inPath path: String = FileManager.default.currentDirectoryPath) { - let xcodeBuildOutput = runXcodeBuild(xcodeBuildArguments + ["-dry-run"], inPath: path) ?? "" - guard let clangArguments = parseCompilerArguments(xcodeBuildOutput as NSString, language: .ObjC, moduleName: nil) else { + let xcodeBuildOutput = runXcodeBuild(arguments: xcodeBuildArguments + ["-dry-run"], inPath: path) ?? "" + guard let clangArguments = parseCompilerArguments(xcodebuildOutput: xcodeBuildOutput as NSString, language: .objc, moduleName: nil) else { fputs("could not parse compiler arguments\n\(xcodeBuildOutput)\n", stderr) return nil } diff --git a/Source/SourceKittenFramework/CodeCompletionItem.swift b/Source/SourceKittenFramework/CodeCompletionItem.swift index 8ec8d51ed..ea2abb91a 100644 --- a/Source/SourceKittenFramework/CodeCompletionItem.swift +++ b/Source/SourceKittenFramework/CodeCompletionItem.swift @@ -44,7 +44,7 @@ public struct CodeCompletionItem: CustomStringConvertible { return toJSON(dictionaryValue as NSDictionary) } - public static func parseResponse(_ response: [String: SourceKitRepresentable]) -> [CodeCompletionItem] { + public static func parse(response: [String: SourceKitRepresentable]) -> [CodeCompletionItem] { return (response["key.results"] as! [SourceKitRepresentable]).map { item in let dict = item as! [String: SourceKitRepresentable] return CodeCompletionItem(kind: dict["key.kind"] as! String, diff --git a/Source/SourceKittenFramework/File.swift b/Source/SourceKittenFramework/File.swift index 3e29d4fda..79a5805ab 100644 --- a/Source/SourceKittenFramework/File.swift +++ b/Source/SourceKittenFramework/File.swift @@ -57,11 +57,11 @@ public final class File { guard let path = path else { return contents } - _ = Request.EditorOpen(self).send() + _ = Request.editorOpen(file: self).send() var newContents = [String]() var offset = 0 for line in lines { - let formatResponse = Request.Format(file: path, + let formatResponse = Request.format(file: path, line: Int64(line.index), useTabs: useTabs, indentWidth: Int64(indentWidth)).send() @@ -70,7 +70,7 @@ public final class File { guard newText != line.content else { continue } - _ = Request.ReplaceText(file: path, + _ = Request.replaceText(file: path, offset: Int64(line.byteRange.location + offset), length: Int64(line.byteRange.length - 1), sourceText: newText).send() @@ -81,7 +81,7 @@ public final class File { if trimmingTrailingWhitespace { newContents = newContents.map { - $0.stringByTrimmingTrailingCharactersInSet(.whitespaces) + $0.trimmingTrailingCharacters(in: .whitespaces) } } @@ -106,7 +106,7 @@ public final class File { } else { substring = contents.substringLinesWithByteRange(start: start, length: 0) } - return substring?.stringByTrimmingWhitespaceAndOpeningCurlyBrace() + return substring?.trimmingWhitespaceAndOpeningCurlyBrace() } /** @@ -139,8 +139,8 @@ public final class File { - returns: Mark name if successfully parsed. */ - private func markNameFromDictionary(_ dictionary: [String: SourceKitRepresentable]) -> String? { - precondition(SwiftDocKey.getKind(dictionary)! == SyntaxKind.CommentMark.rawValue) + private func parseMarkName(_ dictionary: [String: SourceKitRepresentable]) -> String? { + precondition(SwiftDocKey.getKind(dictionary)! == SyntaxKind.commentMark.rawValue) let offset = Int(SwiftDocKey.getOffset(dictionary)!) let length = Int(SwiftDocKey.getLength(dictionary)!) let fileContentsData = contents.data(using: .utf8) @@ -155,7 +155,7 @@ public final class File { - parameter dictionary: Dictionary to process. - parameter cursorInfoRequest: Cursor.Info request to get declaration information. */ - public func processDictionary(_ dictionary: [String: SourceKitRepresentable], cursorInfoRequest: sourcekitd_object_t? = nil, syntaxMap: SyntaxMap? = nil) -> [String: SourceKitRepresentable] { + public func process(dictionary: [String: SourceKitRepresentable], cursorInfoRequest: sourcekitd_object_t? = nil, syntaxMap: SyntaxMap? = nil) -> [String: SourceKitRepresentable] { var dictionary = dictionary if let cursorInfoRequest = cursorInfoRequest { dictionary = merge( @@ -166,13 +166,13 @@ public final class File { // Parse declaration and add to dictionary if let parsedDeclaration = parseDeclaration(dictionary) { - dictionary[SwiftDocKey.ParsedDeclaration.rawValue] = parsedDeclaration + dictionary[SwiftDocKey.parsedDeclaration.rawValue] = parsedDeclaration } // Parse scope range and add to dictionary if let parsedScopeRange = parseScopeRange(dictionary) { - dictionary[SwiftDocKey.ParsedScopeStart.rawValue] = Int64(parsedScopeRange.start) - dictionary[SwiftDocKey.ParsedScopeEnd.rawValue] = Int64(parsedScopeRange.end) + dictionary[SwiftDocKey.parsedScopeStart.rawValue] = Int64(parsedScopeRange.start) + dictionary[SwiftDocKey.parsedScopeEnd.rawValue] = Int64(parsedScopeRange.end) } // Parse `key.doc.full_as_xml` and add to dictionary @@ -180,14 +180,14 @@ public final class File { dictionary = merge(dictionary, parsedXMLDocs) } - if let commentBody = (syntaxMap.flatMap { getDocumentationCommentBody(dictionary, syntaxMap: $0) }) { + if let commentBody = (syntaxMap.flatMap { parseDocumentationCommentBody(dictionary, syntaxMap: $0) }) { // Parse documentation comment and add to dictionary - dictionary[SwiftDocKey.DocumentationComment.rawValue] = commentBody + dictionary[SwiftDocKey.documentationComment.rawValue] = commentBody } // Update substructure if let substructure = newSubstructure(dictionary, cursorInfoRequest: cursorInfoRequest, syntaxMap: syntaxMap) { - dictionary[SwiftDocKey.Substructure.rawValue] = substructure + dictionary[SwiftDocKey.substructure.rawValue] = substructure } return dictionary } @@ -200,15 +200,15 @@ public final class File { - parameter documentedTokenOffsets: Offsets that are likely documented. - parameter cursorInfoRequest: Cursor.Info request to get declaration information. */ - internal func furtherProcessDictionary(_ dictionary: [String: SourceKitRepresentable], documentedTokenOffsets: [Int], cursorInfoRequest: sourcekitd_object_t, syntaxMap: SyntaxMap) -> [String: SourceKitRepresentable] { + internal func furtherProcess(dictionary: [String: SourceKitRepresentable], documentedTokenOffsets: [Int], cursorInfoRequest: sourcekitd_object_t, syntaxMap: SyntaxMap) -> [String: SourceKitRepresentable] { var dictionary = dictionary - let offsetMap = generateOffsetMap(documentedTokenOffsets, dictionary: dictionary) + let offsetMap = makeOffsetMap(documentedTokenOffsets: documentedTokenOffsets, dictionary: dictionary) for offset in offsetMap.keys.reversed() { // Do this in reverse to insert the doc at the correct offset - if let response = Request.sendCursorInfoRequest(cursorInfoRequest, atOffset: Int64(offset)).map({ processDictionary($0, cursorInfoRequest: nil, syntaxMap: syntaxMap) }), + if let response = Request.send(cursorInfoRequest: cursorInfoRequest, atOffset: Int64(offset)).map({ process(dictionary: $0, cursorInfoRequest: nil, syntaxMap: syntaxMap) }), let kind = SwiftDocKey.getKind(response), SwiftDeclarationKind(rawValue: kind) != nil, let parentOffset = offsetMap[offset].flatMap({ Int64($0) }), - let inserted = insertDoc(response, parent: dictionary, offset: parentOffset) { + let inserted = insert(doc: response, parent: dictionary, offset: parentOffset) { dictionary = inserted } } @@ -231,7 +231,7 @@ public final class File { .map({ $0 as! [String: SourceKitRepresentable] }) .filter(isDeclarationOrCommentMark) .map { - processDictionary($0, cursorInfoRequest: cursorInfoRequest, syntaxMap: syntaxMap) + process(dictionary: $0, cursorInfoRequest: cursorInfoRequest, syntaxMap: syntaxMap) } } @@ -246,23 +246,23 @@ public final class File { return nil } // Only update dictionaries with a 'kind' key - if kind == SyntaxKind.CommentMark.rawValue, let markName = markNameFromDictionary(dictionary) { + if kind == SyntaxKind.commentMark.rawValue, let markName = parseMarkName(dictionary) { // Update comment marks - return [SwiftDocKey.Name.rawValue: markName] - } else if let decl = SwiftDeclarationKind(rawValue: kind), decl != .VarParameter { + return [SwiftDocKey.name.rawValue: markName] + } else if let decl = SwiftDeclarationKind(rawValue: kind), decl != .varParameter { // Update if kind is a declaration (but not a parameter) - var updateDict = Request.sendCursorInfoRequest(cursorInfoRequest, - atOffset: SwiftDocKey.getNameOffset(dictionary)!) ?? [String: SourceKitRepresentable]() + var updateDict = Request.send(cursorInfoRequest: cursorInfoRequest, + atOffset: SwiftDocKey.getNameOffset(dictionary)!) ?? [:] // Skip kinds, since values from editor.open are more accurate than cursorinfo - updateDict.removeValue(forKey: SwiftDocKey.Kind.rawValue) + updateDict.removeValue(forKey: SwiftDocKey.kind.rawValue) // Skip offset and length. // Their values are same with "key.nameoffset" and "key.namelength" in most case. // When kind is extension, their values locate **the type's declaration** in their declared file. // That may be different from the file declaring extension. - updateDict.removeValue(forKey: SwiftDocKey.Offset.rawValue) - updateDict.removeValue(forKey: SwiftDocKey.Length.rawValue) + updateDict.removeValue(forKey: SwiftDocKey.offset.rawValue) + updateDict.removeValue(forKey: SwiftDocKey.length.rawValue) return updateDict } return nil @@ -276,7 +276,7 @@ public final class File { - returns: True if a doc should be inserted in the parent at the provided offset. */ - private func shouldInsert(_ parent: [String: SourceKitRepresentable], offset: Int64) -> Bool { + private func shouldInsert(parent: [String: SourceKitRepresentable], offset: Int64) -> Bool { return SwiftDocKey.getSubstructure(parent) != nil && ((offset == 0) || (shouldTreatAsSameFile(parent) && SwiftDocKey.getNameOffset(parent) == offset)) @@ -293,9 +293,9 @@ public final class File { - returns: Parent with doc inserted if successful. */ - private func insertDoc(_ doc: [String: SourceKitRepresentable], parent: [String: SourceKitRepresentable], offset: Int64) -> [String: SourceKitRepresentable]? { + private func insert(doc: [String: SourceKitRepresentable], parent: [String: SourceKitRepresentable], offset: Int64) -> [String: SourceKitRepresentable]? { var parent = parent - if shouldInsert(parent, offset: offset) { + if shouldInsert(parent: parent, offset: offset) { var substructure = SwiftDocKey.getSubstructure(parent)! var insertIndex = substructure.count for (index, structure) in substructure.reversed().enumerated() { @@ -305,14 +305,14 @@ public final class File { insertIndex = substructure.count - index } substructure.insert(doc, at: insertIndex) - parent[SwiftDocKey.Substructure.rawValue] = substructure + parent[SwiftDocKey.substructure.rawValue] = substructure return parent } for key in parent.keys { if let subArray = parent[key] as? [SourceKitRepresentable] { var subArray = subArray for i in 0.. String? { - let isExtension = SwiftDocKey.getKind(dictionary).flatMap(SwiftDeclarationKind.init) == .Extension - let hasFullXMLDocs = dictionary.keys.contains(SwiftDocKey.FullXMLDocs.rawValue) + public func parseDocumentationCommentBody(_ dictionary: [String: SourceKitRepresentable], syntaxMap: SyntaxMap) -> String? { + let isExtension = SwiftDocKey.getKind(dictionary).flatMap(SwiftDeclarationKind.init) == .extension + let hasFullXMLDocs = dictionary.keys.contains(SwiftDocKey.fullXMLDocs.rawValue) let hasRawDocComment: Bool = { if !dictionary.keys.contains("key.attributes") { return false } let attributes = (dictionary["key.attributes"] as! [SourceKitRepresentable]) @@ -371,9 +371,9 @@ public final class File { guard hasDocumentationComment else { return nil } return (isExtension ? SwiftDocKey.getNameOffset(dictionary) : SwiftDocKey.getOffset(dictionary)).flatMap { offset in - return syntaxMap.commentRangeBeforeOffset(Int(offset)).flatMap { commentByteRange in + return syntaxMap.commentRange(beforeOffset: Int(offset)).flatMap { commentByteRange in return contents.byteRangeToNSRange(start: commentByteRange.lowerBound, length: commentByteRange.upperBound - commentByteRange.lowerBound).flatMap { nsRange in - return contents.commentBody(nsRange) + return contents.commentBody(range: nsRange) } } } @@ -387,8 +387,8 @@ Returns true if the dictionary represents a source declaration or a mark-style c */ private func isDeclarationOrCommentMark(_ dictionary: [String: SourceKitRepresentable]) -> Bool { if let kind = SwiftDocKey.getKind(dictionary) { - return kind != SwiftDeclarationKind.VarParameter.rawValue && - (kind == SyntaxKind.CommentMark.rawValue || SwiftDeclarationKind(rawValue: kind) != nil) + return kind != SwiftDeclarationKind.varParameter.rawValue && + (kind == SyntaxKind.commentMark.rawValue || SwiftDeclarationKind(rawValue: kind) != nil) } return false } @@ -407,43 +407,42 @@ public func parseFullXMLDocs(_ xmlDocs: String) -> [String: SourceKitRepresentab .replacingOccurrences(of: "", with: "`") return SWXMLHash.parse(cleanXMLDocs).children.first.map { rootXML in var docs = [String: SourceKitRepresentable]() - docs[SwiftDocKey.DocType.rawValue] = rootXML.element?.name - docs[SwiftDocKey.DocFile.rawValue] = rootXML.element?.allAttributes["file"]?.text - docs[SwiftDocKey.DocLine.rawValue] = (rootXML.element?.allAttributes["line"]?.text).flatMap { + docs[SwiftDocKey.docType.rawValue] = rootXML.element?.name + docs[SwiftDocKey.docFile.rawValue] = rootXML.element?.allAttributes["file"]?.text + docs[SwiftDocKey.docLine.rawValue] = (rootXML.element?.allAttributes["line"]?.text).flatMap { Int64($0) } - docs[SwiftDocKey.DocColumn.rawValue] = (rootXML.element?.allAttributes["column"]?.text).flatMap { + docs[SwiftDocKey.docColumn.rawValue] = (rootXML.element?.allAttributes["column"]?.text).flatMap { Int64($0) } - docs[SwiftDocKey.DocName.rawValue] = rootXML["Name"].element?.text - docs[SwiftDocKey.USR.rawValue] = rootXML["USR"].element?.text - docs[SwiftDocKey.DocDeclaration.rawValue] = rootXML["Declaration"].element?.text + docs[SwiftDocKey.docName.rawValue] = rootXML["Name"].element?.text + docs[SwiftDocKey.usr.rawValue] = rootXML["USR"].element?.text + docs[SwiftDocKey.docDeclaration.rawValue] = rootXML["Declaration"].element?.text let parameters = rootXML["Parameters"].children if parameters.count > 0 { - docs[SwiftDocKey.DocParameters.rawValue] = parameters.map { + docs[SwiftDocKey.docParameters.rawValue] = parameters.map { [ "name": $0["Name"].element?.text ?? "", - "discussion": childrenAsArray($0["Discussion"]) ?? [] + "discussion": $0["Discussion"].childrenAsArray() ?? [] ] as [String: SourceKitRepresentable] } as [SourceKitRepresentable] } - docs[SwiftDocKey.DocDiscussion.rawValue] = childrenAsArray(rootXML["Discussion"]) - docs[SwiftDocKey.DocResultDiscussion.rawValue] = childrenAsArray(rootXML["ResultDiscussion"]) + docs[SwiftDocKey.docDiscussion.rawValue] = rootXML["Discussion"].childrenAsArray() + docs[SwiftDocKey.docResultDiscussion.rawValue] = rootXML["ResultDiscussion"].childrenAsArray() return docs } } -/** -Returns an `[SourceKitRepresentable]` of `[String: SourceKitRepresentable]` items from `indexer` children, if any. - -- parameter indexer: `XMLIndexer` to traverse. -*/ -private func childrenAsArray(_ indexer: XMLIndexer) -> [SourceKitRepresentable]? { - let children = indexer.children - if children.count > 0 { +private extension XMLIndexer { + /** + Returns an `[SourceKitRepresentable]` of `[String: SourceKitRepresentable]` items from `indexer` children, if any. + */ + func childrenAsArray() -> [SourceKitRepresentable]? { + if children.isEmpty { + return nil + } return children.flatMap({ $0.element }).map { [$0.name: $0.text ?? ""] as [String: SourceKitRepresentable] } as [SourceKitRepresentable] } - return nil } diff --git a/Source/SourceKittenFramework/JSONOutput.swift b/Source/SourceKittenFramework/JSONOutput.swift index 7c3b00c0c..c7d3f96fa 100644 --- a/Source/SourceKittenFramework/JSONOutput.swift +++ b/Source/SourceKittenFramework/JSONOutput.swift @@ -74,29 +74,29 @@ private func toOutputDictionary(_ decl: SourceDeclaration) -> [String: Any] { } } - set(.Kind, decl.type.rawValue) - set(.FilePath, decl.location.file) - set(.DocFile, decl.location.file) - set(.DocLine, Int(decl.location.line)) - set(.DocColumn, Int(decl.location.column)) - set(.Name, decl.name) - set(.USR, decl.usr) - set(.ParsedDeclaration, decl.declaration) - set(.DocumentationComment, decl.commentBody) - set(.ParsedScopeStart, Int(decl.extent.start.line)) - set(.ParsedScopeEnd, Int(decl.extent.end.line)) - set(.SwiftDeclaration, decl.swiftDeclaration) - set(.AlwaysDeprecated, decl.availability?.alwaysDeprecated) - set(.AlwaysUnavailable, decl.availability?.alwaysUnavailable) - set(.DeprecationMessage, decl.availability?.deprecationMessage) - set(.UnavailableMessage, decl.availability?.unavailableMessage) - - setA(.DocResultDiscussion, decl.documentation?.returnDiscussion.map(toOutputDictionary)) - setA(.DocParameters, decl.documentation?.parameters.map(toOutputDictionary)) - setA(.Substructure, decl.children.map(toOutputDictionary)) + set(.kind, decl.type.rawValue) + set(.filePath, decl.location.file) + set(.docFile, decl.location.file) + set(.docLine, Int(decl.location.line)) + set(.docColumn, Int(decl.location.column)) + set(.name, decl.name) + set(.usr, decl.usr) + set(.parsedDeclaration, decl.declaration) + set(.documentationComment, decl.commentBody) + set(.parsedScopeStart, Int(decl.extent.start.line)) + set(.parsedScopeEnd, Int(decl.extent.end.line)) + set(.swiftDeclaration, decl.swiftDeclaration) + set(.alwaysDeprecated, decl.availability?.alwaysDeprecated) + set(.alwaysUnavailable, decl.availability?.alwaysUnavailable) + set(.deprecationMessage, decl.availability?.deprecationMessage) + set(.unavailableMessage, decl.availability?.unavailableMessage) + + setA(.docResultDiscussion, decl.documentation?.returnDiscussion.map(toOutputDictionary)) + setA(.docParameters, decl.documentation?.parameters.map(toOutputDictionary)) + setA(.substructure, decl.children.map(toOutputDictionary)) if decl.commentBody != nil { - set(.FullXMLDocs, "") + set(.fullXMLDocs, "") } return dict diff --git a/Source/SourceKittenFramework/Language.swift b/Source/SourceKittenFramework/Language.swift index 634f831e5..69f12567a 100644 --- a/Source/SourceKittenFramework/Language.swift +++ b/Source/SourceKittenFramework/Language.swift @@ -9,7 +9,7 @@ /// Language Enum. public enum Language { /// Swift. - case Swift + case swift /// Objective-C. - case ObjC + case objc } diff --git a/Source/SourceKittenFramework/Module.swift b/Source/SourceKittenFramework/Module.swift index 424fd2658..89a127b2d 100644 --- a/Source/SourceKittenFramework/Module.swift +++ b/Source/SourceKittenFramework/Module.swift @@ -70,8 +70,8 @@ public struct Module { - parameter path: Path to run `xcodebuild` from. Uses current path by default. */ public init?(xcodeBuildArguments: [String], name: String? = nil, inPath path: String = FileManager.default.currentDirectoryPath) { - let xcodeBuildOutput = runXcodeBuild(xcodeBuildArguments, inPath: path) ?? "" - guard let arguments = parseCompilerArguments(xcodeBuildOutput as NSString, language: .Swift, moduleName: name ?? moduleNameFromArguments(xcodeBuildArguments)) else { + let xcodeBuildOutput = runXcodeBuild(arguments: xcodeBuildArguments, inPath: path) ?? "" + guard let arguments = parseCompilerArguments(xcodebuildOutput: xcodeBuildOutput as NSString, language: .swift, moduleName: name ?? moduleName(fromArguments: xcodeBuildArguments)) else { fputs("Could not parse compiler arguments from `xcodebuild` output.\n", stderr) fputs("Please confirm that `xcodebuild` is building a Swift module.\n", stderr) let file = NSURL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("xcodebuild-\(NSUUID().uuidString).log") @@ -79,7 +79,7 @@ public struct Module { fputs("Saved `xcodebuild` log file: \(file!.path)\n", stderr) return nil } - guard let moduleName = moduleNameFromArguments(arguments) else { + guard let moduleName = moduleName(fromArguments: arguments) else { fputs("Could not parse module name from compiler arguments.\n", stderr) return nil } diff --git a/Source/SourceKittenFramework/ObjCDeclarationKind.swift b/Source/SourceKittenFramework/ObjCDeclarationKind.swift index 370fddf3e..a1e6c52bb 100644 --- a/Source/SourceKittenFramework/ObjCDeclarationKind.swift +++ b/Source/SourceKittenFramework/ObjCDeclarationKind.swift @@ -17,61 +17,61 @@ thing as SourceKit for Objective-C. */ public enum ObjCDeclarationKind: String { /// `category`. - case Category = "sourcekitten.source.lang.objc.decl.category" + case category = "sourcekitten.source.lang.objc.decl.category" /// `class`. - case Class = "sourcekitten.source.lang.objc.decl.class" + case `class` = "sourcekitten.source.lang.objc.decl.class" /// `constant`. - case Constant = "sourcekitten.source.lang.objc.decl.constant" + case constant = "sourcekitten.source.lang.objc.decl.constant" /// `enum`. - case Enum = "sourcekitten.source.lang.objc.decl.enum" + case `enum` = "sourcekitten.source.lang.objc.decl.enum" /// `enumcase`. - case Enumcase = "sourcekitten.source.lang.objc.decl.enumcase" + case enumcase = "sourcekitten.source.lang.objc.decl.enumcase" /// `initializer`. - case Initializer = "sourcekitten.source.lang.objc.decl.initializer" + case initializer = "sourcekitten.source.lang.objc.decl.initializer" /// `method.class`. - case MethodClass = "sourcekitten.source.lang.objc.decl.method.class" + case methodClass = "sourcekitten.source.lang.objc.decl.method.class" /// `method.instance`. - case MethodInstance = "sourcekitten.source.lang.objc.decl.method.instance" + case methodInstance = "sourcekitten.source.lang.objc.decl.method.instance" /// `property`. - case Property = "sourcekitten.source.lang.objc.decl.property" + case property = "sourcekitten.source.lang.objc.decl.property" /// `protocol`. - case `Protocol` = "sourcekitten.source.lang.objc.decl.protocol" + case `protocol` = "sourcekitten.source.lang.objc.decl.protocol" /// `typedef`. - case Typedef = "sourcekitten.source.lang.objc.decl.typedef" + case typedef = "sourcekitten.source.lang.objc.decl.typedef" /// `function`. - case Function = "sourcekitten.source.lang.objc.decl.function" + case function = "sourcekitten.source.lang.objc.decl.function" /// `mark`. - case Mark = "sourcekitten.source.lang.objc.mark" + case mark = "sourcekitten.source.lang.objc.mark" /// `struct` - case Struct = "sourcekitten.source.lang.objc.decl.struct" + case `struct` = "sourcekitten.source.lang.objc.decl.struct" /// `field` - case Field = "sourcekitten.source.lang.objc.decl.field" + case field = "sourcekitten.source.lang.objc.decl.field" /// `ivar` - case Ivar = "sourcekitten.source.lang.objc.decl.ivar" + case ivar = "sourcekitten.source.lang.objc.decl.ivar" /// `ModuleImport` - case ModuleImport = "sourcekitten.source.lang.objc.module.import" + case moduleImport = "sourcekitten.source.lang.objc.module.import" /// `UnexposedDecl` - case UnexposedDecl = "sourcekitten.source.lang.objc.decl.unexposed" + case unexposedDecl = "sourcekitten.source.lang.objc.decl.unexposed" - public static func fromClang(_ kind: CXCursorKind) -> ObjCDeclarationKind { - switch kind.rawValue { - case CXCursor_ObjCCategoryDecl.rawValue: return .Category - case CXCursor_ObjCInterfaceDecl.rawValue: return .Class - case CXCursor_EnumDecl.rawValue: return .Enum - case CXCursor_EnumConstantDecl.rawValue: return .Enumcase - case CXCursor_ObjCClassMethodDecl.rawValue: return .MethodClass - case CXCursor_ObjCInstanceMethodDecl.rawValue: return .MethodInstance - case CXCursor_ObjCPropertyDecl.rawValue: return .Property - case CXCursor_ObjCProtocolDecl.rawValue: return .Protocol - case CXCursor_TypedefDecl.rawValue: return .Typedef - case CXCursor_VarDecl.rawValue: return .Constant - case CXCursor_FunctionDecl.rawValue: return .Function - case CXCursor_StructDecl.rawValue: return .Struct - case CXCursor_FieldDecl.rawValue: return .Field - case CXCursor_ObjCIvarDecl.rawValue: return .Ivar - case CXCursor_ModuleImportDecl.rawValue: return .ModuleImport - case CXCursor_UnexposedDecl.rawValue: return .UnexposedDecl - default: fatalError("Unsupported CXCursorKind: \(clang_getCursorKindSpelling(kind))") + public init(_ cursorKind: CXCursorKind) { + switch cursorKind { + case CXCursor_ObjCCategoryDecl: self = .category + case CXCursor_ObjCInterfaceDecl: self = .class + case CXCursor_EnumDecl: self = .enum + case CXCursor_EnumConstantDecl: self = .enumcase + case CXCursor_ObjCClassMethodDecl: self = .methodClass + case CXCursor_ObjCInstanceMethodDecl: self = .methodInstance + case CXCursor_ObjCPropertyDecl: self = .property + case CXCursor_ObjCProtocolDecl: self = .protocol + case CXCursor_TypedefDecl: self = .typedef + case CXCursor_VarDecl: self = .constant + case CXCursor_FunctionDecl: self = .function + case CXCursor_StructDecl: self = .struct + case CXCursor_FieldDecl: self = .field + case CXCursor_ObjCIvarDecl: self = .ivar + case CXCursor_ModuleImportDecl: self = .moduleImport + case CXCursor_UnexposedDecl: self = .unexposedDecl + default: fatalError("Unsupported CXCursorKind: \(clang_getCursorKindSpelling(cursorKind))") } } } diff --git a/Source/SourceKittenFramework/OffsetMap.swift b/Source/SourceKittenFramework/OffsetMap.swift index 1e7511daa..8083d7147 100644 --- a/Source/SourceKittenFramework/OffsetMap.swift +++ b/Source/SourceKittenFramework/OffsetMap.swift @@ -23,7 +23,7 @@ extension File { - returns: OffsetMap containing offset locations at which there are declarations that likely have documentation comments, but haven't been documented by SourceKitten yet. */ - public func generateOffsetMap(_ documentedTokenOffsets: [Int], dictionary: [String: SourceKitRepresentable]) -> OffsetMap { + public func makeOffsetMap(documentedTokenOffsets: [Int], dictionary: [String: SourceKitRepresentable]) -> OffsetMap { var offsetMap = OffsetMap() for offset in documentedTokenOffsets { offsetMap[offset] = 0 diff --git a/Source/SourceKittenFramework/Request.swift b/Source/SourceKittenFramework/Request.swift index 2316eb8e4..2202717f2 100644 --- a/Source/SourceKittenFramework/Request.swift +++ b/Source/SourceKittenFramework/Request.swift @@ -71,7 +71,7 @@ private func fromSourceKit(_ sourcekitObject: sourcekitd_variant_t) -> SourceKit } var dict = [String: SourceKitRepresentable](minimumCapacity: count) _ = sourcekitd_variant_dictionary_apply(sourcekitObject) { key, value in - if let key = stringForSourceKitUID(key!), let value = fromSourceKit(value) { + if let key = String(sourceKitUID: key!), let value = fromSourceKit(value) { dict[key] = value } return true @@ -80,14 +80,13 @@ private func fromSourceKit(_ sourcekitObject: sourcekitd_variant_t) -> SourceKit case SOURCEKITD_VARIANT_TYPE_STRING: let length = sourcekitd_variant_string_get_length(sourcekitObject) let ptr = sourcekitd_variant_string_get_ptr(sourcekitObject) - let string = swiftStringFrom(ptr!, length: length) - return string + return String(bytes: ptr!, length: length) case SOURCEKITD_VARIANT_TYPE_INT64: return sourcekitd_variant_int64_get_value(sourcekitObject) case SOURCEKITD_VARIANT_TYPE_BOOL: return sourcekitd_variant_bool_get_value(sourcekitObject) case SOURCEKITD_VARIANT_TYPE_UID: - return stringForSourceKitUID(sourcekitd_variant_uid_get_value(sourcekitObject)) + return String(sourceKitUID: sourcekitd_variant_uid_get_value(sourcekitObject)) case SOURCEKITD_VARIANT_TYPE_NULL: return nil default: @@ -117,101 +116,103 @@ private var sourceKitWaitingRestoredSemaphore = DispatchSemaphore(value: 0) /// SourceKit UID to String map. private var uidStringMap = [sourcekitd_uid_t: String]() -/** -Cache SourceKit requests for strings from UIDs - -- parameter uid: UID received from sourcekitd* responses. +private extension String { + /** + Cache SourceKit requests for strings from UIDs -- returns: Cached UID string if available, nil otherwise. -*/ -internal func stringForSourceKitUID(_ uid: sourcekitd_uid_t) -> String? { - if let string = uidStringMap[uid] { - return string - } - let length = sourcekitd_uid_get_length(uid) - let bytes = sourcekitd_uid_get_string_ptr(uid) - if let uidString = swiftStringFrom(bytes!, length: length) { - /* - `String` created by `String(UTF8String:)` is based on `NSString`. - `NSString` base `String` has performance penalty on getting `hashValue`. - Everytime on getting `hashValue`, it calls `decomposedStringWithCanonicalMapping` for - "Unicode Normalization Form D" and creates autoreleased `CFString (mutable)` and - `CFString (store)`. Those `CFString` are created every time on using `hashValue`, such as - using `String` for Dictionary's key or adding to Set. - - For avoiding those penalty, replaces with enum's rawValue String if defined in SourceKitten. - That does not cause calling `decomposedStringWithCanonicalMapping`. - */ - let uidString = sourceKittenRawValueStringFrom(uidString) ?? "\(uidString)" - uidStringMap[uid] = uidString - return uidString + - returns: Cached UID string if available, nil otherwise. + */ + init?(sourceKitUID: sourcekitd_uid_t) { + if let string = uidStringMap[sourceKitUID] { + self = string + return + } + let length = sourcekitd_uid_get_length(sourceKitUID) + let bytes = sourcekitd_uid_get_string_ptr(sourceKitUID) + if let uidString = String(bytes: bytes!, length: length) { + /* + `String` created by `String(UTF8String:)` is based on `NSString`. + `NSString` base `String` has performance penalty on getting `hashValue`. + Everytime on getting `hashValue`, it calls `decomposedStringWithCanonicalMapping` for + "Unicode Normalization Form D" and creates autoreleased `CFString (mutable)` and + `CFString (store)`. Those `CFString` are created every time on using `hashValue`, such as + using `String` for Dictionary's key or adding to Set. + + For avoiding those penalty, replaces with enum's rawValue String if defined in SourceKitten. + That does not cause calling `decomposedStringWithCanonicalMapping`. + */ + let uidString = String(uidString: uidString) + uidStringMap[sourceKitUID] = uidString + self = uidString + return + } + return nil } - return nil -} - -/** -Returns SourceKitten defined enum's rawValue String from string -- parameter uidString: String created from sourcekitd_uid_get_string_ptr(). - -- returns: rawValue String if defined in SourceKitten, nil otherwise. -*/ -private func sourceKittenRawValueStringFrom(_ uidString: String) -> String? { - return SwiftDocKey(rawValue: uidString)?.rawValue ?? - SwiftDeclarationKind(rawValue: uidString)?.rawValue ?? - SyntaxKind(rawValue: uidString)?.rawValue -} + /** + Assigns SourceKitten defined enum's rawValue String from string. + rawValue String if defined in SourceKitten, nil otherwise. + + - parameter uidString: String created from sourcekitd_uid_get_string_ptr(). + */ + init(uidString: String) { + self = SwiftDocKey(rawValue: uidString)?.rawValue ?? + SwiftDeclarationKind(rawValue: uidString)?.rawValue ?? + SyntaxKind(rawValue: uidString)?.rawValue ?? "\(uidString)" + } -/** -Returns Swift's native String from NSUTF8StringEncoding bytes and length - -`String(bytesNoCopy:length:encoding:)` creates `String` based on `NSString`. -That is slower than Swift's native String on some scene. - -- parameter bytes: UnsafePointer -- parameter length: length of bytes - -- returns: String Swift's native String -*/ -private func swiftStringFrom(_ bytes: UnsafePointer, length: Int) -> String? { - let pointer = UnsafeMutablePointer(mutating: bytes) - // It seems SourceKitService returns string in other than NSUTF8StringEncoding. - // We'll try another encodings if fail. - for encoding in [String.Encoding.utf8, .nextstep, .ascii] { - if let string = String(bytesNoCopy: pointer, length: length, encoding: encoding, - freeWhenDone: false) { - return "\(string)" + /** + Returns Swift's native String from NSUTF8StringEncoding bytes and length + + `String(bytesNoCopy:length:encoding:)` creates `String` based on `NSString`. + That is slower than Swift's native String on some scene. + + - parameter bytes: UnsafePointer + - parameter length: length of bytes + + - returns: String Swift's native String + */ + init?(bytes: UnsafePointer, length: Int) { + let pointer = UnsafeMutablePointer(mutating: bytes) + // It seems SourceKitService returns string in other than NSUTF8StringEncoding. + // We'll try another encodings if fail. + for encoding in [String.Encoding.utf8, .nextstep, .ascii] { + if let string = String(bytesNoCopy: pointer, length: length, encoding: encoding, + freeWhenDone: false) { + self = "\(string)" + return + } } + return nil } - return nil } /// Represents a SourceKit request. public enum Request { /// An `editor.open` request for the given File. - case EditorOpen(File) + case editorOpen(file: File) /// A `cursorinfo` request for an offset in the given file, using the `arguments` given. - case CursorInfo(file: String, offset: Int64, arguments: [String]) + case cursorInfo(file: String, offset: Int64, arguments: [String]) /// A custom request by passing in the sourcekitd_object_t directly. - case CustomRequest(sourcekitd_object_t) + case customRequest(request: sourcekitd_object_t) /// A `codecomplete` request by passing in the file name, contents, offset /// for which to generate code completion options and array of compiler arguments. - case CodeCompletionRequest(file: String, contents: String, offset: Int64, arguments: [String]) + case codeCompletionRequest(file: String, contents: String, offset: Int64, arguments: [String]) /// ObjC Swift Interface - case Interface(file: String, uuid: String) + case interface(file: String, uuid: String) /// Find USR - case FindUSR(file: String, usr: String) + case findUSR(file: String, usr: String) /// Index - case Index(file: String, arguments: [String]) + case index(file: String, arguments: [String]) /// Format - case Format(file: String, line: Int64, useTabs: Bool, indentWidth: Int64) + case format(file: String, line: Int64, useTabs: Bool, indentWidth: Int64) /// ReplaceText - case ReplaceText(file: String, offset: Int64, length: Int64, sourceText: String) + case replaceText(file: String, offset: Int64, length: Int64, sourceText: String) fileprivate var sourcekitObject: sourcekitd_object_t { let dict: [sourcekitd_uid_t: sourcekitd_object_t?] switch self { - case .EditorOpen(let file): + case .editorOpen(let file): if let path = file.path { dict = [ sourcekitd_uid_get_from_cstr("key.request"): sourcekitd_request_uid_create(sourcekitd_uid_get_from_cstr("source.request.editor.open")), @@ -225,7 +226,7 @@ public enum Request { sourcekitd_uid_get_from_cstr("key.sourcetext"): sourcekitd_request_string_create(file.contents) ] } - case .CursorInfo(let file, let offset, let arguments): + case .cursorInfo(let file, let offset, let arguments): var compilerargs = arguments.map({ sourcekitd_request_string_create($0) }) dict = [ sourcekitd_uid_get_from_cstr("key.request"): sourcekitd_request_uid_create(sourcekitd_uid_get_from_cstr("source.request.cursorinfo")), @@ -234,9 +235,9 @@ public enum Request { sourcekitd_uid_get_from_cstr("key.offset"): sourcekitd_request_int64_create(offset), sourcekitd_uid_get_from_cstr("key.compilerargs"): sourcekitd_request_array_create(&compilerargs, compilerargs.count) ] - case .CustomRequest(let request): + case .customRequest(let request): return request - case .CodeCompletionRequest(let file, let contents, let offset, let arguments): + case .codeCompletionRequest(let file, let contents, let offset, let arguments): var compilerargs = arguments.map({ sourcekitd_request_string_create($0) }) dict = [ sourcekitd_uid_get_from_cstr("key.request"): sourcekitd_request_uid_create(sourcekitd_uid_get_from_cstr("source.request.codecomplete")), @@ -246,7 +247,7 @@ public enum Request { sourcekitd_uid_get_from_cstr("key.offset"): sourcekitd_request_int64_create(offset), sourcekitd_uid_get_from_cstr("key.compilerargs"): sourcekitd_request_array_create(&compilerargs, compilerargs.count) ] - case .Interface(let file, let uuid): + case .interface(let file, let uuid): let arguments = ["-x", "objective-c", file, "-isysroot", sdkPath()] var compilerargs = arguments.map({ sourcekitd_request_string_create($0) }) dict = [ @@ -255,20 +256,20 @@ public enum Request { sourcekitd_uid_get_from_cstr("key.filepath"): sourcekitd_request_string_create(file), sourcekitd_uid_get_from_cstr("key.compilerargs"): sourcekitd_request_array_create(&compilerargs, compilerargs.count) ] - case .FindUSR(let file, let usr): + case .findUSR(let file, let usr): dict = [ sourcekitd_uid_get_from_cstr("key.request"): sourcekitd_request_uid_create(sourcekitd_uid_get_from_cstr("source.request.editor.find_usr")), sourcekitd_uid_get_from_cstr("key.usr"): sourcekitd_request_string_create(usr), sourcekitd_uid_get_from_cstr("key.sourcefile"): sourcekitd_request_string_create(file) ] - case .Index(let file, let arguments): + case .index(let file, let arguments): var compilerargs = arguments.map({ sourcekitd_request_string_create($0) }) dict = [ sourcekitd_uid_get_from_cstr("key.request"): sourcekitd_request_uid_create(sourcekitd_uid_get_from_cstr("source.request.indexsource")), sourcekitd_uid_get_from_cstr("key.sourcefile"): sourcekitd_request_string_create(file), sourcekitd_uid_get_from_cstr("key.compilerargs"): sourcekitd_request_array_create(&compilerargs, compilerargs.count) ] - case .Format(let file, let line, let useTabs, let indentWidth): + case .format(let file, let line, let useTabs, let indentWidth): let formatOptions = [ sourcekitd_uid_get_from_cstr("key.editor.format.indentwidth"): sourcekitd_request_int64_create(indentWidth), sourcekitd_uid_get_from_cstr("key.editor.format.tabwidth"): sourcekitd_request_int64_create(indentWidth), @@ -282,7 +283,7 @@ public enum Request { sourcekitd_uid_get_from_cstr("key.line"): sourcekitd_request_int64_create(line), sourcekitd_uid_get_from_cstr("key.editor.format.options"): sourcekitd_request_dictionary_create(&formatOptionsKeys, &formatOptionsValues, formatOptions.count) ] - case .ReplaceText(let file, let offset, let length, let sourceText): + case .replaceText(let file, let offset, let length, let sourceText): dict = [ sourcekitd_uid_get_from_cstr("key.request"): sourcekitd_request_uid_create(sourcekitd_uid_get_from_cstr("source.request.editor.replacetext")), sourcekitd_uid_get_from_cstr("key.name"): sourcekitd_request_string_create(file), @@ -304,9 +305,9 @@ public enum Request { - returns: sourcekitd_object_t representation of the Request, if successful. */ - internal static func cursorInfoRequestForFilePath(_ filePath: String?, arguments: [String]) -> sourcekitd_object_t? { + internal static func cursorInfoRequest(filePath: String?, arguments: [String]) -> sourcekitd_object_t? { if let path = filePath { - return Request.CursorInfo(file: path, offset: 0, arguments: arguments).sourcekitObject + return Request.cursorInfo(file: path, offset: 0, arguments: arguments).sourcekitObject } return nil } @@ -314,17 +315,17 @@ public enum Request { /** Send a Request.CursorInfo by updating its offset. Returns SourceKit response if successful. - - parameter request: sourcekitd_object_t representation of Request.CursorInfo - - parameter offset: Offset to update request. + - parameter cursorInfoRequest: sourcekitd_object_t representation of Request.CursorInfo + - parameter offset: Offset to update request. - returns: SourceKit response if successful. */ - internal static func sendCursorInfoRequest(_ request: sourcekitd_object_t, atOffset offset: Int64) -> [String: SourceKitRepresentable]? { + internal static func send(cursorInfoRequest: sourcekitd_object_t, atOffset offset: Int64) -> [String: SourceKitRepresentable]? { if offset == 0 { return nil } - sourcekitd_request_dictionary_set_int64(request, sourcekitd_uid_get_from_cstr(SwiftDocKey.Offset.rawValue), offset) - return try? Request.CustomRequest(request).failableSend() + sourcekitd_request_dictionary_set_int64(cursorInfoRequest, sourcekitd_uid_get_from_cstr(SwiftDocKey.offset.rawValue), offset) + return try? Request.customRequest(request: cursorInfoRequest).failableSend() } /** @@ -341,12 +342,12 @@ public enum Request { /// A enum representation of SOURCEKITD_ERROR_* public enum Error: Swift.Error, CustomStringConvertible { - case ConnectionInterrupted(String?) - case Invalid(String?) - case Failed(String?) - case Cancelled(String?) - case Unknown(String?) - + case connectionInterrupted(String?) + case invalid(String?) + case failed(String?) + case cancelled(String?) + case unknown(String?) + /// A textual representation of `self`. public var description: String { return getDescription() ?? "no description" @@ -354,22 +355,22 @@ public enum Request { private func getDescription() -> String? { switch self { - case .ConnectionInterrupted(let string): return string - case .Invalid(let string): return string - case .Failed(let string): return string - case .Cancelled(let string): return string - case .Unknown(let string): return string + case .connectionInterrupted(let string): return string + case .invalid(let string): return string + case .failed(let string): return string + case .cancelled(let string): return string + case .unknown(let string): return string } } fileprivate init(response: sourcekitd_response_t) { let description = String(validatingUTF8: sourcekitd_response_error_get_description(response)!) switch sourcekitd_response_error_get_kind(response) { - case SOURCEKITD_ERROR_CONNECTION_INTERRUPTED: self = .ConnectionInterrupted(description) - case SOURCEKITD_ERROR_REQUEST_INVALID: self = .Invalid(description) - case SOURCEKITD_ERROR_REQUEST_FAILED: self = .Failed(description) - case SOURCEKITD_ERROR_REQUEST_CANCELLED: self = .Cancelled(description) - default: self = .Unknown(description) + case SOURCEKITD_ERROR_CONNECTION_INTERRUPTED: self = .connectionInterrupted(description) + case SOURCEKITD_ERROR_REQUEST_INVALID: self = .invalid(description) + case SOURCEKITD_ERROR_REQUEST_FAILED: self = .failed(description) + case SOURCEKITD_ERROR_REQUEST_CANCELLED: self = .cancelled(description) + default: self = .unknown(description) } } } @@ -386,7 +387,7 @@ public enum Request { defer { sourcekitd_response_dispose(response!) } if sourcekitd_response_is_error(response!) { let error = Request.Error(response: response!) - if case .ConnectionInterrupted = error { + if case .connectionInterrupted = error { _ = sourceKitWaitingRestoredSemaphore.wait(timeout: DispatchTime.now() + 10) } throw error @@ -412,7 +413,7 @@ private func interfaceForModule(_ module: String, compilerArguments: [String]) - ] var keys = Array(dict.keys.map({ $0 as sourcekitd_uid_t? })) var values = Array(dict.values) - return Request.CustomRequest(sourcekitd_request_dictionary_create(&keys, &values, dict.count)).send() + return Request.customRequest(request: sourcekitd_request_dictionary_create(&keys, &values, dict.count)).send() } internal func libraryWrapperForModule(_ module: String, loadPath: String, spmModule: String, compilerArguments: [String]) -> String { @@ -420,7 +421,7 @@ internal func libraryWrapperForModule(_ module: String, loadPath: String, spmMod let substructure = SwiftDocKey.getSubstructure(Structure(sourceKitResponse: sourceKitResponse).dictionary)!.map({ $0 as! [String: SourceKitRepresentable] }) let source = sourceKitResponse["key.sourcetext"] as! String let freeFunctions = substructure.filter({ - SwiftDeclarationKind(rawValue: SwiftDocKey.getKind($0)!) == .FunctionFree + SwiftDeclarationKind(rawValue: SwiftDocKey.getKind($0)!) == .functionFree }).flatMap { function -> String? in let fullFunctionName = function["key.name"] as! String let name = fullFunctionName.substring(to: fullFunctionName.range(of: "(")!.lowerBound) @@ -444,9 +445,9 @@ internal func libraryWrapperForModule(_ module: String, loadPath: String, spmMod } } - return "internal let \(name): @convention(c) (\(parameters.map({ $0.replacingOccurrences(of: "!", with: "?") }).joined(separator: ", "))) -> (\(returnTypes.joined(separator: ", "))) = library.loadSymbol(\"\(name)\")".replacingOccurrences(of: "SourceKittenFramework.", with: "") + return "internal let \(name): @convention(c) (\(parameters.map({ $0.replacingOccurrences(of: "!", with: "?") }).joined(separator: ", "))) -> (\(returnTypes.joined(separator: ", "))) = library.load(symbol: \"\(name)\")".replacingOccurrences(of: "SourceKittenFramework.", with: "") } let spmImport = "#if SWIFT_PACKAGE\nimport \(spmModule)\n#endif\n" - let library = "private let library = toolchainLoader.load(\"\(loadPath)\")\n" + let library = "private let library = toolchainLoader.load(path: \"\(loadPath)\")\n" return spmImport + library + freeFunctions.joined(separator: "\n") + "\n" } diff --git a/Source/SourceKittenFramework/SourceDeclaration.swift b/Source/SourceKittenFramework/SourceDeclaration.swift index 5c3f38f7d..367102372 100644 --- a/Source/SourceKittenFramework/SourceDeclaration.swift +++ b/Source/SourceKittenFramework/SourceDeclaration.swift @@ -11,18 +11,18 @@ import Clang_C #endif import Foundation -public func insertMarks(_ declarations: [SourceDeclaration], limitRange: NSRange? = nil) -> [SourceDeclaration] { +public func insertMarks(declarations: [SourceDeclaration], limit: NSRange? = nil) -> [SourceDeclaration] { guard declarations.count > 0 else { return [] } guard let path = declarations.first?.location.file, let file = File(path: path) else { fatalError("can't extract marks without a file.") } - let currentMarks = file.contents.pragmaMarks(path, excludeRanges: declarations.map({ + let currentMarks = file.contents.pragmaMarks(filename: path, excludeRanges: declarations.map({ file.contents.byteRangeToNSRange(start: $0.range.location, length: $0.range.length) ?? NSRange() - }), limitRange: limitRange) + }), limit: limit) let newDeclarations: [SourceDeclaration] = declarations.map { declaration in var varDeclaration = declaration let range = file.contents.byteRangeToNSRange(start: declaration.range.location, length: declaration.range.length) - varDeclaration.children = insertMarks(declaration.children, limitRange: range) + varDeclaration.children = insertMarks(declarations: declaration.children, limit: range) return varDeclaration } return (newDeclarations + currentMarks).sorted() @@ -44,25 +44,25 @@ public struct SourceDeclaration { /// Range var range: NSRange { - return extent.start.rangeToEndLocation(extent.end) + return extent.start.range(toEnd: extent.end) } /// Returns the USR for the auto-generated getter for this property. /// /// - warning: can only be invoked if `type == .Property`. var getterUSR: String { - return generateAccessorUSR(getter: true) + return accessorUSR(getter: true) } /// Returns the USR for the auto-generated setter for this property. /// /// - warning: can only be invoked if `type == .Property`. var setterUSR: String { - return generateAccessorUSR(getter: false) + return accessorUSR(getter: false) } - private func generateAccessorUSR(getter: Bool) -> String { - assert(type == .Property) + private func accessorUSR(getter: Bool) -> String { + assert(type == .property) guard let usr = usr else { fatalError("Couldn't extract USR") } @@ -103,7 +103,7 @@ extension SourceDeclaration { children = cursor.flatMap({ SourceDeclaration(cursor: $0, compilerArguments: compilerArguments) }).rejectPropertyMethods() - swiftDeclaration = cursor.swiftDeclaration(compilerArguments) + swiftDeclaration = cursor.swiftDeclaration(compilerArguments: compilerArguments) availability = cursor.platformAvailability() } } @@ -112,7 +112,7 @@ extension Sequence where Iterator.Element == SourceDeclaration { /// Removes implicitly generated property getters & setters func rejectPropertyMethods() -> [SourceDeclaration] { let propertyGetterSetterUSRs = filter { - $0.type == .Property + $0.type == .property }.flatMap { [$0.getterUSR, $0.setterUSR] } diff --git a/Source/SourceKittenFramework/SourceLocation.swift b/Source/SourceKittenFramework/SourceLocation.swift index cc9af5d20..668e6bedf 100644 --- a/Source/SourceKittenFramework/SourceLocation.swift +++ b/Source/SourceKittenFramework/SourceLocation.swift @@ -17,7 +17,7 @@ public struct SourceLocation { let column: UInt32 let offset: UInt32 - public func rangeToEndLocation(_ end: SourceLocation) -> NSRange { + public func range(toEnd end: SourceLocation) -> NSRange { return NSRange(location: Int(offset), length: Int(end.offset - offset)) } } diff --git a/Source/SourceKittenFramework/StatementKind.swift b/Source/SourceKittenFramework/StatementKind.swift index b9d0d20ed..c629d2517 100644 --- a/Source/SourceKittenFramework/StatementKind.swift +++ b/Source/SourceKittenFramework/StatementKind.swift @@ -10,25 +10,21 @@ /// Found in `strings SourceKitService | grep source.lang.swift.stmt.`. public enum StatementKind: String, SwiftLangSyntax { /// `brace`. - case Brace = "source.lang.swift.stmt.brace" + case brace = "source.lang.swift.stmt.brace" /// `case`. - case Case = "source.lang.swift.stmt.case" + case `case` = "source.lang.swift.stmt.case" /// `for`. - case For = "source.lang.swift.stmt.for" + case `for` = "source.lang.swift.stmt.for" /// `foreach`. - case ForEach = "source.lang.swift.stmt.foreach" + case forEach = "source.lang.swift.stmt.foreach" /// `guard`. - case Guard = "source.lang.swift.stmt.guard" + case `guard` = "source.lang.swift.stmt.guard" /// `if`. - case If = "source.lang.swift.stmt.if" + case `if` = "source.lang.swift.stmt.if" /// `repeatewhile`. - case RepeatWhile = "source.lang.swift.stmt.repeatwhile" + case repeatWhile = "source.lang.swift.stmt.repeatwhile" /// `switch`. - case Switch = "source.lang.swift.stmt.switch" + case `switch` = "source.lang.swift.stmt.switch" /// `while`. - case While = "source.lang.swift.stmt.while" - - public var value: String { - return rawValue - } + case `while` = "source.lang.swift.stmt.while" } diff --git a/Source/SourceKittenFramework/String+SourceKitten.swift b/Source/SourceKittenFramework/String+SourceKitten.swift index ecbf99e15..75b2dd671 100644 --- a/Source/SourceKittenFramework/String+SourceKitten.swift +++ b/Source/SourceKittenFramework/String+SourceKitten.swift @@ -108,7 +108,7 @@ extension NSString { - returns: UTF16 based offset of string. */ - func locationFromByteOffset(_ byteOffset: Int) -> Int { + func location(fromByteOffset byteOffset: Int) -> Int { if lines.isEmpty { return 0 } @@ -137,7 +137,7 @@ extension NSString { - returns: UTF8 based offset of string. */ - func byteOffsetFromLocation(_ location: Int) -> Int { + func byteOffset(fromLocation location: Int) -> Int { if lines.isEmpty { return 0 } @@ -159,7 +159,7 @@ extension NSString { return line.byteRange.location + byteDiff } - func lineAndCharacterForCharacterOffset(_ offset: Int) -> (line: Int, character: Int)? { + func lineAndCharacter(forCharacterOffset offset: Int) -> (line: Int, character: Int)? { let index = lines.index(where: { NSLocationInRange(offset, $0.range) }) return index.map { let line = lines[$0] @@ -167,7 +167,7 @@ extension NSString { } } - func lineAndCharacterForByteOffset(_ offset: Int) -> (line: Int, character: Int)? { + func lineAndCharacter(forByteOffset offset: Int) -> (line: Int, character: Int)? { let index = lines.index(where: { NSLocationInRange(offset, $0.byteRange) }) return index.map { let line = lines[$0] @@ -205,8 +205,8 @@ extension NSString { - parameter offset: utf16 based index. */ - public func lineAndCharacterForCharacterOffset(_ offset: Int) -> (line: Int, character: Int)? { - return cacheContainer.lineAndCharacterForCharacterOffset(offset) + public func lineAndCharacter(forCharacterOffset offset: Int) -> (line: Int, character: Int)? { + return cacheContainer.lineAndCharacter(forCharacterOffset: offset) } /** @@ -214,8 +214,8 @@ extension NSString { - parameter offset: byte offset. */ - public func lineAndCharacterForByteOffset(_ offset: Int) -> (line: Int, character: Int)? { - return cacheContainer.lineAndCharacterForByteOffset(offset) + public func lineAndCharacter(forByteOffset offset: Int) -> (line: Int, character: Int)? { + return cacheContainer.lineAndCharacter(forByteOffset: offset) } /** @@ -224,7 +224,7 @@ extension NSString { - parameter characterSet: Character set to check for membership. */ - public func stringByTrimmingTrailingCharactersInSet(_ characterSet: CharacterSet) -> String { + public func trimmingTrailingCharacters(in characterSet: CharacterSet) -> String { if length == 0 { return "" } @@ -243,7 +243,7 @@ extension NSString { - parameter rootDirectory: Absolute parent path if not already an absolute path. */ - public func absolutePathRepresentation(_ rootDirectory: String = FileManager.default.currentDirectoryPath) -> String { + public func absolutePathRepresentation(rootDirectory: String = FileManager.default.currentDirectoryPath) -> String { if isAbsolutePath { return self as String } return (NSString.path(withComponents: [rootDirectory, self as String]) as NSString).standardizingPath } @@ -259,11 +259,11 @@ extension NSString { */ public func byteRangeToNSRange(start: Int, length: Int) -> NSRange? { if self.length == 0 { return nil } - let utf16Start = cacheContainer.locationFromByteOffset(start) + let utf16Start = cacheContainer.location(fromByteOffset: start) if length == 0 { return NSRange(location: utf16Start, length: 0) } - let utf16End = cacheContainer.locationFromByteOffset(start + length) + let utf16End = cacheContainer.location(fromByteOffset: start + length) return NSRange(location: utf16Start, length: utf16End - utf16Start) } @@ -296,7 +296,7 @@ extension NSString { // 2. Using cache is overkill for short string. let byteOffset: Int if utf16View.count > 50 { - byteOffset = cacheContainer.byteOffsetFromLocation(start) + byteOffset = cacheContainer.byteOffset(fromLocation: start) } else { byteOffset = utf8View.distance(from: utf8View.startIndex, to: startUTF8Index) } @@ -387,7 +387,7 @@ extension NSString { /** Returns a substring from a start and end SourceLocation. */ - public func substringWithSourceRange(_ start: SourceLocation, end: SourceLocation) -> String? { + public func substringWithSourceRange(start: SourceLocation, end: SourceLocation) -> String? { return substringWithByteRange(start: Int(start.offset), length: Int(end.offset - start.offset)) } } @@ -399,11 +399,11 @@ extension String { /// Returns the `#pragma mark`s in the string. /// Just the content; no leading dashes or leading `#pragma mark`. - public func pragmaMarks(_ filename: String, excludeRanges: [NSRange], limitRange: NSRange?) -> [SourceDeclaration] { + public func pragmaMarks(filename: String, excludeRanges: [NSRange], limit: NSRange?) -> [SourceDeclaration] { let regex = try! NSRegularExpression(pattern: "(#pragma\\smark|@name)[ -]*([^\\n]+)", options: []) // Safe to force try let range: NSRange - if let limitRange = limitRange { - range = NSRange(location: limitRange.location, length: min(utf16.count - limitRange.location, limitRange.length)) + if let limit = limit { + range = NSRange(location: limit.location, length: min(utf16.count - limit.location, limit.length)) } else { range = NSRange(location: 0, length: utf16.count) } @@ -426,7 +426,7 @@ extension String { let location = SourceLocation(file: filename, line: UInt32((self as NSString).lineRangeWithByteRange(start: markByteRange.location, length: 0)!.start), column: 1, offset: UInt32(markByteRange.location)) - return SourceDeclaration(type: .Mark, location: location, extent: (location, location), name: markString, + return SourceDeclaration(type: .mark, location: location, extent: (location, location), name: markString, usr: nil, declaration: nil, documentation: nil, commentBody: nil, children: [], swiftDeclaration: nil, availability: nil) } } @@ -442,12 +442,12 @@ extension String { - parameter token: Token to process. */ public func isTokenDocumentable(token: SyntaxToken) -> Bool { - if token.type == SyntaxKind.Keyword.rawValue { + if token.type == SyntaxKind.keyword.rawValue { let keywordFunctions = ["subscript", "init", "deinit"] return ((self as NSString).substringWithByteRange(start: token.offset, length: token.length)) .map(keywordFunctions.contains) ?? false } - return token.type == SyntaxKind.Identifier.rawValue + return token.type == SyntaxKind.identifier.rawValue } /** @@ -457,7 +457,7 @@ extension String { - returns: Array of documented token offsets. */ - public func documentedTokenOffsets(_ syntaxMap: SyntaxMap) -> [Int] { + public func documentedTokenOffsets(syntaxMap: SyntaxMap) -> [Int] { let documentableOffsets = syntaxMap.tokens.filter(isTokenDocumentable).map { $0.offset } @@ -476,7 +476,7 @@ extension String { - parameter range: Range to restrict the search for a comment body. */ - public func commentBody(_ range: NSRange? = nil) -> String? { + public func commentBody(range: NSRange? = nil) -> String? { let nsString = self as NSString let patterns: [(pattern: String, options: NSRegularExpression.Options)] = [ ("^\\s*\\/\\*\\*\\s*(.*?)\\*\\/", [.anchorsMatchLines, .dotMatchesLineSeparators]), // multi: ^\s*\/\*\*\s*(.*?)\*\/ @@ -500,7 +500,7 @@ extension String { var lineEnd = nsString.length let indexRange = NSRange(location: range.location, length: 0) nsString.getLineStart(&lineStart, end: &lineEnd, contentsEnd: nil, for: indexRange) - let leadingWhitespaceCountToAdd = nsString.substring(with: NSRange(location: lineStart, length: lineEnd - lineStart)).countOfLeadingCharactersInSet(.whitespacesAndNewlines) + let leadingWhitespaceCountToAdd = nsString.substring(with: NSRange(location: lineStart, length: lineEnd - lineStart)).countOfLeadingCharacters(in: .whitespacesAndNewlines) let leadingWhitespaceToAdd = String(repeating: " ", count: leadingWhitespaceCountToAdd) let bodySubstring = nsString.substring(with: range) @@ -512,22 +512,22 @@ extension String { } if bodyParts.count > 0 { return bodyParts.joined(separator: "\n") - .stringByTrimmingTrailingCharactersInSet(.whitespacesAndNewlines) - .stringByRemovingCommonLeadingWhitespaceFromLines() + .trimmingTrailingCharacters(in: .whitespacesAndNewlines) + .removingCommonLeadingWhitespaceFromLines() } } return nil } /// Returns a copy of `self` with the leading whitespace common in each line removed. - public func stringByRemovingCommonLeadingWhitespaceFromLines() -> String { + public func removingCommonLeadingWhitespaceFromLines() -> String { var minLeadingCharacters = Int.max let lineComponents = components(separatedBy: .newlines) for line in lineComponents { - let lineLeadingWhitespace = line.countOfLeadingCharactersInSet(.whitespacesAndNewlines) - let lineLeadingCharacters = line.countOfLeadingCharactersInSet(commentLinePrefixCharacterSet) + let lineLeadingWhitespace = line.countOfLeadingCharacters(in: .whitespacesAndNewlines) + let lineLeadingCharacters = line.countOfLeadingCharacters(in: commentLinePrefixCharacterSet) // Is this prefix smaller than our last and not entirely whitespace? if lineLeadingCharacters < minLeadingCharacters && lineLeadingWhitespace != line.characters.count { minLeadingCharacters = lineLeadingCharacters @@ -547,7 +547,7 @@ extension String { - parameter characterSet: Character set to check for membership. */ - public func countOfLeadingCharactersInSet(_ characterSet: CharacterSet) -> Int { + public func countOfLeadingCharacters(in characterSet: CharacterSet) -> Int { let characterSet = characterSet as NSCharacterSet var count = 0 for char in utf16 { @@ -560,7 +560,7 @@ extension String { } /// Returns a copy of the string by trimming whitespace and the opening curly brace (`{`). - internal func stringByTrimmingWhitespaceAndOpeningCurlyBrace() -> String? { + internal func trimmingWhitespaceAndOpeningCurlyBrace() -> String? { var unwantedSet = CharacterSet.whitespacesAndNewlines unwantedSet.insert(charactersIn: "{") return trimmingCharacters(in: unwantedSet) diff --git a/Source/SourceKittenFramework/Structure.swift b/Source/SourceKittenFramework/Structure.swift index 492270d81..07ae3f536 100644 --- a/Source/SourceKittenFramework/Structure.swift +++ b/Source/SourceKittenFramework/Structure.swift @@ -20,7 +20,7 @@ public struct Structure { */ public init(sourceKitResponse: [String: SourceKitRepresentable]) { var sourceKitResponse = sourceKitResponse - _ = sourceKitResponse.removeValue(forKey: SwiftDocKey.SyntaxMap.rawValue) + _ = sourceKitResponse.removeValue(forKey: SwiftDocKey.syntaxMap.rawValue) dictionary = sourceKitResponse } @@ -30,7 +30,7 @@ public struct Structure { - parameter file: File to parse for structural information. */ public init(file: File) { - self.init(sourceKitResponse: Request.EditorOpen(file).send()) + self.init(sourceKitResponse: Request.editorOpen(file: file).send()) } } diff --git a/Source/SourceKittenFramework/SwiftDeclarationKind.swift b/Source/SourceKittenFramework/SwiftDeclarationKind.swift index 4d298f440..f0e2cc7ac 100644 --- a/Source/SourceKittenFramework/SwiftDeclarationKind.swift +++ b/Source/SourceKittenFramework/SwiftDeclarationKind.swift @@ -10,85 +10,81 @@ /// Found in `strings SourceKitService | grep source.lang.swift.decl.`. public enum SwiftDeclarationKind: String, SwiftLangSyntax { /// `associatedtype`. - case Associatedtype = "source.lang.swift.decl.associatedtype" + case `associatedtype` = "source.lang.swift.decl.associatedtype" /// `class`. - case Class = "source.lang.swift.decl.class" + case `class` = "source.lang.swift.decl.class" /// `enum`. - case Enum = "source.lang.swift.decl.enum" + case `enum` = "source.lang.swift.decl.enum" /// `enumcase`. - case Enumcase = "source.lang.swift.decl.enumcase" + case enumcase = "source.lang.swift.decl.enumcase" /// `enumelement`. - case Enumelement = "source.lang.swift.decl.enumelement" + case enumelement = "source.lang.swift.decl.enumelement" /// `extension`. - case Extension = "source.lang.swift.decl.extension" + case `extension` = "source.lang.swift.decl.extension" /// `extension.class`. - case ExtensionClass = "source.lang.swift.decl.extension.class" + case extensionClass = "source.lang.swift.decl.extension.class" /// `extension.enum`. - case ExtensionEnum = "source.lang.swift.decl.extension.enum" + case extensionEnum = "source.lang.swift.decl.extension.enum" /// `extension.protocol`. - case ExtensionProtocol = "source.lang.swift.decl.extension.protocol" + case extensionProtocol = "source.lang.swift.decl.extension.protocol" /// `extension.struct`. - case ExtensionStruct = "source.lang.swift.decl.extension.struct" + case extensionStruct = "source.lang.swift.decl.extension.struct" /// `function.accessor.address`. - case FunctionAccessorAddress = "source.lang.swift.decl.function.accessor.address" + case functionAccessorAddress = "source.lang.swift.decl.function.accessor.address" /// `function.accessor.didset`. - case FunctionAccessorDidset = "source.lang.swift.decl.function.accessor.didset" + case functionAccessorDidset = "source.lang.swift.decl.function.accessor.didset" /// `function.accessor.getter`. - case FunctionAccessorGetter = "source.lang.swift.decl.function.accessor.getter" + case functionAccessorGetter = "source.lang.swift.decl.function.accessor.getter" /// `function.accessor.mutableaddress`. - case FunctionAccessorMutableaddress = "source.lang.swift.decl.function.accessor.mutableaddress" + case functionAccessorMutableaddress = "source.lang.swift.decl.function.accessor.mutableaddress" /// `function.accessor.setter`. - case FunctionAccessorSetter = "source.lang.swift.decl.function.accessor.setter" + case functionAccessorSetter = "source.lang.swift.decl.function.accessor.setter" /// `function.accessor.willset`. - case FunctionAccessorWillset = "source.lang.swift.decl.function.accessor.willset" + case functionAccessorWillset = "source.lang.swift.decl.function.accessor.willset" /// `function.constructor`. - case FunctionConstructor = "source.lang.swift.decl.function.constructor" + case functionConstructor = "source.lang.swift.decl.function.constructor" /// `function.destructor`. - case FunctionDestructor = "source.lang.swift.decl.function.destructor" + case functionDestructor = "source.lang.swift.decl.function.destructor" /// `function.free`. - case FunctionFree = "source.lang.swift.decl.function.free" + case functionFree = "source.lang.swift.decl.function.free" /// `function.method.class`. - case FunctionMethodClass = "source.lang.swift.decl.function.method.class" + case functionMethodClass = "source.lang.swift.decl.function.method.class" /// `function.method.instance`. - case FunctionMethodInstance = "source.lang.swift.decl.function.method.instance" + case functionMethodInstance = "source.lang.swift.decl.function.method.instance" /// `function.method.static`. - case FunctionMethodStatic = "source.lang.swift.decl.function.method.static" + case functionMethodStatic = "source.lang.swift.decl.function.method.static" /// `function.operator`. - case FunctionOperator = "source.lang.swift.decl.function.operator" + case functionOperator = "source.lang.swift.decl.function.operator" /// `function.operator.infix`. - case FunctionOperatorInfix = "source.lang.swift.decl.function.operator.infix" + case functionOperatorInfix = "source.lang.swift.decl.function.operator.infix" /// `function.operator.postfix`. - case FunctionOperatorPostfix = "source.lang.swift.decl.function.operator.postfix" + case functionOperatorPostfix = "source.lang.swift.decl.function.operator.postfix" /// `function.operator.prefix`. - case FunctionOperatorPrefix = "source.lang.swift.decl.function.operator.prefix" + case functionOperatorPrefix = "source.lang.swift.decl.function.operator.prefix" /// `function.subscript`. - case FunctionSubscript = "source.lang.swift.decl.function.subscript" + case functionSubscript = "source.lang.swift.decl.function.subscript" /// `generic_type_param`. - case GenericTypeParam = "source.lang.swift.decl.generic_type_param" + case genericTypeParam = "source.lang.swift.decl.generic_type_param" /// `module`. - case Module = "source.lang.swift.decl.module" + case module = "source.lang.swift.decl.module" /// `precedencegroup`. - case PrecedenceGroup = "source.lang.swift.decl.precedencegroup" + case precedenceGroup = "source.lang.swift.decl.precedencegroup" /// `protocol`. - case `Protocol` = "source.lang.swift.decl.protocol" + case `protocol` = "source.lang.swift.decl.protocol" /// `struct`. - case Struct = "source.lang.swift.decl.struct" + case `struct` = "source.lang.swift.decl.struct" /// `typealias`. - case Typealias = "source.lang.swift.decl.typealias" + case `typealias` = "source.lang.swift.decl.typealias" /// `var.class`. - case VarClass = "source.lang.swift.decl.var.class" + case varClass = "source.lang.swift.decl.var.class" /// `var.global`. - case VarGlobal = "source.lang.swift.decl.var.global" + case varGlobal = "source.lang.swift.decl.var.global" /// `var.instance`. - case VarInstance = "source.lang.swift.decl.var.instance" + case varInstance = "source.lang.swift.decl.var.instance" /// `var.local`. - case VarLocal = "source.lang.swift.decl.var.local" + case varLocal = "source.lang.swift.decl.var.local" /// `var.parameter`. - case VarParameter = "source.lang.swift.decl.var.parameter" + case varParameter = "source.lang.swift.decl.var.parameter" /// `var.static`. - case VarStatic = "source.lang.swift.decl.var.static" - - public var value: String { - return rawValue - } + case varStatic = "source.lang.swift.decl.var.static" } diff --git a/Source/SourceKittenFramework/SwiftDocKey.swift b/Source/SourceKittenFramework/SwiftDocKey.swift index 7dc977d7a..b03ca2ee5 100644 --- a/Source/SourceKittenFramework/SwiftDocKey.swift +++ b/Source/SourceKittenFramework/SwiftDocKey.swift @@ -13,78 +13,78 @@ public enum SwiftDocKey: String { // MARK: SourceKit Keys /// Annotated declaration (String). - case AnnotatedDeclaration = "key.annotated_decl" + case annotatedDeclaration = "key.annotated_decl" /// Body length (Int64). - case BodyLength = "key.bodylength" + case bodyLength = "key.bodylength" /// Body offset (Int64). - case BodyOffset = "key.bodyoffset" + case bodyOffset = "key.bodyoffset" /// Diagnostic stage (String). - case DiagnosticStage = "key.diagnostic_stage" + case diagnosticStage = "key.diagnostic_stage" /// File path (String). - case FilePath = "key.filepath" + case filePath = "key.filepath" /// Full XML docs (String). - case FullXMLDocs = "key.doc.full_as_xml" + case fullXMLDocs = "key.doc.full_as_xml" /// Kind (String). - case Kind = "key.kind" + case kind = "key.kind" /// Length (Int64). - case Length = "key.length" + case length = "key.length" /// Name (String). - case Name = "key.name" + case name = "key.name" /// Name length (Int64). - case NameLength = "key.namelength" + case nameLength = "key.namelength" /// Name offset (Int64). - case NameOffset = "key.nameoffset" + case nameOffset = "key.nameoffset" /// Offset (Int64). - case Offset = "key.offset" + case offset = "key.offset" /// Substructure ([SourceKitRepresentable]). - case Substructure = "key.substructure" + case substructure = "key.substructure" /// Syntax map (NSData). - case SyntaxMap = "key.syntaxmap" + case syntaxMap = "key.syntaxmap" /// Type name (String). - case TypeName = "key.typename" + case typeName = "key.typename" /// Inheritedtype ([SourceKitRepresentable]) - case Inheritedtypes = "key.inheritedtypes" + case inheritedtypes = "key.inheritedtypes" // MARK: Custom Keys /// Column where the token's declaration begins (Int64). - case DocColumn = "key.doc.column" + case docColumn = "key.doc.column" /// Documentation comment (String). - case DocumentationComment = "key.doc.comment" + case documentationComment = "key.doc.comment" /// Declaration of documented token (String). - case DocDeclaration = "key.doc.declaration" + case docDeclaration = "key.doc.declaration" /// Discussion documentation of documented token ([SourceKitRepresentable]). - case DocDiscussion = "key.doc.discussion" + case docDiscussion = "key.doc.discussion" /// File where the documented token is located (String). - case DocFile = "key.doc.file" + case docFile = "key.doc.file" /// Line where the token's declaration begins (Int64). - case DocLine = "key.doc.line" + case docLine = "key.doc.line" /// Name of documented token (String). - case DocName = "key.doc.name" + case docName = "key.doc.name" /// Parameters of documented token ([SourceKitRepresentable]). - case DocParameters = "key.doc.parameters" + case docParameters = "key.doc.parameters" /// Parsed declaration (String). - case DocResultDiscussion = "key.doc.result_discussion" + case docResultDiscussion = "key.doc.result_discussion" /// Parsed scope start (Int64). - case DocType = "key.doc.type" + case docType = "key.doc.type" /// Parsed scope start end (Int64). - case USR = "key.usr" + case usr = "key.usr" /// Result discussion documentation of documented token ([SourceKitRepresentable]). - case ParsedDeclaration = "key.parsed_declaration" + case parsedDeclaration = "key.parsed_declaration" /// Type of documented token (String). - case ParsedScopeEnd = "key.parsed_scope.end" + case parsedScopeEnd = "key.parsed_scope.end" /// USR of documented token (String). - case ParsedScopeStart = "key.parsed_scope.start" + case parsedScopeStart = "key.parsed_scope.start" /// Swift Declaration (String). - case SwiftDeclaration = "key.swift_declaration" + case swiftDeclaration = "key.swift_declaration" /// Always deprecated (Bool). - case AlwaysDeprecated = "key.always_deprecated" + case alwaysDeprecated = "key.always_deprecated" /// Always unavailable (Bool). - case AlwaysUnavailable = "key.always_unavailable" + case alwaysUnavailable = "key.always_unavailable" /// Always deprecated (String). - case DeprecationMessage = "key.deprecation_message" + case deprecationMessage = "key.deprecation_message" /// Always unavailable (String). - case UnavailableMessage = "key.unavailable_message" + case unavailableMessage = "key.unavailable_message" // MARK: Typed SwiftDocKey Getters @@ -109,7 +109,7 @@ public enum SwiftDocKey: String { - returns: Kind string if successful. */ internal static func getKind(_ dictionary: [String: SourceKitRepresentable]) -> String? { - return get(.Kind, dictionary) + return get(.kind, dictionary) } /** @@ -120,7 +120,7 @@ public enum SwiftDocKey: String { - returns: Syntax map data if successful. */ internal static func getSyntaxMap(_ dictionary: [String: SourceKitRepresentable]) -> [SourceKitRepresentable]? { - return get(.SyntaxMap, dictionary) + return get(.syntaxMap, dictionary) } /** @@ -131,7 +131,7 @@ public enum SwiftDocKey: String { - returns: Offset int if successful. */ internal static func getOffset(_ dictionary: [String: SourceKitRepresentable]) -> Int64? { - return get(.Offset, dictionary) + return get(.offset, dictionary) } /** @@ -142,7 +142,7 @@ public enum SwiftDocKey: String { - returns: Length int if successful. */ internal static func getLength(_ dictionary: [String: SourceKitRepresentable]) -> Int64? { - return get(.Length, dictionary) + return get(.length, dictionary) } /** @@ -153,7 +153,7 @@ public enum SwiftDocKey: String { - returns: Type name string if successful. */ internal static func getTypeName(_ dictionary: [String: SourceKitRepresentable]) -> String? { - return get(.TypeName, dictionary) + return get(.typeName, dictionary) } /** @@ -164,7 +164,7 @@ public enum SwiftDocKey: String { - returns: Annotated declaration string if successful. */ internal static func getAnnotatedDeclaration(_ dictionary: [String: SourceKitRepresentable]) -> String? { - return get(.AnnotatedDeclaration, dictionary) + return get(.annotatedDeclaration, dictionary) } /** @@ -175,7 +175,7 @@ public enum SwiftDocKey: String { - returns: Substructure array if successful. */ internal static func getSubstructure(_ dictionary: [String: SourceKitRepresentable]) -> [SourceKitRepresentable]? { - return get(.Substructure, dictionary) + return get(.substructure, dictionary) } /** @@ -186,7 +186,7 @@ public enum SwiftDocKey: String { - returns: Name offset int if successful. */ internal static func getNameOffset(_ dictionary: [String: SourceKitRepresentable]) -> Int64? { - return get(.NameOffset, dictionary) + return get(.nameOffset, dictionary) } /** @@ -197,7 +197,7 @@ public enum SwiftDocKey: String { - returns: Length int if successful. */ internal static func getNameLength(_ dictionary: [String: SourceKitRepresentable]) -> Int64? { - return get(.NameLength, dictionary) + return get(.nameLength, dictionary) } /** @@ -208,7 +208,7 @@ public enum SwiftDocKey: String { - returns: Body offset int if successful. */ internal static func getBodyOffset(_ dictionary: [String: SourceKitRepresentable]) -> Int64? { - return get(.BodyOffset, dictionary) + return get(.bodyOffset, dictionary) } /** @@ -219,7 +219,7 @@ public enum SwiftDocKey: String { - returns: Body length int if successful. */ internal static func getBodyLength(_ dictionary: [String: SourceKitRepresentable]) -> Int64? { - return get(.BodyLength, dictionary) + return get(.bodyLength, dictionary) } /** @@ -230,7 +230,7 @@ public enum SwiftDocKey: String { - returns: File path string if successful. */ internal static func getFilePath(_ dictionary: [String: SourceKitRepresentable]) -> String? { - return get(.FilePath, dictionary) + return get(.filePath, dictionary) } /** @@ -241,6 +241,6 @@ public enum SwiftDocKey: String { - returns: Full xml docs string if successful. */ internal static func getFullXMLDocs(_ dictionary: [String: SourceKitRepresentable]) -> String? { - return get(.FullXMLDocs, dictionary) + return get(.fullXMLDocs, dictionary) } } diff --git a/Source/SourceKittenFramework/SwiftDocs.swift b/Source/SourceKittenFramework/SwiftDocs.swift index 97bf58747..cca5c0f05 100644 --- a/Source/SourceKittenFramework/SwiftDocs.swift +++ b/Source/SourceKittenFramework/SwiftDocs.swift @@ -29,8 +29,8 @@ public struct SwiftDocs { do { self.init( file: file, - dictionary: try Request.EditorOpen(file).failableSend(), - cursorInfoRequest: Request.cursorInfoRequestForFilePath(file.path, arguments: arguments) + dictionary: try Request.editorOpen(file: file).failableSend(), + cursorInfoRequest: Request.cursorInfoRequest(filePath: file.path, arguments: arguments) ) } catch let error as Request.Error { fputs(error.description, stderr) @@ -50,13 +50,13 @@ public struct SwiftDocs { public init(file: File, dictionary: [String: SourceKitRepresentable], cursorInfoRequest: sourcekitd_object_t?) { self.file = file var dictionary = dictionary - let syntaxMapData = dictionary.removeValue(forKey: SwiftDocKey.SyntaxMap.rawValue) as! [SourceKitRepresentable] + let syntaxMapData = dictionary.removeValue(forKey: SwiftDocKey.syntaxMap.rawValue) as! [SourceKitRepresentable] let syntaxMap = SyntaxMap(data: syntaxMapData) - dictionary = file.processDictionary(dictionary, cursorInfoRequest: cursorInfoRequest, syntaxMap: syntaxMap) + dictionary = file.process(dictionary: dictionary, cursorInfoRequest: cursorInfoRequest, syntaxMap: syntaxMap) if let cursorInfoRequest = cursorInfoRequest { - let documentedTokenOffsets = file.contents.documentedTokenOffsets(syntaxMap) - dictionary = file.furtherProcessDictionary( - dictionary, + let documentedTokenOffsets = file.contents.documentedTokenOffsets(syntaxMap: syntaxMap) + dictionary = file.furtherProcess( + dictionary: dictionary, documentedTokenOffsets: documentedTokenOffsets, cursorInfoRequest: cursorInfoRequest, syntaxMap: syntaxMap diff --git a/Source/SourceKittenFramework/SwiftLangSyntax.swift b/Source/SourceKittenFramework/SwiftLangSyntax.swift index 6746b0405..7350b845c 100644 --- a/Source/SourceKittenFramework/SwiftLangSyntax.swift +++ b/Source/SourceKittenFramework/SwiftLangSyntax.swift @@ -1,5 +1,5 @@ import Foundation public protocol SwiftLangSyntax { - var value: String { get } -} \ No newline at end of file + var rawValue: String { get } +} diff --git a/Source/SourceKittenFramework/SyntaxKind.swift b/Source/SourceKittenFramework/SyntaxKind.swift index c87bc95f0..eb6ac6e43 100644 --- a/Source/SourceKittenFramework/SyntaxKind.swift +++ b/Source/SourceKittenFramework/SyntaxKind.swift @@ -10,50 +10,46 @@ /// Found in `strings SourceKitService | grep source.lang.swift.syntaxtype.`. public enum SyntaxKind: String, SwiftLangSyntax { /// `argument`. - case Argument = "source.lang.swift.syntaxtype.argument" + case argument = "source.lang.swift.syntaxtype.argument" /// `attribute.builtin`. - case AttributeBuiltin = "source.lang.swift.syntaxtype.attribute.builtin" + case attributeBuiltin = "source.lang.swift.syntaxtype.attribute.builtin" /// `attribute.id`. - case AttributeID = "source.lang.swift.syntaxtype.attribute.id" + case attributeID = "source.lang.swift.syntaxtype.attribute.id" /// `buildconfig.id`. - case BuildconfigID = "source.lang.swift.syntaxtype.buildconfig.id" + case buildconfigID = "source.lang.swift.syntaxtype.buildconfig.id" /// `buildconfig.keyword`. - case BuildconfigKeyword = "source.lang.swift.syntaxtype.buildconfig.keyword" + case buildconfigKeyword = "source.lang.swift.syntaxtype.buildconfig.keyword" /// `comment`. - case Comment = "source.lang.swift.syntaxtype.comment" + case comment = "source.lang.swift.syntaxtype.comment" /// `comment.mark`. - case CommentMark = "source.lang.swift.syntaxtype.comment.mark" + case commentMark = "source.lang.swift.syntaxtype.comment.mark" /// `comment.url`. - case CommentURL = "source.lang.swift.syntaxtype.comment.url" + case commentURL = "source.lang.swift.syntaxtype.comment.url" /// `doccomment`. - case DocComment = "source.lang.swift.syntaxtype.doccomment" + case docComment = "source.lang.swift.syntaxtype.doccomment" /// `doccomment.field`. - case DocCommentField = "source.lang.swift.syntaxtype.doccomment.field" + case docCommentField = "source.lang.swift.syntaxtype.doccomment.field" /// `identifier`. - case Identifier = "source.lang.swift.syntaxtype.identifier" + case identifier = "source.lang.swift.syntaxtype.identifier" /// `keyword`. - case Keyword = "source.lang.swift.syntaxtype.keyword" + case keyword = "source.lang.swift.syntaxtype.keyword" /// `number`. - case Number = "source.lang.swift.syntaxtype.number" + case number = "source.lang.swift.syntaxtype.number" /// `objectliteral` - case ObjectLiteral = "source.lang.swift.syntaxtype.objectliteral" + case objectLiteral = "source.lang.swift.syntaxtype.objectliteral" /// `parameter`. - case Parameter = "source.lang.swift.syntaxtype.parameter" + case parameter = "source.lang.swift.syntaxtype.parameter" /// `placeholder`. - case Placeholder = "source.lang.swift.syntaxtype.placeholder" + case placeholder = "source.lang.swift.syntaxtype.placeholder" /// `string`. - case String = "source.lang.swift.syntaxtype.string" + case string = "source.lang.swift.syntaxtype.string" /// `string_interpolation_anchor`. - case StringInterpolationAnchor = "source.lang.swift.syntaxtype.string_interpolation_anchor" + case stringInterpolationAnchor = "source.lang.swift.syntaxtype.string_interpolation_anchor" /// `typeidentifier`. - case Typeidentifier = "source.lang.swift.syntaxtype.typeidentifier" + case typeidentifier = "source.lang.swift.syntaxtype.typeidentifier" /// Returns the valid documentation comment syntax kinds. internal static func docComments() -> [SyntaxKind] { - return [CommentURL, DocComment, DocCommentField] - } - - public var value: Swift.String { - return rawValue + return [.commentURL, .docComment, .docCommentField] } } diff --git a/Source/SourceKittenFramework/SyntaxMap.swift b/Source/SourceKittenFramework/SyntaxMap.swift index 45c768c7b..6d28ad502 100644 --- a/Source/SourceKittenFramework/SyntaxMap.swift +++ b/Source/SourceKittenFramework/SyntaxMap.swift @@ -49,7 +49,7 @@ public struct SyntaxMap { - parameter file: File to be parsed. */ public init(file: File) { - self.init(sourceKitResponse: Request.EditorOpen(file).send()) + self.init(sourceKitResponse: Request.editorOpen(file: file).send()) } /** @@ -59,7 +59,7 @@ public struct SyntaxMap { - parameter offset: Last possible byte offset of the range's start. */ - public func commentRangeBeforeOffset(_ offset: Int) -> Range? { + public func commentRange(beforeOffset offset: Int) -> Range? { let tokensBeforeOffset = tokens.reversed().filter { $0.offset < offset } let docTypes = SyntaxKind.docComments().map({ $0.rawValue }) @@ -78,7 +78,7 @@ public struct SyntaxMap { return commentTokensImmediatelyPrecedingOffset.first.flatMap { firstToken in return commentTokensImmediatelyPrecedingOffset.last.flatMap { lastToken in let regularCommentTokensBetweenDocCommentAndOffset = tokensBeforeOffset - .filter({ $0.offset > lastToken.offset && SyntaxKind(rawValue: $0.type) == .Comment }) + .filter({ $0.offset > lastToken.offset && SyntaxKind(rawValue: $0.type) == .comment }) if !regularCommentTokensBetweenDocCommentAndOffset.isEmpty { return nil // "doc comment" isn't actually a doc comment } diff --git a/Source/SourceKittenFramework/Xcode.swift b/Source/SourceKittenFramework/Xcode.swift index dac2b06b9..219700d53 100644 --- a/Source/SourceKittenFramework/Xcode.swift +++ b/Source/SourceKittenFramework/Xcode.swift @@ -16,7 +16,7 @@ Run `xcodebuild clean build` along with any passed in build arguments. - returns: `xcodebuild`'s STDERR+STDOUT output combined. */ -internal func runXcodeBuild(_ arguments: [String], inPath path: String) -> String? { +internal func runXcodeBuild(arguments: [String], inPath path: String) -> String? { fputs("Running xcodebuild\n", stderr) let task = Process() @@ -45,7 +45,7 @@ Will the following values, in this priority: module name, target name, scheme na - returns: Module name if successful. */ -internal func moduleNameFromArguments(_ arguments: [String]) -> String? { +internal func moduleName(fromArguments arguments: [String]) -> String? { for flag in ["-module-name", "-target", "-scheme"] { if let flagIndex = arguments.index(of: flag), flagIndex + 1 < arguments.count { return arguments[flagIndex + 1] @@ -62,7 +62,7 @@ Partially filters compiler arguments from `xcodebuild` to something that SourceK - returns: A tuple of partially filtered compiler arguments in `.0`, and whether or not there are more flags to remove in `.1`. */ -private func partiallyFilterArguments(_ args: [String]) -> ([String], Bool) { +private func partiallyFilter(arguments args: [String]) -> ([String], Bool) { guard let indexOfFlagToRemove = args.index(of: "-output-file-map") else { return (args, false) } @@ -79,12 +79,12 @@ Filters compiler arguments from `xcodebuild` to something that SourceKit/Clang w - returns: Filtered compiler arguments. */ -private func filterArguments(_ args: [String]) -> [String] { +private func filter(arguments args: [String]) -> [String] { var args = args args.append(contentsOf: ["-D", "DEBUG"]) var shouldContinueToFilterArguments = true while shouldContinueToFilterArguments { - (args, shouldContinueToFilterArguments) = partiallyFilterArguments(args) + (args, shouldContinueToFilterArguments) = partiallyFilter(arguments: args) } return args.filter { ![ @@ -112,9 +112,9 @@ Parses the compiler arguments needed to compile the `language` files. - returns: Compiler arguments, filtered for suitable use by SourceKit if `.Swift` or Clang if `.ObjC`. */ -internal func parseCompilerArguments(_ xcodebuildOutput: NSString, language: Language, moduleName: String?) -> [String]? { +internal func parseCompilerArguments(xcodebuildOutput: NSString, language: Language, moduleName: String?) -> [String]? { let pattern: String - if language == .ObjC { + if language == .objc { pattern = "/usr/bin/clang.*" } else if let moduleName = moduleName { pattern = "/usr/bin/swiftc.*-module-name \(moduleName) .*" @@ -129,7 +129,7 @@ internal func parseCompilerArguments(_ xcodebuildOutput: NSString, language: Lan } let escapedSpacePlaceholder = "\u{0}" - let args = filterArguments(xcodebuildOutput + let args = filter(arguments: xcodebuildOutput .substring(with: regexMatch.range) .replacingOccurrences(of: "\\ ", with: escapedSpacePlaceholder) .components(separatedBy: " ")) @@ -147,7 +147,7 @@ Extracts Objective-C header files and `xcodebuild` arguments from an array of he - returns: Tuple of header files and xcodebuild arguments. */ -public func parseHeaderFilesAndXcodebuildArguments(_ sourcekittenArguments: [String]) -> (headerFiles: [String], xcodebuildArguments: [String]) { +public func parseHeaderFilesAndXcodebuildArguments(sourcekittenArguments: [String]) -> (headerFiles: [String], xcodebuildArguments: [String]) { var xcodebuildArguments = sourcekittenArguments var headerFiles = [String]() while let headerFile = xcodebuildArguments.first, headerFile.isObjectiveCHeaderFile() { diff --git a/Source/SourceKittenFramework/library_wrapper.swift b/Source/SourceKittenFramework/library_wrapper.swift index b1371c058..a8bcd2106 100644 --- a/Source/SourceKittenFramework/library_wrapper.swift +++ b/Source/SourceKittenFramework/library_wrapper.swift @@ -12,7 +12,7 @@ struct DynamicLinkLibrary { let path: String let handle: UnsafeMutableRawPointer - func loadSymbol(_ symbol: String) -> T { + func load(symbol: String) -> T { if let sym = dlsym(handle, symbol) { return unsafeBitCast(sym, to: T.self) } @@ -43,8 +43,8 @@ let toolchainLoader = Loader(searchPaths: [ struct Loader { let searchPaths: [String] - func load(_ path: String) -> DynamicLinkLibrary { - let fullPaths = searchPaths.map { $0.stringByAppendingPathComponent(path) }.filter { $0.isFile } + func load(path: String) -> DynamicLinkLibrary { + let fullPaths = searchPaths.map { $0.appending(pathComponent: path) }.filter { $0.isFile } // try all fullPaths that contains target file, // then try loading with simple path that depends resolving to DYLD @@ -105,7 +105,7 @@ private let xcrunFindPath: String? = { guard xcrunFindSwiftPath.hasSuffix("/usr/bin/swift") else { return nil } - let xcrunFindPath = xcrunFindSwiftPath.deletingLastPathComponents(3) + let xcrunFindPath = xcrunFindSwiftPath.deleting(lastPathComponents: 3) // Return nil if xcrunFindPath points to "Command Line Tools OS X for Xcode" // because it doesn't contain `sourcekitd.framework`. if xcrunFindPath == "/Library/Developer/CommandLineTools" { @@ -122,26 +122,26 @@ private let userApplicationsDir: String? = private extension String { var toolchainDir: String { - return stringByAppendingPathComponent("Toolchains/XcodeDefault.xctoolchain") + return appending(pathComponent: "Toolchains/XcodeDefault.xctoolchain") } var xcodeDeveloperDir: String { - return stringByAppendingPathComponent("Xcode.app/Contents/Developer") + return appending(pathComponent: "Xcode.app/Contents/Developer") } var xcodeBetaDeveloperDir: String { - return stringByAppendingPathComponent("Xcode-beta.app/Contents/Developer") + return appending(pathComponent: "Xcode-beta.app/Contents/Developer") } var usrLibDir: String { - return stringByAppendingPathComponent("/usr/lib") + return appending(pathComponent: "/usr/lib") } - func stringByAppendingPathComponent(_ str: String) -> String { - return URL(fileURLWithPath: self).appendingPathComponent(str).path + func appending(pathComponent: String) -> String { + return URL(fileURLWithPath: self).appendingPathComponent(pathComponent).path } - func deletingLastPathComponents(_ n: Int) -> String { + func deleting(lastPathComponents n: Int) -> String { var url = URL(fileURLWithPath: self) for _ in 0.. (UnsafePointer!) = library.loadSymbol("clang_getCString") -internal let clang_disposeString: @convention(c) (CXString) -> () = library.loadSymbol("clang_disposeString") +private let library = toolchainLoader.load(path: "libclang.dylib") +internal let clang_getCString: @convention(c) (CXString) -> (UnsafePointer!) = library.load(symbol: "clang_getCString") +internal let clang_disposeString: @convention(c) (CXString) -> () = library.load(symbol: "clang_disposeString") diff --git a/Source/SourceKittenFramework/library_wrapper_Documentation.swift b/Source/SourceKittenFramework/library_wrapper_Documentation.swift index e7d31365e..168db1705 100644 --- a/Source/SourceKittenFramework/library_wrapper_Documentation.swift +++ b/Source/SourceKittenFramework/library_wrapper_Documentation.swift @@ -1,38 +1,38 @@ #if SWIFT_PACKAGE import Clang_C #endif -private let library = toolchainLoader.load("libclang.dylib") -internal let clang_Cursor_getParsedComment: @convention(c) (CXCursor) -> (CXComment) = library.loadSymbol("clang_Cursor_getParsedComment") -internal let clang_Comment_getKind: @convention(c) (CXComment) -> (CXCommentKind) = library.loadSymbol("clang_Comment_getKind") -internal let clang_Comment_getNumChildren: @convention(c) (CXComment) -> (UInt32) = library.loadSymbol("clang_Comment_getNumChildren") -internal let clang_Comment_getChild: @convention(c) (CXComment, UInt32) -> (CXComment) = library.loadSymbol("clang_Comment_getChild") -internal let clang_Comment_isWhitespace: @convention(c) (CXComment) -> (UInt32) = library.loadSymbol("clang_Comment_isWhitespace") -internal let clang_InlineContentComment_hasTrailingNewline: @convention(c) (CXComment) -> (UInt32) = library.loadSymbol("clang_InlineContentComment_hasTrailingNewline") -internal let clang_TextComment_getText: @convention(c) (CXComment) -> (CXString) = library.loadSymbol("clang_TextComment_getText") -internal let clang_InlineCommandComment_getCommandName: @convention(c) (CXComment) -> (CXString) = library.loadSymbol("clang_InlineCommandComment_getCommandName") -internal let clang_InlineCommandComment_getRenderKind: @convention(c) (CXComment) -> (CXCommentInlineCommandRenderKind) = library.loadSymbol("clang_InlineCommandComment_getRenderKind") -internal let clang_InlineCommandComment_getNumArgs: @convention(c) (CXComment) -> (UInt32) = library.loadSymbol("clang_InlineCommandComment_getNumArgs") -internal let clang_InlineCommandComment_getArgText: @convention(c) (CXComment, UInt32) -> (CXString) = library.loadSymbol("clang_InlineCommandComment_getArgText") -internal let clang_HTMLTagComment_getTagName: @convention(c) (CXComment) -> (CXString) = library.loadSymbol("clang_HTMLTagComment_getTagName") -internal let clang_HTMLStartTagComment_isSelfClosing: @convention(c) (CXComment) -> (UInt32) = library.loadSymbol("clang_HTMLStartTagComment_isSelfClosing") -internal let clang_HTMLStartTag_getNumAttrs: @convention(c) (CXComment) -> (UInt32) = library.loadSymbol("clang_HTMLStartTag_getNumAttrs") -internal let clang_HTMLStartTag_getAttrName: @convention(c) (CXComment, UInt32) -> (CXString) = library.loadSymbol("clang_HTMLStartTag_getAttrName") -internal let clang_HTMLStartTag_getAttrValue: @convention(c) (CXComment, UInt32) -> (CXString) = library.loadSymbol("clang_HTMLStartTag_getAttrValue") -internal let clang_BlockCommandComment_getCommandName: @convention(c) (CXComment) -> (CXString) = library.loadSymbol("clang_BlockCommandComment_getCommandName") -internal let clang_BlockCommandComment_getNumArgs: @convention(c) (CXComment) -> (UInt32) = library.loadSymbol("clang_BlockCommandComment_getNumArgs") -internal let clang_BlockCommandComment_getArgText: @convention(c) (CXComment, UInt32) -> (CXString) = library.loadSymbol("clang_BlockCommandComment_getArgText") -internal let clang_BlockCommandComment_getParagraph: @convention(c) (CXComment) -> (CXComment) = library.loadSymbol("clang_BlockCommandComment_getParagraph") -internal let clang_ParamCommandComment_getParamName: @convention(c) (CXComment) -> (CXString) = library.loadSymbol("clang_ParamCommandComment_getParamName") -internal let clang_ParamCommandComment_isParamIndexValid: @convention(c) (CXComment) -> (UInt32) = library.loadSymbol("clang_ParamCommandComment_isParamIndexValid") -internal let clang_ParamCommandComment_getParamIndex: @convention(c) (CXComment) -> (UInt32) = library.loadSymbol("clang_ParamCommandComment_getParamIndex") -internal let clang_ParamCommandComment_isDirectionExplicit: @convention(c) (CXComment) -> (UInt32) = library.loadSymbol("clang_ParamCommandComment_isDirectionExplicit") -internal let clang_ParamCommandComment_getDirection: @convention(c) (CXComment) -> (CXCommentParamPassDirection) = library.loadSymbol("clang_ParamCommandComment_getDirection") -internal let clang_TParamCommandComment_getParamName: @convention(c) (CXComment) -> (CXString) = library.loadSymbol("clang_TParamCommandComment_getParamName") -internal let clang_TParamCommandComment_isParamPositionValid: @convention(c) (CXComment) -> (UInt32) = library.loadSymbol("clang_TParamCommandComment_isParamPositionValid") -internal let clang_TParamCommandComment_getDepth: @convention(c) (CXComment) -> (UInt32) = library.loadSymbol("clang_TParamCommandComment_getDepth") -internal let clang_TParamCommandComment_getIndex: @convention(c) (CXComment, UInt32) -> (UInt32) = library.loadSymbol("clang_TParamCommandComment_getIndex") -internal let clang_VerbatimBlockLineComment_getText: @convention(c) (CXComment) -> (CXString) = library.loadSymbol("clang_VerbatimBlockLineComment_getText") -internal let clang_VerbatimLineComment_getText: @convention(c) (CXComment) -> (CXString) = library.loadSymbol("clang_VerbatimLineComment_getText") -internal let clang_HTMLTagComment_getAsString: @convention(c) (CXComment) -> (CXString) = library.loadSymbol("clang_HTMLTagComment_getAsString") -internal let clang_FullComment_getAsHTML: @convention(c) (CXComment) -> (CXString) = library.loadSymbol("clang_FullComment_getAsHTML") -internal let clang_FullComment_getAsXML: @convention(c) (CXComment) -> (CXString) = library.loadSymbol("clang_FullComment_getAsXML") +private let library = toolchainLoader.load(path: "libclang.dylib") +internal let clang_Cursor_getParsedComment: @convention(c) (CXCursor) -> (CXComment) = library.load(symbol: "clang_Cursor_getParsedComment") +internal let clang_Comment_getKind: @convention(c) (CXComment) -> (CXCommentKind) = library.load(symbol: "clang_Comment_getKind") +internal let clang_Comment_getNumChildren: @convention(c) (CXComment) -> (UInt32) = library.load(symbol: "clang_Comment_getNumChildren") +internal let clang_Comment_getChild: @convention(c) (CXComment, UInt32) -> (CXComment) = library.load(symbol: "clang_Comment_getChild") +internal let clang_Comment_isWhitespace: @convention(c) (CXComment) -> (UInt32) = library.load(symbol: "clang_Comment_isWhitespace") +internal let clang_InlineContentComment_hasTrailingNewline: @convention(c) (CXComment) -> (UInt32) = library.load(symbol: "clang_InlineContentComment_hasTrailingNewline") +internal let clang_TextComment_getText: @convention(c) (CXComment) -> (CXString) = library.load(symbol: "clang_TextComment_getText") +internal let clang_InlineCommandComment_getCommandName: @convention(c) (CXComment) -> (CXString) = library.load(symbol: "clang_InlineCommandComment_getCommandName") +internal let clang_InlineCommandComment_getRenderKind: @convention(c) (CXComment) -> (CXCommentInlineCommandRenderKind) = library.load(symbol: "clang_InlineCommandComment_getRenderKind") +internal let clang_InlineCommandComment_getNumArgs: @convention(c) (CXComment) -> (UInt32) = library.load(symbol: "clang_InlineCommandComment_getNumArgs") +internal let clang_InlineCommandComment_getArgText: @convention(c) (CXComment, UInt32) -> (CXString) = library.load(symbol: "clang_InlineCommandComment_getArgText") +internal let clang_HTMLTagComment_getTagName: @convention(c) (CXComment) -> (CXString) = library.load(symbol: "clang_HTMLTagComment_getTagName") +internal let clang_HTMLStartTagComment_isSelfClosing: @convention(c) (CXComment) -> (UInt32) = library.load(symbol: "clang_HTMLStartTagComment_isSelfClosing") +internal let clang_HTMLStartTag_getNumAttrs: @convention(c) (CXComment) -> (UInt32) = library.load(symbol: "clang_HTMLStartTag_getNumAttrs") +internal let clang_HTMLStartTag_getAttrName: @convention(c) (CXComment, UInt32) -> (CXString) = library.load(symbol: "clang_HTMLStartTag_getAttrName") +internal let clang_HTMLStartTag_getAttrValue: @convention(c) (CXComment, UInt32) -> (CXString) = library.load(symbol: "clang_HTMLStartTag_getAttrValue") +internal let clang_BlockCommandComment_getCommandName: @convention(c) (CXComment) -> (CXString) = library.load(symbol: "clang_BlockCommandComment_getCommandName") +internal let clang_BlockCommandComment_getNumArgs: @convention(c) (CXComment) -> (UInt32) = library.load(symbol: "clang_BlockCommandComment_getNumArgs") +internal let clang_BlockCommandComment_getArgText: @convention(c) (CXComment, UInt32) -> (CXString) = library.load(symbol: "clang_BlockCommandComment_getArgText") +internal let clang_BlockCommandComment_getParagraph: @convention(c) (CXComment) -> (CXComment) = library.load(symbol: "clang_BlockCommandComment_getParagraph") +internal let clang_ParamCommandComment_getParamName: @convention(c) (CXComment) -> (CXString) = library.load(symbol: "clang_ParamCommandComment_getParamName") +internal let clang_ParamCommandComment_isParamIndexValid: @convention(c) (CXComment) -> (UInt32) = library.load(symbol: "clang_ParamCommandComment_isParamIndexValid") +internal let clang_ParamCommandComment_getParamIndex: @convention(c) (CXComment) -> (UInt32) = library.load(symbol: "clang_ParamCommandComment_getParamIndex") +internal let clang_ParamCommandComment_isDirectionExplicit: @convention(c) (CXComment) -> (UInt32) = library.load(symbol: "clang_ParamCommandComment_isDirectionExplicit") +internal let clang_ParamCommandComment_getDirection: @convention(c) (CXComment) -> (CXCommentParamPassDirection) = library.load(symbol: "clang_ParamCommandComment_getDirection") +internal let clang_TParamCommandComment_getParamName: @convention(c) (CXComment) -> (CXString) = library.load(symbol: "clang_TParamCommandComment_getParamName") +internal let clang_TParamCommandComment_isParamPositionValid: @convention(c) (CXComment) -> (UInt32) = library.load(symbol: "clang_TParamCommandComment_isParamPositionValid") +internal let clang_TParamCommandComment_getDepth: @convention(c) (CXComment) -> (UInt32) = library.load(symbol: "clang_TParamCommandComment_getDepth") +internal let clang_TParamCommandComment_getIndex: @convention(c) (CXComment, UInt32) -> (UInt32) = library.load(symbol: "clang_TParamCommandComment_getIndex") +internal let clang_VerbatimBlockLineComment_getText: @convention(c) (CXComment) -> (CXString) = library.load(symbol: "clang_VerbatimBlockLineComment_getText") +internal let clang_VerbatimLineComment_getText: @convention(c) (CXComment) -> (CXString) = library.load(symbol: "clang_VerbatimLineComment_getText") +internal let clang_HTMLTagComment_getAsString: @convention(c) (CXComment) -> (CXString) = library.load(symbol: "clang_HTMLTagComment_getAsString") +internal let clang_FullComment_getAsHTML: @convention(c) (CXComment) -> (CXString) = library.load(symbol: "clang_FullComment_getAsHTML") +internal let clang_FullComment_getAsXML: @convention(c) (CXComment) -> (CXString) = library.load(symbol: "clang_FullComment_getAsXML") diff --git a/Source/SourceKittenFramework/library_wrapper_Index.swift b/Source/SourceKittenFramework/library_wrapper_Index.swift index 5913a8dd6..3e01f07fc 100644 --- a/Source/SourceKittenFramework/library_wrapper_Index.swift +++ b/Source/SourceKittenFramework/library_wrapper_Index.swift @@ -1,259 +1,259 @@ #if SWIFT_PACKAGE import Clang_C #endif -private let library = toolchainLoader.load("libclang.dylib") -internal let clang_createIndex: @convention(c) (Int32, Int32) -> (CXIndex!) = library.loadSymbol("clang_createIndex") -internal let clang_disposeIndex: @convention(c) (CXIndex?) -> () = library.loadSymbol("clang_disposeIndex") -internal let clang_CXIndex_setGlobalOptions: @convention(c) (CXIndex?, UInt32) -> () = library.loadSymbol("clang_CXIndex_setGlobalOptions") -internal let clang_CXIndex_getGlobalOptions: @convention(c) (CXIndex?) -> (UInt32) = library.loadSymbol("clang_CXIndex_getGlobalOptions") -internal let clang_getFileName: @convention(c) (CXFile?) -> (CXString) = library.loadSymbol("clang_getFileName") -internal let clang_getFileTime: @convention(c) (CXFile?) -> (time_t) = library.loadSymbol("clang_getFileTime") -internal let clang_getFileUniqueID: @convention(c) (CXFile?, UnsafeMutablePointer?) -> (Int32) = library.loadSymbol("clang_getFileUniqueID") -internal let clang_isFileMultipleIncludeGuarded: @convention(c) (CXTranslationUnit?, CXFile?) -> (UInt32) = library.loadSymbol("clang_isFileMultipleIncludeGuarded") -internal let clang_getFile: @convention(c) (CXTranslationUnit?, UnsafePointer?) -> (CXFile!) = library.loadSymbol("clang_getFile") -internal let clang_File_isEqual: @convention(c) (CXFile?, CXFile?) -> (Int32) = library.loadSymbol("clang_File_isEqual") -internal let clang_getNullLocation: @convention(c) () -> (CXSourceLocation) = library.loadSymbol("clang_getNullLocation") -internal let clang_equalLocations: @convention(c) (CXSourceLocation, CXSourceLocation) -> (UInt32) = library.loadSymbol("clang_equalLocations") -internal let clang_getLocation: @convention(c) (CXTranslationUnit?, CXFile?, UInt32, UInt32) -> (CXSourceLocation) = library.loadSymbol("clang_getLocation") -internal let clang_getLocationForOffset: @convention(c) (CXTranslationUnit?, CXFile?, UInt32) -> (CXSourceLocation) = library.loadSymbol("clang_getLocationForOffset") -internal let clang_Location_isInSystemHeader: @convention(c) (CXSourceLocation) -> (Int32) = library.loadSymbol("clang_Location_isInSystemHeader") -internal let clang_Location_isFromMainFile: @convention(c) (CXSourceLocation) -> (Int32) = library.loadSymbol("clang_Location_isFromMainFile") -internal let clang_getNullRange: @convention(c) () -> (CXSourceRange) = library.loadSymbol("clang_getNullRange") -internal let clang_getRange: @convention(c) (CXSourceLocation, CXSourceLocation) -> (CXSourceRange) = library.loadSymbol("clang_getRange") -internal let clang_equalRanges: @convention(c) (CXSourceRange, CXSourceRange) -> (UInt32) = library.loadSymbol("clang_equalRanges") -internal let clang_Range_isNull: @convention(c) (CXSourceRange) -> (Int32) = library.loadSymbol("clang_Range_isNull") -internal let clang_getExpansionLocation: @convention(c) (CXSourceLocation, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?) -> () = library.loadSymbol("clang_getExpansionLocation") -internal let clang_getPresumedLocation: @convention(c) (CXSourceLocation, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?) -> () = library.loadSymbol("clang_getPresumedLocation") -internal let clang_getInstantiationLocation: @convention(c) (CXSourceLocation, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?) -> () = library.loadSymbol("clang_getInstantiationLocation") -internal let clang_getSpellingLocation: @convention(c) (CXSourceLocation, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?) -> () = library.loadSymbol("clang_getSpellingLocation") -internal let clang_getFileLocation: @convention(c) (CXSourceLocation, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?) -> () = library.loadSymbol("clang_getFileLocation") -internal let clang_getRangeStart: @convention(c) (CXSourceRange) -> (CXSourceLocation) = library.loadSymbol("clang_getRangeStart") -internal let clang_getRangeEnd: @convention(c) (CXSourceRange) -> (CXSourceLocation) = library.loadSymbol("clang_getRangeEnd") -internal let clang_getSkippedRanges: @convention(c) (CXTranslationUnit?, CXFile?) -> (UnsafeMutablePointer!) = library.loadSymbol("clang_getSkippedRanges") -internal let clang_disposeSourceRangeList: @convention(c) (UnsafeMutablePointer?) -> () = library.loadSymbol("clang_disposeSourceRangeList") -internal let clang_getNumDiagnosticsInSet: @convention(c) (CXDiagnosticSet?) -> (UInt32) = library.loadSymbol("clang_getNumDiagnosticsInSet") -internal let clang_getDiagnosticInSet: @convention(c) (CXDiagnosticSet?, UInt32) -> (CXDiagnostic!) = library.loadSymbol("clang_getDiagnosticInSet") -internal let clang_loadDiagnostics: @convention(c) (UnsafePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?) -> (CXDiagnosticSet!) = library.loadSymbol("clang_loadDiagnostics") -internal let clang_disposeDiagnosticSet: @convention(c) (CXDiagnosticSet?) -> () = library.loadSymbol("clang_disposeDiagnosticSet") -internal let clang_getChildDiagnostics: @convention(c) (CXDiagnostic?) -> (CXDiagnosticSet!) = library.loadSymbol("clang_getChildDiagnostics") -internal let clang_getNumDiagnostics: @convention(c) (CXTranslationUnit?) -> (UInt32) = library.loadSymbol("clang_getNumDiagnostics") -internal let clang_getDiagnostic: @convention(c) (CXTranslationUnit?, UInt32) -> (CXDiagnostic!) = library.loadSymbol("clang_getDiagnostic") -internal let clang_getDiagnosticSetFromTU: @convention(c) (CXTranslationUnit?) -> (CXDiagnosticSet!) = library.loadSymbol("clang_getDiagnosticSetFromTU") -internal let clang_disposeDiagnostic: @convention(c) (CXDiagnostic?) -> () = library.loadSymbol("clang_disposeDiagnostic") -internal let clang_formatDiagnostic: @convention(c) (CXDiagnostic?, UInt32) -> (CXString) = library.loadSymbol("clang_formatDiagnostic") -internal let clang_defaultDiagnosticDisplayOptions: @convention(c) () -> (UInt32) = library.loadSymbol("clang_defaultDiagnosticDisplayOptions") -internal let clang_getDiagnosticSeverity: @convention(c) (CXDiagnostic?) -> (CXDiagnosticSeverity) = library.loadSymbol("clang_getDiagnosticSeverity") -internal let clang_getDiagnosticLocation: @convention(c) (CXDiagnostic?) -> (CXSourceLocation) = library.loadSymbol("clang_getDiagnosticLocation") -internal let clang_getDiagnosticSpelling: @convention(c) (CXDiagnostic?) -> (CXString) = library.loadSymbol("clang_getDiagnosticSpelling") -internal let clang_getDiagnosticOption: @convention(c) (CXDiagnostic?, UnsafeMutablePointer?) -> (CXString) = library.loadSymbol("clang_getDiagnosticOption") -internal let clang_getDiagnosticCategory: @convention(c) (CXDiagnostic?) -> (UInt32) = library.loadSymbol("clang_getDiagnosticCategory") -internal let clang_getDiagnosticCategoryName: @convention(c) (UInt32) -> (CXString) = library.loadSymbol("clang_getDiagnosticCategoryName") -internal let clang_getDiagnosticCategoryText: @convention(c) (CXDiagnostic?) -> (CXString) = library.loadSymbol("clang_getDiagnosticCategoryText") -internal let clang_getDiagnosticNumRanges: @convention(c) (CXDiagnostic?) -> (UInt32) = library.loadSymbol("clang_getDiagnosticNumRanges") -internal let clang_getDiagnosticRange: @convention(c) (CXDiagnostic?, UInt32) -> (CXSourceRange) = library.loadSymbol("clang_getDiagnosticRange") -internal let clang_getDiagnosticNumFixIts: @convention(c) (CXDiagnostic?) -> (UInt32) = library.loadSymbol("clang_getDiagnosticNumFixIts") -internal let clang_getDiagnosticFixIt: @convention(c) (CXDiagnostic?, UInt32, UnsafeMutablePointer?) -> (CXString) = library.loadSymbol("clang_getDiagnosticFixIt") -internal let clang_getTranslationUnitSpelling: @convention(c) (CXTranslationUnit?) -> (CXString) = library.loadSymbol("clang_getTranslationUnitSpelling") -internal let clang_createTranslationUnitFromSourceFile: @convention(c) (CXIndex?, UnsafePointer?, Int32, UnsafePointer?>?, UInt32, UnsafeMutablePointer?) -> (CXTranslationUnit!) = library.loadSymbol("clang_createTranslationUnitFromSourceFile") -internal let clang_createTranslationUnit: @convention(c) (CXIndex?, UnsafePointer?) -> (CXTranslationUnit!) = library.loadSymbol("clang_createTranslationUnit") -internal let clang_createTranslationUnit2: @convention(c) (CXIndex?, UnsafePointer?, UnsafeMutablePointer?) -> (CXErrorCode) = library.loadSymbol("clang_createTranslationUnit2") -internal let clang_defaultEditingTranslationUnitOptions: @convention(c) () -> (UInt32) = library.loadSymbol("clang_defaultEditingTranslationUnitOptions") -internal let clang_parseTranslationUnit: @convention(c) (CXIndex?, UnsafePointer?, UnsafePointer?>?, Int32, UnsafeMutablePointer?, UInt32, UInt32) -> (CXTranslationUnit!) = library.loadSymbol("clang_parseTranslationUnit") -internal let clang_parseTranslationUnit2: @convention(c) (CXIndex?, UnsafePointer?, UnsafePointer?>?, Int32, UnsafeMutablePointer?, UInt32, UInt32, UnsafeMutablePointer?) -> (CXErrorCode) = library.loadSymbol("clang_parseTranslationUnit2") -internal let clang_defaultSaveOptions: @convention(c) (CXTranslationUnit?) -> (UInt32) = library.loadSymbol("clang_defaultSaveOptions") -internal let clang_saveTranslationUnit: @convention(c) (CXTranslationUnit?, UnsafePointer?, UInt32) -> (Int32) = library.loadSymbol("clang_saveTranslationUnit") -internal let clang_disposeTranslationUnit: @convention(c) (CXTranslationUnit?) -> () = library.loadSymbol("clang_disposeTranslationUnit") -internal let clang_defaultReparseOptions: @convention(c) (CXTranslationUnit?) -> (UInt32) = library.loadSymbol("clang_defaultReparseOptions") -internal let clang_reparseTranslationUnit: @convention(c) (CXTranslationUnit?, UInt32, UnsafeMutablePointer?, UInt32) -> (Int32) = library.loadSymbol("clang_reparseTranslationUnit") -internal let clang_getTUResourceUsageName: @convention(c) (CXTUResourceUsageKind) -> (UnsafePointer!) = library.loadSymbol("clang_getTUResourceUsageName") -internal let clang_getCXTUResourceUsage: @convention(c) (CXTranslationUnit?) -> (CXTUResourceUsage) = library.loadSymbol("clang_getCXTUResourceUsage") -internal let clang_disposeCXTUResourceUsage: @convention(c) (CXTUResourceUsage) -> () = library.loadSymbol("clang_disposeCXTUResourceUsage") -internal let clang_getNullCursor: @convention(c) () -> (CXCursor) = library.loadSymbol("clang_getNullCursor") -internal let clang_getTranslationUnitCursor: @convention(c) (CXTranslationUnit?) -> (CXCursor) = library.loadSymbol("clang_getTranslationUnitCursor") -internal let clang_equalCursors: @convention(c) (CXCursor, CXCursor) -> (UInt32) = library.loadSymbol("clang_equalCursors") -internal let clang_Cursor_isNull: @convention(c) (CXCursor) -> (Int32) = library.loadSymbol("clang_Cursor_isNull") -internal let clang_hashCursor: @convention(c) (CXCursor) -> (UInt32) = library.loadSymbol("clang_hashCursor") -internal let clang_getCursorKind: @convention(c) (CXCursor) -> (CXCursorKind) = library.loadSymbol("clang_getCursorKind") -internal let clang_isDeclaration: @convention(c) (CXCursorKind) -> (UInt32) = library.loadSymbol("clang_isDeclaration") -internal let clang_isReference: @convention(c) (CXCursorKind) -> (UInt32) = library.loadSymbol("clang_isReference") -internal let clang_isExpression: @convention(c) (CXCursorKind) -> (UInt32) = library.loadSymbol("clang_isExpression") -internal let clang_isStatement: @convention(c) (CXCursorKind) -> (UInt32) = library.loadSymbol("clang_isStatement") -internal let clang_isAttribute: @convention(c) (CXCursorKind) -> (UInt32) = library.loadSymbol("clang_isAttribute") -internal let clang_isInvalid: @convention(c) (CXCursorKind) -> (UInt32) = library.loadSymbol("clang_isInvalid") -internal let clang_isTranslationUnit: @convention(c) (CXCursorKind) -> (UInt32) = library.loadSymbol("clang_isTranslationUnit") -internal let clang_isPreprocessing: @convention(c) (CXCursorKind) -> (UInt32) = library.loadSymbol("clang_isPreprocessing") -internal let clang_isUnexposed: @convention(c) (CXCursorKind) -> (UInt32) = library.loadSymbol("clang_isUnexposed") -internal let clang_getCursorLinkage: @convention(c) (CXCursor) -> (CXLinkageKind) = library.loadSymbol("clang_getCursorLinkage") -internal let clang_getCursorAvailability: @convention(c) (CXCursor) -> (CXAvailabilityKind) = library.loadSymbol("clang_getCursorAvailability") -internal let clang_getCursorPlatformAvailability: @convention(c) (CXCursor, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?, Int32) -> (Int32) = library.loadSymbol("clang_getCursorPlatformAvailability") -internal let clang_disposeCXPlatformAvailability: @convention(c) (UnsafeMutablePointer?) -> () = library.loadSymbol("clang_disposeCXPlatformAvailability") -internal let clang_getCursorLanguage: @convention(c) (CXCursor) -> (CXLanguageKind) = library.loadSymbol("clang_getCursorLanguage") -internal let clang_Cursor_getTranslationUnit: @convention(c) (CXCursor) -> (CXTranslationUnit!) = library.loadSymbol("clang_Cursor_getTranslationUnit") -internal let clang_createCXCursorSet: @convention(c) () -> (CXCursorSet!) = library.loadSymbol("clang_createCXCursorSet") -internal let clang_disposeCXCursorSet: @convention(c) (CXCursorSet?) -> () = library.loadSymbol("clang_disposeCXCursorSet") -internal let clang_CXCursorSet_contains: @convention(c) (CXCursorSet?, CXCursor) -> (UInt32) = library.loadSymbol("clang_CXCursorSet_contains") -internal let clang_CXCursorSet_insert: @convention(c) (CXCursorSet?, CXCursor) -> (UInt32) = library.loadSymbol("clang_CXCursorSet_insert") -internal let clang_getCursorSemanticParent: @convention(c) (CXCursor) -> (CXCursor) = library.loadSymbol("clang_getCursorSemanticParent") -internal let clang_getCursorLexicalParent: @convention(c) (CXCursor) -> (CXCursor) = library.loadSymbol("clang_getCursorLexicalParent") -internal let clang_getOverriddenCursors: @convention(c) (CXCursor, UnsafeMutablePointer?>?, UnsafeMutablePointer?) -> () = library.loadSymbol("clang_getOverriddenCursors") -internal let clang_disposeOverriddenCursors: @convention(c) (UnsafeMutablePointer?) -> () = library.loadSymbol("clang_disposeOverriddenCursors") -internal let clang_getIncludedFile: @convention(c) (CXCursor) -> (CXFile!) = library.loadSymbol("clang_getIncludedFile") -internal let clang_getCursor: @convention(c) (CXTranslationUnit?, CXSourceLocation) -> (CXCursor) = library.loadSymbol("clang_getCursor") -internal let clang_getCursorLocation: @convention(c) (CXCursor) -> (CXSourceLocation) = library.loadSymbol("clang_getCursorLocation") -internal let clang_getCursorExtent: @convention(c) (CXCursor) -> (CXSourceRange) = library.loadSymbol("clang_getCursorExtent") -internal let clang_getCursorType: @convention(c) (CXCursor) -> (CXType) = library.loadSymbol("clang_getCursorType") -internal let clang_getTypeSpelling: @convention(c) (CXType) -> (CXString) = library.loadSymbol("clang_getTypeSpelling") -internal let clang_getTypedefDeclUnderlyingType: @convention(c) (CXCursor) -> (CXType) = library.loadSymbol("clang_getTypedefDeclUnderlyingType") -internal let clang_getEnumDeclIntegerType: @convention(c) (CXCursor) -> (CXType) = library.loadSymbol("clang_getEnumDeclIntegerType") -internal let clang_getEnumConstantDeclValue: @convention(c) (CXCursor) -> (Int64) = library.loadSymbol("clang_getEnumConstantDeclValue") -internal let clang_getEnumConstantDeclUnsignedValue: @convention(c) (CXCursor) -> (UInt64) = library.loadSymbol("clang_getEnumConstantDeclUnsignedValue") -internal let clang_getFieldDeclBitWidth: @convention(c) (CXCursor) -> (Int32) = library.loadSymbol("clang_getFieldDeclBitWidth") -internal let clang_Cursor_getNumArguments: @convention(c) (CXCursor) -> (Int32) = library.loadSymbol("clang_Cursor_getNumArguments") -internal let clang_Cursor_getArgument: @convention(c) (CXCursor, UInt32) -> (CXCursor) = library.loadSymbol("clang_Cursor_getArgument") -internal let clang_Cursor_getNumTemplateArguments: @convention(c) (CXCursor) -> (Int32) = library.loadSymbol("clang_Cursor_getNumTemplateArguments") -internal let clang_Cursor_getTemplateArgumentKind: @convention(c) (CXCursor, UInt32) -> (CXTemplateArgumentKind) = library.loadSymbol("clang_Cursor_getTemplateArgumentKind") -internal let clang_Cursor_getTemplateArgumentType: @convention(c) (CXCursor, UInt32) -> (CXType) = library.loadSymbol("clang_Cursor_getTemplateArgumentType") -internal let clang_Cursor_getTemplateArgumentValue: @convention(c) (CXCursor, UInt32) -> (Int64) = library.loadSymbol("clang_Cursor_getTemplateArgumentValue") -internal let clang_Cursor_getTemplateArgumentUnsignedValue: @convention(c) (CXCursor, UInt32) -> (UInt64) = library.loadSymbol("clang_Cursor_getTemplateArgumentUnsignedValue") -internal let clang_equalTypes: @convention(c) (CXType, CXType) -> (UInt32) = library.loadSymbol("clang_equalTypes") -internal let clang_getCanonicalType: @convention(c) (CXType) -> (CXType) = library.loadSymbol("clang_getCanonicalType") -internal let clang_isConstQualifiedType: @convention(c) (CXType) -> (UInt32) = library.loadSymbol("clang_isConstQualifiedType") -internal let clang_isVolatileQualifiedType: @convention(c) (CXType) -> (UInt32) = library.loadSymbol("clang_isVolatileQualifiedType") -internal let clang_isRestrictQualifiedType: @convention(c) (CXType) -> (UInt32) = library.loadSymbol("clang_isRestrictQualifiedType") -internal let clang_getPointeeType: @convention(c) (CXType) -> (CXType) = library.loadSymbol("clang_getPointeeType") -internal let clang_getTypeDeclaration: @convention(c) (CXType) -> (CXCursor) = library.loadSymbol("clang_getTypeDeclaration") -internal let clang_getDeclObjCTypeEncoding: @convention(c) (CXCursor) -> (CXString) = library.loadSymbol("clang_getDeclObjCTypeEncoding") -internal let clang_getTypeKindSpelling: @convention(c) (CXTypeKind) -> (CXString) = library.loadSymbol("clang_getTypeKindSpelling") -internal let clang_getFunctionTypeCallingConv: @convention(c) (CXType) -> (CXCallingConv) = library.loadSymbol("clang_getFunctionTypeCallingConv") -internal let clang_getResultType: @convention(c) (CXType) -> (CXType) = library.loadSymbol("clang_getResultType") -internal let clang_getNumArgTypes: @convention(c) (CXType) -> (Int32) = library.loadSymbol("clang_getNumArgTypes") -internal let clang_getArgType: @convention(c) (CXType, UInt32) -> (CXType) = library.loadSymbol("clang_getArgType") -internal let clang_isFunctionTypeVariadic: @convention(c) (CXType) -> (UInt32) = library.loadSymbol("clang_isFunctionTypeVariadic") -internal let clang_getCursorResultType: @convention(c) (CXCursor) -> (CXType) = library.loadSymbol("clang_getCursorResultType") -internal let clang_isPODType: @convention(c) (CXType) -> (UInt32) = library.loadSymbol("clang_isPODType") -internal let clang_getElementType: @convention(c) (CXType) -> (CXType) = library.loadSymbol("clang_getElementType") -internal let clang_getNumElements: @convention(c) (CXType) -> (Int64) = library.loadSymbol("clang_getNumElements") -internal let clang_getArrayElementType: @convention(c) (CXType) -> (CXType) = library.loadSymbol("clang_getArrayElementType") -internal let clang_getArraySize: @convention(c) (CXType) -> (Int64) = library.loadSymbol("clang_getArraySize") -internal let clang_Type_getAlignOf: @convention(c) (CXType) -> (Int64) = library.loadSymbol("clang_Type_getAlignOf") -internal let clang_Type_getClassType: @convention(c) (CXType) -> (CXType) = library.loadSymbol("clang_Type_getClassType") -internal let clang_Type_getSizeOf: @convention(c) (CXType) -> (Int64) = library.loadSymbol("clang_Type_getSizeOf") -internal let clang_Type_getOffsetOf: @convention(c) (CXType, UnsafePointer?) -> (Int64) = library.loadSymbol("clang_Type_getOffsetOf") -internal let clang_Cursor_getOffsetOfField: @convention(c) (CXCursor) -> (Int64) = library.loadSymbol("clang_Cursor_getOffsetOfField") -internal let clang_Cursor_isAnonymous: @convention(c) (CXCursor) -> (UInt32) = library.loadSymbol("clang_Cursor_isAnonymous") -internal let clang_Type_getNumTemplateArguments: @convention(c) (CXType) -> (Int32) = library.loadSymbol("clang_Type_getNumTemplateArguments") -internal let clang_Type_getTemplateArgumentAsType: @convention(c) (CXType, UInt32) -> (CXType) = library.loadSymbol("clang_Type_getTemplateArgumentAsType") -internal let clang_Type_getCXXRefQualifier: @convention(c) (CXType) -> (CXRefQualifierKind) = library.loadSymbol("clang_Type_getCXXRefQualifier") -internal let clang_Cursor_isBitField: @convention(c) (CXCursor) -> (UInt32) = library.loadSymbol("clang_Cursor_isBitField") -internal let clang_isVirtualBase: @convention(c) (CXCursor) -> (UInt32) = library.loadSymbol("clang_isVirtualBase") -internal let clang_getCXXAccessSpecifier: @convention(c) (CXCursor) -> (CX_CXXAccessSpecifier) = library.loadSymbol("clang_getCXXAccessSpecifier") -internal let clang_Cursor_getStorageClass: @convention(c) (CXCursor) -> (CX_StorageClass) = library.loadSymbol("clang_Cursor_getStorageClass") -internal let clang_getNumOverloadedDecls: @convention(c) (CXCursor) -> (UInt32) = library.loadSymbol("clang_getNumOverloadedDecls") -internal let clang_getOverloadedDecl: @convention(c) (CXCursor, UInt32) -> (CXCursor) = library.loadSymbol("clang_getOverloadedDecl") -internal let clang_getIBOutletCollectionType: @convention(c) (CXCursor) -> (CXType) = library.loadSymbol("clang_getIBOutletCollectionType") -internal let clang_visitChildren: @convention(c) (CXCursor, CXCursorVisitor?, CXClientData?) -> (UInt32) = library.loadSymbol("clang_visitChildren") -internal let clang_visitChildrenWithBlock: @convention(c) (CXCursor, CXCursorVisitorBlock?) -> (UInt32) = library.loadSymbol("clang_visitChildrenWithBlock") -internal let clang_getCursorUSR: @convention(c) (CXCursor) -> (CXString) = library.loadSymbol("clang_getCursorUSR") -internal let clang_constructUSR_ObjCClass: @convention(c) (UnsafePointer?) -> (CXString) = library.loadSymbol("clang_constructUSR_ObjCClass") -internal let clang_constructUSR_ObjCCategory: @convention(c) (UnsafePointer?, UnsafePointer?) -> (CXString) = library.loadSymbol("clang_constructUSR_ObjCCategory") -internal let clang_constructUSR_ObjCProtocol: @convention(c) (UnsafePointer?) -> (CXString) = library.loadSymbol("clang_constructUSR_ObjCProtocol") -internal let clang_constructUSR_ObjCIvar: @convention(c) (UnsafePointer?, CXString) -> (CXString) = library.loadSymbol("clang_constructUSR_ObjCIvar") -internal let clang_constructUSR_ObjCMethod: @convention(c) (UnsafePointer?, UInt32, CXString) -> (CXString) = library.loadSymbol("clang_constructUSR_ObjCMethod") -internal let clang_constructUSR_ObjCProperty: @convention(c) (UnsafePointer?, CXString) -> (CXString) = library.loadSymbol("clang_constructUSR_ObjCProperty") -internal let clang_getCursorSpelling: @convention(c) (CXCursor) -> (CXString) = library.loadSymbol("clang_getCursorSpelling") -internal let clang_Cursor_getSpellingNameRange: @convention(c) (CXCursor, UInt32, UInt32) -> (CXSourceRange) = library.loadSymbol("clang_Cursor_getSpellingNameRange") -internal let clang_getCursorDisplayName: @convention(c) (CXCursor) -> (CXString) = library.loadSymbol("clang_getCursorDisplayName") -internal let clang_getCursorReferenced: @convention(c) (CXCursor) -> (CXCursor) = library.loadSymbol("clang_getCursorReferenced") -internal let clang_getCursorDefinition: @convention(c) (CXCursor) -> (CXCursor) = library.loadSymbol("clang_getCursorDefinition") -internal let clang_isCursorDefinition: @convention(c) (CXCursor) -> (UInt32) = library.loadSymbol("clang_isCursorDefinition") -internal let clang_getCanonicalCursor: @convention(c) (CXCursor) -> (CXCursor) = library.loadSymbol("clang_getCanonicalCursor") -internal let clang_Cursor_getObjCSelectorIndex: @convention(c) (CXCursor) -> (Int32) = library.loadSymbol("clang_Cursor_getObjCSelectorIndex") -internal let clang_Cursor_isDynamicCall: @convention(c) (CXCursor) -> (Int32) = library.loadSymbol("clang_Cursor_isDynamicCall") -internal let clang_Cursor_getReceiverType: @convention(c) (CXCursor) -> (CXType) = library.loadSymbol("clang_Cursor_getReceiverType") -internal let clang_Cursor_getObjCPropertyAttributes: @convention(c) (CXCursor, UInt32) -> (UInt32) = library.loadSymbol("clang_Cursor_getObjCPropertyAttributes") -internal let clang_Cursor_getObjCDeclQualifiers: @convention(c) (CXCursor) -> (UInt32) = library.loadSymbol("clang_Cursor_getObjCDeclQualifiers") -internal let clang_Cursor_isObjCOptional: @convention(c) (CXCursor) -> (UInt32) = library.loadSymbol("clang_Cursor_isObjCOptional") -internal let clang_Cursor_isVariadic: @convention(c) (CXCursor) -> (UInt32) = library.loadSymbol("clang_Cursor_isVariadic") -internal let clang_Cursor_getCommentRange: @convention(c) (CXCursor) -> (CXSourceRange) = library.loadSymbol("clang_Cursor_getCommentRange") -internal let clang_Cursor_getRawCommentText: @convention(c) (CXCursor) -> (CXString) = library.loadSymbol("clang_Cursor_getRawCommentText") -internal let clang_Cursor_getBriefCommentText: @convention(c) (CXCursor) -> (CXString) = library.loadSymbol("clang_Cursor_getBriefCommentText") -internal let clang_Cursor_getMangling: @convention(c) (CXCursor) -> (CXString) = library.loadSymbol("clang_Cursor_getMangling") -internal let clang_Cursor_getModule: @convention(c) (CXCursor) -> (CXModule!) = library.loadSymbol("clang_Cursor_getModule") -internal let clang_getModuleForFile: @convention(c) (CXTranslationUnit?, CXFile?) -> (CXModule!) = library.loadSymbol("clang_getModuleForFile") -internal let clang_Module_getASTFile: @convention(c) (CXModule?) -> (CXFile!) = library.loadSymbol("clang_Module_getASTFile") -internal let clang_Module_getParent: @convention(c) (CXModule?) -> (CXModule!) = library.loadSymbol("clang_Module_getParent") -internal let clang_Module_getName: @convention(c) (CXModule?) -> (CXString) = library.loadSymbol("clang_Module_getName") -internal let clang_Module_getFullName: @convention(c) (CXModule?) -> (CXString) = library.loadSymbol("clang_Module_getFullName") -internal let clang_Module_isSystem: @convention(c) (CXModule?) -> (Int32) = library.loadSymbol("clang_Module_isSystem") -internal let clang_Module_getNumTopLevelHeaders: @convention(c) (CXTranslationUnit?, CXModule?) -> (UInt32) = library.loadSymbol("clang_Module_getNumTopLevelHeaders") -internal let clang_Module_getTopLevelHeader: @convention(c) (CXTranslationUnit?, CXModule?, UInt32) -> (CXFile!) = library.loadSymbol("clang_Module_getTopLevelHeader") -internal let clang_CXXField_isMutable: @convention(c) (CXCursor) -> (UInt32) = library.loadSymbol("clang_CXXField_isMutable") -internal let clang_CXXMethod_isPureVirtual: @convention(c) (CXCursor) -> (UInt32) = library.loadSymbol("clang_CXXMethod_isPureVirtual") -internal let clang_CXXMethod_isStatic: @convention(c) (CXCursor) -> (UInt32) = library.loadSymbol("clang_CXXMethod_isStatic") -internal let clang_CXXMethod_isVirtual: @convention(c) (CXCursor) -> (UInt32) = library.loadSymbol("clang_CXXMethod_isVirtual") -internal let clang_CXXMethod_isConst: @convention(c) (CXCursor) -> (UInt32) = library.loadSymbol("clang_CXXMethod_isConst") -internal let clang_getTemplateCursorKind: @convention(c) (CXCursor) -> (CXCursorKind) = library.loadSymbol("clang_getTemplateCursorKind") -internal let clang_getSpecializedCursorTemplate: @convention(c) (CXCursor) -> (CXCursor) = library.loadSymbol("clang_getSpecializedCursorTemplate") -internal let clang_getCursorReferenceNameRange: @convention(c) (CXCursor, UInt32, UInt32) -> (CXSourceRange) = library.loadSymbol("clang_getCursorReferenceNameRange") -internal let clang_getTokenKind: @convention(c) (CXToken) -> (CXTokenKind) = library.loadSymbol("clang_getTokenKind") -internal let clang_getTokenSpelling: @convention(c) (CXTranslationUnit?, CXToken) -> (CXString) = library.loadSymbol("clang_getTokenSpelling") -internal let clang_getTokenLocation: @convention(c) (CXTranslationUnit?, CXToken) -> (CXSourceLocation) = library.loadSymbol("clang_getTokenLocation") -internal let clang_getTokenExtent: @convention(c) (CXTranslationUnit?, CXToken) -> (CXSourceRange) = library.loadSymbol("clang_getTokenExtent") -internal let clang_tokenize: @convention(c) (CXTranslationUnit?, CXSourceRange, UnsafeMutablePointer?>?, UnsafeMutablePointer?) -> () = library.loadSymbol("clang_tokenize") -internal let clang_annotateTokens: @convention(c) (CXTranslationUnit?, UnsafeMutablePointer?, UInt32, UnsafeMutablePointer?) -> () = library.loadSymbol("clang_annotateTokens") -internal let clang_disposeTokens: @convention(c) (CXTranslationUnit?, UnsafeMutablePointer?, UInt32) -> () = library.loadSymbol("clang_disposeTokens") -internal let clang_getCursorKindSpelling: @convention(c) (CXCursorKind) -> (CXString) = library.loadSymbol("clang_getCursorKindSpelling") -internal let clang_getDefinitionSpellingAndExtent: @convention(c) (CXCursor, UnsafeMutablePointer?>?, UnsafeMutablePointer?>?, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?) -> () = library.loadSymbol("clang_getDefinitionSpellingAndExtent") -internal let clang_enableStackTraces: @convention(c) () -> () = library.loadSymbol("clang_enableStackTraces") -internal let clang_getCompletionChunkKind: @convention(c) (CXCompletionString?, UInt32) -> (CXCompletionChunkKind) = library.loadSymbol("clang_getCompletionChunkKind") -internal let clang_getCompletionChunkText: @convention(c) (CXCompletionString?, UInt32) -> (CXString) = library.loadSymbol("clang_getCompletionChunkText") -internal let clang_getCompletionChunkCompletionString: @convention(c) (CXCompletionString?, UInt32) -> (CXCompletionString!) = library.loadSymbol("clang_getCompletionChunkCompletionString") -internal let clang_getNumCompletionChunks: @convention(c) (CXCompletionString?) -> (UInt32) = library.loadSymbol("clang_getNumCompletionChunks") -internal let clang_getCompletionPriority: @convention(c) (CXCompletionString?) -> (UInt32) = library.loadSymbol("clang_getCompletionPriority") -internal let clang_getCompletionAvailability: @convention(c) (CXCompletionString?) -> (CXAvailabilityKind) = library.loadSymbol("clang_getCompletionAvailability") -internal let clang_getCompletionNumAnnotations: @convention(c) (CXCompletionString?) -> (UInt32) = library.loadSymbol("clang_getCompletionNumAnnotations") -internal let clang_getCompletionAnnotation: @convention(c) (CXCompletionString?, UInt32) -> (CXString) = library.loadSymbol("clang_getCompletionAnnotation") -internal let clang_getCompletionParent: @convention(c) (CXCompletionString?, UnsafeMutablePointer?) -> (CXString) = library.loadSymbol("clang_getCompletionParent") -internal let clang_getCompletionBriefComment: @convention(c) (CXCompletionString?) -> (CXString) = library.loadSymbol("clang_getCompletionBriefComment") -internal let clang_getCursorCompletionString: @convention(c) (CXCursor) -> (CXCompletionString!) = library.loadSymbol("clang_getCursorCompletionString") -internal let clang_defaultCodeCompleteOptions: @convention(c) () -> (UInt32) = library.loadSymbol("clang_defaultCodeCompleteOptions") -internal let clang_codeCompleteAt: @convention(c) (CXTranslationUnit?, UnsafePointer?, UInt32, UInt32, UnsafeMutablePointer?, UInt32, UInt32) -> (UnsafeMutablePointer!) = library.loadSymbol("clang_codeCompleteAt") -internal let clang_sortCodeCompletionResults: @convention(c) (UnsafeMutablePointer?, UInt32) -> () = library.loadSymbol("clang_sortCodeCompletionResults") -internal let clang_disposeCodeCompleteResults: @convention(c) (UnsafeMutablePointer?) -> () = library.loadSymbol("clang_disposeCodeCompleteResults") -internal let clang_codeCompleteGetNumDiagnostics: @convention(c) (UnsafeMutablePointer?) -> (UInt32) = library.loadSymbol("clang_codeCompleteGetNumDiagnostics") -internal let clang_codeCompleteGetDiagnostic: @convention(c) (UnsafeMutablePointer?, UInt32) -> (CXDiagnostic!) = library.loadSymbol("clang_codeCompleteGetDiagnostic") -internal let clang_codeCompleteGetContexts: @convention(c) (UnsafeMutablePointer?) -> (UInt64) = library.loadSymbol("clang_codeCompleteGetContexts") -internal let clang_codeCompleteGetContainerKind: @convention(c) (UnsafeMutablePointer?, UnsafeMutablePointer?) -> (CXCursorKind) = library.loadSymbol("clang_codeCompleteGetContainerKind") -internal let clang_codeCompleteGetContainerUSR: @convention(c) (UnsafeMutablePointer?) -> (CXString) = library.loadSymbol("clang_codeCompleteGetContainerUSR") -internal let clang_codeCompleteGetObjCSelector: @convention(c) (UnsafeMutablePointer?) -> (CXString) = library.loadSymbol("clang_codeCompleteGetObjCSelector") -internal let clang_getClangVersion: @convention(c) () -> (CXString) = library.loadSymbol("clang_getClangVersion") -internal let clang_toggleCrashRecovery: @convention(c) (UInt32) -> () = library.loadSymbol("clang_toggleCrashRecovery") -internal let clang_getInclusions: @convention(c) (CXTranslationUnit?, CXInclusionVisitor?, CXClientData?) -> () = library.loadSymbol("clang_getInclusions") -internal let clang_getRemappings: @convention(c) (UnsafePointer?) -> (CXRemapping!) = library.loadSymbol("clang_getRemappings") -internal let clang_getRemappingsFromFileList: @convention(c) (UnsafeMutablePointer?>?, UInt32) -> (CXRemapping!) = library.loadSymbol("clang_getRemappingsFromFileList") -internal let clang_remap_getNumFiles: @convention(c) (CXRemapping?) -> (UInt32) = library.loadSymbol("clang_remap_getNumFiles") -internal let clang_remap_getFilenames: @convention(c) (CXRemapping?, UInt32, UnsafeMutablePointer?, UnsafeMutablePointer?) -> () = library.loadSymbol("clang_remap_getFilenames") -internal let clang_remap_dispose: @convention(c) (CXRemapping?) -> () = library.loadSymbol("clang_remap_dispose") -internal let clang_findReferencesInFile: @convention(c) (CXCursor, CXFile?, CXCursorAndRangeVisitor) -> (CXResult) = library.loadSymbol("clang_findReferencesInFile") -internal let clang_findIncludesInFile: @convention(c) (CXTranslationUnit?, CXFile?, CXCursorAndRangeVisitor) -> (CXResult) = library.loadSymbol("clang_findIncludesInFile") -internal let clang_findReferencesInFileWithBlock: @convention(c) (CXCursor, CXFile?, CXCursorAndRangeVisitorBlock?) -> (CXResult) = library.loadSymbol("clang_findReferencesInFileWithBlock") -internal let clang_findIncludesInFileWithBlock: @convention(c) (CXTranslationUnit?, CXFile?, CXCursorAndRangeVisitorBlock?) -> (CXResult) = library.loadSymbol("clang_findIncludesInFileWithBlock") -internal let clang_index_isEntityObjCContainerKind: @convention(c) (CXIdxEntityKind) -> (Int32) = library.loadSymbol("clang_index_isEntityObjCContainerKind") -internal let clang_index_getObjCContainerDeclInfo: @convention(c) (UnsafePointer?) -> (UnsafePointer!) = library.loadSymbol("clang_index_getObjCContainerDeclInfo") -internal let clang_index_getObjCInterfaceDeclInfo: @convention(c) (UnsafePointer?) -> (UnsafePointer!) = library.loadSymbol("clang_index_getObjCInterfaceDeclInfo") -internal let clang_index_getObjCCategoryDeclInfo: @convention(c) (UnsafePointer?) -> (UnsafePointer!) = library.loadSymbol("clang_index_getObjCCategoryDeclInfo") -internal let clang_index_getObjCProtocolRefListInfo: @convention(c) (UnsafePointer?) -> (UnsafePointer!) = library.loadSymbol("clang_index_getObjCProtocolRefListInfo") -internal let clang_index_getObjCPropertyDeclInfo: @convention(c) (UnsafePointer?) -> (UnsafePointer!) = library.loadSymbol("clang_index_getObjCPropertyDeclInfo") -internal let clang_index_getIBOutletCollectionAttrInfo: @convention(c) (UnsafePointer?) -> (UnsafePointer!) = library.loadSymbol("clang_index_getIBOutletCollectionAttrInfo") -internal let clang_index_getCXXClassDeclInfo: @convention(c) (UnsafePointer?) -> (UnsafePointer!) = library.loadSymbol("clang_index_getCXXClassDeclInfo") -internal let clang_index_getClientContainer: @convention(c) (UnsafePointer?) -> (CXIdxClientContainer!) = library.loadSymbol("clang_index_getClientContainer") -internal let clang_index_setClientContainer: @convention(c) (UnsafePointer?, CXIdxClientContainer?) -> () = library.loadSymbol("clang_index_setClientContainer") -internal let clang_index_getClientEntity: @convention(c) (UnsafePointer?) -> (CXIdxClientEntity!) = library.loadSymbol("clang_index_getClientEntity") -internal let clang_index_setClientEntity: @convention(c) (UnsafePointer?, CXIdxClientEntity?) -> () = library.loadSymbol("clang_index_setClientEntity") -internal let clang_IndexAction_create: @convention(c) (CXIndex?) -> (CXIndexAction!) = library.loadSymbol("clang_IndexAction_create") -internal let clang_IndexAction_dispose: @convention(c) (CXIndexAction?) -> () = library.loadSymbol("clang_IndexAction_dispose") -internal let clang_indexSourceFile: @convention(c) (CXIndexAction?, CXClientData?, UnsafeMutablePointer?, UInt32, UInt32, UnsafePointer?, UnsafePointer?>?, Int32, UnsafeMutablePointer?, UInt32, UnsafeMutablePointer?, UInt32) -> (Int32) = library.loadSymbol("clang_indexSourceFile") -internal let clang_indexTranslationUnit: @convention(c) (CXIndexAction?, CXClientData?, UnsafeMutablePointer?, UInt32, UInt32, CXTranslationUnit?) -> (Int32) = library.loadSymbol("clang_indexTranslationUnit") -internal let clang_indexLoc_getFileLocation: @convention(c) (CXIdxLoc, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?) -> () = library.loadSymbol("clang_indexLoc_getFileLocation") -internal let clang_indexLoc_getCXSourceLocation: @convention(c) (CXIdxLoc) -> (CXSourceLocation) = library.loadSymbol("clang_indexLoc_getCXSourceLocation") -internal let clang_Type_visitFields: @convention(c) (CXType, CXFieldVisitor?, CXClientData?) -> (UInt32) = library.loadSymbol("clang_Type_visitFields") +private let library = toolchainLoader.load(path: "libclang.dylib") +internal let clang_createIndex: @convention(c) (Int32, Int32) -> (CXIndex!) = library.load(symbol: "clang_createIndex") +internal let clang_disposeIndex: @convention(c) (CXIndex?) -> () = library.load(symbol: "clang_disposeIndex") +internal let clang_CXIndex_setGlobalOptions: @convention(c) (CXIndex?, UInt32) -> () = library.load(symbol: "clang_CXIndex_setGlobalOptions") +internal let clang_CXIndex_getGlobalOptions: @convention(c) (CXIndex?) -> (UInt32) = library.load(symbol: "clang_CXIndex_getGlobalOptions") +internal let clang_getFileName: @convention(c) (CXFile?) -> (CXString) = library.load(symbol: "clang_getFileName") +internal let clang_getFileTime: @convention(c) (CXFile?) -> (time_t) = library.load(symbol: "clang_getFileTime") +internal let clang_getFileUniqueID: @convention(c) (CXFile?, UnsafeMutablePointer?) -> (Int32) = library.load(symbol: "clang_getFileUniqueID") +internal let clang_isFileMultipleIncludeGuarded: @convention(c) (CXTranslationUnit?, CXFile?) -> (UInt32) = library.load(symbol: "clang_isFileMultipleIncludeGuarded") +internal let clang_getFile: @convention(c) (CXTranslationUnit?, UnsafePointer?) -> (CXFile!) = library.load(symbol: "clang_getFile") +internal let clang_File_isEqual: @convention(c) (CXFile?, CXFile?) -> (Int32) = library.load(symbol: "clang_File_isEqual") +internal let clang_getNullLocation: @convention(c) () -> (CXSourceLocation) = library.load(symbol: "clang_getNullLocation") +internal let clang_equalLocations: @convention(c) (CXSourceLocation, CXSourceLocation) -> (UInt32) = library.load(symbol: "clang_equalLocations") +internal let clang_getLocation: @convention(c) (CXTranslationUnit?, CXFile?, UInt32, UInt32) -> (CXSourceLocation) = library.load(symbol: "clang_getLocation") +internal let clang_getLocationForOffset: @convention(c) (CXTranslationUnit?, CXFile?, UInt32) -> (CXSourceLocation) = library.load(symbol: "clang_getLocationForOffset") +internal let clang_Location_isInSystemHeader: @convention(c) (CXSourceLocation) -> (Int32) = library.load(symbol: "clang_Location_isInSystemHeader") +internal let clang_Location_isFromMainFile: @convention(c) (CXSourceLocation) -> (Int32) = library.load(symbol: "clang_Location_isFromMainFile") +internal let clang_getNullRange: @convention(c) () -> (CXSourceRange) = library.load(symbol: "clang_getNullRange") +internal let clang_getRange: @convention(c) (CXSourceLocation, CXSourceLocation) -> (CXSourceRange) = library.load(symbol: "clang_getRange") +internal let clang_equalRanges: @convention(c) (CXSourceRange, CXSourceRange) -> (UInt32) = library.load(symbol: "clang_equalRanges") +internal let clang_Range_isNull: @convention(c) (CXSourceRange) -> (Int32) = library.load(symbol: "clang_Range_isNull") +internal let clang_getExpansionLocation: @convention(c) (CXSourceLocation, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?) -> () = library.load(symbol: "clang_getExpansionLocation") +internal let clang_getPresumedLocation: @convention(c) (CXSourceLocation, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?) -> () = library.load(symbol: "clang_getPresumedLocation") +internal let clang_getInstantiationLocation: @convention(c) (CXSourceLocation, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?) -> () = library.load(symbol: "clang_getInstantiationLocation") +internal let clang_getSpellingLocation: @convention(c) (CXSourceLocation, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?) -> () = library.load(symbol: "clang_getSpellingLocation") +internal let clang_getFileLocation: @convention(c) (CXSourceLocation, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?) -> () = library.load(symbol: "clang_getFileLocation") +internal let clang_getRangeStart: @convention(c) (CXSourceRange) -> (CXSourceLocation) = library.load(symbol: "clang_getRangeStart") +internal let clang_getRangeEnd: @convention(c) (CXSourceRange) -> (CXSourceLocation) = library.load(symbol: "clang_getRangeEnd") +internal let clang_getSkippedRanges: @convention(c) (CXTranslationUnit?, CXFile?) -> (UnsafeMutablePointer!) = library.load(symbol: "clang_getSkippedRanges") +internal let clang_disposeSourceRangeList: @convention(c) (UnsafeMutablePointer?) -> () = library.load(symbol: "clang_disposeSourceRangeList") +internal let clang_getNumDiagnosticsInSet: @convention(c) (CXDiagnosticSet?) -> (UInt32) = library.load(symbol: "clang_getNumDiagnosticsInSet") +internal let clang_getDiagnosticInSet: @convention(c) (CXDiagnosticSet?, UInt32) -> (CXDiagnostic!) = library.load(symbol: "clang_getDiagnosticInSet") +internal let clang_loadDiagnostics: @convention(c) (UnsafePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?) -> (CXDiagnosticSet!) = library.load(symbol: "clang_loadDiagnostics") +internal let clang_disposeDiagnosticSet: @convention(c) (CXDiagnosticSet?) -> () = library.load(symbol: "clang_disposeDiagnosticSet") +internal let clang_getChildDiagnostics: @convention(c) (CXDiagnostic?) -> (CXDiagnosticSet!) = library.load(symbol: "clang_getChildDiagnostics") +internal let clang_getNumDiagnostics: @convention(c) (CXTranslationUnit?) -> (UInt32) = library.load(symbol: "clang_getNumDiagnostics") +internal let clang_getDiagnostic: @convention(c) (CXTranslationUnit?, UInt32) -> (CXDiagnostic!) = library.load(symbol: "clang_getDiagnostic") +internal let clang_getDiagnosticSetFromTU: @convention(c) (CXTranslationUnit?) -> (CXDiagnosticSet!) = library.load(symbol: "clang_getDiagnosticSetFromTU") +internal let clang_disposeDiagnostic: @convention(c) (CXDiagnostic?) -> () = library.load(symbol: "clang_disposeDiagnostic") +internal let clang_formatDiagnostic: @convention(c) (CXDiagnostic?, UInt32) -> (CXString) = library.load(symbol: "clang_formatDiagnostic") +internal let clang_defaultDiagnosticDisplayOptions: @convention(c) () -> (UInt32) = library.load(symbol: "clang_defaultDiagnosticDisplayOptions") +internal let clang_getDiagnosticSeverity: @convention(c) (CXDiagnostic?) -> (CXDiagnosticSeverity) = library.load(symbol: "clang_getDiagnosticSeverity") +internal let clang_getDiagnosticLocation: @convention(c) (CXDiagnostic?) -> (CXSourceLocation) = library.load(symbol: "clang_getDiagnosticLocation") +internal let clang_getDiagnosticSpelling: @convention(c) (CXDiagnostic?) -> (CXString) = library.load(symbol: "clang_getDiagnosticSpelling") +internal let clang_getDiagnosticOption: @convention(c) (CXDiagnostic?, UnsafeMutablePointer?) -> (CXString) = library.load(symbol: "clang_getDiagnosticOption") +internal let clang_getDiagnosticCategory: @convention(c) (CXDiagnostic?) -> (UInt32) = library.load(symbol: "clang_getDiagnosticCategory") +internal let clang_getDiagnosticCategoryName: @convention(c) (UInt32) -> (CXString) = library.load(symbol: "clang_getDiagnosticCategoryName") +internal let clang_getDiagnosticCategoryText: @convention(c) (CXDiagnostic?) -> (CXString) = library.load(symbol: "clang_getDiagnosticCategoryText") +internal let clang_getDiagnosticNumRanges: @convention(c) (CXDiagnostic?) -> (UInt32) = library.load(symbol: "clang_getDiagnosticNumRanges") +internal let clang_getDiagnosticRange: @convention(c) (CXDiagnostic?, UInt32) -> (CXSourceRange) = library.load(symbol: "clang_getDiagnosticRange") +internal let clang_getDiagnosticNumFixIts: @convention(c) (CXDiagnostic?) -> (UInt32) = library.load(symbol: "clang_getDiagnosticNumFixIts") +internal let clang_getDiagnosticFixIt: @convention(c) (CXDiagnostic?, UInt32, UnsafeMutablePointer?) -> (CXString) = library.load(symbol: "clang_getDiagnosticFixIt") +internal let clang_getTranslationUnitSpelling: @convention(c) (CXTranslationUnit?) -> (CXString) = library.load(symbol: "clang_getTranslationUnitSpelling") +internal let clang_createTranslationUnitFromSourceFile: @convention(c) (CXIndex?, UnsafePointer?, Int32, UnsafePointer?>?, UInt32, UnsafeMutablePointer?) -> (CXTranslationUnit!) = library.load(symbol: "clang_createTranslationUnitFromSourceFile") +internal let clang_createTranslationUnit: @convention(c) (CXIndex?, UnsafePointer?) -> (CXTranslationUnit!) = library.load(symbol: "clang_createTranslationUnit") +internal let clang_createTranslationUnit2: @convention(c) (CXIndex?, UnsafePointer?, UnsafeMutablePointer?) -> (CXErrorCode) = library.load(symbol: "clang_createTranslationUnit2") +internal let clang_defaultEditingTranslationUnitOptions: @convention(c) () -> (UInt32) = library.load(symbol: "clang_defaultEditingTranslationUnitOptions") +internal let clang_parseTranslationUnit: @convention(c) (CXIndex?, UnsafePointer?, UnsafePointer?>?, Int32, UnsafeMutablePointer?, UInt32, UInt32) -> (CXTranslationUnit!) = library.load(symbol: "clang_parseTranslationUnit") +internal let clang_parseTranslationUnit2: @convention(c) (CXIndex?, UnsafePointer?, UnsafePointer?>?, Int32, UnsafeMutablePointer?, UInt32, UInt32, UnsafeMutablePointer?) -> (CXErrorCode) = library.load(symbol: "clang_parseTranslationUnit2") +internal let clang_defaultSaveOptions: @convention(c) (CXTranslationUnit?) -> (UInt32) = library.load(symbol: "clang_defaultSaveOptions") +internal let clang_saveTranslationUnit: @convention(c) (CXTranslationUnit?, UnsafePointer?, UInt32) -> (Int32) = library.load(symbol: "clang_saveTranslationUnit") +internal let clang_disposeTranslationUnit: @convention(c) (CXTranslationUnit?) -> () = library.load(symbol: "clang_disposeTranslationUnit") +internal let clang_defaultReparseOptions: @convention(c) (CXTranslationUnit?) -> (UInt32) = library.load(symbol: "clang_defaultReparseOptions") +internal let clang_reparseTranslationUnit: @convention(c) (CXTranslationUnit?, UInt32, UnsafeMutablePointer?, UInt32) -> (Int32) = library.load(symbol: "clang_reparseTranslationUnit") +internal let clang_getTUResourceUsageName: @convention(c) (CXTUResourceUsageKind) -> (UnsafePointer!) = library.load(symbol: "clang_getTUResourceUsageName") +internal let clang_getCXTUResourceUsage: @convention(c) (CXTranslationUnit?) -> (CXTUResourceUsage) = library.load(symbol: "clang_getCXTUResourceUsage") +internal let clang_disposeCXTUResourceUsage: @convention(c) (CXTUResourceUsage) -> () = library.load(symbol: "clang_disposeCXTUResourceUsage") +internal let clang_getNullCursor: @convention(c) () -> (CXCursor) = library.load(symbol: "clang_getNullCursor") +internal let clang_getTranslationUnitCursor: @convention(c) (CXTranslationUnit?) -> (CXCursor) = library.load(symbol: "clang_getTranslationUnitCursor") +internal let clang_equalCursors: @convention(c) (CXCursor, CXCursor) -> (UInt32) = library.load(symbol: "clang_equalCursors") +internal let clang_Cursor_isNull: @convention(c) (CXCursor) -> (Int32) = library.load(symbol: "clang_Cursor_isNull") +internal let clang_hashCursor: @convention(c) (CXCursor) -> (UInt32) = library.load(symbol: "clang_hashCursor") +internal let clang_getCursorKind: @convention(c) (CXCursor) -> (CXCursorKind) = library.load(symbol: "clang_getCursorKind") +internal let clang_isDeclaration: @convention(c) (CXCursorKind) -> (UInt32) = library.load(symbol: "clang_isDeclaration") +internal let clang_isReference: @convention(c) (CXCursorKind) -> (UInt32) = library.load(symbol: "clang_isReference") +internal let clang_isExpression: @convention(c) (CXCursorKind) -> (UInt32) = library.load(symbol: "clang_isExpression") +internal let clang_isStatement: @convention(c) (CXCursorKind) -> (UInt32) = library.load(symbol: "clang_isStatement") +internal let clang_isAttribute: @convention(c) (CXCursorKind) -> (UInt32) = library.load(symbol: "clang_isAttribute") +internal let clang_isInvalid: @convention(c) (CXCursorKind) -> (UInt32) = library.load(symbol: "clang_isInvalid") +internal let clang_isTranslationUnit: @convention(c) (CXCursorKind) -> (UInt32) = library.load(symbol: "clang_isTranslationUnit") +internal let clang_isPreprocessing: @convention(c) (CXCursorKind) -> (UInt32) = library.load(symbol: "clang_isPreprocessing") +internal let clang_isUnexposed: @convention(c) (CXCursorKind) -> (UInt32) = library.load(symbol: "clang_isUnexposed") +internal let clang_getCursorLinkage: @convention(c) (CXCursor) -> (CXLinkageKind) = library.load(symbol: "clang_getCursorLinkage") +internal let clang_getCursorAvailability: @convention(c) (CXCursor) -> (CXAvailabilityKind) = library.load(symbol: "clang_getCursorAvailability") +internal let clang_getCursorPlatformAvailability: @convention(c) (CXCursor, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?, Int32) -> (Int32) = library.load(symbol: "clang_getCursorPlatformAvailability") +internal let clang_disposeCXPlatformAvailability: @convention(c) (UnsafeMutablePointer?) -> () = library.load(symbol: "clang_disposeCXPlatformAvailability") +internal let clang_getCursorLanguage: @convention(c) (CXCursor) -> (CXLanguageKind) = library.load(symbol: "clang_getCursorLanguage") +internal let clang_Cursor_getTranslationUnit: @convention(c) (CXCursor) -> (CXTranslationUnit!) = library.load(symbol: "clang_Cursor_getTranslationUnit") +internal let clang_createCXCursorSet: @convention(c) () -> (CXCursorSet!) = library.load(symbol: "clang_createCXCursorSet") +internal let clang_disposeCXCursorSet: @convention(c) (CXCursorSet?) -> () = library.load(symbol: "clang_disposeCXCursorSet") +internal let clang_CXCursorSet_contains: @convention(c) (CXCursorSet?, CXCursor) -> (UInt32) = library.load(symbol: "clang_CXCursorSet_contains") +internal let clang_CXCursorSet_insert: @convention(c) (CXCursorSet?, CXCursor) -> (UInt32) = library.load(symbol: "clang_CXCursorSet_insert") +internal let clang_getCursorSemanticParent: @convention(c) (CXCursor) -> (CXCursor) = library.load(symbol: "clang_getCursorSemanticParent") +internal let clang_getCursorLexicalParent: @convention(c) (CXCursor) -> (CXCursor) = library.load(symbol: "clang_getCursorLexicalParent") +internal let clang_getOverriddenCursors: @convention(c) (CXCursor, UnsafeMutablePointer?>?, UnsafeMutablePointer?) -> () = library.load(symbol: "clang_getOverriddenCursors") +internal let clang_disposeOverriddenCursors: @convention(c) (UnsafeMutablePointer?) -> () = library.load(symbol: "clang_disposeOverriddenCursors") +internal let clang_getIncludedFile: @convention(c) (CXCursor) -> (CXFile!) = library.load(symbol: "clang_getIncludedFile") +internal let clang_getCursor: @convention(c) (CXTranslationUnit?, CXSourceLocation) -> (CXCursor) = library.load(symbol: "clang_getCursor") +internal let clang_getCursorLocation: @convention(c) (CXCursor) -> (CXSourceLocation) = library.load(symbol: "clang_getCursorLocation") +internal let clang_getCursorExtent: @convention(c) (CXCursor) -> (CXSourceRange) = library.load(symbol: "clang_getCursorExtent") +internal let clang_getCursorType: @convention(c) (CXCursor) -> (CXType) = library.load(symbol: "clang_getCursorType") +internal let clang_getTypeSpelling: @convention(c) (CXType) -> (CXString) = library.load(symbol: "clang_getTypeSpelling") +internal let clang_getTypedefDeclUnderlyingType: @convention(c) (CXCursor) -> (CXType) = library.load(symbol: "clang_getTypedefDeclUnderlyingType") +internal let clang_getEnumDeclIntegerType: @convention(c) (CXCursor) -> (CXType) = library.load(symbol: "clang_getEnumDeclIntegerType") +internal let clang_getEnumConstantDeclValue: @convention(c) (CXCursor) -> (Int64) = library.load(symbol: "clang_getEnumConstantDeclValue") +internal let clang_getEnumConstantDeclUnsignedValue: @convention(c) (CXCursor) -> (UInt64) = library.load(symbol: "clang_getEnumConstantDeclUnsignedValue") +internal let clang_getFieldDeclBitWidth: @convention(c) (CXCursor) -> (Int32) = library.load(symbol: "clang_getFieldDeclBitWidth") +internal let clang_Cursor_getNumArguments: @convention(c) (CXCursor) -> (Int32) = library.load(symbol: "clang_Cursor_getNumArguments") +internal let clang_Cursor_getArgument: @convention(c) (CXCursor, UInt32) -> (CXCursor) = library.load(symbol: "clang_Cursor_getArgument") +internal let clang_Cursor_getNumTemplateArguments: @convention(c) (CXCursor) -> (Int32) = library.load(symbol: "clang_Cursor_getNumTemplateArguments") +internal let clang_Cursor_getTemplateArgumentKind: @convention(c) (CXCursor, UInt32) -> (CXTemplateArgumentKind) = library.load(symbol: "clang_Cursor_getTemplateArgumentKind") +internal let clang_Cursor_getTemplateArgumentType: @convention(c) (CXCursor, UInt32) -> (CXType) = library.load(symbol: "clang_Cursor_getTemplateArgumentType") +internal let clang_Cursor_getTemplateArgumentValue: @convention(c) (CXCursor, UInt32) -> (Int64) = library.load(symbol: "clang_Cursor_getTemplateArgumentValue") +internal let clang_Cursor_getTemplateArgumentUnsignedValue: @convention(c) (CXCursor, UInt32) -> (UInt64) = library.load(symbol: "clang_Cursor_getTemplateArgumentUnsignedValue") +internal let clang_equalTypes: @convention(c) (CXType, CXType) -> (UInt32) = library.load(symbol: "clang_equalTypes") +internal let clang_getCanonicalType: @convention(c) (CXType) -> (CXType) = library.load(symbol: "clang_getCanonicalType") +internal let clang_isConstQualifiedType: @convention(c) (CXType) -> (UInt32) = library.load(symbol: "clang_isConstQualifiedType") +internal let clang_isVolatileQualifiedType: @convention(c) (CXType) -> (UInt32) = library.load(symbol: "clang_isVolatileQualifiedType") +internal let clang_isRestrictQualifiedType: @convention(c) (CXType) -> (UInt32) = library.load(symbol: "clang_isRestrictQualifiedType") +internal let clang_getPointeeType: @convention(c) (CXType) -> (CXType) = library.load(symbol: "clang_getPointeeType") +internal let clang_getTypeDeclaration: @convention(c) (CXType) -> (CXCursor) = library.load(symbol: "clang_getTypeDeclaration") +internal let clang_getDeclObjCTypeEncoding: @convention(c) (CXCursor) -> (CXString) = library.load(symbol: "clang_getDeclObjCTypeEncoding") +internal let clang_getTypeKindSpelling: @convention(c) (CXTypeKind) -> (CXString) = library.load(symbol: "clang_getTypeKindSpelling") +internal let clang_getFunctionTypeCallingConv: @convention(c) (CXType) -> (CXCallingConv) = library.load(symbol: "clang_getFunctionTypeCallingConv") +internal let clang_getResultType: @convention(c) (CXType) -> (CXType) = library.load(symbol: "clang_getResultType") +internal let clang_getNumArgTypes: @convention(c) (CXType) -> (Int32) = library.load(symbol: "clang_getNumArgTypes") +internal let clang_getArgType: @convention(c) (CXType, UInt32) -> (CXType) = library.load(symbol: "clang_getArgType") +internal let clang_isFunctionTypeVariadic: @convention(c) (CXType) -> (UInt32) = library.load(symbol: "clang_isFunctionTypeVariadic") +internal let clang_getCursorResultType: @convention(c) (CXCursor) -> (CXType) = library.load(symbol: "clang_getCursorResultType") +internal let clang_isPODType: @convention(c) (CXType) -> (UInt32) = library.load(symbol: "clang_isPODType") +internal let clang_getElementType: @convention(c) (CXType) -> (CXType) = library.load(symbol: "clang_getElementType") +internal let clang_getNumElements: @convention(c) (CXType) -> (Int64) = library.load(symbol: "clang_getNumElements") +internal let clang_getArrayElementType: @convention(c) (CXType) -> (CXType) = library.load(symbol: "clang_getArrayElementType") +internal let clang_getArraySize: @convention(c) (CXType) -> (Int64) = library.load(symbol: "clang_getArraySize") +internal let clang_Type_getAlignOf: @convention(c) (CXType) -> (Int64) = library.load(symbol: "clang_Type_getAlignOf") +internal let clang_Type_getClassType: @convention(c) (CXType) -> (CXType) = library.load(symbol: "clang_Type_getClassType") +internal let clang_Type_getSizeOf: @convention(c) (CXType) -> (Int64) = library.load(symbol: "clang_Type_getSizeOf") +internal let clang_Type_getOffsetOf: @convention(c) (CXType, UnsafePointer?) -> (Int64) = library.load(symbol: "clang_Type_getOffsetOf") +internal let clang_Cursor_getOffsetOfField: @convention(c) (CXCursor) -> (Int64) = library.load(symbol: "clang_Cursor_getOffsetOfField") +internal let clang_Cursor_isAnonymous: @convention(c) (CXCursor) -> (UInt32) = library.load(symbol: "clang_Cursor_isAnonymous") +internal let clang_Type_getNumTemplateArguments: @convention(c) (CXType) -> (Int32) = library.load(symbol: "clang_Type_getNumTemplateArguments") +internal let clang_Type_getTemplateArgumentAsType: @convention(c) (CXType, UInt32) -> (CXType) = library.load(symbol: "clang_Type_getTemplateArgumentAsType") +internal let clang_Type_getCXXRefQualifier: @convention(c) (CXType) -> (CXRefQualifierKind) = library.load(symbol: "clang_Type_getCXXRefQualifier") +internal let clang_Cursor_isBitField: @convention(c) (CXCursor) -> (UInt32) = library.load(symbol: "clang_Cursor_isBitField") +internal let clang_isVirtualBase: @convention(c) (CXCursor) -> (UInt32) = library.load(symbol: "clang_isVirtualBase") +internal let clang_getCXXAccessSpecifier: @convention(c) (CXCursor) -> (CX_CXXAccessSpecifier) = library.load(symbol: "clang_getCXXAccessSpecifier") +internal let clang_Cursor_getStorageClass: @convention(c) (CXCursor) -> (CX_StorageClass) = library.load(symbol: "clang_Cursor_getStorageClass") +internal let clang_getNumOverloadedDecls: @convention(c) (CXCursor) -> (UInt32) = library.load(symbol: "clang_getNumOverloadedDecls") +internal let clang_getOverloadedDecl: @convention(c) (CXCursor, UInt32) -> (CXCursor) = library.load(symbol: "clang_getOverloadedDecl") +internal let clang_getIBOutletCollectionType: @convention(c) (CXCursor) -> (CXType) = library.load(symbol: "clang_getIBOutletCollectionType") +internal let clang_visitChildren: @convention(c) (CXCursor, CXCursorVisitor?, CXClientData?) -> (UInt32) = library.load(symbol: "clang_visitChildren") +internal let clang_visitChildrenWithBlock: @convention(c) (CXCursor, CXCursorVisitorBlock?) -> (UInt32) = library.load(symbol: "clang_visitChildrenWithBlock") +internal let clang_getCursorUSR: @convention(c) (CXCursor) -> (CXString) = library.load(symbol: "clang_getCursorUSR") +internal let clang_constructUSR_ObjCClass: @convention(c) (UnsafePointer?) -> (CXString) = library.load(symbol: "clang_constructUSR_ObjCClass") +internal let clang_constructUSR_ObjCCategory: @convention(c) (UnsafePointer?, UnsafePointer?) -> (CXString) = library.load(symbol: "clang_constructUSR_ObjCCategory") +internal let clang_constructUSR_ObjCProtocol: @convention(c) (UnsafePointer?) -> (CXString) = library.load(symbol: "clang_constructUSR_ObjCProtocol") +internal let clang_constructUSR_ObjCIvar: @convention(c) (UnsafePointer?, CXString) -> (CXString) = library.load(symbol: "clang_constructUSR_ObjCIvar") +internal let clang_constructUSR_ObjCMethod: @convention(c) (UnsafePointer?, UInt32, CXString) -> (CXString) = library.load(symbol: "clang_constructUSR_ObjCMethod") +internal let clang_constructUSR_ObjCProperty: @convention(c) (UnsafePointer?, CXString) -> (CXString) = library.load(symbol: "clang_constructUSR_ObjCProperty") +internal let clang_getCursorSpelling: @convention(c) (CXCursor) -> (CXString) = library.load(symbol: "clang_getCursorSpelling") +internal let clang_Cursor_getSpellingNameRange: @convention(c) (CXCursor, UInt32, UInt32) -> (CXSourceRange) = library.load(symbol: "clang_Cursor_getSpellingNameRange") +internal let clang_getCursorDisplayName: @convention(c) (CXCursor) -> (CXString) = library.load(symbol: "clang_getCursorDisplayName") +internal let clang_getCursorReferenced: @convention(c) (CXCursor) -> (CXCursor) = library.load(symbol: "clang_getCursorReferenced") +internal let clang_getCursorDefinition: @convention(c) (CXCursor) -> (CXCursor) = library.load(symbol: "clang_getCursorDefinition") +internal let clang_isCursorDefinition: @convention(c) (CXCursor) -> (UInt32) = library.load(symbol: "clang_isCursorDefinition") +internal let clang_getCanonicalCursor: @convention(c) (CXCursor) -> (CXCursor) = library.load(symbol: "clang_getCanonicalCursor") +internal let clang_Cursor_getObjCSelectorIndex: @convention(c) (CXCursor) -> (Int32) = library.load(symbol: "clang_Cursor_getObjCSelectorIndex") +internal let clang_Cursor_isDynamicCall: @convention(c) (CXCursor) -> (Int32) = library.load(symbol: "clang_Cursor_isDynamicCall") +internal let clang_Cursor_getReceiverType: @convention(c) (CXCursor) -> (CXType) = library.load(symbol: "clang_Cursor_getReceiverType") +internal let clang_Cursor_getObjCPropertyAttributes: @convention(c) (CXCursor, UInt32) -> (UInt32) = library.load(symbol: "clang_Cursor_getObjCPropertyAttributes") +internal let clang_Cursor_getObjCDeclQualifiers: @convention(c) (CXCursor) -> (UInt32) = library.load(symbol: "clang_Cursor_getObjCDeclQualifiers") +internal let clang_Cursor_isObjCOptional: @convention(c) (CXCursor) -> (UInt32) = library.load(symbol: "clang_Cursor_isObjCOptional") +internal let clang_Cursor_isVariadic: @convention(c) (CXCursor) -> (UInt32) = library.load(symbol: "clang_Cursor_isVariadic") +internal let clang_Cursor_getCommentRange: @convention(c) (CXCursor) -> (CXSourceRange) = library.load(symbol: "clang_Cursor_getCommentRange") +internal let clang_Cursor_getRawCommentText: @convention(c) (CXCursor) -> (CXString) = library.load(symbol: "clang_Cursor_getRawCommentText") +internal let clang_Cursor_getBriefCommentText: @convention(c) (CXCursor) -> (CXString) = library.load(symbol: "clang_Cursor_getBriefCommentText") +internal let clang_Cursor_getMangling: @convention(c) (CXCursor) -> (CXString) = library.load(symbol: "clang_Cursor_getMangling") +internal let clang_Cursor_getModule: @convention(c) (CXCursor) -> (CXModule!) = library.load(symbol: "clang_Cursor_getModule") +internal let clang_getModuleForFile: @convention(c) (CXTranslationUnit?, CXFile?) -> (CXModule!) = library.load(symbol: "clang_getModuleForFile") +internal let clang_Module_getASTFile: @convention(c) (CXModule?) -> (CXFile!) = library.load(symbol: "clang_Module_getASTFile") +internal let clang_Module_getParent: @convention(c) (CXModule?) -> (CXModule!) = library.load(symbol: "clang_Module_getParent") +internal let clang_Module_getName: @convention(c) (CXModule?) -> (CXString) = library.load(symbol: "clang_Module_getName") +internal let clang_Module_getFullName: @convention(c) (CXModule?) -> (CXString) = library.load(symbol: "clang_Module_getFullName") +internal let clang_Module_isSystem: @convention(c) (CXModule?) -> (Int32) = library.load(symbol: "clang_Module_isSystem") +internal let clang_Module_getNumTopLevelHeaders: @convention(c) (CXTranslationUnit?, CXModule?) -> (UInt32) = library.load(symbol: "clang_Module_getNumTopLevelHeaders") +internal let clang_Module_getTopLevelHeader: @convention(c) (CXTranslationUnit?, CXModule?, UInt32) -> (CXFile!) = library.load(symbol: "clang_Module_getTopLevelHeader") +internal let clang_CXXField_isMutable: @convention(c) (CXCursor) -> (UInt32) = library.load(symbol: "clang_CXXField_isMutable") +internal let clang_CXXMethod_isPureVirtual: @convention(c) (CXCursor) -> (UInt32) = library.load(symbol: "clang_CXXMethod_isPureVirtual") +internal let clang_CXXMethod_isStatic: @convention(c) (CXCursor) -> (UInt32) = library.load(symbol: "clang_CXXMethod_isStatic") +internal let clang_CXXMethod_isVirtual: @convention(c) (CXCursor) -> (UInt32) = library.load(symbol: "clang_CXXMethod_isVirtual") +internal let clang_CXXMethod_isConst: @convention(c) (CXCursor) -> (UInt32) = library.load(symbol: "clang_CXXMethod_isConst") +internal let clang_getTemplateCursorKind: @convention(c) (CXCursor) -> (CXCursorKind) = library.load(symbol: "clang_getTemplateCursorKind") +internal let clang_getSpecializedCursorTemplate: @convention(c) (CXCursor) -> (CXCursor) = library.load(symbol: "clang_getSpecializedCursorTemplate") +internal let clang_getCursorReferenceNameRange: @convention(c) (CXCursor, UInt32, UInt32) -> (CXSourceRange) = library.load(symbol: "clang_getCursorReferenceNameRange") +internal let clang_getTokenKind: @convention(c) (CXToken) -> (CXTokenKind) = library.load(symbol: "clang_getTokenKind") +internal let clang_getTokenSpelling: @convention(c) (CXTranslationUnit?, CXToken) -> (CXString) = library.load(symbol: "clang_getTokenSpelling") +internal let clang_getTokenLocation: @convention(c) (CXTranslationUnit?, CXToken) -> (CXSourceLocation) = library.load(symbol: "clang_getTokenLocation") +internal let clang_getTokenExtent: @convention(c) (CXTranslationUnit?, CXToken) -> (CXSourceRange) = library.load(symbol: "clang_getTokenExtent") +internal let clang_tokenize: @convention(c) (CXTranslationUnit?, CXSourceRange, UnsafeMutablePointer?>?, UnsafeMutablePointer?) -> () = library.load(symbol: "clang_tokenize") +internal let clang_annotateTokens: @convention(c) (CXTranslationUnit?, UnsafeMutablePointer?, UInt32, UnsafeMutablePointer?) -> () = library.load(symbol: "clang_annotateTokens") +internal let clang_disposeTokens: @convention(c) (CXTranslationUnit?, UnsafeMutablePointer?, UInt32) -> () = library.load(symbol: "clang_disposeTokens") +internal let clang_getCursorKindSpelling: @convention(c) (CXCursorKind) -> (CXString) = library.load(symbol: "clang_getCursorKindSpelling") +internal let clang_getDefinitionSpellingAndExtent: @convention(c) (CXCursor, UnsafeMutablePointer?>?, UnsafeMutablePointer?>?, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?) -> () = library.load(symbol: "clang_getDefinitionSpellingAndExtent") +internal let clang_enableStackTraces: @convention(c) () -> () = library.load(symbol: "clang_enableStackTraces") +internal let clang_getCompletionChunkKind: @convention(c) (CXCompletionString?, UInt32) -> (CXCompletionChunkKind) = library.load(symbol: "clang_getCompletionChunkKind") +internal let clang_getCompletionChunkText: @convention(c) (CXCompletionString?, UInt32) -> (CXString) = library.load(symbol: "clang_getCompletionChunkText") +internal let clang_getCompletionChunkCompletionString: @convention(c) (CXCompletionString?, UInt32) -> (CXCompletionString!) = library.load(symbol: "clang_getCompletionChunkCompletionString") +internal let clang_getNumCompletionChunks: @convention(c) (CXCompletionString?) -> (UInt32) = library.load(symbol: "clang_getNumCompletionChunks") +internal let clang_getCompletionPriority: @convention(c) (CXCompletionString?) -> (UInt32) = library.load(symbol: "clang_getCompletionPriority") +internal let clang_getCompletionAvailability: @convention(c) (CXCompletionString?) -> (CXAvailabilityKind) = library.load(symbol: "clang_getCompletionAvailability") +internal let clang_getCompletionNumAnnotations: @convention(c) (CXCompletionString?) -> (UInt32) = library.load(symbol: "clang_getCompletionNumAnnotations") +internal let clang_getCompletionAnnotation: @convention(c) (CXCompletionString?, UInt32) -> (CXString) = library.load(symbol: "clang_getCompletionAnnotation") +internal let clang_getCompletionParent: @convention(c) (CXCompletionString?, UnsafeMutablePointer?) -> (CXString) = library.load(symbol: "clang_getCompletionParent") +internal let clang_getCompletionBriefComment: @convention(c) (CXCompletionString?) -> (CXString) = library.load(symbol: "clang_getCompletionBriefComment") +internal let clang_getCursorCompletionString: @convention(c) (CXCursor) -> (CXCompletionString!) = library.load(symbol: "clang_getCursorCompletionString") +internal let clang_defaultCodeCompleteOptions: @convention(c) () -> (UInt32) = library.load(symbol: "clang_defaultCodeCompleteOptions") +internal let clang_codeCompleteAt: @convention(c) (CXTranslationUnit?, UnsafePointer?, UInt32, UInt32, UnsafeMutablePointer?, UInt32, UInt32) -> (UnsafeMutablePointer!) = library.load(symbol: "clang_codeCompleteAt") +internal let clang_sortCodeCompletionResults: @convention(c) (UnsafeMutablePointer?, UInt32) -> () = library.load(symbol: "clang_sortCodeCompletionResults") +internal let clang_disposeCodeCompleteResults: @convention(c) (UnsafeMutablePointer?) -> () = library.load(symbol: "clang_disposeCodeCompleteResults") +internal let clang_codeCompleteGetNumDiagnostics: @convention(c) (UnsafeMutablePointer?) -> (UInt32) = library.load(symbol: "clang_codeCompleteGetNumDiagnostics") +internal let clang_codeCompleteGetDiagnostic: @convention(c) (UnsafeMutablePointer?, UInt32) -> (CXDiagnostic!) = library.load(symbol: "clang_codeCompleteGetDiagnostic") +internal let clang_codeCompleteGetContexts: @convention(c) (UnsafeMutablePointer?) -> (UInt64) = library.load(symbol: "clang_codeCompleteGetContexts") +internal let clang_codeCompleteGetContainerKind: @convention(c) (UnsafeMutablePointer?, UnsafeMutablePointer?) -> (CXCursorKind) = library.load(symbol: "clang_codeCompleteGetContainerKind") +internal let clang_codeCompleteGetContainerUSR: @convention(c) (UnsafeMutablePointer?) -> (CXString) = library.load(symbol: "clang_codeCompleteGetContainerUSR") +internal let clang_codeCompleteGetObjCSelector: @convention(c) (UnsafeMutablePointer?) -> (CXString) = library.load(symbol: "clang_codeCompleteGetObjCSelector") +internal let clang_getClangVersion: @convention(c) () -> (CXString) = library.load(symbol: "clang_getClangVersion") +internal let clang_toggleCrashRecovery: @convention(c) (UInt32) -> () = library.load(symbol: "clang_toggleCrashRecovery") +internal let clang_getInclusions: @convention(c) (CXTranslationUnit?, CXInclusionVisitor?, CXClientData?) -> () = library.load(symbol: "clang_getInclusions") +internal let clang_getRemappings: @convention(c) (UnsafePointer?) -> (CXRemapping!) = library.load(symbol: "clang_getRemappings") +internal let clang_getRemappingsFromFileList: @convention(c) (UnsafeMutablePointer?>?, UInt32) -> (CXRemapping!) = library.load(symbol: "clang_getRemappingsFromFileList") +internal let clang_remap_getNumFiles: @convention(c) (CXRemapping?) -> (UInt32) = library.load(symbol: "clang_remap_getNumFiles") +internal let clang_remap_getFilenames: @convention(c) (CXRemapping?, UInt32, UnsafeMutablePointer?, UnsafeMutablePointer?) -> () = library.load(symbol: "clang_remap_getFilenames") +internal let clang_remap_dispose: @convention(c) (CXRemapping?) -> () = library.load(symbol: "clang_remap_dispose") +internal let clang_findReferencesInFile: @convention(c) (CXCursor, CXFile?, CXCursorAndRangeVisitor) -> (CXResult) = library.load(symbol: "clang_findReferencesInFile") +internal let clang_findIncludesInFile: @convention(c) (CXTranslationUnit?, CXFile?, CXCursorAndRangeVisitor) -> (CXResult) = library.load(symbol: "clang_findIncludesInFile") +internal let clang_findReferencesInFileWithBlock: @convention(c) (CXCursor, CXFile?, CXCursorAndRangeVisitorBlock?) -> (CXResult) = library.load(symbol: "clang_findReferencesInFileWithBlock") +internal let clang_findIncludesInFileWithBlock: @convention(c) (CXTranslationUnit?, CXFile?, CXCursorAndRangeVisitorBlock?) -> (CXResult) = library.load(symbol: "clang_findIncludesInFileWithBlock") +internal let clang_index_isEntityObjCContainerKind: @convention(c) (CXIdxEntityKind) -> (Int32) = library.load(symbol: "clang_index_isEntityObjCContainerKind") +internal let clang_index_getObjCContainerDeclInfo: @convention(c) (UnsafePointer?) -> (UnsafePointer!) = library.load(symbol: "clang_index_getObjCContainerDeclInfo") +internal let clang_index_getObjCInterfaceDeclInfo: @convention(c) (UnsafePointer?) -> (UnsafePointer!) = library.load(symbol: "clang_index_getObjCInterfaceDeclInfo") +internal let clang_index_getObjCCategoryDeclInfo: @convention(c) (UnsafePointer?) -> (UnsafePointer!) = library.load(symbol: "clang_index_getObjCCategoryDeclInfo") +internal let clang_index_getObjCProtocolRefListInfo: @convention(c) (UnsafePointer?) -> (UnsafePointer!) = library.load(symbol: "clang_index_getObjCProtocolRefListInfo") +internal let clang_index_getObjCPropertyDeclInfo: @convention(c) (UnsafePointer?) -> (UnsafePointer!) = library.load(symbol: "clang_index_getObjCPropertyDeclInfo") +internal let clang_index_getIBOutletCollectionAttrInfo: @convention(c) (UnsafePointer?) -> (UnsafePointer!) = library.load(symbol: "clang_index_getIBOutletCollectionAttrInfo") +internal let clang_index_getCXXClassDeclInfo: @convention(c) (UnsafePointer?) -> (UnsafePointer!) = library.load(symbol: "clang_index_getCXXClassDeclInfo") +internal let clang_index_getClientContainer: @convention(c) (UnsafePointer?) -> (CXIdxClientContainer!) = library.load(symbol: "clang_index_getClientContainer") +internal let clang_index_setClientContainer: @convention(c) (UnsafePointer?, CXIdxClientContainer?) -> () = library.load(symbol: "clang_index_setClientContainer") +internal let clang_index_getClientEntity: @convention(c) (UnsafePointer?) -> (CXIdxClientEntity!) = library.load(symbol: "clang_index_getClientEntity") +internal let clang_index_setClientEntity: @convention(c) (UnsafePointer?, CXIdxClientEntity?) -> () = library.load(symbol: "clang_index_setClientEntity") +internal let clang_IndexAction_create: @convention(c) (CXIndex?) -> (CXIndexAction!) = library.load(symbol: "clang_IndexAction_create") +internal let clang_IndexAction_dispose: @convention(c) (CXIndexAction?) -> () = library.load(symbol: "clang_IndexAction_dispose") +internal let clang_indexSourceFile: @convention(c) (CXIndexAction?, CXClientData?, UnsafeMutablePointer?, UInt32, UInt32, UnsafePointer?, UnsafePointer?>?, Int32, UnsafeMutablePointer?, UInt32, UnsafeMutablePointer?, UInt32) -> (Int32) = library.load(symbol: "clang_indexSourceFile") +internal let clang_indexTranslationUnit: @convention(c) (CXIndexAction?, CXClientData?, UnsafeMutablePointer?, UInt32, UInt32, CXTranslationUnit?) -> (Int32) = library.load(symbol: "clang_indexTranslationUnit") +internal let clang_indexLoc_getFileLocation: @convention(c) (CXIdxLoc, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?, UnsafeMutablePointer?) -> () = library.load(symbol: "clang_indexLoc_getFileLocation") +internal let clang_indexLoc_getCXSourceLocation: @convention(c) (CXIdxLoc) -> (CXSourceLocation) = library.load(symbol: "clang_indexLoc_getCXSourceLocation") +internal let clang_Type_visitFields: @convention(c) (CXType, CXFieldVisitor?, CXClientData?) -> (UInt32) = library.load(symbol: "clang_Type_visitFields") diff --git a/Source/SourceKittenFramework/library_wrapper_sourcekitd.swift b/Source/SourceKittenFramework/library_wrapper_sourcekitd.swift index 210972ce1..6a0c8e34a 100644 --- a/Source/SourceKittenFramework/library_wrapper_sourcekitd.swift +++ b/Source/SourceKittenFramework/library_wrapper_sourcekitd.swift @@ -1,70 +1,70 @@ #if SWIFT_PACKAGE import SourceKit #endif -private let library = toolchainLoader.load("sourcekitd.framework/Versions/A/sourcekitd") -internal let sourcekitd_initialize: @convention(c) () -> () = library.loadSymbol("sourcekitd_initialize") -internal let sourcekitd_shutdown: @convention(c) () -> () = library.loadSymbol("sourcekitd_shutdown") -internal let sourcekitd_set_interrupted_connection_handler: @convention(c) (sourcekitd_interrupted_connection_handler_t) -> () = library.loadSymbol("sourcekitd_set_interrupted_connection_handler") -internal let sourcekitd_uid_get_from_cstr: @convention(c) (UnsafePointer) -> (sourcekitd_uid_t!) = library.loadSymbol("sourcekitd_uid_get_from_cstr") -internal let sourcekitd_uid_get_from_buf: @convention(c) (UnsafePointer, Int) -> (sourcekitd_uid_t!) = library.loadSymbol("sourcekitd_uid_get_from_buf") -internal let sourcekitd_uid_get_length: @convention(c) (sourcekitd_uid_t) -> (Int) = library.loadSymbol("sourcekitd_uid_get_length") -internal let sourcekitd_uid_get_string_ptr: @convention(c) (sourcekitd_uid_t) -> (UnsafePointer!) = library.loadSymbol("sourcekitd_uid_get_string_ptr") -internal let sourcekitd_request_retain: @convention(c) (sourcekitd_object_t) -> (sourcekitd_object_t!) = library.loadSymbol("sourcekitd_request_retain") -internal let sourcekitd_request_release: @convention(c) (sourcekitd_object_t) -> () = library.loadSymbol("sourcekitd_request_release") -internal let sourcekitd_request_dictionary_create: @convention(c) (UnsafePointer?, UnsafePointer?, Int) -> (sourcekitd_object_t!) = library.loadSymbol("sourcekitd_request_dictionary_create") -internal let sourcekitd_request_dictionary_set_value: @convention(c) (sourcekitd_object_t, sourcekitd_uid_t, sourcekitd_object_t) -> () = library.loadSymbol("sourcekitd_request_dictionary_set_value") -internal let sourcekitd_request_dictionary_set_string: @convention(c) (sourcekitd_object_t, sourcekitd_uid_t, UnsafePointer) -> () = library.loadSymbol("sourcekitd_request_dictionary_set_string") -internal let sourcekitd_request_dictionary_set_stringbuf: @convention(c) (sourcekitd_object_t, sourcekitd_uid_t, UnsafePointer, Int) -> () = library.loadSymbol("sourcekitd_request_dictionary_set_stringbuf") -internal let sourcekitd_request_dictionary_set_int64: @convention(c) (sourcekitd_object_t, sourcekitd_uid_t, Int64) -> () = library.loadSymbol("sourcekitd_request_dictionary_set_int64") -internal let sourcekitd_request_dictionary_set_uid: @convention(c) (sourcekitd_object_t, sourcekitd_uid_t, sourcekitd_uid_t) -> () = library.loadSymbol("sourcekitd_request_dictionary_set_uid") -internal let sourcekitd_request_array_create: @convention(c) (UnsafePointer?, Int) -> (sourcekitd_object_t!) = library.loadSymbol("sourcekitd_request_array_create") -internal let sourcekitd_request_array_set_value: @convention(c) (sourcekitd_object_t, Int, sourcekitd_object_t) -> () = library.loadSymbol("sourcekitd_request_array_set_value") -internal let sourcekitd_request_array_set_string: @convention(c) (sourcekitd_object_t, Int, UnsafePointer) -> () = library.loadSymbol("sourcekitd_request_array_set_string") -internal let sourcekitd_request_array_set_stringbuf: @convention(c) (sourcekitd_object_t, Int, UnsafePointer, Int) -> () = library.loadSymbol("sourcekitd_request_array_set_stringbuf") -internal let sourcekitd_request_array_set_int64: @convention(c) (sourcekitd_object_t, Int, Int64) -> () = library.loadSymbol("sourcekitd_request_array_set_int64") -internal let sourcekitd_request_array_set_uid: @convention(c) (sourcekitd_object_t, Int, sourcekitd_uid_t) -> () = library.loadSymbol("sourcekitd_request_array_set_uid") -internal let sourcekitd_request_int64_create: @convention(c) (Int64) -> (sourcekitd_object_t!) = library.loadSymbol("sourcekitd_request_int64_create") -internal let sourcekitd_request_string_create: @convention(c) (UnsafePointer) -> (sourcekitd_object_t!) = library.loadSymbol("sourcekitd_request_string_create") -internal let sourcekitd_request_uid_create: @convention(c) (sourcekitd_uid_t) -> (sourcekitd_object_t!) = library.loadSymbol("sourcekitd_request_uid_create") -internal let sourcekitd_request_create_from_yaml: @convention(c) (UnsafePointer, UnsafeMutablePointer?>?) -> (sourcekitd_object_t!) = library.loadSymbol("sourcekitd_request_create_from_yaml") -internal let sourcekitd_request_description_dump: @convention(c) (sourcekitd_object_t) -> () = library.loadSymbol("sourcekitd_request_description_dump") -internal let sourcekitd_request_description_copy: @convention(c) (sourcekitd_object_t) -> (UnsafeMutablePointer!) = library.loadSymbol("sourcekitd_request_description_copy") -internal let sourcekitd_response_dispose: @convention(c) (sourcekitd_response_t) -> () = library.loadSymbol("sourcekitd_response_dispose") -internal let sourcekitd_response_is_error: @convention(c) (sourcekitd_response_t) -> (Bool) = library.loadSymbol("sourcekitd_response_is_error") -internal let sourcekitd_response_error_get_kind: @convention(c) (sourcekitd_response_t) -> (sourcekitd_error_t) = library.loadSymbol("sourcekitd_response_error_get_kind") -internal let sourcekitd_response_error_get_description: @convention(c) (sourcekitd_response_t) -> (UnsafePointer!) = library.loadSymbol("sourcekitd_response_error_get_description") -internal let sourcekitd_response_get_value: @convention(c) (sourcekitd_response_t) -> (sourcekitd_variant_t) = library.loadSymbol("sourcekitd_response_get_value") -internal let sourcekitd_variant_get_type: @convention(c) (sourcekitd_variant_t) -> (sourcekitd_variant_type_t) = library.loadSymbol("sourcekitd_variant_get_type") -internal let sourcekitd_variant_dictionary_get_value: @convention(c) (sourcekitd_variant_t, sourcekitd_uid_t) -> (sourcekitd_variant_t) = library.loadSymbol("sourcekitd_variant_dictionary_get_value") -internal let sourcekitd_variant_dictionary_get_string: @convention(c) (sourcekitd_variant_t, sourcekitd_uid_t) -> (UnsafePointer!) = library.loadSymbol("sourcekitd_variant_dictionary_get_string") -internal let sourcekitd_variant_dictionary_get_int64: @convention(c) (sourcekitd_variant_t, sourcekitd_uid_t) -> (Int64) = library.loadSymbol("sourcekitd_variant_dictionary_get_int64") -internal let sourcekitd_variant_dictionary_get_bool: @convention(c) (sourcekitd_variant_t, sourcekitd_uid_t) -> (Bool) = library.loadSymbol("sourcekitd_variant_dictionary_get_bool") -internal let sourcekitd_variant_dictionary_get_uid: @convention(c) (sourcekitd_variant_t, sourcekitd_uid_t) -> (sourcekitd_uid_t!) = library.loadSymbol("sourcekitd_variant_dictionary_get_uid") -internal let sourcekitd_variant_dictionary_apply: @convention(c) (sourcekitd_variant_t, sourcekitd_variant_dictionary_applier_t) -> (Bool) = library.loadSymbol("sourcekitd_variant_dictionary_apply") -internal let sourcekitd_variant_dictionary_apply_f: @convention(c) (sourcekitd_variant_t, sourcekitd_variant_dictionary_applier_f_t, UnsafeMutableRawPointer?) -> (Bool) = library.loadSymbol("sourcekitd_variant_dictionary_apply_f") -internal let sourcekitd_variant_array_get_count: @convention(c) (sourcekitd_variant_t) -> (Int) = library.loadSymbol("sourcekitd_variant_array_get_count") -internal let sourcekitd_variant_array_get_value: @convention(c) (sourcekitd_variant_t, Int) -> (sourcekitd_variant_t) = library.loadSymbol("sourcekitd_variant_array_get_value") -internal let sourcekitd_variant_array_get_string: @convention(c) (sourcekitd_variant_t, Int) -> (UnsafePointer!) = library.loadSymbol("sourcekitd_variant_array_get_string") -internal let sourcekitd_variant_array_get_int64: @convention(c) (sourcekitd_variant_t, Int) -> (Int64) = library.loadSymbol("sourcekitd_variant_array_get_int64") -internal let sourcekitd_variant_array_get_bool: @convention(c) (sourcekitd_variant_t, Int) -> (Bool) = library.loadSymbol("sourcekitd_variant_array_get_bool") -internal let sourcekitd_variant_array_get_uid: @convention(c) (sourcekitd_variant_t, Int) -> (sourcekitd_uid_t!) = library.loadSymbol("sourcekitd_variant_array_get_uid") -internal let sourcekitd_variant_array_apply: @convention(c) (sourcekitd_variant_t, sourcekitd_variant_array_applier_t) -> (Bool) = library.loadSymbol("sourcekitd_variant_array_apply") -internal let sourcekitd_variant_array_apply_f: @convention(c) (sourcekitd_variant_t, sourcekitd_variant_array_applier_f_t, UnsafeMutableRawPointer?) -> (Bool) = library.loadSymbol("sourcekitd_variant_array_apply_f") -internal let sourcekitd_variant_int64_get_value: @convention(c) (sourcekitd_variant_t) -> (Int64) = library.loadSymbol("sourcekitd_variant_int64_get_value") -internal let sourcekitd_variant_bool_get_value: @convention(c) (sourcekitd_variant_t) -> (Bool) = library.loadSymbol("sourcekitd_variant_bool_get_value") -internal let sourcekitd_variant_string_get_length: @convention(c) (sourcekitd_variant_t) -> (Int) = library.loadSymbol("sourcekitd_variant_string_get_length") -internal let sourcekitd_variant_string_get_ptr: @convention(c) (sourcekitd_variant_t) -> (UnsafePointer!) = library.loadSymbol("sourcekitd_variant_string_get_ptr") -internal let sourcekitd_variant_uid_get_value: @convention(c) (sourcekitd_variant_t) -> (sourcekitd_uid_t!) = library.loadSymbol("sourcekitd_variant_uid_get_value") -internal let sourcekitd_response_description_dump: @convention(c) (sourcekitd_response_t) -> () = library.loadSymbol("sourcekitd_response_description_dump") -internal let sourcekitd_response_description_dump_filedesc: @convention(c) (sourcekitd_response_t, Int32) -> () = library.loadSymbol("sourcekitd_response_description_dump_filedesc") -internal let sourcekitd_response_description_copy: @convention(c) (sourcekitd_response_t) -> (UnsafeMutablePointer!) = library.loadSymbol("sourcekitd_response_description_copy") -internal let sourcekitd_variant_description_dump: @convention(c) (sourcekitd_variant_t) -> () = library.loadSymbol("sourcekitd_variant_description_dump") -internal let sourcekitd_variant_description_dump_filedesc: @convention(c) (sourcekitd_variant_t, Int32) -> () = library.loadSymbol("sourcekitd_variant_description_dump_filedesc") -internal let sourcekitd_variant_description_copy: @convention(c) (sourcekitd_variant_t) -> (UnsafeMutablePointer!) = library.loadSymbol("sourcekitd_variant_description_copy") -internal let sourcekitd_variant_json_description_copy: @convention(c) (sourcekitd_variant_t) -> (UnsafeMutablePointer!) = library.loadSymbol("sourcekitd_variant_json_description_copy") -internal let sourcekitd_send_request_sync: @convention(c) (sourcekitd_object_t) -> (sourcekitd_response_t!) = library.loadSymbol("sourcekitd_send_request_sync") -internal let sourcekitd_send_request: @convention(c) (sourcekitd_object_t, UnsafeMutablePointer?, sourcekitd_response_receiver_t?) -> () = library.loadSymbol("sourcekitd_send_request") -internal let sourcekitd_cancel_request: @convention(c) (sourcekitd_request_handle_t?) -> () = library.loadSymbol("sourcekitd_cancel_request") -internal let sourcekitd_set_notification_handler: @convention(c) (sourcekitd_response_receiver_t?) -> () = library.loadSymbol("sourcekitd_set_notification_handler") -internal let sourcekitd_set_uid_handler: @convention(c) (sourcekitd_uid_handler_t?) -> () = library.loadSymbol("sourcekitd_set_uid_handler") -internal let sourcekitd_set_uid_handlers: @convention(c) (sourcekitd_uid_from_str_handler_t?, sourcekitd_str_from_uid_handler_t?) -> () = library.loadSymbol("sourcekitd_set_uid_handlers") +private let library = toolchainLoader.load(path: "sourcekitd.framework/Versions/A/sourcekitd") +internal let sourcekitd_initialize: @convention(c) () -> () = library.load(symbol: "sourcekitd_initialize") +internal let sourcekitd_shutdown: @convention(c) () -> () = library.load(symbol: "sourcekitd_shutdown") +internal let sourcekitd_set_interrupted_connection_handler: @convention(c) (sourcekitd_interrupted_connection_handler_t) -> () = library.load(symbol: "sourcekitd_set_interrupted_connection_handler") +internal let sourcekitd_uid_get_from_cstr: @convention(c) (UnsafePointer) -> (sourcekitd_uid_t!) = library.load(symbol: "sourcekitd_uid_get_from_cstr") +internal let sourcekitd_uid_get_from_buf: @convention(c) (UnsafePointer, Int) -> (sourcekitd_uid_t!) = library.load(symbol: "sourcekitd_uid_get_from_buf") +internal let sourcekitd_uid_get_length: @convention(c) (sourcekitd_uid_t) -> (Int) = library.load(symbol: "sourcekitd_uid_get_length") +internal let sourcekitd_uid_get_string_ptr: @convention(c) (sourcekitd_uid_t) -> (UnsafePointer!) = library.load(symbol: "sourcekitd_uid_get_string_ptr") +internal let sourcekitd_request_retain: @convention(c) (sourcekitd_object_t) -> (sourcekitd_object_t!) = library.load(symbol: "sourcekitd_request_retain") +internal let sourcekitd_request_release: @convention(c) (sourcekitd_object_t) -> () = library.load(symbol: "sourcekitd_request_release") +internal let sourcekitd_request_dictionary_create: @convention(c) (UnsafePointer?, UnsafePointer?, Int) -> (sourcekitd_object_t!) = library.load(symbol: "sourcekitd_request_dictionary_create") +internal let sourcekitd_request_dictionary_set_value: @convention(c) (sourcekitd_object_t, sourcekitd_uid_t, sourcekitd_object_t) -> () = library.load(symbol: "sourcekitd_request_dictionary_set_value") +internal let sourcekitd_request_dictionary_set_string: @convention(c) (sourcekitd_object_t, sourcekitd_uid_t, UnsafePointer) -> () = library.load(symbol: "sourcekitd_request_dictionary_set_string") +internal let sourcekitd_request_dictionary_set_stringbuf: @convention(c) (sourcekitd_object_t, sourcekitd_uid_t, UnsafePointer, Int) -> () = library.load(symbol: "sourcekitd_request_dictionary_set_stringbuf") +internal let sourcekitd_request_dictionary_set_int64: @convention(c) (sourcekitd_object_t, sourcekitd_uid_t, Int64) -> () = library.load(symbol: "sourcekitd_request_dictionary_set_int64") +internal let sourcekitd_request_dictionary_set_uid: @convention(c) (sourcekitd_object_t, sourcekitd_uid_t, sourcekitd_uid_t) -> () = library.load(symbol: "sourcekitd_request_dictionary_set_uid") +internal let sourcekitd_request_array_create: @convention(c) (UnsafePointer?, Int) -> (sourcekitd_object_t!) = library.load(symbol: "sourcekitd_request_array_create") +internal let sourcekitd_request_array_set_value: @convention(c) (sourcekitd_object_t, Int, sourcekitd_object_t) -> () = library.load(symbol: "sourcekitd_request_array_set_value") +internal let sourcekitd_request_array_set_string: @convention(c) (sourcekitd_object_t, Int, UnsafePointer) -> () = library.load(symbol: "sourcekitd_request_array_set_string") +internal let sourcekitd_request_array_set_stringbuf: @convention(c) (sourcekitd_object_t, Int, UnsafePointer, Int) -> () = library.load(symbol: "sourcekitd_request_array_set_stringbuf") +internal let sourcekitd_request_array_set_int64: @convention(c) (sourcekitd_object_t, Int, Int64) -> () = library.load(symbol: "sourcekitd_request_array_set_int64") +internal let sourcekitd_request_array_set_uid: @convention(c) (sourcekitd_object_t, Int, sourcekitd_uid_t) -> () = library.load(symbol: "sourcekitd_request_array_set_uid") +internal let sourcekitd_request_int64_create: @convention(c) (Int64) -> (sourcekitd_object_t!) = library.load(symbol: "sourcekitd_request_int64_create") +internal let sourcekitd_request_string_create: @convention(c) (UnsafePointer) -> (sourcekitd_object_t!) = library.load(symbol: "sourcekitd_request_string_create") +internal let sourcekitd_request_uid_create: @convention(c) (sourcekitd_uid_t) -> (sourcekitd_object_t!) = library.load(symbol: "sourcekitd_request_uid_create") +internal let sourcekitd_request_create_from_yaml: @convention(c) (UnsafePointer, UnsafeMutablePointer?>?) -> (sourcekitd_object_t!) = library.load(symbol: "sourcekitd_request_create_from_yaml") +internal let sourcekitd_request_description_dump: @convention(c) (sourcekitd_object_t) -> () = library.load(symbol: "sourcekitd_request_description_dump") +internal let sourcekitd_request_description_copy: @convention(c) (sourcekitd_object_t) -> (UnsafeMutablePointer!) = library.load(symbol: "sourcekitd_request_description_copy") +internal let sourcekitd_response_dispose: @convention(c) (sourcekitd_response_t) -> () = library.load(symbol: "sourcekitd_response_dispose") +internal let sourcekitd_response_is_error: @convention(c) (sourcekitd_response_t) -> (Bool) = library.load(symbol: "sourcekitd_response_is_error") +internal let sourcekitd_response_error_get_kind: @convention(c) (sourcekitd_response_t) -> (sourcekitd_error_t) = library.load(symbol: "sourcekitd_response_error_get_kind") +internal let sourcekitd_response_error_get_description: @convention(c) (sourcekitd_response_t) -> (UnsafePointer!) = library.load(symbol: "sourcekitd_response_error_get_description") +internal let sourcekitd_response_get_value: @convention(c) (sourcekitd_response_t) -> (sourcekitd_variant_t) = library.load(symbol: "sourcekitd_response_get_value") +internal let sourcekitd_variant_get_type: @convention(c) (sourcekitd_variant_t) -> (sourcekitd_variant_type_t) = library.load(symbol: "sourcekitd_variant_get_type") +internal let sourcekitd_variant_dictionary_get_value: @convention(c) (sourcekitd_variant_t, sourcekitd_uid_t) -> (sourcekitd_variant_t) = library.load(symbol: "sourcekitd_variant_dictionary_get_value") +internal let sourcekitd_variant_dictionary_get_string: @convention(c) (sourcekitd_variant_t, sourcekitd_uid_t) -> (UnsafePointer!) = library.load(symbol: "sourcekitd_variant_dictionary_get_string") +internal let sourcekitd_variant_dictionary_get_int64: @convention(c) (sourcekitd_variant_t, sourcekitd_uid_t) -> (Int64) = library.load(symbol: "sourcekitd_variant_dictionary_get_int64") +internal let sourcekitd_variant_dictionary_get_bool: @convention(c) (sourcekitd_variant_t, sourcekitd_uid_t) -> (Bool) = library.load(symbol: "sourcekitd_variant_dictionary_get_bool") +internal let sourcekitd_variant_dictionary_get_uid: @convention(c) (sourcekitd_variant_t, sourcekitd_uid_t) -> (sourcekitd_uid_t!) = library.load(symbol: "sourcekitd_variant_dictionary_get_uid") +internal let sourcekitd_variant_dictionary_apply: @convention(c) (sourcekitd_variant_t, sourcekitd_variant_dictionary_applier_t) -> (Bool) = library.load(symbol: "sourcekitd_variant_dictionary_apply") +internal let sourcekitd_variant_dictionary_apply_f: @convention(c) (sourcekitd_variant_t, sourcekitd_variant_dictionary_applier_f_t, UnsafeMutableRawPointer?) -> (Bool) = library.load(symbol: "sourcekitd_variant_dictionary_apply_f") +internal let sourcekitd_variant_array_get_count: @convention(c) (sourcekitd_variant_t) -> (Int) = library.load(symbol: "sourcekitd_variant_array_get_count") +internal let sourcekitd_variant_array_get_value: @convention(c) (sourcekitd_variant_t, Int) -> (sourcekitd_variant_t) = library.load(symbol: "sourcekitd_variant_array_get_value") +internal let sourcekitd_variant_array_get_string: @convention(c) (sourcekitd_variant_t, Int) -> (UnsafePointer!) = library.load(symbol: "sourcekitd_variant_array_get_string") +internal let sourcekitd_variant_array_get_int64: @convention(c) (sourcekitd_variant_t, Int) -> (Int64) = library.load(symbol: "sourcekitd_variant_array_get_int64") +internal let sourcekitd_variant_array_get_bool: @convention(c) (sourcekitd_variant_t, Int) -> (Bool) = library.load(symbol: "sourcekitd_variant_array_get_bool") +internal let sourcekitd_variant_array_get_uid: @convention(c) (sourcekitd_variant_t, Int) -> (sourcekitd_uid_t!) = library.load(symbol: "sourcekitd_variant_array_get_uid") +internal let sourcekitd_variant_array_apply: @convention(c) (sourcekitd_variant_t, sourcekitd_variant_array_applier_t) -> (Bool) = library.load(symbol: "sourcekitd_variant_array_apply") +internal let sourcekitd_variant_array_apply_f: @convention(c) (sourcekitd_variant_t, sourcekitd_variant_array_applier_f_t, UnsafeMutableRawPointer?) -> (Bool) = library.load(symbol: "sourcekitd_variant_array_apply_f") +internal let sourcekitd_variant_int64_get_value: @convention(c) (sourcekitd_variant_t) -> (Int64) = library.load(symbol: "sourcekitd_variant_int64_get_value") +internal let sourcekitd_variant_bool_get_value: @convention(c) (sourcekitd_variant_t) -> (Bool) = library.load(symbol: "sourcekitd_variant_bool_get_value") +internal let sourcekitd_variant_string_get_length: @convention(c) (sourcekitd_variant_t) -> (Int) = library.load(symbol: "sourcekitd_variant_string_get_length") +internal let sourcekitd_variant_string_get_ptr: @convention(c) (sourcekitd_variant_t) -> (UnsafePointer!) = library.load(symbol: "sourcekitd_variant_string_get_ptr") +internal let sourcekitd_variant_uid_get_value: @convention(c) (sourcekitd_variant_t) -> (sourcekitd_uid_t!) = library.load(symbol: "sourcekitd_variant_uid_get_value") +internal let sourcekitd_response_description_dump: @convention(c) (sourcekitd_response_t) -> () = library.load(symbol: "sourcekitd_response_description_dump") +internal let sourcekitd_response_description_dump_filedesc: @convention(c) (sourcekitd_response_t, Int32) -> () = library.load(symbol: "sourcekitd_response_description_dump_filedesc") +internal let sourcekitd_response_description_copy: @convention(c) (sourcekitd_response_t) -> (UnsafeMutablePointer!) = library.load(symbol: "sourcekitd_response_description_copy") +internal let sourcekitd_variant_description_dump: @convention(c) (sourcekitd_variant_t) -> () = library.load(symbol: "sourcekitd_variant_description_dump") +internal let sourcekitd_variant_description_dump_filedesc: @convention(c) (sourcekitd_variant_t, Int32) -> () = library.load(symbol: "sourcekitd_variant_description_dump_filedesc") +internal let sourcekitd_variant_description_copy: @convention(c) (sourcekitd_variant_t) -> (UnsafeMutablePointer!) = library.load(symbol: "sourcekitd_variant_description_copy") +internal let sourcekitd_variant_json_description_copy: @convention(c) (sourcekitd_variant_t) -> (UnsafeMutablePointer!) = library.load(symbol: "sourcekitd_variant_json_description_copy") +internal let sourcekitd_send_request_sync: @convention(c) (sourcekitd_object_t) -> (sourcekitd_response_t!) = library.load(symbol: "sourcekitd_send_request_sync") +internal let sourcekitd_send_request: @convention(c) (sourcekitd_object_t, UnsafeMutablePointer?, sourcekitd_response_receiver_t?) -> () = library.load(symbol: "sourcekitd_send_request") +internal let sourcekitd_cancel_request: @convention(c) (sourcekitd_request_handle_t?) -> () = library.load(symbol: "sourcekitd_cancel_request") +internal let sourcekitd_set_notification_handler: @convention(c) (sourcekitd_response_receiver_t?) -> () = library.load(symbol: "sourcekitd_set_notification_handler") +internal let sourcekitd_set_uid_handler: @convention(c) (sourcekitd_uid_handler_t?) -> () = library.load(symbol: "sourcekitd_set_uid_handler") +internal let sourcekitd_set_uid_handlers: @convention(c) (sourcekitd_uid_from_str_handler_t?, sourcekitd_str_from_uid_handler_t?) -> () = library.load(symbol: "sourcekitd_set_uid_handlers") diff --git a/Source/sourcekitten/CompleteCommand.swift b/Source/sourcekitten/CompleteCommand.swift index e77d6ce94..dad17a4ef 100644 --- a/Source/sourcekitten/CompleteCommand.swift +++ b/Source/sourcekitten/CompleteCommand.swift @@ -42,7 +42,7 @@ struct CompleteCommand: CommandProtocol { if !options.file.isEmpty { path = options.file.absolutePathRepresentation() guard let file = File(path: path) else { - return .failure(.ReadFailed(path: options.file)) + return .failure(.readFailed(path: options.file)) } contents = file.contents } else { @@ -57,10 +57,10 @@ struct CompleteCommand: CommandProtocol { args.append(contentsOf: ["-sdk", sdkPath()]) } - let request = Request.CodeCompletionRequest(file: path, contents: contents, + let request = Request.codeCompletionRequest(file: path, contents: contents, offset: Int64(options.offset), arguments: args) - print(CodeCompletionItem.parseResponse(request.send())) + print(CodeCompletionItem.parse(response: request.send())) return .success() } } diff --git a/Source/sourcekitten/DocCommand.swift b/Source/sourcekitten/DocCommand.swift index 81481f68b..20755e4e7 100644 --- a/Source/sourcekitten/DocCommand.swift +++ b/Source/sourcekitten/DocCommand.swift @@ -41,37 +41,37 @@ struct DocCommand: CommandProtocol { func run(_ options: Options) -> Result<(), SourceKittenError> { let args = options.arguments if !options.spmModule.isEmpty { - return runSPMModule(options.spmModule) + return runSPMModule(moduleName: options.spmModule) } else if options.objc { - return runObjC(options, args: args) + return runObjC(options: options, args: args) } else if options.singleFile { - return runSwiftSingleFile(args) + return runSwiftSingleFile(args: args) } let moduleName: String? = options.moduleName.isEmpty ? nil : options.moduleName - return runSwiftModule(moduleName, args: args) + return runSwiftModule(moduleName: moduleName, args: args) } - func runSPMModule(_ moduleName: String) -> Result<(), SourceKittenError> { + func runSPMModule(moduleName: String) -> Result<(), SourceKittenError> { if let docs = Module(spmName: moduleName)?.docs { print(docs) return .success() } - return .failure(.DocFailed) + return .failure(.docFailed) } - func runSwiftModule(_ moduleName: String?, args: [String]) -> Result<(), SourceKittenError> { + func runSwiftModule(moduleName: String?, args: [String]) -> Result<(), SourceKittenError> { let module = Module(xcodeBuildArguments: args, name: moduleName) if let docs = module?.docs { print(docs) return .success() } - return .failure(.DocFailed) + return .failure(.docFailed) } - func runSwiftSingleFile(_ args: [String]) -> Result<(), SourceKittenError> { + func runSwiftSingleFile(args: [String]) -> Result<(), SourceKittenError> { if args.isEmpty { - return .failure(.InvalidArgument(description: "at least 5 arguments are required when using `--single-file`")) + return .failure(.invalidArgument(description: "at least 5 arguments are required when using `--single-file`")) } let sourcekitdArguments = Array(args.dropFirst(1)) if let file = File(path: args[0]), @@ -79,12 +79,12 @@ struct DocCommand: CommandProtocol { print(docs) return .success() } - return .failure(.ReadFailed(path: args[0])) + return .failure(.readFailed(path: args[0])) } - func runObjC(_ options: Options, args: [String]) -> Result<(), SourceKittenError> { + func runObjC(options: Options, args: [String]) -> Result<(), SourceKittenError> { if args.isEmpty { - return .failure(.InvalidArgument(description: "at least 5 arguments are required when using `--objc`")) + return .failure(.invalidArgument(description: "at least 5 arguments are required when using `--objc`")) } let translationUnit = ClangTranslationUnit(headerFiles: [args[0]], compilerArguments: Array(args.dropFirst(1))) print(translationUnit) diff --git a/Source/sourcekitten/Errors.swift b/Source/sourcekitten/Errors.swift index a9d127a99..7501d16cd 100644 --- a/Source/sourcekitten/Errors.swift +++ b/Source/sourcekitten/Errors.swift @@ -9,22 +9,22 @@ /// Possible errors within SourceKitten. enum SourceKittenError: Error, CustomStringConvertible { /// One or more argument was invalid. - case InvalidArgument(description: String) + case invalidArgument(description: String) /// Failed to read a file at the given path. - case ReadFailed(path: String) + case readFailed(path: String) /// Failed to generate documentation. - case DocFailed + case docFailed /// An error message corresponding to this error. var description: String { switch self { - case let .InvalidArgument(description): + case let .invalidArgument(description): return description - case let .ReadFailed(path): + case let .readFailed(path): return "Failed to read file at '\(path)'" - case .DocFailed: + case .docFailed: return "Failed to generate documentation" } } diff --git a/Source/sourcekitten/FormatCommand.swift b/Source/sourcekitten/FormatCommand.swift index d3c7e32d5..736333d3d 100644 --- a/Source/sourcekitten/FormatCommand.swift +++ b/Source/sourcekitten/FormatCommand.swift @@ -38,7 +38,7 @@ struct FormatCommand: CommandProtocol { func run(_ options: Options) -> Result<(), SourceKittenError> { guard !options.file.isEmpty else { - return .failure(.InvalidArgument(description: "file must be set when calling format")) + return .failure(.invalidArgument(description: "file must be set when calling format")) } try! File(path: options.file)? .format(trimmingTrailingWhitespace: options.trimWhitespace, diff --git a/Source/sourcekitten/IndexCommand.swift b/Source/sourcekitten/IndexCommand.swift index 9b485f7cc..a9a33e5a7 100644 --- a/Source/sourcekitten/IndexCommand.swift +++ b/Source/sourcekitten/IndexCommand.swift @@ -34,10 +34,10 @@ struct IndexCommand: CommandProtocol { func run(_ options: Options) -> Result<(), SourceKittenError> { guard !options.file.isEmpty else { - return .failure(.InvalidArgument(description: "file must be set when calling index")) + return .failure(.invalidArgument(description: "file must be set when calling index")) } let absoluteFile = options.file.absolutePathRepresentation() - let request = Request.Index(file: absoluteFile, arguments: options.compilerargs.components(separatedBy: " ")) + let request = Request.index(file: absoluteFile, arguments: options.compilerargs.components(separatedBy: " ")) print(toJSON(toNSDictionary(request.send()))) return .success() } diff --git a/Source/sourcekitten/StructureCommand.swift b/Source/sourcekitten/StructureCommand.swift index 4964e009f..825e58738 100644 --- a/Source/sourcekitten/StructureCommand.swift +++ b/Source/sourcekitten/StructureCommand.swift @@ -38,14 +38,14 @@ struct StructureCommand: CommandProtocol { print(Structure(file: file)) return .success() } - return .failure(.ReadFailed(path: options.file)) + return .failure(.readFailed(path: options.file)) } if !options.text.isEmpty { print(Structure(file: File(contents: options.text))) return .success() } return .failure( - .InvalidArgument(description: "either file or text must be set when calling structure") + .invalidArgument(description: "either file or text must be set when calling structure") ) } } diff --git a/Source/sourcekitten/SyntaxCommand.swift b/Source/sourcekitten/SyntaxCommand.swift index c78d28eb9..5e3f34243 100644 --- a/Source/sourcekitten/SyntaxCommand.swift +++ b/Source/sourcekitten/SyntaxCommand.swift @@ -38,7 +38,7 @@ struct SyntaxCommand: CommandProtocol { print(SyntaxMap(file: file)) return .success() } - return .failure(.ReadFailed(path: options.file)) + return .failure(.readFailed(path: options.file)) } print(SyntaxMap(file: File(contents: options.text))) return .success() diff --git a/Source/sourcekitten/main.swift b/Source/sourcekitten/main.swift index 6d402b491..8273a1b16 100644 --- a/Source/sourcekitten/main.swift +++ b/Source/sourcekitten/main.swift @@ -6,8 +6,8 @@ // Copyright (c) 2015 SourceKitten. All rights reserved. // -import Darwin import Commandant +import Darwin // `sourcekitd_set_notification_handler()` sets the handler to be executed on main thread queue. // So, we vacate main thread to `dispatchMain()`. diff --git a/Tests/SourceKittenFramework/ClangTranslationUnitTests.swift b/Tests/SourceKittenFramework/ClangTranslationUnitTests.swift index 348eee4f9..8d7f8ab32 100644 --- a/Tests/SourceKittenFramework/ClangTranslationUnitTests.swift +++ b/Tests/SourceKittenFramework/ClangTranslationUnitTests.swift @@ -24,26 +24,26 @@ class ClangTranslationUnitTests: XCTestCase { "arg1", "arg2" ] - let (parsedHeaderFiles, parsedXcodebuildArguments) = parseHeaderFilesAndXcodebuildArguments(headerFiles + xcodebuildArguments) + let (parsedHeaderFiles, parsedXcodebuildArguments) = parseHeaderFilesAndXcodebuildArguments(sourcekittenArguments: headerFiles + xcodebuildArguments) XCTAssertEqual(parsedHeaderFiles, headerFiles.map({$0.absolutePathRepresentation()}), "Objective-C header files should be parsed") XCTAssertEqual(parsedXcodebuildArguments, xcodebuildArguments, "xcodebuild arguments should be parsed") } - private func compareClangFixture(_ fixture: String) { + private func compare(clangFixture fixture: String) { let tu = ClangTranslationUnit(headerFiles: [fixturesDirectory + fixture + ".h"], compilerArguments: ["-x", "objective-c", "-isysroot", sdkPath(), "-I", fixturesDirectory]) - compareJSONStringWithFixturesName((fixture as NSString).lastPathComponent, jsonString: tu) + compareJSONString(withFixtureNamed: (fixture as NSString).lastPathComponent, jsonString: tu) } func testBasicObjectiveCDocs() { - compareClangFixture("Musician") + compare(clangFixture: "Musician") } func testUnicodeInObjectiveCDocs() { - compareClangFixture("SuperScript") + compare(clangFixture: "SuperScript") } func testRealmObjectiveCDocs() { - compareClangFixture("Realm/Realm") + compare(clangFixture: "Realm/Realm") } } diff --git a/Tests/SourceKittenFramework/CodeCompletionTests.swift b/Tests/SourceKittenFramework/CodeCompletionTests.swift index 9ccb4d169..b130f0097 100644 --- a/Tests/SourceKittenFramework/CodeCompletionTests.swift +++ b/Tests/SourceKittenFramework/CodeCompletionTests.swift @@ -14,10 +14,10 @@ class CodeCompletionTests: XCTestCase { func testSimpleCodeCompletion() { let file = "\(NSUUID().uuidString).swift" - let completionItems = CodeCompletionItem.parseResponse( - Request.CodeCompletionRequest(file: file, contents: "0.", offset: 2, + let completionItems = CodeCompletionItem.parse(response: + Request.codeCompletionRequest(file: file, contents: "0.", offset: 2, arguments: ["-c", file, "-sdk", sdkPath()]).send()) - compareJSONStringWithFixturesName("SimpleCodeCompletion", + compareJSONString(withFixtureNamed: "SimpleCodeCompletion", jsonString: completionItems) } } diff --git a/Tests/SourceKittenFramework/ModuleTests.swift b/Tests/SourceKittenFramework/ModuleTests.swift index b569498d4..b4f5eb323 100644 --- a/Tests/SourceKittenFramework/ModuleTests.swift +++ b/Tests/SourceKittenFramework/ModuleTests.swift @@ -38,6 +38,6 @@ class ModuleTests: XCTestCase { func testCommandantDocs() { let commandantPath = projectRoot + "/Carthage/Checkouts/Commandant/" let commandantModule = Module(xcodeBuildArguments: ["-workspace", "Commandant.xcworkspace", "-scheme", "Commandant"], name: nil, inPath: commandantPath)! - compareJSONStringWithFixturesName("Commandant", jsonString: commandantModule.docs, rootDirectory: commandantPath) + compareJSONString(withFixtureNamed: "Commandant", jsonString: commandantModule.docs, rootDirectory: commandantPath) } } diff --git a/Tests/SourceKittenFramework/OffsetMapTests.swift b/Tests/SourceKittenFramework/OffsetMapTests.swift index 98787d8b8..99a25fbde 100644 --- a/Tests/SourceKittenFramework/OffsetMapTests.swift +++ b/Tests/SourceKittenFramework/OffsetMapTests.swift @@ -18,18 +18,18 @@ class OffsetMapTests: XCTestCase { "struct VoidStruct {\n/// Returns or sets Void.\nsubscript(key: String) -> () {\n" + "get { return () }\nset {}\n}\n}" ) - let documentedTokenOffsets = file.contents.documentedTokenOffsets(SyntaxMap(file: file)) - let response = file.processDictionary(Request.EditorOpen(file).send(), cursorInfoRequest: nil) - let offsetMap = file.generateOffsetMap(documentedTokenOffsets, dictionary: response) + let documentedTokenOffsets = file.contents.documentedTokenOffsets(syntaxMap: SyntaxMap(file: file)) + let response = file.process(dictionary: Request.editorOpen(file: file).send(), cursorInfoRequest: nil) + let offsetMap = file.makeOffsetMap(documentedTokenOffsets: documentedTokenOffsets, dictionary: response) XCTAssertEqual(offsetMap, [46: 7], "should generate correct offset map of [(declaration offset): (parent offset)]") } func testOffsetMapDoesntContainAlreadyDocumentedDeclarationOffset() { // Struct declarations are parsed by SourceKit, so OffsetMap shouldn't contain its offset. let file = File(contents: "/// Doc Comment\nstruct DocumentedStruct {}") - let documentedTokenOffsets = file.contents.documentedTokenOffsets(SyntaxMap(file: file)) - let response = file.processDictionary(Request.EditorOpen(file).send(), cursorInfoRequest: nil) - let offsetMap = file.generateOffsetMap(documentedTokenOffsets, dictionary: response) + let documentedTokenOffsets = file.contents.documentedTokenOffsets(syntaxMap: SyntaxMap(file: file)) + let response = file.process(dictionary: Request.editorOpen(file: file).send(), cursorInfoRequest: nil) + let offsetMap = file.makeOffsetMap(documentedTokenOffsets: documentedTokenOffsets, dictionary: response) XCTAssertEqual(offsetMap, [:], "should generate empty offset map") } } diff --git a/Tests/SourceKittenFramework/SourceKitTests.swift b/Tests/SourceKittenFramework/SourceKitTests.swift index acd2ece24..89e99bcbb 100644 --- a/Tests/SourceKittenFramework/SourceKitTests.swift +++ b/Tests/SourceKittenFramework/SourceKitTests.swift @@ -10,7 +10,7 @@ import Foundation @testable import SourceKittenFramework import XCTest -private func run(_ executable: String, arguments: [String]) -> String? { +private func run(executable: String, arguments: [String]) -> String? { let task = Process() task.launchPath = executable task.arguments = arguments @@ -26,12 +26,12 @@ private func run(_ executable: String, arguments: [String]) -> String? { return output } -private func sourcekitStringsStartingWith(_ pattern: String) -> Set { - let sourceKitServicePath = (((run("/usr/bin/xcrun", arguments: ["-f", "swiftc"])! as NSString) +private func sourcekitStrings(startingWith pattern: String) -> Set { + let sourceKitServicePath = (((run(executable: "/usr/bin/xcrun", arguments: ["-f", "swiftc"])! as NSString) .deletingLastPathComponent as NSString) .deletingLastPathComponent as NSString) .appendingPathComponent("lib/sourcekitd.framework/XPCServices/SourceKitService.xpc/Contents/MacOS/SourceKitService") - let strings = run("/usr/bin/strings", arguments: [sourceKitServicePath]) + let strings = run(executable: "/usr/bin/strings", arguments: [sourceKitServicePath]) return Set(strings!.components(separatedBy: "\n").filter { string in return string.range(of: pattern)?.lowerBound == string.startIndex }) @@ -41,18 +41,18 @@ class SourceKitTests: XCTestCase { func testStatementKinds() { let expected: [StatementKind] = [ - .Brace, - .Case, - .For, - .ForEach, - .Guard, - .If, - .RepeatWhile, - .Switch, - .While, + .brace, + .case, + .for, + .forEach, + .guard, + .if, + .repeatWhile, + .switch, + .while, ] - let actual = sourcekitStringsStartingWith("source.lang.swift.stmt.") + let actual = sourcekitStrings(startingWith: "source.lang.swift.stmt.") let expectedStrings = Set(expected.map { $0.rawValue }) XCTAssertEqual( actual, @@ -66,27 +66,27 @@ class SourceKitTests: XCTestCase { func testSyntaxKinds() { let expected: [SyntaxKind] = [ - .Argument, - .AttributeBuiltin, - .AttributeID, - .BuildconfigID, - .BuildconfigKeyword, - .Comment, - .CommentMark, - .CommentURL, - .DocComment, - .DocCommentField, - .Identifier, - .Keyword, - .Number, - .ObjectLiteral, - .Parameter, - .Placeholder, - .String, - .StringInterpolationAnchor, - .Typeidentifier + .argument, + .attributeBuiltin, + .attributeID, + .buildconfigID, + .buildconfigKeyword, + .comment, + .commentMark, + .commentURL, + .docComment, + .docCommentField, + .identifier, + .keyword, + .number, + .objectLiteral, + .parameter, + .placeholder, + .string, + .stringInterpolationAnchor, + .typeidentifier ] - let actual = sourcekitStringsStartingWith("source.lang.swift.syntaxtype.") + let actual = sourcekitStrings(startingWith: "source.lang.swift.syntaxtype.") let expectedStrings = Set(expected.map { $0.rawValue }) XCTAssertEqual( actual, @@ -100,46 +100,46 @@ class SourceKitTests: XCTestCase { func testSwiftDeclarationKind() { let expected: [SwiftDeclarationKind] = [ - .Associatedtype, - .Class, - .Enum, - .Enumcase, - .Enumelement, - .Extension, - .ExtensionClass, - .ExtensionEnum, - .ExtensionProtocol, - .ExtensionStruct, - .FunctionAccessorAddress, - .FunctionAccessorDidset, - .FunctionAccessorGetter, - .FunctionAccessorMutableaddress, - .FunctionAccessorSetter, - .FunctionAccessorWillset, - .FunctionConstructor, - .FunctionDestructor, - .FunctionFree, - .FunctionMethodClass, - .FunctionMethodInstance, - .FunctionMethodStatic, - .FunctionOperatorInfix, - .FunctionOperatorPostfix, - .FunctionOperatorPrefix, - .FunctionSubscript, - .GenericTypeParam, - .Module, - .PrecedenceGroup, - .Protocol, - .Struct, - .Typealias, - .VarClass, - .VarGlobal, - .VarInstance, - .VarLocal, - .VarParameter, - .VarStatic + .associatedtype, + .class, + .enum, + .enumcase, + .enumelement, + .extension, + .extensionClass, + .extensionEnum, + .extensionProtocol, + .extensionStruct, + .functionAccessorAddress, + .functionAccessorDidset, + .functionAccessorGetter, + .functionAccessorMutableaddress, + .functionAccessorSetter, + .functionAccessorWillset, + .functionConstructor, + .functionDestructor, + .functionFree, + .functionMethodClass, + .functionMethodInstance, + .functionMethodStatic, + .functionOperatorInfix, + .functionOperatorPostfix, + .functionOperatorPrefix, + .functionSubscript, + .genericTypeParam, + .module, + .precedenceGroup, + .protocol, + .struct, + .typealias, + .varClass, + .varGlobal, + .varInstance, + .varLocal, + .varParameter, + .varStatic ] - let actual = sourcekitStringsStartingWith("source.lang.swift.decl.") + let actual = sourcekitStrings(startingWith: "source.lang.swift.decl.") let expectedStrings = Set(expected.map { $0.rawValue }) XCTAssertEqual( actual, @@ -174,7 +174,7 @@ class SourceKitTests: XCTestCase { func testIndex() { let file = "\(fixturesDirectory)Bicycle.swift" let arguments = ["-sdk", sdkPath(), "-j4", file ] - let indexJSON = NSMutableString(string: toJSON(toNSDictionary(Request.Index(file: file, arguments: arguments).send())) + "\n") + let indexJSON = NSMutableString(string: toJSON(toNSDictionary(Request.index(file: file, arguments: arguments).send())) + "\n") func replace(_ pattern: String, withTemplate template: String) { _ = try! NSRegularExpression(pattern: pattern, options: []).replaceMatches(in: indexJSON, options: [], range: NSRange(location: 0, length: indexJSON.length), withTemplate: template) @@ -184,6 +184,6 @@ class SourceKitTests: XCTestCase { replace("\"key\\.filepath\"[^\\n]*", withTemplate: "\"key\\.filepath\" : \"\",") replace("\"key\\.hash\"[^\\n]*", withTemplate: "\"key\\.hash\" : \"\",") - compareJSONStringWithFixturesName("BicycleIndex", jsonString: indexJSON as String) + compareJSONString(withFixtureNamed: "BicycleIndex", jsonString: indexJSON as String) } } diff --git a/Tests/SourceKittenFramework/StringTests.swift b/Tests/SourceKittenFramework/StringTests.swift index 3a652349a..41e25db9b 100644 --- a/Tests/SourceKittenFramework/StringTests.swift +++ b/Tests/SourceKittenFramework/StringTests.swift @@ -14,17 +14,17 @@ class StringTests: XCTestCase { func testStringByRemovingCommonLeadingWhitespaceFromLines() { var input = "a\n b\n c" - XCTAssertEqual(input.stringByRemovingCommonLeadingWhitespaceFromLines(), input) + XCTAssertEqual(input.removingCommonLeadingWhitespaceFromLines(), input) input = " a\n b\n c" - XCTAssertEqual(input.stringByRemovingCommonLeadingWhitespaceFromLines(), "a\n b\n c") + XCTAssertEqual(input.removingCommonLeadingWhitespaceFromLines(), "a\n b\n c") } func testStringByTrimmingTrailingCharactersInSet() { - XCTAssertEqual("".stringByTrimmingTrailingCharactersInSet(.whitespacesAndNewlines), "") - XCTAssertEqual(" a ".stringByTrimmingTrailingCharactersInSet(.whitespacesAndNewlines), " a") - XCTAssertEqual(" ".stringByTrimmingTrailingCharactersInSet(.whitespacesAndNewlines), "") - XCTAssertEqual("a".stringByTrimmingTrailingCharactersInSet(.whitespacesAndNewlines), "a") + XCTAssertEqual("".trimmingTrailingCharacters(in: .whitespacesAndNewlines), "") + XCTAssertEqual(" a ".trimmingTrailingCharacters(in: .whitespacesAndNewlines), " a") + XCTAssertEqual(" ".trimmingTrailingCharacters(in: .whitespacesAndNewlines), "") + XCTAssertEqual("a".trimmingTrailingCharacters(in: .whitespacesAndNewlines), "a") } func testCommentBody() { @@ -85,9 +85,9 @@ class StringTests: XCTestCase { let source = "struct A { subscript(key: String) -> Void { return () } }" let actual = SyntaxMap(file: File(contents: source)).tokens.filter(source.isTokenDocumentable) let expected = [ - SyntaxToken(type: SyntaxKind.Identifier.rawValue, offset: 7, length: 1), // `A` - SyntaxToken(type: SyntaxKind.Keyword.rawValue, offset: 11, length: 9), // `subscript` - SyntaxToken(type: SyntaxKind.Identifier.rawValue, offset: 21, length: 3) // `key` + SyntaxToken(type: SyntaxKind.identifier.rawValue, offset: 7, length: 1), // `A` + SyntaxToken(type: SyntaxKind.keyword.rawValue, offset: 11, length: 9), // `subscript` + SyntaxToken(type: SyntaxKind.identifier.rawValue, offset: 21, length: 3) // `key` ] XCTAssertEqual(actual, expected, "should detect documentable tokens") } @@ -108,19 +108,19 @@ class StringTests: XCTestCase { func testGenerateDocumentedTokenOffsets() { let fileContents = "/// Comment\nlet global = 0" let syntaxMap = SyntaxMap(file: File(contents: fileContents)) - XCTAssertEqual(fileContents.documentedTokenOffsets(syntaxMap), [16], "should generate documented token offsets") + XCTAssertEqual(fileContents.documentedTokenOffsets(syntaxMap: syntaxMap), [16], "should generate documented token offsets") } func testDocumentedTokenOffsetsWithSubscript() { let file = File(path: fixturesDirectory + "Subscript.swift")! let syntaxMap = SyntaxMap(file: file) - XCTAssertEqual(file.contents.documentedTokenOffsets(syntaxMap), [54], "should generate documented token offsets") + XCTAssertEqual(file.contents.documentedTokenOffsets(syntaxMap: syntaxMap), [54], "should generate documented token offsets") } func testGenerateDocumentedTokenOffsetsEmpty() { let fileContents = "// Comment\nlet global = 0" let syntaxMap = SyntaxMap(file: File(contents: fileContents)) - XCTAssertEqual(fileContents.documentedTokenOffsets(syntaxMap).count, 0, "shouldn't detect any documented token offsets when there are none") + XCTAssertEqual(fileContents.documentedTokenOffsets(syntaxMap: syntaxMap).count, 0, "shouldn't detect any documented token offsets when there are none") } func testSubstringWithByteRange() { diff --git a/Tests/SourceKittenFramework/SwiftDocsTests.swift b/Tests/SourceKittenFramework/SwiftDocsTests.swift index ef6db6e6c..17547b3ab 100644 --- a/Tests/SourceKittenFramework/SwiftDocsTests.swift +++ b/Tests/SourceKittenFramework/SwiftDocsTests.swift @@ -10,7 +10,7 @@ import Foundation import SourceKittenFramework import XCTest -func compareJSONStringWithFixturesName(_ name: String, jsonString: CustomStringConvertible, rootDirectory: String = fixturesDirectory) { +func compareJSONString(withFixtureNamed name: String, jsonString: CustomStringConvertible, rootDirectory: String = fixturesDirectory) { // Strip out fixtures directory since it's dependent on the test machine's setup let escapedFixturesDirectory = rootDirectory.replacingOccurrences(of: "/", with: "\\/") let jsonString = String(describing: jsonString).replacingOccurrences(of: escapedFixturesDirectory, with: "") @@ -39,20 +39,20 @@ func compareJSONStringWithFixturesName(_ name: String, jsonString: CustomStringC } } -func compareDocsWithFixturesName(_ name: String) { +private func compareDocs(withFixtureNamed name: String) { let swiftFilePath = fixturesDirectory + name + ".swift" let docs = SwiftDocs(file: File(path: swiftFilePath)!, arguments: ["-j4", swiftFilePath])! - compareJSONStringWithFixturesName(name, jsonString: docs) + compareJSONString(withFixtureNamed: name, jsonString: docs) } class SwiftDocsTests: XCTestCase { func testSubscript() { - compareDocsWithFixturesName("Subscript") + compareDocs(withFixtureNamed: "Subscript") } func testBicycle() { - compareDocsWithFixturesName("Bicycle") + compareDocs(withFixtureNamed: "Bicycle") } func testParseFullXMLDocs() { diff --git a/Tests/SourceKittenFramework/SyntaxTests.swift b/Tests/SourceKittenFramework/SyntaxTests.swift index a2f716a65..977b47c37 100644 --- a/Tests/SourceKittenFramework/SyntaxTests.swift +++ b/Tests/SourceKittenFramework/SyntaxTests.swift @@ -10,7 +10,7 @@ import Foundation import SourceKittenFramework import XCTest -func compareSyntax(_ file: File, _ expectedTokens: [(SyntaxKind, Int, Int)]) { +private func compareSyntax(file: File, expectedTokens: [(SyntaxKind, Int, Int)]) { let expectedSyntaxMap = SyntaxMap(tokens: expectedTokens.map { tokenTuple in return SyntaxToken(type: tokenTuple.0.rawValue, offset: tokenTuple.1, length: tokenTuple.2) }) @@ -37,24 +37,24 @@ class SyntaxTests: XCTestCase { } func testSubscript() { - compareSyntax(File(contents: "struct A { subscript(index: Int) -> () { return () } }"), - [ - (.Keyword, 0, 6), - (.Identifier, 7, 1), - (.Keyword, 11, 9), - (.Identifier, 21, 5), - (.Typeidentifier, 28, 3), - (.Keyword, 41, 6) + compareSyntax(file: File(contents: "struct A { subscript(index: Int) -> () { return () } }"), + expectedTokens: [ + (.keyword, 0, 6), + (.identifier, 7, 1), + (.keyword, 11, 9), + (.identifier, 21, 5), + (.typeidentifier, 28, 3), + (.keyword, 41, 6) ] ) } func testSyntaxMapPrintValidJSON() { - compareSyntax(File(contents: "import Foundation // Hello World!"), - [ - (.Keyword, 0, 6), - (.Identifier, 7, 10), - (.Comment, 18, 15) + compareSyntax(file: File(contents: "import Foundation // Hello World!"), + expectedTokens: [ + (.keyword, 0, 6), + (.identifier, 7, 10), + (.comment, 18, 15) ] ) }