erlang.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. ace.define("ace/snippets/erlang",[], function(require, exports, module) {
  2. "use strict";
  3. exports.snippetText = "# module and export all\n\
  4. snippet mod\n\
  5. -module(${1:`Filename('', 'my')`}).\n\
  6. \n\
  7. -compile([export_all]).\n\
  8. \n\
  9. start() ->\n\
  10. ${2}\n\
  11. \n\
  12. stop() ->\n\
  13. ok.\n\
  14. # define directive\n\
  15. snippet def\n\
  16. -define(${1:macro}, ${2:body}).${3}\n\
  17. # export directive\n\
  18. snippet exp\n\
  19. -export([${1:function}/${2:arity}]).\n\
  20. # include directive\n\
  21. snippet inc\n\
  22. -include(\"${1:file}\").${2}\n\
  23. # behavior directive\n\
  24. snippet beh\n\
  25. -behaviour(${1:behaviour}).${2}\n\
  26. # if expression\n\
  27. snippet if\n\
  28. if\n\
  29. ${1:guard} ->\n\
  30. ${2:body}\n\
  31. end\n\
  32. # case expression\n\
  33. snippet case\n\
  34. case ${1:expression} of\n\
  35. ${2:pattern} ->\n\
  36. ${3:body};\n\
  37. end\n\
  38. # anonymous function\n\
  39. snippet fun\n\
  40. fun (${1:Parameters}) -> ${2:body} end${3}\n\
  41. # try...catch\n\
  42. snippet try\n\
  43. try\n\
  44. ${1}\n\
  45. catch\n\
  46. ${2:_:_} -> ${3:got_some_exception}\n\
  47. end\n\
  48. # record directive\n\
  49. snippet rec\n\
  50. -record(${1:record}, {\n\
  51. ${2:field}=${3:value}}).${4}\n\
  52. # todo comment\n\
  53. snippet todo\n\
  54. %% TODO: ${1}\n\
  55. ## Snippets below (starting with '%') are in EDoc format.\n\
  56. ## See http://www.erlang.org/doc/apps/edoc/chapter.html#id56887 for more details\n\
  57. # doc comment\n\
  58. snippet %d\n\
  59. %% @doc ${1}\n\
  60. # end of doc comment\n\
  61. snippet %e\n\
  62. %% @end\n\
  63. # specification comment\n\
  64. snippet %s\n\
  65. %% @spec ${1}\n\
  66. # private function marker\n\
  67. snippet %p\n\
  68. %% @private\n\
  69. # OTP application\n\
  70. snippet application\n\
  71. -module(${1:`Filename('', 'my')`}).\n\
  72. \n\
  73. -behaviour(application).\n\
  74. \n\
  75. -export([start/2, stop/1]).\n\
  76. \n\
  77. start(_Type, _StartArgs) ->\n\
  78. case ${2:root_supervisor}:start_link() of\n\
  79. {ok, Pid} ->\n\
  80. {ok, Pid};\n\
  81. Other ->\n\
  82. {error, Other}\n\
  83. end.\n\
  84. \n\
  85. stop(_State) ->\n\
  86. ok. \n\
  87. # OTP supervisor\n\
  88. snippet supervisor\n\
  89. -module(${1:`Filename('', 'my')`}).\n\
  90. \n\
  91. -behaviour(supervisor).\n\
  92. \n\
  93. %% API\n\
  94. -export([start_link/0]).\n\
  95. \n\
  96. %% Supervisor callbacks\n\
  97. -export([init/1]).\n\
  98. \n\
  99. -define(SERVER, ?MODULE).\n\
  100. \n\
  101. start_link() ->\n\
  102. supervisor:start_link({local, ?SERVER}, ?MODULE, []).\n\
  103. \n\
  104. init([]) ->\n\
  105. Server = {${2:my_server}, {$2, start_link, []},\n\
  106. permanent, 2000, worker, [$2]},\n\
  107. Children = [Server],\n\
  108. RestartStrategy = {one_for_one, 0, 1},\n\
  109. {ok, {RestartStrategy, Children}}.\n\
  110. # OTP gen_server\n\
  111. snippet gen_server\n\
  112. -module(${1:`Filename('', 'my')`}).\n\
  113. \n\
  114. -behaviour(gen_server).\n\
  115. \n\
  116. %% API\n\
  117. -export([\n\
  118. start_link/0\n\
  119. ]).\n\
  120. \n\
  121. %% gen_server callbacks\n\
  122. -export([init/1, handle_call/3, handle_cast/2, handle_info/2,\n\
  123. terminate/2, code_change/3]).\n\
  124. \n\
  125. -define(SERVER, ?MODULE).\n\
  126. \n\
  127. -record(state, {}).\n\
  128. \n\
  129. %%%===================================================================\n\
  130. %%% API\n\
  131. %%%===================================================================\n\
  132. \n\
  133. start_link() ->\n\
  134. gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).\n\
  135. \n\
  136. %%%===================================================================\n\
  137. %%% gen_server callbacks\n\
  138. %%%===================================================================\n\
  139. \n\
  140. init([]) ->\n\
  141. {ok, #state{}}.\n\
  142. \n\
  143. handle_call(_Request, _From, State) ->\n\
  144. Reply = ok,\n\
  145. {reply, Reply, State}.\n\
  146. \n\
  147. handle_cast(_Msg, State) ->\n\
  148. {noreply, State}.\n\
  149. \n\
  150. handle_info(_Info, State) ->\n\
  151. {noreply, State}.\n\
  152. \n\
  153. terminate(_Reason, _State) ->\n\
  154. ok.\n\
  155. \n\
  156. code_change(_OldVsn, State, _Extra) ->\n\
  157. {ok, State}.\n\
  158. \n\
  159. %%%===================================================================\n\
  160. %%% Internal functions\n\
  161. %%%===================================================================\n\
  162. \n\
  163. ";
  164. exports.scope = "erlang";
  165. });
  166. (function() {
  167. ace.require(["ace/snippets/erlang"], function(m) {
  168. if (typeof module == "object" && typeof exports == "object" && module) {
  169. module.exports = m;
  170. }
  171. });
  172. })();