Skip to content

Instantly share code, notes, and snippets.

@mavris
Last active September 20, 2016 06:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mavris/ab9ebde3173049aedaa49e5076e41c06 to your computer and use it in GitHub Desktop.
Save mavris/ab9ebde3173049aedaa49e5076e41c06 to your computer and use it in GitHub Desktop.
- (void)performCommandWithInvocation:(XCSourceEditorCommandInvocation *)invocation completionHandler:(void (^)(NSError * _Nullable nilOrError))completionHandler {
//Checks if the file contains source code of Objective-C or Swift. Then is sets the appropriate variables
if ([invocation.buffer.contentUTI isEqualToString:@"public.objective-c-source"]) {
logString = @"NSLog(";
logCommentString=@"DSLog(";
regularExpressionString =@"NSLog\\([^\\)]*\\)[\\s]*\\;";
regularExpressionCommentString=@"\\/\\*DSLog\\([^\\)]*\\)[\\s]*\\;\\*\\/";
}
else if ([invocation.buffer.contentUTI isEqualToString:@"public.swift-source"]){
logString = @"print(";
logCommentString = @"drint(";
regularExpressionString =@"(Swift.){0,1}print\\([^\\)]*\\)[\t]*[\\;]{0,1}";
regularExpressionCommentString=@"\\/\\*(Swift.){0,1}drint\\([^\\)]*\\)[\ts]*[\\;]{0,1}\\*\\/";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment