Skip to content

Commit d801e63

Browse files
Merge pull request #547 from gjsjohnmurray/fix-546
Tidy up and improve snippet definitions, inc fix for #546
2 parents 9c4b1a1 + 2dbf05e commit d801e63

File tree

2 files changed

+244
-120
lines changed

2 files changed

+244
-120
lines changed

snippets/objectscript-class.json

Lines changed: 201 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,161 +1,260 @@
11
{
2-
"Class Definition without super": {
2+
"Class definition without superclass": {
33
"prefix": "Class",
4-
"body": ["Class $1", "{", "$0", "}"]
4+
"body": [
5+
"/// ${1:Description}",
6+
"Class ${2:PackageName.ClassName}",
7+
"{",
8+
"$0",
9+
"}"
10+
]
511
},
6-
"Class Definition with one superclass": {
12+
"Class definition with one superclass": {
713
"prefix": "Class",
8-
"body": ["Class $1 Extends ${2|%Persistent,%SerialObject,%RegisteredObject|}", "{", "$0", "}"]
14+
"body": [
15+
"/// ${1:Description}",
16+
"Class ${2:PackageName.ClassName} Extends ${3|%Persistent,%SerialObject,%RegisteredObject|}",
17+
"{",
18+
"$0",
19+
"}"
20+
]
921
},
10-
"Class Definition with multiple superclasses": {
11-
"prefix": "Class",
12-
"body": ["Class $1 Extends (${2|%Persistent,%SerialObject,%RegisteredObject|}, $3)", "{", "$0", "}"]
22+
"Class definition with multiple superclasses": {
23+
"prefix": "Class",
24+
"body": [
25+
"/// ${1:Description}",
26+
"Class ${2:PackageName.ClassName} Extends (${3|%Persistent,%SerialObject,%RegisteredObject|}, ${4:%JSON.Adaptor}, ${5:%XML.Adaptor})",
27+
"{",
28+
"$0",
29+
"}"
30+
]
1331
},
1432
"ClassMethod definition": {
15-
"prefix": "ClassMethod",
16-
"body": ["ClassMethod $1($2) As ${3:%Status}", "{", "\tset $4 = \\$\\$\\$OK", "\t$0", "\treturn $4","}"]
33+
"prefix": "ClassMethod",
34+
"body": [
35+
"/// ${1:Description}",
36+
"ClassMethod ${2:MethodName}($3) As ${4:%Status}",
37+
"{",
38+
"\tSet ${5:sc} = \\$\\$\\$OK",
39+
"\t${0:// do something}",
40+
"\tReturn $5",
41+
"}"
42+
]
1743
},
1844
"Method definition": {
19-
"prefix": "Method",
20-
"body": ["Method $1($2) As ${3:%Status}", "{", "\tset $4 = \\$\\$\\$OK", "\t$0", "\treturn $4", "}"]
45+
"prefix": "Method",
46+
"body": [
47+
"/// ${1:Description}",
48+
"Method ${2:MethodName}($3) As ${4:%Status}",
49+
"{",
50+
"\tSet ${5:sc} = \\$\\$\\$OK",
51+
"\t${0:// do something}",
52+
"\tReturn $5",
53+
"}"
54+
]
2155
},
2256
"Property": {
2357
"prefix": "Property",
24-
"body": "Property $1 As ${2:%String};"
58+
"body": [
59+
"/// ${1:Description}",
60+
"Property ${2:PropertyName} As ${3:%String};"
61+
]
2562
},
2663
"Projection": {
2764
"prefix": "Projection",
28-
"body": "Projection $1 As $2;"
65+
"body": [
66+
"/// ${1:Description}",
67+
"Projection ${2:ProjectionName} As ${3:PackageName.ProjectionClassName};"
68+
]
2969
},
3070
"Unique Property": {
31-
"prefix": ["Unique", "Property"],
32-
"body": ["Property $1 As ${2:%String};", "", "Index $1Index On $1 [Unique];"]
71+
"prefix": ["Unique", "Property"],
72+
"body": [
73+
"/// ${1:Description}",
74+
"Property ${2:PropertyName} As ${3:%String};",
75+
"",
76+
"Index $2Index On $2 [Unique];"
77+
]
3378
},
3479
"Always-Computed Property": {
35-
"prefix": ["Computed", "Property"],
36-
"body" : ["Property $1 As ${2:%String} [Calculated, SqlComputed, SqlComputeCode =", "{set {$1} = {$3}}];"]
80+
"prefix": ["Computed", "Property"],
81+
"body" : [
82+
"/// ${1:Description}",
83+
"Property ${2:PropertyName} As ${3:%String} [Calculated, SqlComputed, SqlComputeCode =",
84+
"\t{Set {$2} = {${4:expression}}}",
85+
"];"
86+
]
3787
},
3888
"Date/Time Property": {
39-
"prefix": ["Date", "Time", "Property"],
40-
"body" : ["Property $1 as ${2|%Date,%Time|}(MINVAL = $3, MAXVAL = $4);"]
89+
"prefix": ["Date", "Time", "Property"],
90+
"body" : [
91+
"/// ${1:Description}",
92+
"Property ${2:PropertyName} As ${3|%Date,%Time|}(MINVAL = $4, MAXVAL = $5);"
93+
]
4194
},
4295
"Parameter": {
4396
"prefix": "Parameter",
44-
"body": "Parameter $1 = \"$0\";"
97+
"body": [
98+
"/// ${1:Description}",
99+
"Parameter ${2:PARAMETERNAME} = \"$0\";"
100+
]
45101
},
46102
"Index": {
47103
"prefix": "Index",
48-
"body": "Index $1 On ${2:Name};"
104+
"body": [
105+
"/// ${1:Description}",
106+
"Index ${2:IndexName} On ${3:property};"
107+
]
49108
},
50109
"Unique Index": {
51110
"prefix": "Index",
52-
"body": "Index $1 On ${2:property} [Unique];",
111+
"body": [
112+
"/// ${1:Description}",
113+
"Index ${2:IndexName} On ${3:property} [Unique];"
114+
],
53115
"description": "Unique Index"
54116
},
55117
"Query": {
56118
"prefix":["Query"],
57-
"body":["Query $1($2) As %SQLQuery [ SqlProc ]","{","\tSELECT $3", "\tFROM $4", "\tWHERE $5", "\tORDER BY $6", "}"],
119+
"body":[
120+
"/// ${1:Description}",
121+
"Query ${2:QueryName}($3) As %SQLQuery [ SqlProc ]",
122+
"{",
123+
"\tSELECT ${4:select-items}",
124+
"\tFROM ${5:table-refs}",
125+
"\tWHERE ${6:condition-expression}",
126+
"\tORDER BY ${7:ordering-items}",
127+
"}"
128+
],
58129
"description": "SQL statement"
59130
},
60131
"Trigger": {
61132
"prefix": "Trigger",
62133
"body": [
63-
"Trigger $1 [Event=${2|INSERT,UPDATE,DELETE|}, Time=${3|BEFORE,AFTER|}, Foreach=${4|row/object,row,statement|}]",
64-
"{",
65-
"\t$5",
66-
"}"
67-
],
134+
"/// ${1:Description}",
135+
"Trigger ${2:TriggerName} [Event=${3|INSERT,UPDATE,DELETE|}, Time=${4|BEFORE,AFTER|}, Foreach=${5|row/object,row,statement|}]",
136+
"{",
137+
"\t${0:// do something}",
138+
"}"
139+
],
68140
"description": "Trigger"
69141
},
70142
"ForeignKey": {
71-
"prefix": "Foreignkey",
72-
"body": "ForeignKey $1 (${2:property}) References ${3:referencedClass}(${4:refIndex});",
143+
"prefix": "ForeignKey",
144+
"body": [
145+
"/// ${1:Description}",
146+
"ForeignKey ${2:ForeignKeyName}(${3:property}) References ${4:referencedClass}(${5:refIndex});"
147+
],
73148
"description": "ForeignKey"
74149
},
75150
"Relationship": {
76151
"prefix": ["Relationship"],
77-
"body": "Relationship $1 As ${2:classname} [ Cardinality = ${3|one,many,parent,children|}, Inverse = ${4:correspondingProperty} ];",
152+
"body": [
153+
"/// ${1:Description}",
154+
"Relationship ${2:RelationshipName} As ${3:classname} [ Cardinality = ${4|one,many,parent,children|}, Inverse = ${5:correspondingProperty} ];"
155+
],
78156
"description": "Relationship"
79157
},
80158
"XData": {
81159
"prefix": "XData",
82160
"body": [
83-
"XData $1",
161+
"/// ${1:Description}",
162+
"XData ${2:XDataName}",
84163
"{",
85164
"$0",
86165
"}"
87166
],
88167
"description": "XData"
89168
},
90169
"BusinessService": {
91-
"prefix": ["BusinessService","Interoperability","ClassService"],
92-
"body": ["Class ${1:${TM_DIRECTORY/^.+\\/(.*)$/$1/}.$TM_FILENAME_BASE} Extends Ens.BusinessService",
93-
"{\n",
94-
"Property Adapter As ${2:Ens.InboundAdapter};\n",
95-
"Parameter ADAPTER = \"${2:Ens.InboundAdapter}\";\n",
96-
"Method OnProcessInput(pInput As %RegisteredObject, pOutput As %RegisteredObject) As %Status",
97-
"{",
98-
"\t$3",
99-
"\tReturn \\$\\$\\$ERROR(\\$\\$\\$NotImplemented)",
100-
"}",
101-
"}"],
102-
"description": "Business Service Definition"
103-
},
104-
"BusinessOperation": {
105-
"prefix":["BusinessOperation","Interoperability","ClassOperation"],
106-
"body": ["Class ${1:${TM_DIRECTORY/^.+\\/(.*)$/$1/}.$TM_FILENAME_BASE} Extends Ens.BusinessOperation",
107-
"{\n",
108-
"Property Adapter As ${2:Ens.OutboundAdapter};\n",
109-
"Parameter ADAPTER = \"${2:Ens.OutboundAdapter}\";\n",
110-
"Parameter INVOCATION = \"Queue\";\n",
111-
"Method SampleCall(pRequest As ${3:Ens.Request}, Output pResponse As ${4:Ens.Response} ) As %Status",
112-
"{",
113-
"\t$5",
114-
"\tReturn \\$\\$\\$ERROR(\\$\\$\\$NotImplemented)",
115-
"}\n",
116-
"XData MessageMap",
117-
"{",
118-
"<MapItems>",
119-
"\t<MapItem MessageType=\"${3:Ens.Request}\">",
120-
"\t\t<Method>SampleCall</Method>",
121-
"\t</MapItem>",
122-
"</MapItems>",
123-
"}",
124-
"}"],
125-
"description": "Business Operation Definition"
126-
},
127-
"Production": {
128-
"prefix": ["Production","Interoperability","ClassProduction"],
129-
"body": ["Class ${1:${TM_DIRECTORY/^.+\\/(.*)$/$1/}.$TM_FILENAME_BASE} Extends Ens.Production",
130-
"{\n",
131-
"XData ProductionDefinition",
132-
"{",
133-
"\t<Production Name=\"${1:${TM_DIRECTORY/^.+\\/(.*)$/$1/}.$TM_FILENAME_BASE}\">",
134-
"\t\t<ActorPoolSize>2</ActorPoolSize>",
135-
"\t\t<Item ClassName=\"$2\" Name=\"$3\" PoolSize=\"1\"/>",
136-
"\t</Production>",
137-
"}",
138-
"}"],
139-
"description": "Production Definition"
140-
},
141-
"Request": {
142-
"prefix": ["Request","Interoperability","ClassRequest"],
143-
"body": [
144-
"Class ${1:${TM_DIRECTORY/^.+\\/(.*)$/$1/}.$TM_FILENAME_BASE} Extends Ens.Request",
145-
"{",
146-
"\t$0",
147-
"}"
148-
],
149-
"description": "Request Message Definition"
150-
},
151-
"Response": {
152-
"prefix": ["Response","Interoperability","ClassResponse"],
153-
"body": [
154-
"Class ${1:${TM_DIRECTORY/^.+\\/(.*)$/$1/}.$TM_FILENAME_BASE} Extends Ens.Response",
155-
"{",
156-
"\t$0",
157-
"}"
158-
],
159-
"description": "Response Message Definition"
160-
}
170+
"prefix": ["BusinessService","Interoperability","ClassService"],
171+
"body": [
172+
"/// ${1:Description}",
173+
"Class ${2:${TM_DIRECTORY/^.+\\/(.*)$/$1/}.$TM_FILENAME_BASE} Extends Ens.BusinessService",
174+
"{",
175+
"",
176+
"Property Adapter As ${3:Ens.InboundAdapter};",
177+
"",
178+
"Parameter ADAPTER = \"$3\";",
179+
"",
180+
"Method OnProcessInput(pInput As %RegisteredObject, pOutput As %RegisteredObject) As %Status",
181+
"{",
182+
"\t$0",
183+
"\tReturn \\$\\$\\$ERROR(\\$\\$\\$NotImplemented)",
184+
"}",
185+
"}"
186+
],
187+
"description": "Business Service Definition"
188+
},
189+
"BusinessOperation": {
190+
"prefix":["BusinessOperation","Interoperability","ClassOperation"],
191+
"body": [
192+
"/// ${1:Description}",
193+
"Class ${2:${TM_DIRECTORY/^.+\\/(.*)$/$1/}.$TM_FILENAME_BASE} Extends Ens.BusinessOperation",
194+
"{",
195+
"",
196+
"Property Adapter As ${3:Ens.OutboundAdapter};",
197+
"",
198+
"Parameter ADAPTER = \"$3\";",
199+
"",
200+
"Parameter INVOCATION = \"Queue\";",
201+
"",
202+
"Method SampleCall(pRequest As ${4:Ens.Request}, Output pResponse As ${5:Ens.Response} ) As %Status",
203+
"{",
204+
"\t$0",
205+
"\tReturn \\$\\$\\$ERROR(\\$\\$\\$NotImplemented)",
206+
"}",
207+
"",
208+
"XData MessageMap",
209+
"{",
210+
"<MapItems>",
211+
"\t<MapItem MessageType=\"$4\">",
212+
"\t\t<Method>SampleCall</Method>",
213+
"\t</MapItem>",
214+
"</MapItems>",
215+
"}",
216+
"}"
217+
],
218+
"description": "Business Operation Definition"
219+
},
220+
"Production": {
221+
"prefix": ["Production","Interoperability","ClassProduction"],
222+
"body": [
223+
"/// ${1:Description}",
224+
"Class ${2:${TM_DIRECTORY/^.+\\/(.*)$/$1/}.$TM_FILENAME_BASE} Extends Ens.Production",
225+
"{",
226+
"",
227+
"XData ProductionDefinition",
228+
"{",
229+
"\t<Production Name=\"$2\">",
230+
"\t\t<ActorPoolSize>2</ActorPoolSize>",
231+
"\t\t<Item ClassName=\"$3\" Name=\"$4\" PoolSize=\"1\"/>",
232+
"\t</Production>",
233+
"}",
234+
"}"
235+
],
236+
"description": "Production Definition"
237+
},
238+
"Request": {
239+
"prefix": ["Request","Interoperability","ClassRequest"],
240+
"body": [
241+
"/// ${1:Description}",
242+
"Class ${2:${TM_DIRECTORY/^.+\\/(.*)$/$1/}.$TM_FILENAME_BASE} Extends Ens.Request",
243+
"{",
244+
"$0",
245+
"}"
246+
],
247+
"description": "Request Message Definition"
248+
},
249+
"Response": {
250+
"prefix": ["Response","Interoperability","ClassResponse"],
251+
"body": [
252+
"/// ${1:Description}",
253+
"Class ${2:${TM_DIRECTORY/^.+\\/(.*)$/$1/}.$TM_FILENAME_BASE} Extends Ens.Response",
254+
"{",
255+
"$0",
256+
"}"
257+
],
258+
"description": "Response Message Definition"
259+
}
161260
}

0 commit comments

Comments
 (0)