beforeRunningCommand nop command #!/usr/bin/env ruby proto_re = / ^\s* # Start of the line and optional space [+-]\s* # a plus or minus for method specifier \([^)]+\) # the return type in brackets ((?:\n|[^{])*) (?m:.*?) \{ /x previous_lines = STDIN.readlines[1..ENV['TM_LINE_NUMBER'].to_i - 1] invocation_line = previous_lines[-1] proto = previous_lines.join.scan(proto_re)[-1] exit if proto.nil? or proto.empty? last_proto_sel_with_types = proto[0].strip.sub(/^\s+/, '').sub(%r{\s*//.*$}, '').gsub(/\n\s*/, ' ') params = [] params = last_proto_sel_with_types.scan(/(.+?):\((.+?)\)(\w+)/) def format_specifier_for_type(type) %w[int bool BOOL long].each { |t| return('%d') if type.include? t } return '%c' if type == 'char' return '%C' if type == 'unichar' return '%s' if type == 'char*' '%@' end def transformer_for(type, name) return "CPStringFromRect(#{name})" if type == 'CPRect' return "CPStringFromPoint(#{name})" if type == 'CPPoint' return "CPStringFromSize(#{name})" if type == 'CPSize' return "CPStringFromSelector(#{name})" if type == 'SEL' name end print 'CPLog("[%@ ' if params.empty? print last_proto_sel_with_types else print params.map { |param, type, name| param + ':' + format_specifier_for_type(type) }.join end print ']", [self class]' print ', ' + params.map { |param, type, name| transformer_for(type, name) }.join(', ') unless params.empty? print ");" input document name CPLog() for Current Method output insertAsSnippet scope source.js.objj meta.scope.implementation tabTrigger logm uuid F220FEE6-6522-4281-8091-CF8C66AED44F