Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
66 lines (57 sloc) 2.17 KB
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">
<plist version="1.0">
<string>#!/usr/bin/env ruby18
# Inserts a [super method] call suitable for the current method.
# The command is inserted as a snippet with each parameter as a tabstop
# An opening bracket is inserted if necessary, and a semicolon is
# added after the closing bracket if there is nothing else on the line.
# The command uses heuristics to find which method implementation is
# being edited. It should be reasonably tolerant to various coding styles,
# including different bracket and indentation styles.
proto_re = /
^\s* # Start of the line and optional space
[+-]\s* # a plus or minus for method specifier
\([^)]+\) # the return type in brackets
(?!.*;) # Assert implementation and not interface
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*/, ' ')
tabstop = 0
last_proto_sel_with_types.gsub!(/\([^)]+\)\s*(([A-Za-z0-9_][A-Za-z0-9_]*))/) do |match|
%Q{${#{tabstop += 1}:#$1}}
print '[' if invocation_line[ENV["TM_LINE_INDEX"].to_i - 1] != ?[
print 'super '
print last_proto_sel_with_types
print "]"
print ";" if invocation_line =~ /^\s+$/
<string>Insert Call to Super</string>
<string>source.objc meta.scope.implementation, source.objc++ meta.scope.implementation</string>
Something went wrong with that request. Please try again.