Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: b56f1cd470
Fetching contributors…

Cannot retrieve contributors at this time

71 lines (61 sloc) 2.164 kb
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>#!/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 ");"
</string>
<key>input</key>
<string>document</string>
<key>name</key>
<string>CPLog() for Current Method</string>
<key>output</key>
<string>insertAsSnippet</string>
<key>scope</key>
<string>source.js.objj meta.scope.implementation</string>
<key>tabTrigger</key>
<string>logm</string>
<key>uuid</key>
<string>F220FEE6-6522-4281-8091-CF8C66AED44F</string>
</dict>
</plist>
Jump to Line
Something went wrong with that request. Please try again.