Created
September 10, 2016 12:24
-
-
Save dolphinsue319/fa552a6fe18b210ca70730476e73df92 to your computer and use it in GitHub Desktop.
Sample of SourceEditorCommand.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import XcodeKit | |
class SourceEditorCommand: NSObject, XCSourceEditorCommand { | |
func perform(with invocation: XCSourceEditorCommandInvocation, completionHandler: @escaping (Error?) -> Void ) -> Void { | |
// Implement your command here, invoking the completion handler when done. Pass it nil on success, and an NSError on failure. | |
print("command identifier: \(invocation.commandIdentifier)") | |
print("content UTI: \(invocation.buffer.contentUTI)") | |
print("tab width: \(invocation.buffer.tabWidth)") | |
print("indentation width: \(invocation.buffer.indentationWidth)") | |
print("is use tab for indentation: \(invocation.buffer.usesTabsForIndentation)") | |
print("lines (strings in each line): \(invocation.buffer.lines)") | |
print("selections (array of XCSourceTextRange): \(invocation.buffer.selections)") | |
print("completeBuffer: \(invocation.buffer.completeBuffer)") | |
let error = NSError(domain: "the Domain", code: 60, userInfo: nil) | |
completionHandler(error) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment