Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
127 lines (117 sloc) 3.01 KB
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//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>bundleUUID</key>
<string>4679484F-6227-11D9-BFB1-000D93589AF6</string>
<key>command</key>
<string>#!/usr/bin/env ruby18
require "#{ENV['TM_SUPPORT_PATH']}/lib/escape"
line = STDIN.read
offset = ENV['TM_INPUT_START_COLUMN'].to_i - 1
caret_placement = 0
tmp = ENV['TM_LINE_NUMBER'].to_i - ENV['TM_INPUT_START_LINE'].to_i
if tmp &gt; 0
class String
def index_of_nth_occurrence_of(n, ch)
self.unpack("U*").each_with_index do |e, i|
return i if e == ch &amp;&amp; (n -= 1) == 0
end
return -1
end
end
caret_placement += line.index_of_nth_occurrence_of(tmp,?\n) + ENV['TM_LINE_INDEX'].to_i
else
caret_placement =ENV['TM_LINE_INDEX'].to_i-ENV['TM_INPUT_START_LINE_INDEX'].to_i - 1
end
def match_iter(rgxp,str)
offset = 0
while m = str.match(rgxp)
yield [m[0], m.begin(0) + offset, m[0].length]
str = m.post_match
offset += m.end(0)
end
end
pat = /("(\\.|[^"\\])*"|\[|\]|@selector\([^\)]*\)|[a-zA-Z][a-zA-Z0-9]*:)/
up = 0
list = []
up = 0
pat = /("(\\.|[^"\\])*"|\[|\]|@selector\([^\)]*\)|[a-zA-Z][a-zA-Z0-9]*:)/
start = [0]
match_iter(pat , line[0..caret_placement]) do |tok, beg, len|
t = tok[0].chr
if t == "["
start &lt;&lt; beg
elsif t == "]"
start.pop
end
end
up = 0
last = line.length
match_iter(pat , line[caret_placement+1..line.length]) do |tok, beg, len|
t = tok[0].chr
if t == "["
up +=1
elsif t == "]"
if up == 0
last = beg + caret_placement + 1
break
end
up -=1
end
end
list = []
prefix = ""
prefix = line[0..start[-1]-1] unless start[-1] == 0
suffix = line[last+1..-1]
l = line[start[-1]..last]
up = -1
match_iter(pat , l) do |tok, beg, len|
t = tok[0].chr
if t == "["
up +=1
elsif t == "]"
up -=1
elsif t !='"' and t !='@' and up == 0
list &lt;&lt; [beg,len]
end
end
list &lt;&lt; [l.length,0]
offset += start[-1]
if list.length &gt; 2
print e_sn(prefix+ l[0...list[1][0]].strip)
#check to if the first "selector:" is not in the first line
if k = line[0...start[-1]+list[0][0]].rindex("\n")
firstIndex = list[0][0]+list[0][1]- k -1
offset = start[-1]
else
firstIndex = list[0][0] + list[0][1]
end
(1..(list.length() -2)).each do |ind|
list[ind][1]+list[ind][0]
b = (b = firstIndex-list[ind][1]+offset) &gt; 0 ? b : 0
print e_sn("\n" + " "*b + l[(list[ind][0])...(list[ind+1][0])].strip)
end
print e_sn(suffix) unless suffix.nil?
else
print e_sn(line)
end
</string>
<key>fallbackInput</key>
<string>scope</string>
<key>input</key>
<string>selection</string>
<key>keyEquivalent</key>
<string>^q</string>
<key>name</key>
<string>Reformat Method Call</string>
<key>output</key>
<string>replaceSelectedText</string>
<key>scope</key>
<string>meta.bracketed.objc</string>
<key>uuid</key>
<string>8957C99F-88F5-42CC-B355-AAC6BF3FDF8D</string>
</dict>
</plist>
Something went wrong with that request. Please try again.