corrade-nucleus-nucleons – Blame information for rev 24
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
20 | office | 1 | define("ace/snippets/perl",["require","exports","module"], function(require, exports, module) { |
2 | "use strict"; |
||
3 | |||
4 | exports.snippetText = "# #!/usr/bin/perl\n\ |
||
5 | snippet #!\n\ |
||
6 | #!/usr/bin/env perl\n\ |
||
7 | \n\ |
||
8 | # Hash Pointer\n\ |
||
9 | snippet .\n\ |
||
10 | =>\n\ |
||
11 | # Function\n\ |
||
12 | snippet sub\n\ |
||
13 | sub ${1:function_name} {\n\ |
||
14 | ${2:#body ...}\n\ |
||
15 | }\n\ |
||
16 | # Conditional\n\ |
||
17 | snippet if\n\ |
||
18 | if (${1}) {\n\ |
||
19 | ${2:# body...}\n\ |
||
20 | }\n\ |
||
21 | # Conditional if..else\n\ |
||
22 | snippet ife\n\ |
||
23 | if (${1}) {\n\ |
||
24 | ${2:# body...}\n\ |
||
25 | }\n\ |
||
26 | else {\n\ |
||
27 | ${3:# else...}\n\ |
||
28 | }\n\ |
||
29 | # Conditional if..elsif..else\n\ |
||
30 | snippet ifee\n\ |
||
31 | if (${1}) {\n\ |
||
32 | ${2:# body...}\n\ |
||
33 | }\n\ |
||
34 | elsif (${3}) {\n\ |
||
35 | ${4:# elsif...}\n\ |
||
36 | }\n\ |
||
37 | else {\n\ |
||
38 | ${5:# else...}\n\ |
||
39 | }\n\ |
||
40 | # Conditional One-line\n\ |
||
41 | snippet xif\n\ |
||
42 | ${1:expression} if ${2:condition};${3}\n\ |
||
43 | # Unless conditional\n\ |
||
44 | snippet unless\n\ |
||
45 | unless (${1}) {\n\ |
||
46 | ${2:# body...}\n\ |
||
47 | }\n\ |
||
48 | # Unless conditional One-line\n\ |
||
49 | snippet xunless\n\ |
||
50 | ${1:expression} unless ${2:condition};${3}\n\ |
||
51 | # Try/Except\n\ |
||
52 | snippet eval\n\ |
||
53 | local $@;\n\ |
||
54 | eval {\n\ |
||
55 | ${1:# do something risky...}\n\ |
||
56 | };\n\ |
||
57 | if (my $e = $@) {\n\ |
||
58 | ${2:# handle failure...}\n\ |
||
59 | }\n\ |
||
60 | # While Loop\n\ |
||
61 | snippet wh\n\ |
||
62 | while (${1}) {\n\ |
||
63 | ${2:# body...}\n\ |
||
64 | }\n\ |
||
65 | # While Loop One-line\n\ |
||
66 | snippet xwh\n\ |
||
67 | ${1:expression} while ${2:condition};${3}\n\ |
||
68 | # C-style For Loop\n\ |
||
69 | snippet cfor\n\ |
||
70 | for (my $${2:var} = 0; $$2 < ${1:count}; $$2${3:++}) {\n\ |
||
71 | ${4:# body...}\n\ |
||
72 | }\n\ |
||
73 | # For loop one-line\n\ |
||
74 | snippet xfor\n\ |
||
75 | ${1:expression} for @${2:array};${3}\n\ |
||
76 | # Foreach Loop\n\ |
||
77 | snippet for\n\ |
||
78 | foreach my $${1:x} (@${2:array}) {\n\ |
||
79 | ${3:# body...}\n\ |
||
80 | }\n\ |
||
81 | # Foreach Loop One-line\n\ |
||
82 | snippet fore\n\ |
||
83 | ${1:expression} foreach @${2:array};${3}\n\ |
||
84 | # Package\n\ |
||
85 | snippet package\n\ |
||
86 | package ${1:`substitute(Filename('', 'Page Title'), '^.', '\\u&', '')`};\n\ |
||
87 | \n\ |
||
88 | ${2}\n\ |
||
89 | \n\ |
||
90 | 1;\n\ |
||
91 | \n\ |
||
92 | __END__\n\ |
||
93 | # Package syntax perl >= 5.14\n\ |
||
94 | snippet packagev514\n\ |
||
95 | package ${1:`substitute(Filename('', 'Page Title'), '^.', '\\u&', '')`} ${2:0.99};\n\ |
||
96 | \n\ |
||
97 | ${3}\n\ |
||
98 | \n\ |
||
99 | 1;\n\ |
||
100 | \n\ |
||
101 | __END__\n\ |
||
102 | #moose\n\ |
||
103 | snippet moose\n\ |
||
104 | use Moose;\n\ |
||
105 | use namespace::autoclean;\n\ |
||
106 | ${1:#}BEGIN {extends '${2:ParentClass}'};\n\ |
||
107 | \n\ |
||
108 | ${3}\n\ |
||
109 | # parent\n\ |
||
110 | snippet parent\n\ |
||
111 | use parent qw(${1:Parent Class});\n\ |
||
112 | # Read File\n\ |
||
113 | snippet slurp\n\ |
||
114 | my $${1:var} = do { local $/; open my $file, '<', \"${2:file}\"; <$file> };\n\ |
||
115 | ${3}\n\ |
||
116 | # strict warnings\n\ |
||
117 | snippet strwar\n\ |
||
118 | use strict;\n\ |
||
119 | use warnings;\n\ |
||
120 | # older versioning with perlcritic bypass\n\ |
||
121 | snippet vers\n\ |
||
122 | ## no critic\n\ |
||
123 | our $VERSION = '${1:version}';\n\ |
||
124 | eval $VERSION;\n\ |
||
125 | ## use critic\n\ |
||
126 | # new 'switch' like feature\n\ |
||
127 | snippet switch\n\ |
||
128 | use feature 'switch';\n\ |
||
129 | \n\ |
||
130 | # Anonymous subroutine\n\ |
||
131 | snippet asub\n\ |
||
132 | sub {\n\ |
||
133 | ${1:# body }\n\ |
||
134 | }\n\ |
||
135 | \n\ |
||
136 | \n\ |
||
137 | \n\ |
||
138 | # Begin block\n\ |
||
139 | snippet begin\n\ |
||
140 | BEGIN {\n\ |
||
141 | ${1:# begin body}\n\ |
||
142 | }\n\ |
||
143 | \n\ |
||
144 | # call package function with some parameter\n\ |
||
145 | snippet pkgmv\n\ |
||
146 | __PACKAGE__->${1:package_method}(${2:var})\n\ |
||
147 | \n\ |
||
148 | # call package function without a parameter\n\ |
||
149 | snippet pkgm\n\ |
||
150 | __PACKAGE__->${1:package_method}()\n\ |
||
151 | \n\ |
||
152 | # call package \"get_\" function without a parameter\n\ |
||
153 | snippet pkget\n\ |
||
154 | __PACKAGE__->get_${1:package_method}()\n\ |
||
155 | \n\ |
||
156 | # call package function with a parameter\n\ |
||
157 | snippet pkgetv\n\ |
||
158 | __PACKAGE__->get_${1:package_method}(${2:var})\n\ |
||
159 | \n\ |
||
160 | # complex regex\n\ |
||
161 | snippet qrx\n\ |
||
162 | qr/\n\ |
||
163 | ${1:regex}\n\ |
||
164 | /xms\n\ |
||
165 | \n\ |
||
166 | #simpler regex\n\ |
||
167 | snippet qr/\n\ |
||
168 | qr/${1:regex}/x\n\ |
||
169 | \n\ |
||
170 | #given\n\ |
||
171 | snippet given\n\ |
||
172 | given ($${1:var}) {\n\ |
||
173 | ${2:# cases}\n\ |
||
174 | ${3:# default}\n\ |
||
175 | }\n\ |
||
176 | \n\ |
||
177 | # switch-like case\n\ |
||
178 | snippet when\n\ |
||
179 | when (${1:case}) {\n\ |
||
180 | ${2:# body}\n\ |
||
181 | }\n\ |
||
182 | \n\ |
||
183 | # hash slice\n\ |
||
184 | snippet hslice\n\ |
||
185 | @{ ${1:hash} }{ ${2:array} }\n\ |
||
186 | \n\ |
||
187 | \n\ |
||
188 | # map\n\ |
||
189 | snippet map\n\ |
||
190 | map { ${2: body } } ${1: @array } ;\n\ |
||
191 | \n\ |
||
192 | \n\ |
||
193 | \n\ |
||
194 | # Pod stub\n\ |
||
195 | snippet ppod\n\ |
||
196 | =head1 NAME\n\ |
||
197 | \n\ |
||
198 | ${1:ClassName} - ${2:ShortDesc}\n\ |
||
199 | \n\ |
||
200 | =head1 SYNOPSIS\n\ |
||
201 | \n\ |
||
202 | use $1;\n\ |
||
203 | \n\ |
||
204 | ${3:# synopsis...}\n\ |
||
205 | \n\ |
||
206 | =head1 DESCRIPTION\n\ |
||
207 | \n\ |
||
208 | ${4:# longer description...}\n\ |
||
209 | \n\ |
||
210 | \n\ |
||
211 | =head1 INTERFACE\n\ |
||
212 | \n\ |
||
213 | \n\ |
||
214 | =head1 DEPENDENCIES\n\ |
||
215 | \n\ |
||
216 | \n\ |
||
217 | =head1 SEE ALSO\n\ |
||
218 | \n\ |
||
219 | \n\ |
||
220 | # Heading for a subroutine stub\n\ |
||
221 | snippet psub\n\ |
||
222 | =head2 ${1:MethodName}\n\ |
||
223 | \n\ |
||
224 | ${2:Summary....}\n\ |
||
225 | \n\ |
||
226 | # Heading for inline subroutine pod\n\ |
||
227 | snippet psubi\n\ |
||
228 | =head2 ${1:MethodName}\n\ |
||
229 | \n\ |
||
230 | ${2:Summary...}\n\ |
||
231 | \n\ |
||
232 | \n\ |
||
233 | =cut\n\ |
||
234 | # inline documented subroutine\n\ |
||
235 | snippet subpod\n\ |
||
236 | =head2 $1\n\ |
||
237 | \n\ |
||
238 | Summary of $1\n\ |
||
239 | \n\ |
||
240 | =cut\n\ |
||
241 | \n\ |
||
242 | sub ${1:subroutine_name} {\n\ |
||
243 | ${2:# body...}\n\ |
||
244 | }\n\ |
||
245 | # Subroutine signature\n\ |
||
246 | snippet parg\n\ |
||
247 | =over 2\n\ |
||
248 | \n\ |
||
249 | =item\n\ |
||
250 | Arguments\n\ |
||
251 | \n\ |
||
252 | \n\ |
||
253 | =over 3\n\ |
||
254 | \n\ |
||
255 | =item\n\ |
||
256 | C<${1:DataStructure}>\n\ |
||
257 | \n\ |
||
258 | ${2:Sample}\n\ |
||
259 | \n\ |
||
260 | \n\ |
||
261 | =back\n\ |
||
262 | \n\ |
||
263 | \n\ |
||
264 | =item\n\ |
||
265 | Return\n\ |
||
266 | \n\ |
||
267 | =over 3\n\ |
||
268 | \n\ |
||
269 | \n\ |
||
270 | =item\n\ |
||
271 | C<${3:...return data}>\n\ |
||
272 | \n\ |
||
273 | \n\ |
||
274 | =back\n\ |
||
275 | \n\ |
||
276 | \n\ |
||
277 | =back\n\ |
||
278 | \n\ |
||
279 | \n\ |
||
280 | \n\ |
||
281 | # Moose has\n\ |
||
282 | snippet has\n\ |
||
283 | has ${1:attribute} => (\n\ |
||
284 | is => '${2:ro|rw}',\n\ |
||
285 | isa => '${3:Str|Int|HashRef|ArrayRef|etc}',\n\ |
||
286 | default => sub {\n\ |
||
287 | ${4:defaultvalue}\n\ |
||
288 | },\n\ |
||
289 | ${5:# other attributes}\n\ |
||
290 | );\n\ |
||
291 | \n\ |
||
292 | \n\ |
||
293 | # override\n\ |
||
294 | snippet override\n\ |
||
295 | override ${1:attribute} => sub {\n\ |
||
296 | ${2:# my $self = shift;};\n\ |
||
297 | ${3:# my ($self, $args) = @_;};\n\ |
||
298 | };\n\ |
||
299 | \n\ |
||
300 | \n\ |
||
301 | # use test classes\n\ |
||
302 | snippet tuse\n\ |
||
303 | use Test::More;\n\ |
||
304 | use Test::Deep; # (); # uncomment to stop prototype errors\n\ |
||
305 | use Test::Exception;\n\ |
||
306 | \n\ |
||
307 | # local test lib\n\ |
||
308 | snippet tlib\n\ |
||
309 | use lib qw{ ./t/lib };\n\ |
||
310 | \n\ |
||
311 | #test methods\n\ |
||
312 | snippet tmeths\n\ |
||
313 | $ENV{TEST_METHOD} = '${1:regex}';\n\ |
||
314 | \n\ |
||
315 | # runtestclass\n\ |
||
316 | snippet trunner\n\ |
||
317 | use ${1:test_class};\n\ |
||
318 | $1->runtests();\n\ |
||
319 | \n\ |
||
320 | # Test::Class-style test\n\ |
||
321 | snippet tsub\n\ |
||
322 | sub t${1:number}_${2:test_case} :Test(${3:num_of_tests}) {\n\ |
||
323 | my $self = shift;\n\ |
||
324 | ${4:# body}\n\ |
||
325 | \n\ |
||
326 | }\n\ |
||
327 | \n\ |
||
328 | # Test::Routine-style test\n\ |
||
329 | snippet trsub\n\ |
||
330 | test ${1:test_name} => { description => '${2:Description of test.}'} => sub {\n\ |
||
331 | my ($self) = @_;\n\ |
||
332 | ${3:# test code}\n\ |
||
333 | };\n\ |
||
334 | \n\ |
||
335 | #prep test method\n\ |
||
336 | snippet tprep\n\ |
||
337 | sub prep${1:number}_${2:test_case} :Test(startup) {\n\ |
||
338 | my $self = shift;\n\ |
||
339 | ${4:# body}\n\ |
||
340 | }\n\ |
||
341 | \n\ |
||
342 | # cause failures to print stack trace\n\ |
||
343 | snippet debug_trace\n\ |
||
344 | use Carp; # 'verbose';\n\ |
||
345 | # cloak \"die\"\n\ |
||
346 | # warn \"warning\"\n\ |
||
347 | $SIG{'__DIE__'} = sub {\n\ |
||
348 | require Carp; Carp::confess\n\ |
||
349 | };\n\ |
||
350 | \n\ |
||
351 | "; |
||
352 | exports.scope = "perl"; |
||
353 | |||
354 | }); |