├── .gitignore
├── Commands
├── Cocoa Context.tmCommand
├── Cocoa Function Completion.tmCommand
├── Cocoa Method Signature Completion.tmCommand
├── Completion: Inside @selector.tmCommand
├── Delete Outer Method.tmCommand
├── Documentation for Selector.tmCommand
├── Format Method Signature.plist
├── Generate Index.tmCommand
├── Help.tmCommand
├── Insert Call to Super.plist
├── Insert Matching Start Bracket.tmCommand
├── Insert NSLog() for current method.tmCommand
├── Lookup Cocoa Class.plist
├── Paste Implementation : Interface.tmCommand
├── Paste selector.tmCommand
├── Reflow Method Call.tmCommand
├── Toggle Import : Include Keyword.tmCommand
└── Wrap in [[alloc] init] (alloc).plist
├── Preferences
├── Cocoa completions.plist
├── Folding.tmPreferences
├── Highlight Pairs: Protocol Specifiers.tmPreferences
├── Symbol List.plist
└── Typing Pairs: Protocol Specifier.tmPreferences
├── README.mdown
├── Snippets
├── #import "" (imp).plist
├── #import <> (Imp).plist
├── 020 Class (objc).plist
├── 030 NSArray (array).plist
├── 040 NSDictionary (dict).plist
├── 050 Method (m).plist
├── 060 SubMethod (sm).plist
├── @selector.tmSnippet
├── Category (cat).plist
├── Category Implementation.tmSnippet
├── Category Interface Only (cati).plist
├── Class Implementation.tmSnippet
├── Class Interface Only (classi).plist
├── Class Method (M).plist
├── Class Method Interface (M).plist
├── CoreData Accessors Implementation.plist
├── Delegate Responds to Selector.plist
├── Detach New NSThread.tmSnippet
├── For Loop.tmSnippet
├── IBOutlet (ibo).plist
├── Initialize Implementation (I).plist
├── Key:value binding (bind).plist
├── LoD array (arracc).plist
├── LoD array interface (arracc).plist
├── Lock Focus.plist
├── Method Interface (m).plist
├── NSAutoreleasePool (pool).plist
├── NSBezierPath (bez).plist
├── NSLog (log) 2.plist
├── NSLog(.., _cmd) (log).plist
├── NSRunAlertPanel (alert).plist
├── NSString stringWithFormat (format).plist
├── Object Accessors Interface (objacc).plist
├── Property.tmSnippet
├── Protocol.tmSnippet
├── Read from defaults (getprefs).plist
├── Register for Notification.tmSnippet
├── Responds to Selector.plist
├── Save and Restore Graphics Context (gsave).plist
├── Scalar Accessors (acc).plist
├── Scalar Accessors Interface (acc).plist
├── String Accessors Interface (stracc).plist
├── Synthesize.tmSnippet
├── Write to defaults (setprefs).plist
└── for(… in …).tmSnippet
├── Support
├── CocoaAnnotatedStrings.txt.gz
├── CocoaAnonymousEnums.txt.gz
├── CocoaClasses.txt.gz
├── CocoaClassesWithAncestry.txt.gz
├── CocoaClassesWithFramework.txt.gz
├── CocoaConstants.txt.gz
├── CocoaFunctions.txt.gz
├── CocoaMethods.txt.gz
├── CocoaNotifications.txt.gz
├── CocoaProtocols.txt.gz
├── CocoaTypes.txt.gz
├── CppReferenceWiki.tsf
├── Platform
│ ├── Makefile
│ ├── README.md
│ ├── generator.mm
│ ├── includes.c
│ └── includes.mm
├── SpecialRules.txt
├── anonymousEnums.rb
├── generateMethodList.rb
├── lib
│ └── docset_query.rb
├── objcParser.rb
├── objc_completion2.rb
├── objc_selector_completion2.rb
└── typedefdump.rb
├── Syntaxes
├── Objective-C++.tmLanguage
├── Objective-C.tmLanguage
├── Platform.md
├── Platform.tmLanguage
└── Strings File.tmLanguage
├── Templates
└── Singleton
│ ├── class_in.mm
│ ├── header_in.h
│ └── info.plist
└── info.plist
/.gitignore:
--------------------------------------------------------------------------------
1 | Support/Platform/generator
2 |
--------------------------------------------------------------------------------
/Commands/Cocoa Context.tmCommand:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | beforeRunningCommand
6 | nop
7 | bundleUUID
8 | 4679484F-6227-11D9-BFB1-000D93589AF6
9 | command
10 | #!/usr/bin/env ruby18
11 | require "#{ENV['TM_SUPPORT_PATH']}/lib/exit_codes"
12 | require "#{ENV['TM_SUPPORT_PATH']}/lib/escape"
13 | require "#{ENV['TM_BUNDLE_SUPPORT']}/objc_completion2"
14 |
15 | def stripComments(line)
16 | line.gsub(/((['"])(?:\\.|.)*?\2)|\/\*.*?\*\/|\/\/[^\n\r]*/m) do |s|
17 | if $1
18 | s
19 | else
20 | s.split("\n").map{|e| ' ' * e.length() }.join("\n")
21 | end
22 | end
23 | end
24 |
25 | class String
26 | def index_of_nth_occurrence_of(n, ch)
27 | self.unpack("U*").each_with_index do |e, i|
28 | return i if e == ch && (n -= 1) == 0
29 | end
30 | return -1
31 | end
32 | end
33 |
34 | def caret_position(line)
35 | tmp = ENV['TM_LINE_NUMBER'].to_i - ENV['TM_INPUT_START_LINE'].to_i
36 | if tmp > 0
37 | caret_placement = line.index_of_nth_occurrence_of(tmp,?\n) + ENV['TM_LINE_INDEX'].to_i
38 | else
39 | caret_placement =ENV['TM_LINE_INDEX'].to_i-ENV['TM_INPUT_START_LINE_INDEX'].to_i - 1
40 | end
41 | end
42 |
43 | if ENV['TERMINAL_MATE_NEW']
44 | class ObjCMethodCompletion
45 | def show_dialog(prettyCandidates,start,&snip_gen)
46 | require "#{ENV['TM_SUPPORT_PATH']}/lib/osx/plist"
47 | pl = {'menuItems' => prettyCandidates.map { |pretty, junk, full | { 'title' => pretty, 'cand' => full} }}
48 | pl.to_plist
49 | res = pl['menuItems'][0]
50 | snip_gen.call( res['cand'], start )
51 | end
52 | end
53 |
54 | class TextMateEarlyExitException < RuntimeError
55 | end
56 |
57 | module TextMate
58 | module_function
59 | def exit_show_tool_tip(out = nil)
60 | print out if out
61 | raise TextMateEarlyExitException, "show tool kit"
62 | end
63 |
64 | def exit_discard(out = nil)
65 | print out if out
66 | raise TextMateEarlyExitException, "exit discard"
67 | end
68 | end
69 |
70 |
71 |
72 | tc = [
73 | {:tmVars => {'TM_LINE_NUMBER' => '19', 'TM_INPUT_START_LINE' => '19', 'TM_LINE_INDEX' => '8', 'TM_INPUT_START_LINE_INDEX' => '0'}, :line => '[self ad]'},
74 | {:tmVars => {'TM_LINE_NUMBER' => '20', 'TM_INPUT_START_LINE' => '20', 'TM_LINE_INDEX' => '20', 'TM_INPUT_START_LINE_INDEX' => '0'}, :line => '[[NSStrig alloc] ini]'},
75 | {:tmVars => {'TM_LINE_NUMBER' => '19', 'TM_INPUT_START_LINE' => '19', 'TM_LINE_INDEX' => '8', 'TM_INPUT_START_LINE_INDEX' => '0'}, :line => '[self adbl]'},
76 | {:tmVars => {'TM_LINE_NUMBER' => '21', 'TM_INPUT_START_LINE' => '21', 'TM_LINE_INDEX' => '26', 'TM_INPUT_START_LINE_INDEX' => '0'}, :line => '[NSObject isKindOfClass:NS]'},
77 | {:tmVars => {'TM_LINE_NUMBER' => '22', 'TM_INPUT_START_LINE' => '22', 'TM_LINE_INDEX' => '18', 'TM_INPUT_START_LINE_INDEX' => '0'}, :line => '[sto setObject:for]'},
78 | {:tmVars => {'TM_LINE_NUMBER' => '23', 'TM_INPUT_START_LINE' => '23', 'TM_LINE_INDEX' => '22', 'TM_INPUT_START_LINE_INDEX' => '0'}, :line => '[sto setObject:for for]'},
79 | {:tmVars => {'TM_LINE_NUMBER' => '24', 'TM_INPUT_START_LINE' => '24', 'TM_LINE_INDEX' => '21', 'TM_INPUT_START_LINE_INDEX' => '0'}, :line => '[sto setObject:for + ]'},
80 | {:tmVars => {'TM_LINE_NUMBER' => '25', 'TM_INPUT_START_LINE' => '25', 'TM_LINE_INDEX' => '5', 'TM_INPUT_START_LINE_INDEX' => '0'}, :line => '[obj ]'},
81 | {:tmVars => {'TM_LINE_NUMBER' => '26', 'TM_INPUT_START_LINE' => '26', 'TM_LINE_INDEX' => '7', 'TM_INPUT_START_LINE_INDEX' => '0'}, :line => '[NSObje]'},
82 | {:tmVars => {'TM_LINE_NUMBER' => '27', 'TM_INPUT_START_LINE' => '27', 'TM_LINE_INDEX' => '5', 'TM_INPUT_START_LINE_INDEX' => '0'}, :line => '[obj ]'},
83 | {:tmVars => {'TM_LINE_NUMBER' => '28', 'TM_INPUT_START_LINE' => '28', 'TM_LINE_INDEX' => '6', 'TM_INPUT_START_LINE_INDEX' => '0'}, :line => '[obj t]'},
84 | {:tmVars => {'TM_LINE_NUMBER' => '11','TM_INPUT_START_LINE' => '11','TM_LINE_INDEX' => '11','TM_INPUT_START_LINE_INDEX' => '0'}, :line => '[obj t:b:av]'},
85 | {:tmVars => {'TM_LINE_NUMBER' => '30', 'TM_INPUT_START_LINE' => '30', 'TM_LINE_INDEX' => '19', 'TM_INPUT_START_LINE_INDEX' => '0'}, :line => '[obj set:[NSString ]]'},
86 | {:tmVars => {'TM_LINE_NUMBER' => '31', 'TM_INPUT_START_LINE' => '31', 'TM_LINE_INDEX' => '30', 'TM_INPUT_START_LINE_INDEX' => '0'}, :line => '[obj set:[NSString role:@"eu" ]]'},
87 | {:tmVars => {'TM_LINE_NUMBER' => '32', 'TM_INPUT_START_LINE' => '32', 'TM_LINE_INDEX' => '35', 'TM_INPUT_START_LINE_INDEX' => '0'}, :line => '[obj set:[NSString role:@"eu" forYo]]'},
88 | {:tmVars => {'TM_LINE_NUMBER' => '33', 'TM_INPUT_START_LINE' => '33', 'TM_LINE_INDEX' => '40', 'TM_INPUT_START_LINE_INDEX' => '0'}, :line => '[obj set:[NSString role:@"eu" forYou:sel]]'},
89 | {:tmVars => {'TM_LINE_NUMBER' => '34', 'TM_INPUT_START_LINE' => '34', 'TM_LINE_INDEX' => '26', 'TM_INPUT_START_LINE_INDEX' => '0'}, :line => '[obj postNotificationName: object:NSString *]'},
90 | {:tmVars => {'TM_LINE_NUMBER'=> '7','TM_INPUT_START_LINE'=> '6','TM_LINE_INDEX'=> '55', 'TM_INPUT_START_LINE_INDEX' => '0'}, :line => "[[NSNotificationCenter defaultCenter] addObserver:self\n selector:@selector(colorPicker:) ]"}]
91 |
92 |
93 | ENV['TM_BUNDLE_SUPPORT'] = "/Library/Application Support/TextMate/Bundles/Objective-C.tmbundle/Support"
94 | tc.each do |element|
95 | element[:tmVars].each do |key,value|
96 | ENV[key] = value
97 | end
98 | caret_placement = caret_position(element[:line])
99 | begin
100 | res = ObjCMethodCompletion.new(element[:line] , caret_placement).print
101 | rescue NoMethodError => boom
102 |
103 | puts "error in:" + element.inspect
104 |
105 | puts boom
106 |
107 | rescue TextMateEarlyExitException => boom
108 | puts "Early Exit"
109 | end
110 |
111 | end
112 |
113 | else
114 | line = STDIN.read
115 | caret_placement = caret_position(line)
116 | if ENV['TM_SCOPE'].include? "meta.bracketed.objc"
117 | res, os = ObjCMethodCompletion.new(stripComments(line) , caret_placement).print
118 | else
119 | res = ObjCFallbackCompletion.new(stripComments(line) , caret_placement).print
120 | os = 0
121 | end
122 | if res
123 | print e_sn(line[0..caret_placement]) + res + e_sn(line[caret_placement + 1 + os..-1])
124 | else
125 | TextMate.exit_discard
126 | end
127 | end
128 |
129 | disableOutputAutoIndent
130 |
131 | fallbackInput
132 | scope
133 | input
134 | selection
135 | keyEquivalent
136 | ~
137 | name
138 | Completion: Inside Brackets
139 | output
140 | insertAsSnippet
141 | scope
142 | meta.function-with-body.objc | meta.bracketed.objc
143 | uuid
144 | 478FBA1D-C11C-4D53-BE95-8B8ABB5F15DC
145 |
146 |
147 |
--------------------------------------------------------------------------------
/Commands/Cocoa Function Completion.tmCommand:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | beforeRunningCommand
6 | nop
7 | bundleUUID
8 | 4679484F-6227-11D9-BFB1-000D93589AF6
9 | command
10 | #!/usr/bin/env ruby18
11 | require "#{ENV['TM_SUPPORT_PATH']}/lib/exit_codes"
12 | require "#{ENV['TM_SUPPORT_PATH']}/lib/escape"
13 | require "#{ENV['TM_BUNDLE_SUPPORT']}/objc_completion2"
14 |
15 | def stripComments(line)
16 | line.gsub(/((['"])(?:\\.|.)*?\2)|\/\*.*?\*\/|\/\/[^\n\r]*/m) do |s|
17 | if $1
18 | s
19 | else
20 | ' ' * s.length()
21 | end
22 | end
23 | end
24 |
25 | class String
26 | def index_of_nth_occurrence_of(n, ch)
27 | self.unpack("U*").each_with_index do |e, i|
28 | return i if e == ch && (n -= 1) == 0
29 | end
30 | return -1
31 | end
32 | end
33 |
34 | def caret_position(line)
35 | tmp = ENV['TM_LINE_NUMBER'].to_i - ENV['TM_INPUT_START_LINE'].to_i
36 | if tmp > 0
37 | caret_placement = line.index_of_nth_occurrence_of(tmp,?\n) + ENV['TM_LINE_INDEX'].to_i
38 | else
39 | caret_placement =ENV['TM_LINE_INDEX'].to_i-ENV['TM_INPUT_START_LINE_INDEX'].to_i - 1
40 | end
41 | end
42 |
43 | line = ENV['TM_CURRENT_LINE']
44 | caret_placement = caret_position(line)
45 | res = ObjCFallbackCompletion.new(stripComments(line) , caret_placement).print
46 | os = 0
47 | print res
48 | input
49 | none
50 | keyEquivalent
51 | ~
52 | name
53 | Completion: Fallback
54 | output
55 | insertAsSnippet
56 | scope
57 | source.objc, source.objc++
58 | uuid
59 | 88754B0F-D8DB-4796-9D02-058B756C606D
60 |
61 |
62 |
--------------------------------------------------------------------------------
/Commands/Cocoa Method Signature Completion.tmCommand:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | beforeRunningCommand
6 | nop
7 | bundleUUID
8 | 4679484F-6227-11D9-BFB1-000D93589AF6
9 | command
10 | #!/usr/bin/env ruby18
11 | require ENV['TM_SUPPORT_PATH'] + "/lib/exit_codes"
12 | require "#{ENV['TM_SUPPORT_PATH']}/lib/escape"
13 |
14 | line = ENV['TM_CURRENT_LINE']
15 |
16 | def construct_arg_name(arg)
17 | a = arg.match(/(NS|AB|CI|CD)?(Mutable)?(([AEIOQUYi])?[A-Za-z_0-9]+)/)
18 | unless a.nil?
19 | (a[4].nil? ? "a": "an") + a[3].sub!(/\b\w/) { $&.upcase }
20 | else
21 | ""
22 | end
23 | end
24 |
25 | def prettify(cand, call)
26 | stuff = cand.split("\t")
27 | if stuff[0].count(":") > 0
28 | name_array = stuff[0].split(":")
29 | out = ""
30 | begin
31 | stuff[-(name_array.size)..-1].each_with_index do |arg,i|
32 | if arg == "SEL"
33 | out << name_array[i] + ":(SEL)"+ "aSelector "
34 | else
35 | out << name_array[i] + ":("+ arg.gsub(/ \*/,(ENV['TM_C_POINTER'] || " *").rstrip)+")"+ "#{construct_arg_name(arg)} "
36 | end
37 | end
38 | rescue NoMethodError
39 | out << stuff[0]
40 | end
41 | else
42 | out = stuff[0]
43 | end
44 | out = "(#{stuff[5].gsub(/ \*/,(ENV['TM_C_POINTER'] || " *").rstrip)})#{out}" unless call || (stuff.size < 4)
45 |
46 | return [out.chomp.strip, stuff[0], cand]
47 | end
48 |
49 | def snippet_generator(cand, start, call)
50 | start = 0
51 | stuff = cand[start..-1].split("\t")
52 | if stuff[0].count(":") > 0
53 |
54 | name_array = stuff[0].split(":")
55 | name_array = [""] if name_array.empty?
56 | out = ""
57 | begin
58 | stuff[-(name_array.size)..-1].each_with_index do |arg,i|
59 | if arg == "SEL"
60 | out << name_array[i] + ":(#{arg})${#{(i+1).to_s}:aSelector} "
61 | else
62 | out << name_array[i] + ":(#{arg.gsub(/ \*/,(ENV['TM_C_POINTER'] || " *").rstrip)})${#{(i+1).to_s}:#{construct_arg_name(arg)}} "
63 | end
64 | end
65 | rescue NoMethodError
66 | out << stuff[0]
67 | end
68 | else
69 | out = stuff[0]
70 | end
71 | out = "(#{stuff[5].gsub(/ \*/,(ENV['TM_C_POINTER'] || " *").rstrip)})#{out}" unless (stuff.size < 4)
72 | if ENV['TM_SCOPE'].include? "meta.scope.implementation.objc"
73 | if stuff[5].match(/^void$/) || stuff[5].match(/IBAction/)
74 | rv = ""
75 | elsif stuff[5].match(/^BOOL$/)
76 | rv = "\treturn ${1:Y}${1/^(?:(Y)|(N)|.*)/(?1:ES:(?2:O))/};\n"
77 | else
78 | rv = "\treturn nil;\n"
79 | end
80 |
81 | out = out.chomp.strip + "\n\{$0\n#{rv}\}"
82 | else
83 | out = out.chomp.strip + "$0;"
84 | end
85 | return out
86 | end
87 |
88 | def pop_up(candidates, searchTerm, call = true)
89 | start = searchTerm.size
90 | prettyCandidates = candidates.map { |candidate| prettify(candidate,call) }.sort
91 |
92 | if prettyCandidates.size > 1
93 | require "enumerator"
94 | pruneList = []
95 |
96 | prettyCandidates.each_cons(2) do |a|
97 | pruneList << (a[0][0] != a[1][0]) # check if prettified versions are the same
98 | end
99 | pruneList << true
100 | ind = -1
101 | prettyCandidates = prettyCandidates.select do |a| #remove duplicates
102 | pruneList[ind+=1]
103 | end
104 | end
105 | prettyCandidates = prettyCandidates.sort {|x,y| x[1].downcase <=> y[1].downcase }
106 | if prettyCandidates.size > 1
107 | #index = start
108 | #test = false
109 | #while !test
110 | # candidates.each_cons(2) do |a,b|
111 | # break if test = (a[index].chr != b[index].chr || a[index].chr == "\t")
112 | # end
113 | # break if test
114 | # searchTerm << candidates[0][index].chr
115 | # index +=1
116 | #end
117 |
118 | show_dialog(prettyCandidates,start) do |c,s|
119 | snippet_generator(c,s, call)
120 | end
121 | else
122 | snippet_generator( candidates[0], start, call )
123 | end
124 | end
125 |
126 | def show_dialog(prettyCandidates,start,&snip_gen)
127 | require "#{ENV['TM_SUPPORT_PATH']}/lib/osx/plist"
128 | pl = {'menuItems' => prettyCandidates.map { |pretty,junk, full | { 'title' => pretty, 'cand' => full} }}
129 | io = open('|"$DIALOG" -u', "r+")
130 | io << pl.to_plist
131 | io.close_write
132 | res = OSX::PropertyList::load(io.read)
133 | if res.has_key? 'selectedMenuItem'
134 | snip_gen.call( res['selectedMenuItem']['cand'], start )
135 | else
136 | "$0"
137 | end
138 | end
139 |
140 | def candidates_or_exit(methodSearch, list, fileNames, notif = false)
141 | x = candidate_list(methodSearch, list, fileNames, notif)
142 | TextMate.exit_show_tool_tip "No completion available" if x.empty?
143 | return x
144 | end
145 |
146 | def candidate_list(methodSearch, list, fileNames, notif = false)
147 | candidates = []
148 | fileNames.each do |fileName|
149 | zGrepped = %x{ zgrep ^#{e_sh methodSearch } #{e_sh ENV['TM_BUNDLE_SUPPORT']}/#{fileName} }
150 | candidates += zGrepped.split("\n")
151 | end
152 | # strip notifications
153 | if notif
154 | candidates = candidates.select {|cand| cand.match(/\tno\t/) }
155 | else
156 | candidates = candidates.reject {|cand| cand.match(/\tno\t/) }
157 | end
158 | return [] if candidates.empty?
159 | if list.nil?
160 | return candidates
161 | else
162 | n = []
163 | candidates.each do |cand|
164 | n << cand if list.include?(cand.split("\t")[0])
165 | end
166 | n = (n.empty? ? candidates : n)
167 |
168 | return n
169 | end
170 | end
171 |
172 | methodDeclaration = /^((?:\+|-)\s*)([a-zA-Z][a-zA-Z0-9:]*)$/
173 |
174 | if k = line.match(methodDeclaration)
175 | candidates = candidates_or_exit( k[2], nil, "CocoaMethods.txt.gz")
176 | res =pop_up(candidates, k[2])
177 | TextMate.exit_discard if res == "$0"
178 | print k[1] + res
179 | else
180 | TextMate.exit_discard
181 | end
182 |
183 | fallbackInput
184 | line
185 | input
186 | selection
187 | keyEquivalent
188 | ~
189 | name
190 | Completion: Partial Method Signature
191 | output
192 | insertAsSnippet
193 | scope
194 | meta.function.objc - (meta.argument-type.objc | meta.return-type.objc | meta.bracketed)
195 | uuid
196 | 30E93FBA-5A81-4D94-8A03-9CD46FCA3CFA
197 |
198 |
199 |
--------------------------------------------------------------------------------
/Commands/Completion: Inside @selector.tmCommand:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | beforeRunningCommand
6 | nop
7 | bundleUUID
8 | 4679484F-6227-11D9-BFB1-000D93589AF6
9 | command
10 | #!/usr/bin/env ruby18
11 | require "#{ENV['TM_SUPPORT_PATH']}/lib/exit_codes"
12 | require "#{ENV['TM_SUPPORT_PATH']}/lib/escape"
13 | require "#{ENV['TM_BUNDLE_SUPPORT']}/objc_selector_completion2"
14 |
15 | def stripComments(line)
16 | line.gsub(/((['"])(?:\\.|.)*?\2)|\/\*.*?\*\/|\/\/[^\n\r]*/m) do |s|
17 | if $1
18 | s
19 | else
20 | ' ' * s.length()
21 | end
22 | end
23 | end
24 |
25 |
26 | def caret_position(line)
27 | tmp = ENV['TM_LINE_NUMBER'].to_i - ENV['TM_INPUT_START_LINE'].to_i
28 | if tmp > 0
29 | caret_placement = line.index_of_nth_occurrence_of(tmp,?\n) + ENV['TM_LINE_INDEX'].to_i
30 | else
31 | caret_placement =ENV['TM_LINE_INDEX'].to_i-ENV['TM_INPUT_START_LINE_INDEX'].to_i - 1
32 | end
33 | end
34 |
35 | line = STDIN.read
36 |
37 | caret_placement = caret_position(line)
38 |
39 | res = ObjcSelectorCompletion.new(stripComments(line) , caret_placement).print
40 | print res
41 | disableOutputAutoIndent
42 |
43 | fallbackInput
44 | scope
45 | hideFromUser
46 |
47 | input
48 | selection
49 | keyEquivalent
50 | ~
51 | name
52 | Completion: Inside @selector
53 | output
54 | insertAsSnippet
55 | scope
56 | meta.selector.objc
57 | uuid
58 | F929835A-C9F7-4934-87BD-05FD11C4435B
59 |
60 |
61 |
--------------------------------------------------------------------------------
/Commands/Delete Outer Method.tmCommand:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | beforeRunningCommand
6 | nop
7 | command
8 | #!/usr/bin/env ruby18 -wKU
9 | print STDIN.read.sub(/\A\[(.*\])[^\]]*\]\z/, '\\1')
10 |
11 | fallbackInput
12 | scope
13 | input
14 | selection
15 | keyEquivalent
16 | ^@
17 | name
18 | Delete Outer Method Call
19 | output
20 | replaceSelectedText
21 | scope
22 | meta.bracketed.objc
23 | uuid
24 | E802FA1A-1E2E-4F8A-957F-C1533CE57400
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Commands/Documentation for Selector.tmCommand:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | beforeRunningCommand
6 | nop
7 | bundleUUID
8 | 4679484F-6227-11D9-BFB1-000D93589AF6
9 | command
10 | #!/usr/bin/env ruby18 -wKU
11 | require "#{ENV['TM_BUNDLE_SUPPORT']}/lib/docset_query.rb"
12 |
13 | documentation_for_selector
14 |
15 | fallbackInput
16 | scope
17 | input
18 | selection
19 | keyEquivalent
20 | ^h
21 | name
22 | Documentation for Selector
23 | output
24 | showAsTooltip
25 | scope
26 | (meta.bracketed.objc | meta.function.objc) - dyn.selection
27 | uuid
28 | 8AF46225-833C-473E-8EEC-F21C581636F6
29 |
30 |
31 |
--------------------------------------------------------------------------------
/Commands/Format Method Signature.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | beforeRunningCommand
6 | nop
7 | command
8 | #!/usr/bin/env ruby18
9 | text = STDIN.read
10 |
11 | text.gsub!(/(\([^\)]+)\s+(\*\))/, '\1\2')
12 |
13 | offset_to_first_colon = text.index(':')
14 |
15 | argument_triplets = text.scan /(.+?):\s*\((.+?)\)\s*([^\s]*)\s*/
16 |
17 | print(argument_triplets.collect do |triplet|
18 | sprintf "%#{offset_to_first_colon}s:(%s)%s", triplet[0], triplet[1], triplet[2]
19 | end.join("\n"))
20 |
21 | print $1 if text.match /(\n+)\z/
22 | fallbackInput
23 | scope
24 | input
25 | selection
26 | keyEquivalent
27 | ^q
28 | name
29 | Reformat Method Signature
30 | output
31 | replaceSelectedText
32 | scope
33 | meta.function.objc
34 | uuid
35 | 122E10C1-DFA2-4A9E-9B17-8EBFA6E10CC7
36 |
37 |
38 |
--------------------------------------------------------------------------------
/Commands/Generate Index.tmCommand:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | beforeRunningCommand
6 | nop
7 | bundleUUID
8 | 4679484F-6227-11D9-BFB1-000D93589AF6
9 | command
10 | if [[ -d "$TM_PROJECT_DIRECTORY" ]]; then
11 | find -E "$TM_PROJECT_DIRECTORY" -regex '.*/(_darcs|CVS|\..*)' -prune -or -name '*.h' -print0 | ruby18 "$TM_BUNDLE_SUPPORT/generateMethodList.rb" -c "$TM_PROJECT_DIRECTORY/.classes.TM_Completions.txt" -m "$TM_PROJECT_DIRECTORY/.methods.TM_Completions.txt" -w "$TM_BUNDLE_SUPPORT/CocoaClassesWithFramework.txt.gz";
12 | gzip -f "$TM_PROJECT_DIRECTORY/.methods.TM_Completions.txt";
13 | gzip -f "$TM_PROJECT_DIRECTORY/.classes.TM_Completions.txt";
14 | echo "indexing complete";
15 | else
16 | echo "no Project Path found";
17 | fi
18 | fallbackInput
19 | word
20 | input
21 | none
22 | name
23 | Index Headers for Completion
24 | output
25 | showAsTooltip
26 | scope
27 | source.objc, source.objc++
28 | uuid
29 | 42B1691B-DC28-4743-9B18-C8D51B70722C
30 |
31 |
32 |
--------------------------------------------------------------------------------
/Commands/Help.tmCommand:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | beforeRunningCommand
6 | nop
7 | bundleUUID
8 | 4679484F-6227-11D9-BFB1-000D93589AF6
9 | command
10 | . "$TM_SUPPORT_PATH/lib/webpreview.sh"
11 | html_header "Objective-C Bundle Help" "Objective-C"
12 | "$TM_SUPPORT_PATH/lib/markdown_to_help.rb" <<'MARKDOWN'
13 |
14 | # Introduction
15 |
16 | This document describes the commands of the Objective-C bundle and is a recommended read, since not all features are easy to discover.
17 |
18 | In addition to this help file there are also 3 screencasts dedicated to showing Objective-C features (the links below are to more info about the screencast):
19 |
20 | 1. The [most recent][SC1] is by Joachim Mårtensson and shows completion, bracket matching, reformatting methods, and documentation lookup.
21 | 2. [Objective-C Part 2][SC2] by Allan Odgaard.
22 | 3. [Graceful Objective-C Snippets][SC3] by Allan Odgaard.
23 |
24 | You can see [all screencasts here][AllCasts].
25 |
26 | [SC1]: http://macromates.com/screencast/TextMateObjCScreenCast.mov
27 | [SC2]: http://macromates.com/blog/archives/2006/04/29/objective-c-part-2-screencast/
28 | [SC3]: http://macromates.com/blog/archives/2006/03/17/graceful-objective-c-snippets/
29 | [AllCasts]: http://macromates.com/screencasts
30 |
31 | # Code Completion
32 |
33 | Code Completion is activated using the ⌥⎋ key equivalent. Code completion is available in several places which will be the topic of the next few sections.
34 |
35 | ## Within Brackets
36 |
37 | A method call in Objective-C consists of three different types (though not all method calls take arguments):
38 |
39 | [«receiver» «selector»:«argument»]
40 |
41 | The completion support can help you with all three parts, which will be explained in the following three sections.
42 |
43 | ### Receiver
44 |
45 | A partially typed receiver can be completed, here candidates are all Cocoa classes (class objects). For example if we have:
46 |
47 | [NSObje‸ ]
48 |
49 | Then the list of possible completions will contain `NSObject` and `NSObjectController`.
50 |
51 | ### Selector
52 |
53 | When the receiver is a class object, like in the following example:
54 |
55 | [NSString ‸]
56 |
57 | Then the candidates are all methods implemented by that class, in the above example, that would be all `NSString` class methods.
58 |
59 | If the selector is partially typed, and the receiver is not a known class object, as is the case below:
60 |
61 | [object setV‸]
62 |
63 | Then a list is shown with all Cocoa methods starting with `setV`.
64 |
65 | Currently the list of completion candidates are only filtered to those implemented by `object`, when object is a method local variable of a type that has been indexed.
66 |
67 | One exception is when the receiver is itself a method call, for example in the following case:
68 |
69 | [[object string] ‸]
70 |
71 | Here only methods implemented by `NSString` are suggested, since it is know that the result of the `string` selector is an `NSString` object.
72 |
73 | For selectors with multiple arguments, it is possible to activate completion when entering the name of a later argument, for example:
74 |
75 | [object setObject:name forK‸]
76 |
77 | Will list all methods starting with `setObject:forK`.
78 |
79 | ### Argument
80 |
81 | When at the argument position, like here:
82 |
83 | [NSString stringWithCString:"foo" encoding:‸]
84 |
85 | The completion command will check the argument type and find all constants which match that type. In the above example that would be all string encoding constants.
86 |
87 | ## Outside of Brackets
88 |
89 | The completion command will give different suggestions based on the caret’s scope. To see the current scope you can press ⌃⇧P. The 6 different scopes are marked below:
90 |
91 | @interface MyClass : NSO‸₁ <NSObj‸₂>
92 | {
93 | NSSt‸₃
94 | }
95 | @end
96 |
97 | @implementation MyClass
98 | - (id)init
99 | {
100 | if(self = [super init])
101 | {
102 | NSArr‸₄
103 | }
104 | return self;
105 | }
106 | - windowW‸₅
107 | - (NSStr‸₆)stringFromString(NSSt‸₆<NSCod‸₂>)
108 | @end
109 |
110 | The candidates suggested for the 6 different scopes are:
111 |
112 | 1. Known Cocoa classes.
113 | 2. Known Cocoa protocols.
114 | 3. Same as 1, but a variable name will also be inserted. For example the above will suggest `NSString` and `NSStream`. If we pick the former, it will insert `NSString *aString`.
115 | 4. Same as 3, but completion of known (C, C++, and Cocoa) functions is also suggested.
116 | 5. Here completion candidates are known Cocoa methods, but inserted as when implementing the method. For example in the above, one of the suggestions is `windowWillClose`, which when selected, will have the line changed to: `- (void)windowWillClose:(NSNotification *)aNotification`.
117 | 6. Same as 1, but an asterisk (`*`) is inserted.
118 |
119 | ## Completing User Methods
120 |
121 | By default completion candidates comes from the various Apple frameworks (mostly under the Cocoa umbrella).
122 |
123 | If you wish to have your own methods and classes shown as completion candidates, you can invoke the *Index Headers for Completion* command.
124 |
125 | This scans all headers in the current project folder and saves the result as `.methods.TM_Completions.txt.gz` and `.classes.TM_Completions.txt.gz` in your project folder.
126 |
127 | You can later re-run the command to update the index.
128 |
129 | # Bracket Matching
130 |
131 | ## Wrapping Selectors
132 |
133 | When you want to send a message (selector) to an object, you need to wrap both the object and message in square brackets (`[object message]`). Even if you did not put an opening bracket at the start of the expression, there is no need to go back and place it, since TextMate is smart enough to figure out where to place the start bracket, when typing an unmatched close bracket.
134 |
135 | Here are two simple examples:
136 |
137 | obj message‸ → [obj message]
138 |
139 | obj message:arg‸ → [obj message:arg]
140 |
141 | An ambiguity exists when sending multi-argument messages to the object. For example if we have:
142 |
143 | obj message:arg otherMessage:arg2‸
144 |
145 | Then there are two candidates for the outcome:
146 |
147 | 1. [obj message:arg otherMessage:arg2]
148 | 2. obj message:[arg otherMessage:arg2]
149 |
150 | If `message:otherMessage:` is a known Cocoa method or one of your indexed methods, then the first one is picked, otherwise the second one.
151 |
152 | ## Wrapping Objects
153 |
154 | If you type a closing bracket after a single word, it is assumed that this word is an object to which you want to send a message, e.g.:
155 |
156 | obj‸ → [obj ‸]
157 |
158 | The space is only inserted if there is not already a space after the object.
159 |
160 | ## General
161 |
162 | The bracket completion is aware of quite a few C and Objective-C constructs and will not wrap when it does not make (much) sense.
163 |
164 | nil‸ → nil] // no messaging nil
165 | return self‸ → return [self ‸]
166 | NSArray arrayWithObjects:names, urls, nil‸
167 | → [NSArray arrayWithObjects:names, urls, nil]
168 |
169 | Here is how the bracket matcher (basically) works:
170 |
171 | 1. If there is a word to the left of the caret, try to find an object to the left of it.
172 | 2. If the above failed, look for a message that takes an argument. If found, try to find even more such messages compare them with known Cocoa methods as we go, if no known Cocoa methods are found we use only the first matched message. try to find an object to the left of the message.
173 | 3. If neither 1 or 2, we have a single object, wrap it and insert the caret between the brackets.
174 |
175 | # Reformatting
176 |
177 | ## Method Calls
178 |
179 | Pressing ⌃Q when the caret is inside a multi-part method call will align the method-parts around the colon (`:`). For example the following:
180 |
181 | [NSEvent enterExitEventWithType:anEventType location:aPoint
182 | modifierFlags:flags timestamp:aTimeInterval
183 | windowNumber:number context:aGraphicsContext
184 | eventNumber:x trackingNumber:tracker userData:data]
185 |
186 | Will be reformatted as:
187 |
188 | [NSEvent enterExitEventWithType:anEventType
189 | location:aPoint
190 | modifierFlags:flags
191 | timestamp:aTimeInterval
192 | windowNumber:number
193 | context:aGraphicsContext
194 | eventNumber:x
195 | trackingNumber:tracker
196 | userData:data]
197 |
198 | By default the inner brackets will be reformatted if the brackets are nested, move the caret to a non nested area to get the outer methods reformatted.
199 |
200 | ## Method Implementations
201 |
202 | Like with method calls, we can reformat method implementations using ⌃Q. If for example we implemented the method above, and our source looks like this:
203 |
204 | + (NSEvent *)enterExitEventWithType:(NSEventType)type
205 | location:(NSPoint)location modifierFlags:(unsigned int)flags
206 | timestamp:(NSTimeInterval)time windowNumber:(int)windowNumber
207 | context:(NSGraphicsContext *)context eventNumber:(int)eventNumber
208 | trackingNumber:(int)trackingNumber userData:(void *)userData
209 | {
210 |
211 | }
212 |
213 | Then we can reformat it easily using ⌃Q on the first line, and we get:
214 |
215 | + (NSEvent *)enterExitEventWithType:(NSEventType)type
216 | location:(NSPoint)location
217 | modifierFlags:(unsigned int)flags
218 | timestamp:(NSTimeInterval)time
219 | windowNumber:(int)windowNumber
220 | context:(NSGraphicsContext *)context
221 | eventNumber:(int)eventNumber
222 | trackingNumber:(int)trackingNumber
223 | userData:(void*)userData
224 | {
225 |
226 | }
227 |
228 | # Documentation Look-up
229 |
230 | Pressing ⌃H when the caret is on a class name, method call, function name, constant, or similar, will (for most known Cocoa stuff) find the appropriate spot in the documentation.
231 |
232 | There are actually two documentation look-up commands (for two different scopes), so generally use the ⌃H key equivalent rather than the menu item.
233 |
234 | # Snippets
235 |
236 | The Objective-C bundle has specialized several of the snippets for different scopes.
237 |
238 | An example is shown below:
239 |
240 | @interface MyClass : NSObject
241 | {
242 | }
243 | m‸
244 | @end
245 |
246 | @implementation MyClass
247 | m‸
248 |
249 | - (void)myMethod
250 | {
251 | log‸
252 | }
253 | @end
254 |
255 | void MyFunction ()
256 | {
257 | log‸
258 | }
259 |
260 | Here we have entered both the tab trigger `m` and `log` in two different scopes. If we press tab (⇥) to expand all four tab triggers, then the resulting code becomes:
261 |
262 | @interface MyClass : NSObject
263 | {
264 | }
265 | - (id‸)method:(id)anArgument;
266 | @end
267 |
268 | @implementation MyClass
269 | - (id‸)method:(id)anArgument
270 | {
271 | return nil;
272 | }
273 |
274 | - (void)myMethod
275 | {
276 | NSLog(@"%s‸", _cmd);
277 | }
278 | @end
279 |
280 | void MyFunction ()
281 | {
282 | NSLog(@"‸");
283 | }
284 |
285 | What’s interesting here is that the `m` tab trigger expands to a full method implementation inside `@implementation…@end`, but only a prototype when inside `@interface…@end`. Likewise the `log` tab trigger will only output the `_cmd` variable when called from inside a method (where it is available).
286 |
287 | All the accessor snippets are likewise specialized for `@implementation` and `@interface`, though only one set appears in the menu (so use the tab trigger to get the proper one).
288 |
289 | In addition to specializing the snippets for different scopes, a lot of other magic has also been put into them. If for example you add `%d` to the format string of the `NSLog` snippet, then an argument placeholder is automatically inserted. The method snippet will remove the `return nil;` line if you change the return type to `void`, and it will let the argument variable’s name match its type, for example if you change the type from `id` to `NSString*` then the variable becomes `aString`.
290 |
291 | # Credits
292 |
293 | The cool stuff in this bundle is done by Joachim Mårtensson.
294 |
295 | Additional work by Chris Thomas and Allan Odgaard. The initial bracket matcher (which served us well for a long time) was done by Rob Rix.
296 |
297 | MARKDOWN
298 | html_footer
299 | input
300 | none
301 | name
302 | Help
303 | output
304 | showAsHTML
305 | scope
306 | source.objc, source.objc++
307 | uuid
308 | AFB40870-6F83-4211-9362-0538287B52A9
309 |
310 |
311 |
--------------------------------------------------------------------------------
/Commands/Insert Call to Super.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | beforeRunningCommand
6 | nop
7 | command
8 | #!/usr/bin/env ruby18
9 |
10 | # Inserts a [super method] call suitable for the current method.
11 | #
12 | # The command is inserted as a snippet with each parameter as a tabstop
13 | # An opening bracket is inserted if necessary, and a semicolon is
14 | # added after the closing bracket if there is nothing else on the line.
15 | #
16 | # The command uses heuristics to find which method implementation is
17 | # being edited. It should be reasonably tolerant to various coding styles,
18 | # including different bracket and indentation styles.
19 |
20 | proto_re = /
21 | ^\s* # Start of the line and optional space
22 | [+-]\s* # a plus or minus for method specifier
23 | \([^)]+\) # the return type in brackets
24 | (?!.*;) # Assert implementation and not interface
25 | ((?:\n|[^{])*)
26 | (?m:.*?)
27 | \{
28 | /x
29 |
30 | previous_lines = STDIN.readlines[1..ENV['TM_LINE_NUMBER'].to_i - 1]
31 | invocation_line = previous_lines[-1]
32 | proto = previous_lines.join.scan(proto_re)[-1]
33 |
34 | exit if proto.nil? or proto.empty?
35 |
36 | last_proto_sel_with_types = proto[0].strip.sub(/^\s+/, '').sub(%r{\s*//.*$}, '').gsub(/\n\s*/, ' ')
37 |
38 | tabstop = 0
39 |
40 | last_proto_sel_with_types.gsub!(/\([^)]+\)\s*(([A-Za-z0-9_][A-Za-z0-9_]*))/) do |match|
41 | %Q{${#{tabstop += 1}:#$1}}
42 | end
43 |
44 | print '[' if invocation_line[ENV["TM_LINE_INDEX"].to_i - 1] != ?[
45 | print 'super '
46 | print last_proto_sel_with_types
47 | print "]"
48 | print ";" if invocation_line =~ /^\s+$/
49 |
50 | fallbackInput
51 | scope
52 | input
53 | document
54 | name
55 | Insert Call to Super
56 | output
57 | insertAsSnippet
58 | scope
59 | source.objc meta.scope.implementation, source.objc++ meta.scope.implementation
60 | tabTrigger
61 | super
62 | uuid
63 | DA9B35AF-938D-4166-8576-E8E3C73F0739
64 |
65 |
66 |
--------------------------------------------------------------------------------
/Commands/Insert Matching Start Bracket.tmCommand:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | beforeRunningCommand
6 | nop
7 | bundleUUID
8 | 4679484F-6227-11D9-BFB1-000D93589AF6
9 | command
10 | #!/usr/bin/env ruby18
11 | require "#{ENV['TM_SUPPORT_PATH']}/lib/escape"
12 | require ENV['TM_SUPPORT_PATH'] + "/lib/exit_codes"
13 |
14 | class Lexer
15 | include Enumerable
16 | def initialize
17 | @label = nil
18 | @pattern = nil
19 | @handler = nil
20 | @input = nil
21 |
22 | reset
23 |
24 | yield self if block_given?
25 | end
26 |
27 | def input(&reader)
28 | if @input.is_a? self.class
29 | @input.input(&reader)
30 | else
31 | class << reader
32 | alias_method :next, :call
33 | end
34 |
35 | @input = reader
36 | end
37 | end
38 |
39 | def add_token(label, pattern, &handler)
40 | unless @label.nil?
41 | @input = clone
42 | end
43 |
44 | @label = label
45 | @pattern = /(#{pattern})/
46 | @handler = handler || lambda { |label, match| [label, match] }
47 |
48 | reset
49 | end
50 |
51 | def next(peek = false)
52 | while @tokens.empty? and not @finished
53 | new_input = @input.next
54 | if new_input.nil? or new_input.is_a? String
55 | @buffer += new_input unless new_input.nil?
56 | new_tokens = @buffer.split(@pattern)
57 | while new_tokens.size > 2 or (new_input.nil? and not new_tokens.empty?)
58 | @tokens << new_tokens.shift
59 | @tokens << @handler[@label, new_tokens.shift] unless new_tokens.empty?
60 | end
61 | @buffer = new_tokens.join
62 | @finished = true if new_input.nil?
63 | else
64 | separator, new_token = @buffer.split(@pattern)
65 | new_token = @handler[@label, new_token] unless new_token.nil?
66 | @tokens.push( *[ separator,
67 | new_token,
68 | new_input ].select { |t| not t.nil? and t != "" } )
69 | reset(:buffer)
70 | end
71 | end
72 | peek ? @tokens.first : @tokens.shift
73 | end
74 |
75 | def peek
76 | self.next(true)
77 | end
78 |
79 | def each
80 | while token = self.next
81 | yield token
82 | end
83 | end
84 |
85 | private
86 |
87 | def reset(*attrs)
88 | @buffer = String.new if attrs.empty? or attrs.include? :buffer
89 | @tokens = Array.new if attrs.empty? or attrs.include? :tokens
90 | @finished = false if attrs.empty? or attrs.include? :finished
91 | end
92 | end
93 |
94 |
95 | class ObjcParser
96 |
97 | attr_reader :list
98 | def initialize(args)
99 | @list = args
100 | end
101 |
102 | def get_position
103 | return nil,nil if @list.empty?
104 | has_message = true
105 |
106 | a = @list.pop
107 | endings = [:close,:post_op,:at_string,:at_selector,:identifier]
108 | openings = [:open,:return,:control]
109 | if a.tt == :identifier && !@list.empty? && endings.include?(@list[-1].tt)
110 | insert_point = find_object_start
111 | else
112 | @list << a
113 | has_message = false unless methodList
114 | insert_point = find_object_start
115 | end
116 | return insert_point, has_message
117 | end
118 |
119 | def methodList
120 | old = Array.new(@list)
121 |
122 | a = selector_loop(@list)
123 | if !a.nil? && a.tt == :selector
124 | if file_contains_selector? a.text
125 | return true
126 | else
127 | internal = Array.new(@list)
128 | b = a.text
129 | until internal.empty?
130 | tmp = selector_loop(internal)
131 | return true if tmp.nil?
132 | b = tmp.text + b
133 | if file_contains_selector? b
134 | @list = internal
135 | return true
136 | end
137 | end
138 | end
139 | else
140 | end
141 | @list = old
142 | return false
143 | end
144 |
145 | def file_contains_selector?(methodName)
146 | fileNames = ["#{ENV['TM_BUNDLE_SUPPORT']}/CocoaMethods.txt.gz"]
147 | userMethods = "#{ENV['TM_PROJECT_DIRECTORY']}/.methods.TM_Completions.txt.gz"
148 |
149 | fileNames += [userMethods] if File.exists? userMethods
150 | candidates = []
151 | fileNames.each do |fileName|
152 | zGrepped = %x{zgrep ^#{e_sh methodName }[[:space:]] #{e_sh fileName }}
153 | candidates += zGrepped.split("\n")
154 | end
155 |
156 | return !candidates.empty?
157 | end
158 |
159 | def selector_loop(l)
160 | until l.empty?
161 | obj = l.pop
162 | case obj.tt
163 | when :selector
164 | return obj
165 | when :close
166 | return nil if match_bracket(obj.text,l).nil?
167 | when :open
168 | return nil
169 | end
170 | end
171 | return nil
172 | end
173 |
174 | def match_bracket(type,l)
175 | partner = {"]"=>"[",")"=>"(","}"=>"{"}[type]
176 | up = 1
177 | until l.empty?
178 | obj = l.pop
179 | case obj.text
180 | when type
181 | up +=1
182 | when partner
183 | up -=1
184 | end
185 | return obj.beg if up == 0
186 | end
187 | end
188 |
189 | def find_object_start
190 | openings = [:operator,:selector,:open,:return,:control]
191 | until @list.empty? || openings.include?(@list[-1].tt)
192 | obj = @list.pop
193 | case obj.tt
194 | when :close
195 | tmp = match_bracket(obj.text, @list)
196 | b = tmp unless tmp.nil?
197 | when :star
198 | b, ate = eat_star(b,obj.beg)
199 | return b unless ate
200 | when :nil
201 | b = nil
202 | else
203 | b = obj.beg
204 | end
205 | end
206 | return b
207 | end
208 |
209 | def eat_star(prev, curr)
210 | openings = [:operator,:selector,:open,:return,:control,:star]
211 | if @list.empty? || openings.include?(@list[-1].tt)
212 | return curr, true
213 | else
214 | return prev, false
215 | end
216 | end
217 | end
218 |
219 | if __FILE__ == $PROGRAM_NAME
220 | require "stringio"
221 | line = ENV['TM_CURRENT_LINE']
222 | caret_placement =ENV['TM_LINE_INDEX'].to_i - 1
223 |
224 | up = 0
225 | pat = /"(?:\\.|[^"\\])*"|\[|\]/
226 | line.scan(pat).each do |item|
227 | case item
228 | when "["
229 | up+=1
230 | when "]"
231 | up -=1
232 | end
233 | end
234 | if caret_placement ==-1
235 | print "]$0" + e_sn(line[caret_placement+1..-1])
236 | TextMate.exit_insert_snippet
237 | end
238 |
239 | if up != 0
240 | print e_sn(line[0..caret_placement])+"]$0"+e_sn(line[caret_placement+1..-1])
241 | TextMate.exit_insert_snippet
242 | end
243 |
244 | to_parse = StringIO.new(line[0..caret_placement])
245 | lexer = Lexer.new do |l|
246 | l.add_token(:return, /\breturn\b/)
247 | l.add_token(:nil, /\bnil\b/)
248 | l.add_token(:control, /\b(?:if|while|for|do)(?:\s*)\(/)# /\bif|while|for|do(?:\s*)\(/)
249 | l.add_token(:at_string, /"(?:\\.|[^"\\])*"/)
250 | l.add_token(:selector, /\b[A-Za-z_0-9]+:/)
251 | l.add_token(:identifier, /\b[A-Za-z_0-9]+\b/)
252 | l.add_token(:bind, /(?:->)|\./)
253 | l.add_token(:post_op, /\+\+|\-\-/)
254 | l.add_token(:at, /@/)
255 | l.add_token(:star, /\*/)
256 | l.add_token(:close, /\)|\]|\}/)
257 | l.add_token(:open, /\(|\[|\{/)
258 | l.add_token(:operator, /[&-+\/=%!:\,\?;<>\|\~\^]/)
259 |
260 | l.add_token(:terminator, /;\n*|\n+/)
261 | l.add_token(:whitespace, /\s+/)
262 | l.add_token(:unknown, /./)
263 |
264 | l.input { to_parse.gets }
265 | #l.input {STDIN.read}
266 | end
267 |
268 | offset = 0
269 | tokenList = []
270 | A = Struct.new(:tt, :text, :beg)
271 |
272 | lexer.each do |token|
273 | tokenList << A.new(*(token<<offset)) unless [:whitespace,:terminator].include? token[0]
274 | offset +=token[1].length
275 | end
276 | if tokenList.empty?
277 | print e_sn(line[0..caret_placement])+"]$0"+e_sn(line[caret_placement+1..-1])
278 | TextMate.exit_insert_snippet
279 | end
280 |
281 | par = ObjcParser.new(tokenList)
282 | b, has_message = par.get_position
283 |
284 | if !line[caret_placement+1].nil? && line[caret_placement+1].chr == "]"
285 | if b.nil? || par.list.empty? || par.list[-1].text == "["
286 | print e_sn(line[0..caret_placement])+"]$0"+e_sn(line[caret_placement+2..-1])
287 | TextMate.exit_insert_snippet
288 | end
289 | end
290 |
291 | if b.nil?
292 | print e_sn(line[0..caret_placement])+"]$0"+e_sn(line[caret_placement+1..-1])
293 | elsif !has_message && (b < caret_placement )
294 | print e_sn(line[0..b-1]) unless b == 0
295 | ins = (/\s/ =~ line[caret_placement].chr ? "$0]" : " $0]")
296 | print "[" +e_sn(line[b..caret_placement]) + ins +e_sn(line[caret_placement+1..-1])
297 | elsif b < caret_placement
298 | print e_sn(line[0..b-1]) unless b == 0
299 | print "[" +e_sn(line[b..caret_placement]) +"]$0"+e_sn(line[caret_placement+1..-1])
300 | else
301 | print e_sn(line[0..caret_placement])+"]$0"+e_sn(line[caret_placement+1..-1])
302 | end
303 | end
304 |
305 | fallbackInput
306 | line
307 | input
308 | selection
309 | keyEquivalent
310 | ]
311 | name
312 | Insert Matching Start Bracket
313 | output
314 | insertAsSnippet
315 | scope
316 | (source.objc | source.objc++) - (string | comment | dyn.selection | dyn.caret.mixed)
317 | uuid
318 | DB16585F-4D78-412B-B468-38AD54C254B5
319 |
320 |
321 |
--------------------------------------------------------------------------------
/Commands/Insert NSLog() for current method.tmCommand:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | beforeRunningCommand
6 | nop
7 | command
8 | #!/usr/bin/env ruby18
9 |
10 | proto_re = /
11 | ^\s* # Start of the line and optional space
12 | [+-]\s* # a plus or minus for method specifier
13 | \([^)]+\) # the return type in brackets
14 | ((?:\n|[^@{])*)
15 | (?m:[\s;]*)
16 | \{
17 | /x
18 |
19 | previous_lines = STDIN.readlines[1..ENV['TM_LINE_NUMBER'].to_i - 1]
20 | invocation_line = previous_lines[-1]
21 |
22 | proto = previous_lines.join.scan(proto_re)[-1]
23 |
24 | exit if proto.nil? or proto.empty?
25 |
26 | last_proto_sel_with_types = proto[0].strip.sub(/^\s+/, '').sub(%r{\s*//.*$}, '').gsub(/\n\s*/, ' ')
27 |
28 | params = []
29 | params = last_proto_sel_with_types.scan(/(.+?)\s*:\s*\((.+?)\)\s*(\w+)/)
30 |
31 | def format_specifier_for_type(type)
32 | case type.gsub(/\s*const\s*/, '')
33 | when /\b(int|bool|BOOL)\b/ then '%d'
34 | when /\b(NSInteger|long)\b/ then '%ld'
35 | when /\b(NSUInteger)\b/ then '%lu'
36 | when /\b(size_t)\b/ then '%zu'
37 | when /\b(ssize_t)\b/ then '%zd'
38 | when /\b(float|double|CGFloat)\b/ then '%f'
39 | when /\b(char\*|string\b)/ then '%s'
40 | when /\b(char)\b/ then '%c'
41 | when /\b(unichar)\b/ then '%C'
42 | else '%@'
43 | end
44 | end
45 |
46 | def transformer_for(type, name)
47 | case type
48 | when 'NSRect': "NSStringFromRect(#{name})"
49 | when 'NSRange': "NSStringFromRange(#{name})"
50 | when 'NSPoint': "NSStringFromPoint(#{name})"
51 | when 'NSSize': "NSStringFromSize(#{name})"
52 | when 'SEL': "NSStringFromSelector(#{name})"
53 | when /string/: "#{name}.c_str()"
54 | else name
55 | end
56 | end
57 |
58 | print 'NSLog(@"[%@ '
59 | if params.empty?
60 | print last_proto_sel_with_types
61 | else
62 | print params.map { |param, type, name| param + ':' + format_specifier_for_type(type) }.join
63 | end
64 | print ']", [self class]'
65 | print ', ' + params.map { |param, type, name| transformer_for(type, name) }.join(', ') unless params.empty?
66 | print ");"
67 |
68 | input
69 | document
70 | name
71 | Insert NSLog() for Current Method
72 | output
73 | insertAsSnippet
74 | scope
75 | source.objc meta.scope.implementation, source.objc++ meta.scope.implementation
76 | tabTrigger
77 | logm
78 | uuid
79 | C5624A26-E661-46EE-AA6A-14E6B678CFF9
80 |
81 |
82 |
--------------------------------------------------------------------------------
/Commands/Lookup Cocoa Class.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | beforeRunningCommand
6 | nop
7 | command
8 | #!/usr/bin/env ruby18 -wKU
9 | require "#{ENV['TM_BUNDLE_SUPPORT']}/lib/docset_query.rb"
10 |
11 | documentation_for_word
12 |
13 | fallbackInput
14 | word
15 | input
16 | none
17 | inputFormat
18 | text
19 | keyEquivalent
20 | ^h
21 | name
22 | Documentation for Word / Selection
23 | outputCaret
24 | afterOutput
25 | outputFormat
26 | text
27 | outputLocation
28 | toolTip
29 | scope
30 | source.c, source.c++, source.objc, source.objc++, (source.objc support | source.objc++ support) - support.function.any-method
31 | semanticClass
32 | lookup.define.objc
33 | uuid
34 | 2E0F350A-7B23-11D9-B084-000D93589AF6
35 | version
36 | 2
37 |
38 |
39 |
--------------------------------------------------------------------------------
/Commands/Paste Implementation : Interface.tmCommand:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | beforeRunningCommand
6 | nop
7 | command
8 | #!/usr/bin/env ruby18 -wKU
9 | #
10 | # Possible improvements:
11 | # • Preserve empty lines between methods taken from the clipboard
12 | # • Make the “parser” conform to the actual Objective-C spec
13 | #
14 | require ENV['TM_SUPPORT_PATH'] + '/lib/exit_codes'
15 |
16 | methods = []
17 |
18 | %x{ pbpaste }.scan(/^
19 | \s*
20 | ([-+]) # Class or object method
21 | (\s* \( ([^\)]+) \))? # Optional return type
22 | (\s* [a-z0-9_]+) # Method name
23 |
24 | # Zero or more parameters:
25 |
26 | ( (\s* [a-z0-9_]*) # Optional name of parameter
27 | : # Mandatory colon
28 | (\s* \( [^\)]+ \))? # Optional type of parameter
29 | (\s* [a-z0-9_]+) # Parameter name (might be optional)
30 | (\s* , \s* ...)? # Optional var-args notation
31 | )*
32 |
33 | (?=\s* ;?) # Optional semicolon
34 |
35 | /ix) do
36 | rettype = $3.to_s.strip
37 | methods << [$&.strip.gsub(' *)', (ENV['TM_C_POINTER'] || ' *').rstrip + ')'), rettype]
38 | end
39 |
40 | TextMate::exit_show_tool_tip('No methods found on the clipboard') if methods.empty?
41 |
42 | if ENV['TM_SCOPE'] !~ /meta.implementation.objc/
43 | methods.each { |(proto, rettype)| puts "#{proto};" }
44 | else
45 | tabstop = 0
46 | puts(methods.map do |(proto, rettype)|
47 | ret = case rettype
48 | when "void", "IBAction"
49 | ""
50 | when "BOOL"
51 | "\treturn ${#{tabstop+=1}:Y}${1/^(?:(Y)|(N)|.*)/(?1:ES:(?2:O))/};\n"
52 | else
53 | "\treturn ${#{tabstop+=1}:nil};\n"
54 | end
55 | "#{proto}\n{\n#{ret}}\n"
56 | end.join("\n"))
57 | end
58 |
59 | fallbackInput
60 | line
61 | input
62 | none
63 | keyEquivalent
64 | ^V
65 | name
66 | Paste Implementation / Interface
67 | output
68 | insertAsSnippet
69 | scope
70 | meta.interface-or-protocol.objc, meta.implementation.objc
71 | uuid
72 | CB5EC7EC-35B7-4FD8-9045-31CCC379D474
73 |
74 |
75 |
--------------------------------------------------------------------------------
/Commands/Paste selector.tmCommand:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | beforeRunningCommand
6 | nop
7 | command
8 | pbpaste|head -n1|perl -pe's/:\(.+?\)\w+\s*/:/g'|perl -pe's/^[-+]\s*\(.+?\)\s*|\s+|;//g'
9 | input
10 | none
11 | keyEquivalent
12 | ^V
13 | name
14 | Paste Selector
15 | output
16 | afterSelectedText
17 | scope
18 | meta.selector.objc
19 | uuid
20 | D9CA98D1-7564-4CCB-8156-9A06210A1A7F
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Commands/Reflow Method Call.tmCommand:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | beforeRunningCommand
6 | nop
7 | bundleUUID
8 | 4679484F-6227-11D9-BFB1-000D93589AF6
9 | command
10 | #!/usr/bin/env ruby18
11 | require "#{ENV['TM_SUPPORT_PATH']}/lib/escape"
12 |
13 | line = STDIN.read
14 | offset = ENV['TM_INPUT_START_COLUMN'].to_i - 1
15 | caret_placement = 0
16 | tmp = ENV['TM_LINE_NUMBER'].to_i - ENV['TM_INPUT_START_LINE'].to_i
17 | if tmp > 0
18 | class String
19 | def index_of_nth_occurrence_of(n, ch)
20 | self.unpack("U*").each_with_index do |e, i|
21 | return i if e == ch && (n -= 1) == 0
22 | end
23 | return -1
24 | end
25 | end
26 | caret_placement += line.index_of_nth_occurrence_of(tmp,?\n) + ENV['TM_LINE_INDEX'].to_i
27 | else
28 | caret_placement =ENV['TM_LINE_INDEX'].to_i-ENV['TM_INPUT_START_LINE_INDEX'].to_i - 1
29 | end
30 |
31 | def match_iter(rgxp,str)
32 | offset = 0
33 | while m = str.match(rgxp)
34 | yield [m[0], m.begin(0) + offset, m[0].length]
35 | str = m.post_match
36 | offset += m.end(0)
37 | end
38 | end
39 |
40 | pat = /("(\\.|[^"\\])*"|\[|\]|@selector\([^\)]*\)|[a-zA-Z][a-zA-Z0-9]*:)/
41 | up = 0
42 | list = []
43 |
44 | up = 0
45 | pat = /("(\\.|[^"\\])*"|\[|\]|@selector\([^\)]*\)|[a-zA-Z][a-zA-Z0-9]*:)/
46 | start = [0]
47 | match_iter(pat , line[0..caret_placement]) do |tok, beg, len|
48 | t = tok[0].chr
49 | if t == "["
50 | start << beg
51 | elsif t == "]"
52 | start.pop
53 | end
54 | end
55 |
56 |
57 | up = 0
58 | last = line.length
59 | match_iter(pat , line[caret_placement+1..line.length]) do |tok, beg, len|
60 | t = tok[0].chr
61 | if t == "["
62 | up +=1
63 | elsif t == "]"
64 | if up == 0
65 | last = beg + caret_placement + 1
66 | break
67 | end
68 | up -=1
69 | end
70 | end
71 |
72 | list = []
73 | prefix = ""
74 | prefix = line[0..start[-1]-1] unless start[-1] == 0
75 | suffix = line[last+1..-1]
76 | l = line[start[-1]..last]
77 | up = -1
78 |
79 | match_iter(pat , l) do |tok, beg, len|
80 | t = tok[0].chr
81 | if t == "["
82 | up +=1
83 | elsif t == "]"
84 | up -=1
85 | elsif t !='"' and t !='@' and up == 0
86 | list << [beg,len]
87 | end
88 | end
89 |
90 | list << [l.length,0]
91 | offset += start[-1]
92 | if list.length > 2
93 | print e_sn(prefix+ l[0...list[1][0]].strip)
94 | #check to if the first "selector:" is not in the first line
95 | if k = line[0...start[-1]+list[0][0]].rindex("\n")
96 | firstIndex = list[0][0]+list[0][1]- k -1
97 | offset = start[-1]
98 | else
99 | firstIndex = list[0][0] + list[0][1]
100 | end
101 | (1..(list.length() -2)).each do |ind|
102 | list[ind][1]+list[ind][0]
103 | b = (b = firstIndex-list[ind][1]+offset) > 0 ? b : 0
104 | print e_sn("\n" + " "*b + l[(list[ind][0])...(list[ind+1][0])].strip)
105 | end
106 | print e_sn(suffix) unless suffix.nil?
107 | else
108 | print e_sn(line)
109 | end
110 |
111 | fallbackInput
112 | scope
113 | input
114 | selection
115 | keyEquivalent
116 | ^q
117 | name
118 | Reformat Method Call
119 | output
120 | replaceSelectedText
121 | scope
122 | meta.bracketed.objc
123 | uuid
124 | 8957C99F-88F5-42CC-B355-AAC6BF3FDF8D
125 |
126 |
127 |
--------------------------------------------------------------------------------
/Commands/Toggle Import : Include Keyword.tmCommand:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | beforeRunningCommand
6 | nop
7 | command
8 | #!/usr/bin/env ruby18 -wKU
9 |
10 | def toggle(keyword)
11 | case keyword
12 | when 'import' then 'include'
13 | when 'include' then 'import'
14 | else keyword
15 | end
16 | end
17 |
18 | STDOUT << toggle(STDIN.read)
19 |
20 | hideFromUser
21 |
22 | input
23 | scope
24 | inputFormat
25 | text
26 | keyEquivalent
27 | ^"
28 | name
29 | Toggle Import/Include Keyword
30 | outputCaret
31 | interpolateByChar
32 | outputFormat
33 | text
34 | outputLocation
35 | replaceInput
36 | scope
37 | keyword.control.import.include, L:keyword.control.import.include
38 | uuid
39 | A8F23393-4D73-480A-A268-6DCD514DE2E4
40 | version
41 | 2
42 |
43 |
44 |
--------------------------------------------------------------------------------
/Commands/Wrap in [[alloc] init] (alloc).plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | beforeRunningCommand
6 | nop
7 | command
8 | #!/usr/bin/env ruby18
9 |
10 | def e (str); str.gsub(/[$`\\]/, '\\\\\0'); end
11 |
12 | line = STDIN.read
13 | col = ENV['TM_LINE_INDEX'].to_i
14 |
15 | left, right = line[0...col], line[col..-1]
16 |
17 | if left =~ /(.*?)(\[)?(\w+)\s+$/ then
18 | lead, bracket, cl = $1, $2, $3
19 | right = line[col+1..-1] unless bracket.nil?
20 | if ENV.has_key?('TM_OBJC_MRR')
21 | print "#{e lead}${1/.+/[/}[[#{e cl} alloc] init$2]${1: autorelease]}"
22 | else
23 | print "#{e lead}[[#{e cl} alloc] init$1]"
24 | end
25 | print right.empty? ? ";" : "#{e right}"
26 | else
27 | # this is only if we were not able to interpret the line
28 | print "#{e left}$0#{e right}"
29 | end
30 |
31 | fallbackInput
32 | line
33 | input
34 | selection
35 | name
36 | Insert [[… alloc] init]
37 | output
38 | insertAsSnippet
39 | scope
40 | source.objc, source.objc++
41 | tabTrigger
42 | alloc
43 | uuid
44 | EA820F17-FD1D-4E7A-9961-E75F7D360968
45 |
46 |
47 |
--------------------------------------------------------------------------------
/Preferences/Cocoa completions.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | name
6 | Completions: Cocoa
7 | scope
8 | source.objc, source.objc++
9 | settings
10 |
11 | completions
12 |
13 | retain
14 | release
15 | autorelease
16 | description
17 | stringWithFormat:
18 | componentsSeparatedByString:
19 | componentsJoinedByString:
20 | isEqualToString:
21 | UTF8String
22 | lastPathComponent
23 | pathExtension
24 | stringByAbbreviatingWithTildeInPath
25 | stringByAppendingPathComponent:
26 | stringByAppendingPathExtension:
27 | stringByDeletingLastPathComponent
28 | stringByDeletingPathExtension
29 | stringByExpandingTildeInPath
30 | stringByResolvingSymlinksInPath
31 | stringByStandardizingPath
32 | valueForKey:
33 | valueForKeyPath:
34 | setValue:
35 | forKey:
36 | forKeyPath:
37 | NSArray
38 | NSDictionary
39 | NSMutableArray
40 | NSMutableDictionary
41 | NSMutableString
42 | NSString
43 |
44 |
45 | uuid
46 | 512175CE-933E-4312-BBF2-D744700CB4CA
47 |
48 |
49 |
--------------------------------------------------------------------------------
/Preferences/Folding.tmPreferences:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | name
6 | Folding
7 | scope
8 | source.objc++, source.objc
9 | settings
10 |
11 | foldingStartMarker
12 | (?x)
13 | /\*\*(?!\*)
14 | |^(?![^{]*?//|[^{]*?/\*(?!.*?\*/.*?\{)).*?\{\s*($|//|/\*(?!.*?\*/.*\S))
15 | |^@(interface|protocol|implementation)\b (?!.*;)
16 |
17 | foldingStopMarker
18 | (?<!\*)\*\*/|^\s*\}|^@end\b
19 |
20 | uuid
21 | 1366A19B-083A-4DB1-BD93-3FD9104B5028
22 |
23 |
24 |
--------------------------------------------------------------------------------
/Preferences/Highlight Pairs: Protocol Specifiers.tmPreferences:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | name
6 | Highlight Pairs: Protocol Specifiers
7 | scope
8 | meta.protocol-list.objc | meta.inherited-protocol.end.objc | meta.return-type.objc | meta.argument-type.objc
9 | settings
10 |
11 | highlightPairs
12 |
13 |
14 | <
15 | >
16 |
17 |
18 | (
19 | )
20 |
21 |
22 |
23 | uuid
24 | 0D675D9D-B93C-400D-B8D6-C9888F7FAAE4
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Preferences/Symbol List.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | name
6 | Symbol List: Method
7 | scope
8 | meta.function.objc
9 | settings
10 |
11 | showInSymbolList
12 | 1
13 | symbolTransformation
14 |
15 | s/^([-+])\s*\(.*?\)\s*/ $1 /; # strip result type
16 | s/:\s*\(.*?\)\s*\w+\s*/:/g; # strip argument variables
17 | s/\s*;?$//g; # strip terminating ws + semi-colon
18 |
19 |
20 | uuid
21 | ADFCD53A-3CC4-4C31-88C4-BB607684951A
22 |
23 |
24 |
--------------------------------------------------------------------------------
/Preferences/Typing Pairs: Protocol Specifier.tmPreferences:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | name
6 | Typing Pairs: Protocol Specifier
7 | scope
8 | (meta.interface-or-protocol.objc | meta.return-type.objc | meta.argument-type.objc) - meta.protocol-list.objc
9 | settings
10 |
11 | smartTypingPairs
12 |
13 |
14 | <
15 | >
16 |
17 |
18 | (
19 | )
20 |
21 |
22 |
23 | uuid
24 | C41409C1-97FD-4326-A8E9-7BF89ED6BEAF
25 |
26 |
27 |
--------------------------------------------------------------------------------
/README.mdown:
--------------------------------------------------------------------------------
1 | # Installation
2 |
3 | You can install this bundle in TextMate by opening the preferences and going to the bundles tab. After installation it will be automatically updated for you.
4 |
5 | # General
6 |
7 | * [Bundle Styleguide](http://kb.textmate.org/bundle_styleguide) — _before you make changes_
8 | * [Commit Styleguide](http://kb.textmate.org/commit_styleguide) — _before you send a pull request_
9 | * [Writing Bug Reports](http://kb.textmate.org/writing_bug_reports) — _before you report an issue_
10 |
11 | # License
12 |
13 | If not otherwise specified (see below), files in this repository fall under the following license:
14 |
15 | Permission to copy, use, modify, sell and distribute this
16 | software is granted. This software is provided "as is" without
17 | express or implied warranty, and with no claim as to its
18 | suitability for any purpose.
19 |
20 | An exception is made for files in readable text which contain their own license information, or files where an accompanying file exists (in the same directory) with a “-license” suffix added to the base-name name of the original file, and an extension of txt, html, or similar. For example “tidy” is accompanied by “tidy-license.txt”.
--------------------------------------------------------------------------------
/Snippets/#import "" (imp).plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | #import "${1:${TM_FILENAME/\...*$/.h/}}"
7 | name
8 | #import "…"
9 | scope
10 | source.objc, source.objc++
11 | tabTrigger
12 | imp
13 | uuid
14 | 1E3A92DA-7299-11D9-813A-000D93589AF6
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Snippets/#import <> (Imp).plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | #import <${1:Cocoa/Cocoa.h}>
7 | name
8 | #import <…>
9 | scope
10 | source.objc, source.objc++
11 | tabTrigger
12 | Imp
13 | uuid
14 | 20241464-7299-11D9-813A-000D93589AF6
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Snippets/020 Class (objc).plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | @interface ${1:${TM_FILENAME/\...*$|(^$)/(?1:object)/}} : ${2:NSObject}
7 | {
8 | }
9 | @end
10 |
11 | @implementation $1
12 | - (instancetype)init
13 | {
14 | if(self = [super init])
15 | {$0
16 | }
17 | return self;
18 | }
19 | @end
20 | name
21 | Class
22 | scope
23 | source.objc, source.objc++ - meta.scope.implementation.objc
24 | tabTrigger
25 | cl
26 | uuid
27 | BC8B9C24-5F16-11D9-B9C3-000D93589AF6
28 |
29 |
30 |
--------------------------------------------------------------------------------
/Snippets/030 NSArray (array).plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | NSMutableArray${TM_C_POINTER: *}${1:array} = [NSMutableArray array];
7 | name
8 | NSArray
9 | scope
10 | source.objc, source.objc++
11 | tabTrigger
12 | array
13 | uuid
14 | BC8B9CAD-5F16-11D9-B9C3-000D93589AF6
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Snippets/040 NSDictionary (dict).plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | NSMutableDictionary${TM_C_POINTER: *}${1:dict} = [NSMutableDictionary dictionary];
7 | name
8 | NSDictionary
9 | scope
10 | source.objc, source.objc++
11 | tabTrigger
12 | dict
13 | uuid
14 | BC8B9D3A-5F16-11D9-B9C3-000D93589AF6
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Snippets/050 Method (m).plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | - (${1:id})${2:${TM_SELECTED_TEXT:method}}${3::(${4:id})${5:${4/(NS([AEIOQUY])?(\w+).*)|(.)?.*/(?1:a(?2:n$2)$3:(?4:anArgument))/}}}
7 | {$0${1/^(void|IBAction)$|(.*)/${2:+
8 | return nil;}/}
9 | }
10 | keyEquivalent
11 | ^M
12 | name
13 | Method
14 | scope
15 | (source.objc | source.objc++) & meta.scope.implementation.objc - meta.function-with-body
16 | tabTrigger
17 | m
18 | uuid
19 | BC8B9DD7-5F16-11D9-B9C3-000D93589AF6
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Snippets/060 SubMethod (sm).plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | - (${1:id})${2:method}${3::(${4:id})${5:${4/(NS([AEIOQUY])?(\w+).*)|(.)?.*/(?1:a(?2:n$2)$3:(?4:anArgument))/}}}
7 | {
8 | ${1/^(void|IBAction)$|(.*)/(?2:$2 res = )/}[super ${2:method}${5/.+/:$0/}];$0${1/^(void|IBAction)$|(.*)/(?2:
9 | return res;)/}
10 | }
11 | name
12 | Sub-method (Call Super)
13 | scope
14 | (source.objc | source.objc++) & meta.scope.implementation.objc - meta.function-with-body
15 | tabTrigger
16 | sm
17 | uuid
18 | BC8B9E72-5F16-11D9-B9C3-000D93589AF6
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Snippets/@selector.tmSnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | @selector(${1:method:})
7 | name
8 | @selector(…)
9 | scope
10 | source.objc, source.objc++
11 | tabTrigger
12 | sel
13 | uuid
14 | 7829F2EC-B8BA-11D9-AE51-000393A143CC
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Snippets/Category (cat).plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | @interface ${1:${TM_FILENAME/.*?(\w+).*|.*/(?1:$1:NSObject)/}} (${2:${TM_FILENAME/.*?\w+\W+(\w+).*\..+|.*/(?1:$1:Category)/}})
7 | @end
8 |
9 | @implementation $1 ($2)
10 | $0
11 | @end
12 | name
13 | Category
14 | scope
15 | source.objc, source.objc++
16 | tabTrigger
17 | cat
18 | uuid
19 | 27AC6270-9900-11D9-9BB8-000A95A89C98
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Snippets/Category Implementation.tmSnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | @implementation ${1:${TM_FILENAME/.*?(\w+).*|.*/(?1:$1:NSObject)/}} (${2:${TM_FILENAME/.*?\w+\W+(\w+).*\..+|.*/(?1:$1:Category)/}})
7 | $0
8 | @end
9 | name
10 | Category Implementation
11 | scope
12 | source.objc, source.objc++
13 | tabTrigger
14 | catm
15 | uuid
16 | 3E270C37-E7E2-4D1D-B28F-CEDD8DE0041C
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Snippets/Category Interface Only (cati).plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | @interface ${1:${TM_FILENAME/.*?(\w+).*|.*/(?1:$1:NSObject)/}} (${2:${TM_FILENAME/.*?\w+\W+(\w+).*\..+|.*/(?1:$1:Category)/}})
7 | $0
8 | @end
9 | name
10 | Category Interface
11 | scope
12 | source.objc, source.objc++
13 | tabTrigger
14 | cath
15 | uuid
16 | 596B13EC-9900-11D9-9BB8-000A95A89C98
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Snippets/Class Implementation.tmSnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | @implementation ${1:${TM_FILENAME/\...*$|(^$)/(?1:object)/}}
7 | - (instancetype)init
8 | {
9 | if(self = [super init])
10 | {$0
11 | }
12 | return self;
13 | }
14 | @end
15 | name
16 | Class Implementation
17 | scope
18 | source.objc, source.objc++
19 | tabTrigger
20 | clm
21 | uuid
22 | BE0B2832-D88E-40BF-93EE-281DDA93840B
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Snippets/Class Interface Only (classi).plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | @interface ${1:${TM_FILENAME/\...*$|(^$)/(?1:object)/}} : ${2:NSObject}
7 | {$3
8 | }
9 | $0
10 | @end
11 | name
12 | Class Interface
13 | scope
14 | source.objc, source.objc++
15 | tabTrigger
16 | clh
17 | uuid
18 | 06F15373-9900-11D9-9BB8-000A95A89C98
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Snippets/Class Method (M).plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | + (${1:id})${2:method}${3::(${4:id})${5:${4/(NS([AEIOQUY])?(\w+).*)|(.)?.*/(?1:a(?2:n$2)$3:(?4:anArgument))/}}}
7 | {$0${1/^(void|IBAction)$|(.*)/(?2:
8 | return nil;)/}
9 | }
10 | name
11 | Class Method
12 | scope
13 | (source.objc | source.objc++) & meta.scope.implementation.objc - meta.function-with-body
14 | tabTrigger
15 | M
16 | uuid
17 | 1251B9E2-6BF0-11D9-8384-000D93589AF6
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Snippets/Class Method Interface (M).plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | + (${1:id})${0:method};
7 | name
8 | Interface: Class Method
9 | scope
10 | source.objc meta.scope.interface, source.objc++ meta.scope.interface
11 | tabTrigger
12 | M
13 | uuid
14 | 9D01148D-1073-40D2-936E-FFF67580D2B3
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Snippets/CoreData Accessors Implementation.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | - (${1:id})${2:attribute}
7 | {
8 | [self willAccessValueForKey:@"${2: attribute}"];
9 | ${1:id} value = [self primitiveValueForKey:@"${2: attribute}"];
10 | [self didAccessValueForKey:@"${2: attribute}"];
11 | return value;
12 | }
13 |
14 | - (void)set${2/./\u$0/}:($1)aValue
15 | {
16 | [self willChangeValueForKey:@"${2: attribute}"];
17 | [self setPrimitiveValue:aValue forKey:@"${2: attribute}"];
18 | [self didChangeValueForKey:@"${2: attribute}"];
19 | }
20 | name
21 | CoreData
22 | scope
23 | source.objc, source.objc++
24 | tabTrigger
25 | cdacc
26 | uuid
27 | 563B2FDB-A163-46FE-9380-4178EFC1AD14
28 |
29 |
30 |
--------------------------------------------------------------------------------
/Snippets/Delegate Responds to Selector.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | if([${1:[self delegate]} respondsToSelector:@selector(${2:selfDidSomething:})])
7 | [$1 ${3:${2/((^\s*([A-Za-z0-9_]*:)\s*)|(:\s*$)|(:\s*))/(?2:$2self :\:<>)(?4::)(?5: :)/g}}];
8 |
9 | name
10 | Delegate Responds to Selector
11 | scope
12 | source.objc, source.objc++
13 | tabTrigger
14 | delegate
15 | uuid
16 | 622842E6-11F7-4D7B-A322-F1B8A1FE8CE5
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Snippets/Detach New NSThread.tmSnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | [NSThread detachNewThreadSelector:@selector(${1:method}:) toTarget:${2:aTarget} withObject:${3:anArgument}]
7 | name
8 | Detach New NSThread
9 | scope
10 | source.objc, source.objc++
11 | tabTrigger
12 | thread
13 | uuid
14 | 25AD69B4-905B-4EBC-A3B3-0BAB6D8BDD75
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Snippets/For Loop.tmSnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | for(NSUInteger ${2:i} = 0; $2 < ${1:count}; ${3:++$2})
7 | {
8 | ${0:/* code */}
9 | }
10 | name
11 | For Loop
12 | scope
13 | source.objc, source.objc++
14 | tabTrigger
15 | for
16 | uuid
17 | 7AB60FCF-822A-4D74-A7C4-1B6A724DD669
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Snippets/IBOutlet (ibo).plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | IBOutlet ${1:NSSomeClass}${TM_C_POINTER: *}${2:${1/^[A-Z](?:[A-Z]+|[a-z]+)([A-Z]\w*)/\l$1/}};
7 | name
8 | IBOutlet
9 | scope
10 | source.objc, source.objc++
11 | tabTrigger
12 | ibo
13 | uuid
14 | 30C260A7-AFB1-11D9-9D48-000D93589AF6
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Snippets/Initialize Implementation (I).plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | + (void)initialize
7 | {
8 | [[NSUserDefaults standardUserDefaults] registerDefaults:@{
9 | $0@"key" : @"value",
10 | }];
11 | }
12 | name
13 | Method: Initialize
14 | scope
15 | (source.objc | source.objc++) & meta.scope.implementation.objc - meta.function-with-body
16 | tabTrigger
17 | I
18 | uuid
19 | 366DBAB0-554B-4A38-966E-793DFE13A1EC
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Snippets/Key:value binding (bind).plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | bind:@"${2:binding}" toObject:${3:observableController} withKeyPath:@"${4:keyPath}" options:${5:nil}
7 | name
8 | Bind Property to Key Path of Object
9 | scope
10 | source.objc, source.objc++
11 | tabTrigger
12 | bind
13 | uuid
14 | 59FC2842-A645-11D9-B2CB-000D93589AF6
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Snippets/LoD array (arracc).plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | - (void)addObjectTo${1:Things}:(${2:id})anObject
7 | {
8 | [${3:${1/./\l$0/}} addObject:anObject];
9 | }
10 |
11 | - (void)insertObject:($2)anObject in$1AtIndex:(NSUInteger)idx
12 | {
13 | [$3 insertObject:anObject atIndex:idx];
14 | }
15 |
16 | - ($2)objectIn$1AtIndex:(NSUInteger)idx
17 | {
18 | return [$3 objectAtIndex:idx];
19 | }
20 |
21 | - (NSUInteger)indexOfObjectIn$1:($2)anObject
22 | {
23 | return [$3 indexOfObject:anObject];
24 | }
25 |
26 | - (void)removeObjectFrom$1AtIndex:(NSUInteger)idx
27 | {
28 | [$3 removeObjectAtIndex:idx];
29 | }
30 |
31 | - (NSUInteger)countOf$1
32 | {
33 | return [$3 count];
34 | }
35 |
36 | - (NSArray${TM_C_POINTER/(^(.+?)\s*$)?/(?1:$2: *)/})${1/./\l$0/}
37 | {
38 | return $3;
39 | }
40 |
41 | - (void)set$1:(NSArray${TM_C_POINTER/(^(.+?)\s*$)?/(?1:$2: *)/})new$1
42 | {
43 | [$3 setArray:new$1];
44 | }
45 | name
46 | KVC Array
47 | scope
48 | (source.objc | source.objc++) & meta.scope.implementation.objc - meta.function-with-body
49 | tabTrigger
50 | arracc
51 | uuid
52 | DECC6BAC-94AF-429A-8609-D101C940D18D
53 |
54 |
55 |
--------------------------------------------------------------------------------
/Snippets/LoD array interface (arracc).plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | - (void)addObjectTo${1:Things}:(${2:id})anObject;
7 | - (void)insertObject:($2)anObject in$1AtIndex:(unsigned int)i;
8 | - ($2)objectIn$1AtIndex:(unsigned int)i;
9 | - (unsigned int)indexOfObjectIn$1:($2)anObject;
10 | - (void)removeObjectFrom$1AtIndex:(unsigned int)i;
11 | - (unsigned int)countOf$1;
12 | - (NSArray${TM_C_POINTER/(^(.+?)\s*$)?/(?1:$2: *)/})${1/./\l$0/};
13 | - (void)set$1:(NSArray${TM_C_POINTER/(^(.+?)\s*$)?/(?1:$2: *)/})new$1;
14 | name
15 | Interface: Accessors for KVC Array
16 | scope
17 | source.objc meta.scope.interface, source.objc++ meta.scope.interface
18 | tabTrigger
19 | arracc
20 | uuid
21 | C125E6DB-7FB5-4B19-8648-0A5617B1B5BC
22 |
23 |
24 |
--------------------------------------------------------------------------------
/Snippets/Lock Focus.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | [self lockFocus];
7 | $0
8 | [self unlockFocus];
9 | name
10 | Lock Focus
11 | scope
12 | source.objc, source.objc++
13 | tabTrigger
14 | focus
15 | uuid
16 | 3F57DB1B-9373-46A6-9B6E-19F2D25658DE
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Snippets/Method Interface (m).plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | - (${1:id})${2:${TM_SELECTED_TEXT:method}}${3::(${4:id})${5:${4/(NS([AEIOQUY])?(\w+).*)|(.)?.*/(?1:a(?2:n$2)$3:(?4:anArgument))/}}};
7 | keyEquivalent
8 | ^M
9 | name
10 | Interface: Method
11 | scope
12 | source.objc meta.scope.interface, source.objc++ meta.scope.interface
13 | tabTrigger
14 | m
15 | uuid
16 | 325B0A2B-5939-4805-80A1-6DED5B373283
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Snippets/NSAutoreleasePool (pool).plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | @autoreleasepool {
7 | $0
8 | }
9 | name
10 | Autorelease Pool
11 | scope
12 | source.objc, source.objc++
13 | tabTrigger
14 | pool
15 | uuid
16 | D402B10A-149B-414D-9961-110880389A8E
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Snippets/NSBezierPath (bez).plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | NSBezierPath${TM_C_POINTER: *}${1:path} = [NSBezierPath bezierPath];
7 | name
8 | NSBezierPath
9 | scope
10 | source.objc, source.objc++
11 | tabTrigger
12 | bez
13 | uuid
14 | 917BA9ED-9A62-11D9-9A65-000A95A89C98
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Snippets/NSLog (log) 2.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | NSLog(@"$1"${1/[^%]*(%)?.*/(?1:, :\);)/}$2${1/[^%]*(%)?.*/(?1:\);)/}
7 | name
8 | NSLog(…)
9 | scope
10 | source.objc, source.objc++
11 | tabTrigger
12 | log
13 | uuid
14 | 1251B7E8-6BF0-11D9-8384-000D93589AF6
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Snippets/NSLog(.., _cmd) (log).plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | NSLog(@"%s$1", sel_getName(_cmd)${1/[^%]*(%)?.*/(?1:, :\);)/}$2${1/[^%]*(%)?.*/(?1:\);)/}
7 | name
8 | NSLog(.., _cmd)
9 | scope
10 | source.objc meta.scope.implementation, source.objc++ meta.scope.implementation
11 | tabTrigger
12 | log
13 | uuid
14 | A3555C49-D367-4CF5-8032-13B291820CD3
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Snippets/NSRunAlertPanel (alert).plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | NSAlert* alert = [[NSAlert alloc] init];
7 | alert.messageText = @"${1:Something important!}";
8 | alert.informativeText = @"${2:Something important just happend, and now I need to ask you, do you want to continue?}";
9 | for(NSString* title in @[ @"${3:Continue}", @"${4:Cancel}" ])
10 | [alert addButtonWithTitle:title];
11 |
12 | NSInteger choice = [alert runModal];
13 | if(choice == NSAlertFirstButtonReturn) // “${3:Continue}”
14 | {
15 | $0;
16 | }
17 | else if(choice == NSAlertSecondButtonReturn) // “${4:Cancel}”
18 | {
19 | ;
20 | }
21 | name
22 | NSAlert runModal
23 | scope
24 | source.objc, source.objc++
25 | tabTrigger
26 | alert
27 | uuid
28 | 9EF84198-BDAF-11D9-9140-000D93589AF6
29 |
30 |
31 |
--------------------------------------------------------------------------------
/Snippets/NSString stringWithFormat (format).plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | [NSString stringWithFormat:@"$1", $2]
7 | name
8 | NSString With Format
9 | scope
10 | source.objc, source.objc++
11 | tabTrigger
12 | format
13 | uuid
14 | B07879C7-F1E0-4606-93F1-1A948965CD0E
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Snippets/Object Accessors Interface (objacc).plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | - (${1:id})${2:thing};
7 | - (void)set${2/./\u$0/}:($1)aValue;
8 | name
9 | Interface: Accessors for Object
10 | scope
11 | source.objc meta.scope.interface, source.objc++ meta.scope.interface
12 | tabTrigger
13 | objacc
14 | uuid
15 | 013BFEBB-A744-46F1-94A5-F851635E00FA
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Snippets/Property.tmSnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | @property (${2:nonatomic${1/.+/, /}}${1|readonly,weak,copy,class|}) ${3:NSSomeClass}${3/^((?!NS(U?Integer|Point|Size|Rect)|C[GF]|BOOL|SEL)[A-Z]\w*)|.*/${1:?${TM_C_POINTER: *}: }/}${4:${3/^(?:(BOOL)|(SEL)|[A-Z](?:[A-Z]+|[a-z]+)([A-Z]\w*))/${1:?flag:${2:?action:\l$3}}/}};
7 | name
8 | Property
9 | scope
10 | source.objc meta.scope.interface, source.objc++ meta.scope.interface
11 | tabTrigger
12 | prop
13 | uuid
14 | EE603767-8BA3-4F54-8DE5-0C9E64BE5DF7
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Snippets/Protocol.tmSnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | @protocol ${1:${2:${TM_FILENAME:?${TM_FILENAME/\..+$//}:My}}Delegate}${3: <NSObject>}
7 | $0
8 | @optional
9 | @end
10 | name
11 | Protocol
12 | scope
13 | source.objc, source.objc++
14 | tabTrigger
15 | pro
16 | uuid
17 | B638A0D2-1B84-4932-99D4-3134230C3EC8
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Snippets/Read from defaults (getprefs).plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | [[NSUserDefaults standardUserDefaults] ${1|objectForKey,arrayForKey,boolForKey,dataForKey,dictionaryForKey,doubleForKey,floatForKey,integerForKey,stringForKey,stringArrayForKey,URLForKey|}:${2:key}];
7 | name
8 | Read Defaults Value
9 | scope
10 | source.objc, source.objc++
11 | tabTrigger
12 | getprefs
13 | uuid
14 | 3EF96A1F-B597-11D9-A114-000D93589AF6
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Snippets/Register for Notification.tmSnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | [[NSNotificationCenter defaultCenter] addObserver:${1:self} selector:@selector(${3:${2/^([A-Z]{2})?(.+?)(Notification)?$/\l$2/}}:) name:${2:NSWindowDidBecomeMainNotification} object:${4:nil}];
7 | name
8 | Register for Notification
9 | scope
10 | source.objc meta.scope.implementation, source.objc++ meta.scope.implementation
11 | tabTrigger
12 | obs
13 | uuid
14 | E8107901-70F1-45D9-8633-81BD5E57CC89
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Snippets/Responds to Selector.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | ${TM_COMMENT_START} ${4:Send $2 to $1, if $1 supports it}${TM_COMMENT_END}
7 | if([${1:self} respondsToSelector:@selector(${2:someSelector:})])
8 | {
9 | [$1 ${3:${2/((:\s*$)|(:\s*))/:<>(?3: )/g}}];
10 | }
11 | name
12 | Responds to Selector
13 | scope
14 | source.objc, source.objc++
15 | tabTrigger
16 | responds
17 | uuid
18 | 171FBCAE-0D6F-4D42-B24F-871E3BB6DFF0
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Snippets/Save and Restore Graphics Context (gsave).plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | [NSGraphicsContext saveGraphicsState];
7 | $0
8 | [NSGraphicsContext restoreGraphicsState];
9 |
10 | name
11 | Save and Restore Graphics Context
12 | scope
13 | source.objc, source.objc++
14 | tabTrigger
15 | gsave
16 | uuid
17 | F2D5B215-2C10-40BC-B973-0A859A3E3CBD
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Snippets/Scalar Accessors (acc).plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | - (${1|BOOL,NSInteger,NSUInteger,NSArray*,NSDictionary*,NSString*|})${2:property}
7 | {
8 | return ${3:_$2};
9 | }
10 |
11 | - (void)set${2/./\u$0/}:(${1})new${2/./\u$0/}
12 | {
13 | $3 = new${2/./\u$0/};
14 | }
15 | name
16 | Type
17 | scope
18 | (source.objc | source.objc++) & meta.scope.implementation.objc - meta.function-with-body
19 | tabTrigger
20 | acc
21 | uuid
22 | DADC6C91-415F-463A-9C24-7A059BB5EE56
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Snippets/Scalar Accessors Interface (acc).plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | - (${1:unsigned int})${2:thing};
7 | - (void)set${2/./\u$0/}:($1)new${2/./\u$0/};
8 | name
9 | Interface: Accessors for Primitive Type
10 | scope
11 | source.objc meta.scope.interface, source.objc++ meta.scope.interface
12 | tabTrigger
13 | acc
14 | uuid
15 | BA432891-294B-47A4-BECF-F3C95B3766C1
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Snippets/String Accessors Interface (stracc).plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | - (NSString${TM_C_POINTER/(^(.+?)\s*$)?/(?1:$2: *)/})${1:thing};
7 | - (void)set${1/./\u$0/}:(NSString${TM_C_POINTER/(^(.+?)\s*$)?/(?1:$2: *)/})${2:a${1/.*/\u$0/}};
8 | name
9 | Interface: Accessors for String
10 | scope
11 | source.objc meta.scope.interface, source.objc++ meta.scope.interface
12 | tabTrigger
13 | stracc
14 | uuid
15 | 35EB2F86-DEA0-443B-8DC2-4815F0478F67
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Snippets/Synthesize.tmSnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | @synthesize ${1:property};
7 | name
8 | Synthesize Property
9 | scope
10 | (source.objc | source.objc++) & meta.scope.implementation.objc - meta.function-with-body
11 | tabTrigger
12 | syn
13 | uuid
14 | C0B942C9-07CE-46B6-8FAE-CB8496F9F544
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Snippets/Write to defaults (setprefs).plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | [[NSUserDefaults standardUserDefaults] ${1|setObject,setBool,setDouble,setFloat,setInteger,setURL|}:${2:object} forKey:${3:key}];
7 | name
8 | Write Defaults Value
9 | scope
10 | source.objc, source.objc++
11 | tabTrigger
12 | setprefs
13 | uuid
14 | 53672612-B597-11D9-A114-000D93589AF6
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Snippets/for(… in …).tmSnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | content
6 | for(${1:id} ${2:item} in ${3:array})
7 | {
8 | $0
9 | }
10 | name
11 | for(… in …)
12 | scope
13 | source.objc, source.objc++
14 | tabTrigger
15 | forin
16 | uuid
17 | B47D188C-C0F7-4C53-A6ED-9EFE09371F37
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Support/CocoaAnnotatedStrings.txt.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/textmate/objective-c.tmbundle/d59562b0948d4dae01eaee1a2b2bcde3b478404e/Support/CocoaAnnotatedStrings.txt.gz
--------------------------------------------------------------------------------
/Support/CocoaAnonymousEnums.txt.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/textmate/objective-c.tmbundle/d59562b0948d4dae01eaee1a2b2bcde3b478404e/Support/CocoaAnonymousEnums.txt.gz
--------------------------------------------------------------------------------
/Support/CocoaClasses.txt.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/textmate/objective-c.tmbundle/d59562b0948d4dae01eaee1a2b2bcde3b478404e/Support/CocoaClasses.txt.gz
--------------------------------------------------------------------------------
/Support/CocoaClassesWithAncestry.txt.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/textmate/objective-c.tmbundle/d59562b0948d4dae01eaee1a2b2bcde3b478404e/Support/CocoaClassesWithAncestry.txt.gz
--------------------------------------------------------------------------------
/Support/CocoaClassesWithFramework.txt.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/textmate/objective-c.tmbundle/d59562b0948d4dae01eaee1a2b2bcde3b478404e/Support/CocoaClassesWithFramework.txt.gz
--------------------------------------------------------------------------------
/Support/CocoaConstants.txt.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/textmate/objective-c.tmbundle/d59562b0948d4dae01eaee1a2b2bcde3b478404e/Support/CocoaConstants.txt.gz
--------------------------------------------------------------------------------
/Support/CocoaFunctions.txt.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/textmate/objective-c.tmbundle/d59562b0948d4dae01eaee1a2b2bcde3b478404e/Support/CocoaFunctions.txt.gz
--------------------------------------------------------------------------------
/Support/CocoaMethods.txt.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/textmate/objective-c.tmbundle/d59562b0948d4dae01eaee1a2b2bcde3b478404e/Support/CocoaMethods.txt.gz
--------------------------------------------------------------------------------
/Support/CocoaNotifications.txt.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/textmate/objective-c.tmbundle/d59562b0948d4dae01eaee1a2b2bcde3b478404e/Support/CocoaNotifications.txt.gz
--------------------------------------------------------------------------------
/Support/CocoaProtocols.txt.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/textmate/objective-c.tmbundle/d59562b0948d4dae01eaee1a2b2bcde3b478404e/Support/CocoaProtocols.txt.gz
--------------------------------------------------------------------------------
/Support/CocoaTypes.txt.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/textmate/objective-c.tmbundle/d59562b0948d4dae01eaee1a2b2bcde3b478404e/Support/CocoaTypes.txt.gz
--------------------------------------------------------------------------------
/Support/CppReferenceWiki.tsf:
--------------------------------------------------------------------------------
1 | accumulate std::accumulate http://www.cppreference.com/wiki/stl/algorithm/accumulate
2 | adjacent_difference std::adjacent_difference http://www.cppreference.com/wiki/stl/algorithm/adjacent_difference
3 | adjacent_find std::adjacent_find http://www.cppreference.com/wiki/stl/algorithm/adjacent_find
4 | binary_search std::binary_search http://www.cppreference.com/wiki/stl/algorithm/binary_search
5 | copy std::copy http://www.cppreference.com/wiki/stl/algorithm/copy
6 | copy_backward std::copy_backward http://www.cppreference.com/wiki/stl/algorithm/copy_backward
7 | copy_n std::copy_n http://www.cppreference.com/wiki/stl/algorithm/copy_n
8 | count std::count http://www.cppreference.com/wiki/stl/algorithm/count
9 | count_if std::count_if http://www.cppreference.com/wiki/stl/algorithm/count_if
10 | equal std::equal http://www.cppreference.com/wiki/stl/algorithm/equal
11 | equal_range std::equal_range http://www.cppreference.com/wiki/stl/algorithm/equal_range
12 | fill std::fill http://www.cppreference.com/wiki/stl/algorithm/fill
13 | fill_n std::fill_n http://www.cppreference.com/wiki/stl/algorithm/fill_n
14 | find std::find http://www.cppreference.com/wiki/stl/algorithm/find
15 | find_end std::find_end http://www.cppreference.com/wiki/stl/algorithm/find_end
16 | find_first_of std::find_first_of http://www.cppreference.com/wiki/stl/algorithm/find_first_of
17 | find_if std::find_if http://www.cppreference.com/wiki/stl/algorithm/find_if
18 | for_each std::for_each http://www.cppreference.com/wiki/stl/algorithm/for_each
19 | generate std::generate http://www.cppreference.com/wiki/stl/algorithm/generate
20 | generate_n std::generate_n http://www.cppreference.com/wiki/stl/algorithm/generate_n
21 | includes std::includes http://www.cppreference.com/wiki/stl/algorithm/includes
22 | inner_product std::inner_product http://www.cppreference.com/wiki/stl/algorithm/inner_product
23 | inplace_merge std::inplace_merge http://www.cppreference.com/wiki/stl/algorithm/inplace_merge
24 | is_heap std::is_heap http://www.cppreference.com/wiki/stl/algorithm/is_heap
25 | iter_swap std::iter_swap http://www.cppreference.com/wiki/stl/algorithm/iter_swap
26 | lexicographical_compare std::lexicographical_compare http://www.cppreference.com/wiki/stl/algorithm/lexicographical_compare
27 | lexicographical_compare_3way std::lexicographical_compare_3way http://www.cppreference.com/wiki/stl/algorithm/lexicographical_compare_3way
28 | lower_bound std::lower_bound http://www.cppreference.com/wiki/stl/algorithm/lower_bound
29 | make_heap std::make_heap http://www.cppreference.com/wiki/stl/algorithm/make_heap
30 | max std::max http://www.cppreference.com/wiki/stl/algorithm/max
31 | max_element std::max_element http://www.cppreference.com/wiki/stl/algorithm/max_element
32 | merge std::merge http://www.cppreference.com/wiki/stl/algorithm/merge
33 | min std::min http://www.cppreference.com/wiki/stl/algorithm/min
34 | min_element std::min_element http://www.cppreference.com/wiki/stl/algorithm/min_element
35 | mismatch std::mismatch http://www.cppreference.com/wiki/stl/algorithm/mismatch
36 | next_permutation std::next_permutation http://www.cppreference.com/wiki/stl/algorithm/next_permutation
37 | nth_element std::nth_element http://www.cppreference.com/wiki/stl/algorithm/nth_element
38 | partial_sort std::partial_sort http://www.cppreference.com/wiki/stl/algorithm/partial_sort
39 | partial_sort_copy std::partial_sort_copy http://www.cppreference.com/wiki/stl/algorithm/partial_sort_copy
40 | partial_sum std::partial_sum http://www.cppreference.com/wiki/stl/algorithm/partial_sum
41 | partition std::partition http://www.cppreference.com/wiki/stl/algorithm/partition
42 | pop_heap std::pop_heap http://www.cppreference.com/wiki/stl/algorithm/pop_heap
43 | prev_permutation std::prev_permutation http://www.cppreference.com/wiki/stl/algorithm/prev_permutation
44 | push_heap std::push_heap http://www.cppreference.com/wiki/stl/algorithm/push_heap
45 | random_sample std::random_sample http://www.cppreference.com/wiki/stl/algorithm/random_sample
46 | random_sample_n std::random_sample_n http://www.cppreference.com/wiki/stl/algorithm/random_sample_n
47 | random_shuffle std::random_shuffle http://www.cppreference.com/wiki/stl/algorithm/random_shuffle
48 | remove std::remove http://www.cppreference.com/wiki/stl/algorithm/remove
49 | remove_copy std::remove_copy http://www.cppreference.com/wiki/stl/algorithm/remove_copy
50 | remove_copy_if std::remove_copy_if http://www.cppreference.com/wiki/stl/algorithm/remove_copy_if
51 | remove_if std::remove_if http://www.cppreference.com/wiki/stl/algorithm/remove_if
52 | replace std::replace http://www.cppreference.com/wiki/stl/algorithm/replace
53 | replace_copy std::replace_copy http://www.cppreference.com/wiki/stl/algorithm/replace_copy
54 | replace_copy_if std::replace_copy_if http://www.cppreference.com/wiki/stl/algorithm/replace_copy_if
55 | replace_if std::replace_if http://www.cppreference.com/wiki/stl/algorithm/replace_if
56 | reverse std::reverse http://www.cppreference.com/wiki/stl/algorithm/reverse
57 | reverse_copy std::reverse_copy http://www.cppreference.com/wiki/stl/algorithm/reverse_copy
58 | rotate std::rotate http://www.cppreference.com/wiki/stl/algorithm/rotate
59 | rotate_copy std::rotate_copy http://www.cppreference.com/wiki/stl/algorithm/rotate_copy
60 | search std::search http://www.cppreference.com/wiki/stl/algorithm/search
61 | search_n std::search_n http://www.cppreference.com/wiki/stl/algorithm/search_n
62 | set_difference std::set_difference http://www.cppreference.com/wiki/stl/algorithm/set_difference
63 | set_intersection std::set_intersection http://www.cppreference.com/wiki/stl/algorithm/set_intersection
64 | set_symmetric_difference std::set_symmetric_difference http://www.cppreference.com/wiki/stl/algorithm/set_symmetric_difference
65 | set_union std::set_union http://www.cppreference.com/wiki/stl/algorithm/set_union
66 | sort std::sort http://www.cppreference.com/wiki/stl/algorithm/sort
67 | sort_heap std::sort_heap http://www.cppreference.com/wiki/stl/algorithm/sort_heap
68 | stable_partition std::stable_partition http://www.cppreference.com/wiki/stl/algorithm/stable_partition
69 | stable_sort std::stable_sort http://www.cppreference.com/wiki/stl/algorithm/stable_sort
70 | swap std::swap http://www.cppreference.com/wiki/stl/algorithm/swap
71 | swap_ranges std::swap_ranges http://www.cppreference.com/wiki/stl/algorithm/swap_ranges
72 | transform std::transform http://www.cppreference.com/wiki/stl/algorithm/transform
73 | unique std::unique http://www.cppreference.com/wiki/stl/algorithm/unique
74 | unique_copy std::unique_copy http://www.cppreference.com/wiki/stl/algorithm/unique_copy
75 | upper_bound std::upper_bound http://www.cppreference.com/wiki/stl/algorithm/upper_bound
76 | any std::bitset::any http://www.cppreference.com/wiki/stl/bitset/any
77 | bitset_constructors std::bitset::bitset_constructors http://www.cppreference.com/wiki/stl/bitset/bitset_constructors
78 | bitset_operators std::bitset::bitset_operators http://www.cppreference.com/wiki/stl/bitset/bitset_operators
79 | count std::bitset::count http://www.cppreference.com/wiki/stl/bitset/count
80 | flip std::bitset::flip http://www.cppreference.com/wiki/stl/bitset/flip
81 | none std::bitset::none http://www.cppreference.com/wiki/stl/bitset/none
82 | reset std::bitset::reset http://www.cppreference.com/wiki/stl/bitset/reset
83 | set std::bitset::set http://www.cppreference.com/wiki/stl/bitset/set
84 | size std::bitset::size http://www.cppreference.com/wiki/stl/bitset/size
85 | bitset std::bitset http://www.cppreference.com/wiki/stl/bitset/start
86 | test std::bitset::test http://www.cppreference.com/wiki/stl/bitset/test
87 | to_string std::bitset::to_string http://www.cppreference.com/wiki/stl/bitset/to_string
88 | to_ulong std::bitset::to_ulong http://www.cppreference.com/wiki/stl/bitset/to_ulong
89 | assign std::deque::assign http://www.cppreference.com/wiki/stl/deque/assign
90 | at std::deque::at http://www.cppreference.com/wiki/stl/deque/at
91 | back std::deque::back http://www.cppreference.com/wiki/stl/deque/back
92 | begin std::deque::begin http://www.cppreference.com/wiki/stl/deque/begin
93 | clear std::deque::clear http://www.cppreference.com/wiki/stl/deque/clear
94 | deque_constructors std::deque::deque_constructors http://www.cppreference.com/wiki/stl/deque/deque_constructors
95 | deque_operators std::deque::deque_operators http://www.cppreference.com/wiki/stl/deque/deque_operators
96 | empty std::deque::empty http://www.cppreference.com/wiki/stl/deque/empty
97 | end std::deque::end http://www.cppreference.com/wiki/stl/deque/end
98 | erase std::deque::erase http://www.cppreference.com/wiki/stl/deque/erase
99 | front std::deque::front http://www.cppreference.com/wiki/stl/deque/front
100 | insert std::deque::insert http://www.cppreference.com/wiki/stl/deque/insert
101 | max_size std::deque::max_size http://www.cppreference.com/wiki/stl/deque/max_size
102 | pop_back std::deque::pop_back http://www.cppreference.com/wiki/stl/deque/pop_back
103 | pop_front std::deque::pop_front http://www.cppreference.com/wiki/stl/deque/pop_front
104 | push_back std::deque::push_back http://www.cppreference.com/wiki/stl/deque/push_back
105 | push_front std::deque::push_front http://www.cppreference.com/wiki/stl/deque/push_front
106 | rbegin std::deque::rbegin http://www.cppreference.com/wiki/stl/deque/rbegin
107 | rend std::deque::rend http://www.cppreference.com/wiki/stl/deque/rend
108 | resize std::deque::resize http://www.cppreference.com/wiki/stl/deque/resize
109 | size std::deque::size http://www.cppreference.com/wiki/stl/deque/size
110 | deque std::deque http://www.cppreference.com/wiki/stl/deque/start
111 | swap std::deque::swap http://www.cppreference.com/wiki/stl/deque/swap
112 | binary_function std::functional::binary_function http://www.cppreference.com/wiki/stl/functional/binary_function
113 | binary_negate std::functional::binary_negate http://www.cppreference.com/wiki/stl/functional/binary_negate
114 | bind1st std::functional::bind1st http://www.cppreference.com/wiki/stl/functional/bind1st
115 | bind2nd std::functional::bind2nd http://www.cppreference.com/wiki/stl/functional/bind2nd
116 | binder1st std::functional::binder1st http://www.cppreference.com/wiki/stl/functional/binder1st
117 | binder2nd std::functional::binder2nd http://www.cppreference.com/wiki/stl/functional/binder2nd
118 | const_mem_fun1_ref_t std::functional::const_mem_fun1_ref_t http://www.cppreference.com/wiki/stl/functional/const_mem_fun1_ref_t
119 | const_mem_fun1_t std::functional::const_mem_fun1_t http://www.cppreference.com/wiki/stl/functional/const_mem_fun1_t
120 | const_mem_fun_ref_t std::functional::const_mem_fun_ref_t http://www.cppreference.com/wiki/stl/functional/const_mem_fun_ref_t
121 | const_mem_fun_t std::functional::const_mem_fun_t http://www.cppreference.com/wiki/stl/functional/const_mem_fun_t
122 | divides std::functional::divides http://www.cppreference.com/wiki/stl/functional/divides
123 | functional std::functional http://www.cppreference.com/wiki/stl/functional/start
124 | assign std::list::assign http://www.cppreference.com/wiki/stl/list/assign
125 | back std::list::back http://www.cppreference.com/wiki/stl/list/back
126 | begin std::list::begin http://www.cppreference.com/wiki/stl/list/begin
127 | clear std::list::clear http://www.cppreference.com/wiki/stl/list/clear
128 | empty std::list::empty http://www.cppreference.com/wiki/stl/list/empty
129 | end std::list::end http://www.cppreference.com/wiki/stl/list/end
130 | erase std::list::erase http://www.cppreference.com/wiki/stl/list/erase
131 | front std::list::front http://www.cppreference.com/wiki/stl/list/front
132 | insert std::list::insert http://www.cppreference.com/wiki/stl/list/insert
133 | list_constructors std::list::list_constructors http://www.cppreference.com/wiki/stl/list/list_constructors
134 | list_operators std::list::list_operators http://www.cppreference.com/wiki/stl/list/list_operators
135 | max_size std::list::max_size http://www.cppreference.com/wiki/stl/list/max_size
136 | merge std::list::merge http://www.cppreference.com/wiki/stl/list/merge
137 | pop_back std::list::pop_back http://www.cppreference.com/wiki/stl/list/pop_back
138 | pop_front std::list::pop_front http://www.cppreference.com/wiki/stl/list/pop_front
139 | push_back std::list::push_back http://www.cppreference.com/wiki/stl/list/push_back
140 | push_front std::list::push_front http://www.cppreference.com/wiki/stl/list/push_front
141 | rbegin std::list::rbegin http://www.cppreference.com/wiki/stl/list/rbegin
142 | remove std::list::remove http://www.cppreference.com/wiki/stl/list/remove
143 | remove_if std::list::remove_if http://www.cppreference.com/wiki/stl/list/remove_if
144 | rend std::list::rend http://www.cppreference.com/wiki/stl/list/rend
145 | resize std::list::resize http://www.cppreference.com/wiki/stl/list/resize
146 | reverse std::list::reverse http://www.cppreference.com/wiki/stl/list/reverse
147 | size std::list::size http://www.cppreference.com/wiki/stl/list/size
148 | sort std::list::sort http://www.cppreference.com/wiki/stl/list/sort
149 | splice std::list::splice http://www.cppreference.com/wiki/stl/list/splice
150 | list std::list http://www.cppreference.com/wiki/stl/list/start
151 | swap std::list::swap http://www.cppreference.com/wiki/stl/list/swap
152 | unique std::list::unique http://www.cppreference.com/wiki/stl/list/unique
153 | begin std::map::begin http://www.cppreference.com/wiki/stl/map/begin
154 | clear std::map::clear http://www.cppreference.com/wiki/stl/map/clear
155 | count std::map::count http://www.cppreference.com/wiki/stl/map/count
156 | empty std::map::empty http://www.cppreference.com/wiki/stl/map/empty
157 | end std::map::end http://www.cppreference.com/wiki/stl/map/end
158 | equal_range std::map::equal_range http://www.cppreference.com/wiki/stl/map/equal_range
159 | erase std::map::erase http://www.cppreference.com/wiki/stl/map/erase
160 | find std::map::find http://www.cppreference.com/wiki/stl/map/find
161 | insert std::map::insert http://www.cppreference.com/wiki/stl/map/insert
162 | key_comp std::map::key_comp http://www.cppreference.com/wiki/stl/map/key_comp
163 | lower_bound std::map::lower_bound http://www.cppreference.com/wiki/stl/map/lower_bound
164 | map_constructors std::map::map_constructors http://www.cppreference.com/wiki/stl/map/map_constructors
165 | map_operators std::map::map_operators http://www.cppreference.com/wiki/stl/map/map_operators
166 | map_typedefs std::map::map_typedefs http://www.cppreference.com/wiki/stl/map/map_typedefs
167 | max_size std::map::max_size http://www.cppreference.com/wiki/stl/map/max_size
168 | rbegin std::map::rbegin http://www.cppreference.com/wiki/stl/map/rbegin
169 | rend std::map::rend http://www.cppreference.com/wiki/stl/map/rend
170 | size std::map::size http://www.cppreference.com/wiki/stl/map/size
171 | map std::map http://www.cppreference.com/wiki/stl/map/start
172 | swap std::map::swap http://www.cppreference.com/wiki/stl/map/swap
173 | upper_bound std::map::upper_bound http://www.cppreference.com/wiki/stl/map/upper_bound
174 | value_comp std::map::value_comp http://www.cppreference.com/wiki/stl/map/value_comp
175 | auto_ptr std::memory::auto_ptr http://www.cppreference.com/wiki/stl/memory/auto_ptr
176 | memory std::memory http://www.cppreference.com/wiki/stl/memory/start
177 | begin std::multimap::begin http://www.cppreference.com/wiki/stl/multimap/begin
178 | clear std::multimap::clear http://www.cppreference.com/wiki/stl/multimap/clear
179 | count std::multimap::count http://www.cppreference.com/wiki/stl/multimap/count
180 | empty std::multimap::empty http://www.cppreference.com/wiki/stl/multimap/empty
181 | end std::multimap::end http://www.cppreference.com/wiki/stl/multimap/end
182 | equal_range std::multimap::equal_range http://www.cppreference.com/wiki/stl/multimap/equal_range
183 | erase std::multimap::erase http://www.cppreference.com/wiki/stl/multimap/erase
184 | find std::multimap::find http://www.cppreference.com/wiki/stl/multimap/find
185 | insert std::multimap::insert http://www.cppreference.com/wiki/stl/multimap/insert
186 | key_comp std::multimap::key_comp http://www.cppreference.com/wiki/stl/multimap/key_comp
187 | lower_bound std::multimap::lower_bound http://www.cppreference.com/wiki/stl/multimap/lower_bound
188 | max_size std::multimap::max_size http://www.cppreference.com/wiki/stl/multimap/max_size
189 | multimap_constructors std::multimap::multimap_constructors http://www.cppreference.com/wiki/stl/multimap/multimap_constructors
190 | multimap_operators std::multimap::multimap_operators http://www.cppreference.com/wiki/stl/multimap/multimap_operators
191 | rbegin std::multimap::rbegin http://www.cppreference.com/wiki/stl/multimap/rbegin
192 | rend std::multimap::rend http://www.cppreference.com/wiki/stl/multimap/rend
193 | size std::multimap::size http://www.cppreference.com/wiki/stl/multimap/size
194 | multimap std::multimap http://www.cppreference.com/wiki/stl/multimap/start
195 | swap std::multimap::swap http://www.cppreference.com/wiki/stl/multimap/swap
196 | upper_bound std::multimap::upper_bound http://www.cppreference.com/wiki/stl/multimap/upper_bound
197 | value_comp std::multimap::value_comp http://www.cppreference.com/wiki/stl/multimap/value_comp
198 | begin std::multiset::begin http://www.cppreference.com/wiki/stl/multiset/begin
199 | clear std::multiset::clear http://www.cppreference.com/wiki/stl/multiset/clear
200 | count std::multiset::count http://www.cppreference.com/wiki/stl/multiset/count
201 | empty std::multiset::empty http://www.cppreference.com/wiki/stl/multiset/empty
202 | end std::multiset::end http://www.cppreference.com/wiki/stl/multiset/end
203 | equal_range std::multiset::equal_range http://www.cppreference.com/wiki/stl/multiset/equal_range
204 | erase std::multiset::erase http://www.cppreference.com/wiki/stl/multiset/erase
205 | find std::multiset::find http://www.cppreference.com/wiki/stl/multiset/find
206 | insert std::multiset::insert http://www.cppreference.com/wiki/stl/multiset/insert
207 | key_comp std::multiset::key_comp http://www.cppreference.com/wiki/stl/multiset/key_comp
208 | lower_bound std::multiset::lower_bound http://www.cppreference.com/wiki/stl/multiset/lower_bound
209 | max_size std::multiset::max_size http://www.cppreference.com/wiki/stl/multiset/max_size
210 | multiset_constructors std::multiset::multiset_constructors http://www.cppreference.com/wiki/stl/multiset/multiset_constructors
211 | multiset_operators std::multiset::multiset_operators http://www.cppreference.com/wiki/stl/multiset/multiset_operators
212 | rbegin std::multiset::rbegin http://www.cppreference.com/wiki/stl/multiset/rbegin
213 | rend std::multiset::rend http://www.cppreference.com/wiki/stl/multiset/rend
214 | size std::multiset::size http://www.cppreference.com/wiki/stl/multiset/size
215 | multiset std::multiset http://www.cppreference.com/wiki/stl/multiset/start
216 | swap std::multiset::swap http://www.cppreference.com/wiki/stl/multiset/swap
217 | upper_bound std::multiset::upper_bound http://www.cppreference.com/wiki/stl/multiset/upper_bound
218 | value_comp std::multiset::value_comp http://www.cppreference.com/wiki/stl/multiset/value_comp
219 | empty std::priority_queue::empty http://www.cppreference.com/wiki/stl/priority_queue/empty
220 | pop std::priority_queue::pop http://www.cppreference.com/wiki/stl/priority_queue/pop
221 | pqueue_constructors std::priority_queue::pqueue_constructors http://www.cppreference.com/wiki/stl/priority_queue/pqueue_constructors
222 | push std::priority_queue::push http://www.cppreference.com/wiki/stl/priority_queue/push
223 | size std::priority_queue::size http://www.cppreference.com/wiki/stl/priority_queue/size
224 | priority_queue std::priority_queue http://www.cppreference.com/wiki/stl/priority_queue/start
225 | top std::priority_queue::top http://www.cppreference.com/wiki/stl/priority_queue/top
226 | back std::queue::back http://www.cppreference.com/wiki/stl/queue/back
227 | empty std::queue::empty http://www.cppreference.com/wiki/stl/queue/empty
228 | front std::queue::front http://www.cppreference.com/wiki/stl/queue/front
229 | pop std::queue::pop http://www.cppreference.com/wiki/stl/queue/pop
230 | push std::queue::push http://www.cppreference.com/wiki/stl/queue/push
231 | queue_constructors std::queue::queue_constructors http://www.cppreference.com/wiki/stl/queue/queue_constructors
232 | size std::queue::size http://www.cppreference.com/wiki/stl/queue/size
233 | queue std::queue http://www.cppreference.com/wiki/stl/queue/start
234 | begin std::set::begin http://www.cppreference.com/wiki/stl/set/begin
235 | clear std::set::clear http://www.cppreference.com/wiki/stl/set/clear
236 | count std::set::count http://www.cppreference.com/wiki/stl/set/count
237 | empty std::set::empty http://www.cppreference.com/wiki/stl/set/empty
238 | end std::set::end http://www.cppreference.com/wiki/stl/set/end
239 | equal_range std::set::equal_range http://www.cppreference.com/wiki/stl/set/equal_range
240 | erase std::set::erase http://www.cppreference.com/wiki/stl/set/erase
241 | find std::set::find http://www.cppreference.com/wiki/stl/set/find
242 | insert std::set::insert http://www.cppreference.com/wiki/stl/set/insert
243 | key_comp std::set::key_comp http://www.cppreference.com/wiki/stl/set/key_comp
244 | lower_bound std::set::lower_bound http://www.cppreference.com/wiki/stl/set/lower_bound
245 | max_size std::set::max_size http://www.cppreference.com/wiki/stl/set/max_size
246 | rbegin std::set::rbegin http://www.cppreference.com/wiki/stl/set/rbegin
247 | rend std::set::rend http://www.cppreference.com/wiki/stl/set/rend
248 | set_constructors std::set::set_constructors http://www.cppreference.com/wiki/stl/set/set_constructors
249 | set_operators std::set::set_operators http://www.cppreference.com/wiki/stl/set/set_operators
250 | size std::set::size http://www.cppreference.com/wiki/stl/set/size
251 | set std::set http://www.cppreference.com/wiki/stl/set/start
252 | swap std::set::swap http://www.cppreference.com/wiki/stl/set/swap
253 | upper_bound std::set::upper_bound http://www.cppreference.com/wiki/stl/set/upper_bound
254 | value_comp std::set::value_comp http://www.cppreference.com/wiki/stl/set/value_comp
255 | empty std::stack::empty http://www.cppreference.com/wiki/stl/stack/empty
256 | pop std::stack::pop http://www.cppreference.com/wiki/stl/stack/pop
257 | push std::stack::push http://www.cppreference.com/wiki/stl/stack/push
258 | size std::stack::size http://www.cppreference.com/wiki/stl/stack/size
259 | stack_constructors std::stack::stack_constructors http://www.cppreference.com/wiki/stl/stack/stack_constructors
260 | stack std::stack http://www.cppreference.com/wiki/stl/stack/start
261 | top std::stack::top http://www.cppreference.com/wiki/stl/stack/top
262 | make_pair std::utility::make_pair http://www.cppreference.com/wiki/stl/utility/make_pair
263 | pair std::utility::pair http://www.cppreference.com/wiki/stl/utility/pair
264 | utility std::utility http://www.cppreference.com/wiki/stl/utility/start
265 | assign std::vector::assign http://www.cppreference.com/wiki/stl/vector/assign
266 | at std::vector::at http://www.cppreference.com/wiki/stl/vector/at
267 | back std::vector::back http://www.cppreference.com/wiki/stl/vector/back
268 | begin std::vector::begin http://www.cppreference.com/wiki/stl/vector/begin
269 | capacity std::vector::capacity http://www.cppreference.com/wiki/stl/vector/capacity
270 | clear std::vector::clear http://www.cppreference.com/wiki/stl/vector/clear
271 | empty std::vector::empty http://www.cppreference.com/wiki/stl/vector/empty
272 | end std::vector::end http://www.cppreference.com/wiki/stl/vector/end
273 | erase std::vector::erase http://www.cppreference.com/wiki/stl/vector/erase
274 | front std::vector::front http://www.cppreference.com/wiki/stl/vector/front
275 | insert std::vector::insert http://www.cppreference.com/wiki/stl/vector/insert
276 | max_size std::vector::max_size http://www.cppreference.com/wiki/stl/vector/max_size
277 | pop_back std::vector::pop_back http://www.cppreference.com/wiki/stl/vector/pop_back
278 | push_back std::vector::push_back http://www.cppreference.com/wiki/stl/vector/push_back
279 | rbegin std::vector::rbegin http://www.cppreference.com/wiki/stl/vector/rbegin
280 | rend std::vector::rend http://www.cppreference.com/wiki/stl/vector/rend
281 | reserve std::vector::reserve http://www.cppreference.com/wiki/stl/vector/reserve
282 | resize std::vector::resize http://www.cppreference.com/wiki/stl/vector/resize
283 | size std::vector::size http://www.cppreference.com/wiki/stl/vector/size
284 | vector std::vector http://www.cppreference.com/wiki/stl/vector/start
285 | swap std::vector::swap http://www.cppreference.com/wiki/stl/vector/swap
286 | vector_constructors std::vector::vector_constructors http://www.cppreference.com/wiki/stl/vector/vector_constructors
287 | vector_operators std::vector::vector_operators http://www.cppreference.com/wiki/stl/vector/vector_operators
288 |
--------------------------------------------------------------------------------
/Support/Platform/Makefile:
--------------------------------------------------------------------------------
1 | SDK=$(shell xcrun --sdk macosx --show-sdk-path)
2 | BUILD_DATE=$(shell date +%Y-%m-%d)
3 | LLVM=/usr/local/opt/llvm
4 | CC=xcrun clang
5 | CFLAGS=-Os -Wall -std=c++1y -lc++ --sysroot $(SDK) -DCOMPILE_DATE=\"$(BUILD_DATE)\" -framework Foundation -I$(LLVM)/include -L$(LLVM)/lib -lclang
6 |
7 | C_PATH='$(HOME)/Library/Application Support/TextMate/Bundles/c.tmbundle/Syntaxes/Platform'
8 | OBJC_PATH='$(HOME)/Library/Application Support/TextMate/Bundles/objective-c.tmbundle/Syntaxes/Platform'
9 |
10 | all: c objective-c
11 |
12 | c: generator
13 | ./generator --sdk=$(SDK) --grammar=$(C_PATH).tmLanguage --text=$(C_PATH).md --suffix='.c' includes.c
14 |
15 | objective-c: generator
16 | ./generator --sdk=$(SDK) --grammar=$(OBJC_PATH).tmLanguage --text=$(OBJC_PATH).md --suffix='.objc' --cocoa includes.mm
17 |
18 | generator: generator.mm Makefile
19 | @$(CC) $(CFLAGS) -o $@ $<
20 |
21 | .PHONY: all c objective-c
22 |
--------------------------------------------------------------------------------
/Support/Platform/README.md:
--------------------------------------------------------------------------------
1 | The code in this directory is used to generate `Platform.tmLanguage`.
2 |
3 | It requires `libclang` and the clang C includes. This can be obtained by installing `llvm`:
4 |
5 | brew install llvm
6 |
7 | There is a `Makefile` which builds the `generator` executable and will also update `Platform.tmLanguage` in the C and Objective-C bundles.
8 |
9 | Before running `make` you should clone the respective bundles:
10 |
11 | ```shell
12 | cd ~/Library/Application\ Support/TextMate/Bundles
13 | git clone "git@github.com:textmate/c.tmbundle"
14 | git clone "git@github.com:textmate/objective-c.tmbundle"
15 | ```
16 |
17 | ## How it Works
18 |
19 | We parse either `includes.c` or `includes.mm` (based on the `--cocoa` flag) using clang’s C interface.
20 |
21 | Once the file has been parsed we traverse the parse tree and harvest enumerations, functions, variable declarations, etc.
22 |
23 | For each symbol we check the path of the file path (from where the symbol came) against a list of regular expressions, this determines how to name the scope, and also means that if the file is not matched by any of our regular expressions, the symbol is left out.
24 |
25 | Here is an excerpt from the table:
26 |
27 | ```c
28 | struct { bool objC; std::string scope; std::regex pattern; } const headerTypes[] =
29 | {
30 | { false, ".pthread", std::regex(".*/_?pthread(/.*|\\.h)") },
31 | { false, ".dispatch", std::regex(".*/dispatch/.*") },
32 | { false, ".quartz", std::regex(".*/CoreGraphics\\.framework/.*") },
33 | { false, ".mac-classic", std::regex(".*/MacTypes\\.h") },
34 | { false, ".cf", std::regex(".*/CoreFoundation\\.framework/.*") },
35 | { true, ".run-time", std::regex(".*?/objc/(?:objc|runtime|NSObjCRuntime).h") },
36 | ⋮
37 | };
38 | ```
39 |
40 | If you want to add more symbols to the generated `Platform.tmLanguage` file then you need to edit this table and you may also need to add new include statements to one or both of the `includes.{c,mm}` files.
41 |
--------------------------------------------------------------------------------
/Support/Platform/generator.mm:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 | #import
4 | #import
5 | #import
6 | #import
7 | #import
8 | #import
9 | #import