perl.js 6.4 KB

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