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