Skip to content

Commit 2f11663

Browse files
committed
Tidy up and improve snippet definitions, inc fix for #546
1 parent 752df2f commit 2f11663

File tree

2 files changed

+205
-120
lines changed

2 files changed

+205
-120
lines changed

snippets/objectscript-class.json

+162-102
Original file line numberDiff line numberDiff line change
@@ -1,161 +1,221 @@
11
{
2-
"Class Definition without super": {
2+
"Class definition without superclass": {
33
"prefix": "Class",
4-
"body": ["Class $1", "{", "$0", "}"]
4+
"body": [
5+
"Class ${1:PackageName.ClassName}",
6+
"{",
7+
"$0",
8+
"}"
9+
]
510
},
6-
"Class Definition with one superclass": {
11+
"Class definition with one superclass": {
712
"prefix": "Class",
8-
"body": ["Class $1 Extends ${2|%Persistent,%SerialObject,%RegisteredObject|}", "{", "$0", "}"]
13+
"body": [
14+
"Class ${1:PackageName.ClassName} Extends ${2|%Persistent,%SerialObject,%RegisteredObject|}",
15+
"{",
16+
"$0",
17+
"}"
18+
]
919
},
10-
"Class Definition with multiple superclasses": {
11-
"prefix": "Class",
12-
"body": ["Class $1 Extends (${2|%Persistent,%SerialObject,%RegisteredObject|}, $3)", "{", "$0", "}"]
20+
"Class definition with multiple superclasses": {
21+
"prefix": "Class",
22+
"body": [
23+
"Class ${1:PackageName.ClassName} Extends (${2|%Persistent,%SerialObject,%RegisteredObject|}, ${3:%XML.Adaptor})",
24+
"{",
25+
"$0",
26+
"}"
27+
]
1328
},
1429
"ClassMethod definition": {
15-
"prefix": "ClassMethod",
16-
"body": ["ClassMethod $1($2) As ${3:%Status}", "{", "\tset $4 = \\$\\$\\$OK", "\t$0", "\treturn $4","}"]
30+
"prefix": "ClassMethod",
31+
"body": [
32+
"ClassMethod ${1:MethodName}($2) As ${3:%Status}",
33+
"{",
34+
"\tSet ${4:sc} = \\$\\$\\$OK",
35+
"\t${0:// do something}",
36+
"\tReturn $4",
37+
"}"
38+
]
1739
},
1840
"Method definition": {
19-
"prefix": "Method",
20-
"body": ["Method $1($2) As ${3:%Status}", "{", "\tset $4 = \\$\\$\\$OK", "\t$0", "\treturn $4", "}"]
41+
"prefix": "Method",
42+
"body": [
43+
"Method ${1:MethodName}($2) As ${3:%Status}",
44+
"{",
45+
"\tSet ${4:sc} = \\$\\$\\$OK",
46+
"\t${0:// do something}",
47+
"\tReturn $4",
48+
"}"
49+
]
2150
},
2251
"Property": {
2352
"prefix": "Property",
24-
"body": "Property $1 As ${2:%String};"
53+
"body": "Property ${1:PropertyName} As ${2:%String};"
2554
},
2655
"Projection": {
2756
"prefix": "Projection",
28-
"body": "Projection $1 As $2;"
57+
"body": "Projection ${1:ProjectionName} As ${2:PackageName.ProjectionClassName};"
2958
},
3059
"Unique Property": {
31-
"prefix": ["Unique", "Property"],
32-
"body": ["Property $1 As ${2:%String};", "", "Index $1Index On $1 [Unique];"]
60+
"prefix": ["Unique", "Property"],
61+
"body": [
62+
"Property ${1:PropertyName} As ${2:%String};",
63+
"",
64+
"Index $1Index On $1 [Unique];"
65+
]
3366
},
3467
"Always-Computed Property": {
35-
"prefix": ["Computed", "Property"],
36-
"body" : ["Property $1 As ${2:%String} [Calculated, SqlComputed, SqlComputeCode =", "{set {$1} = {$3}}];"]
68+
"prefix": ["Computed", "Property"],
69+
"body" : [
70+
"Property ${1:PropertyName} As ${2:%String} [Calculated, SqlComputed, SqlComputeCode =",
71+
"\t{Set {$1} = {${3:expression}}}",
72+
"];"
73+
]
3774
},
3875
"Date/Time Property": {
39-
"prefix": ["Date", "Time", "Property"],
40-
"body" : ["Property $1 as ${2|%Date,%Time|}(MINVAL = $3, MAXVAL = $4);"]
76+
"prefix": ["Date", "Time", "Property"],
77+
"body" : ["Property ${1:PropertyName} As ${2|%Date,%Time|}(MINVAL = $3, MAXVAL = $4);"]
4178
},
4279
"Parameter": {
4380
"prefix": "Parameter",
44-
"body": "Parameter $1 = \"$0\";"
81+
"body": "Parameter ${1:PARAMETERNAME} = \"$0\";"
4582
},
4683
"Index": {
4784
"prefix": "Index",
48-
"body": "Index $1 On ${2:Name};"
85+
"body": "Index ${1:IndexName} On ${2:property};"
4986
},
5087
"Unique Index": {
5188
"prefix": "Index",
52-
"body": "Index $1 On ${2:property} [Unique];",
89+
"body": "Index ${1:IndexName} On ${2:property} [Unique];",
5390
"description": "Unique Index"
5491
},
5592
"Query": {
5693
"prefix":["Query"],
57-
"body":["Query $1($2) As %SQLQuery [ SqlProc ]","{","\tSELECT $3", "\tFROM $4", "\tWHERE $5", "\tORDER BY $6", "}"],
94+
"body":[
95+
"Query ${1:QueryName}($2) As %SQLQuery [ SqlProc ]",
96+
"{",
97+
"\tSELECT ${3:select-items}",
98+
"\tFROM ${4:table-refs}",
99+
"\tWHERE ${5:condition-expression}",
100+
"\tORDER BY ${6:ordering-items}",
101+
"}"
102+
],
58103
"description": "SQL statement"
59104
},
60105
"Trigger": {
61106
"prefix": "Trigger",
62107
"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-
],
108+
"Trigger ${1:TriggerName} [Event=${2|INSERT,UPDATE,DELETE|}, Time=${3|BEFORE,AFTER|}, Foreach=${4|row/object,row,statement|}]",
109+
"{",
110+
"\t${0:// do something}",
111+
"}"
112+
],
68113
"description": "Trigger"
69114
},
70115
"ForeignKey": {
71-
"prefix": "Foreignkey",
72-
"body": "ForeignKey $1 (${2:property}) References ${3:referencedClass}(${4:refIndex});",
116+
"prefix": "ForeignKey",
117+
"body": "ForeignKey ${1:ForeignKeyName}(${2:property}) References ${3:referencedClass}(${4:refIndex});",
73118
"description": "ForeignKey"
74119
},
75120
"Relationship": {
76121
"prefix": ["Relationship"],
77-
"body": "Relationship $1 As ${2:classname} [ Cardinality = ${3|one,many,parent,children|}, Inverse = ${4:correspondingProperty} ];",
122+
"body": "Relationship ${1:RelationshipName} As ${2:classname} [ Cardinality = ${3|one,many,parent,children|}, Inverse = ${4:correspondingProperty} ];",
78123
"description": "Relationship"
79124
},
80125
"XData": {
81126
"prefix": "XData",
82127
"body": [
83-
"XData $1",
128+
"XData ${1:XDataName}",
84129
"{",
85130
"$0",
86131
"}"
87132
],
88133
"description": "XData"
89134
},
90135
"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-
}
136+
"prefix": ["BusinessService","Interoperability","ClassService"],
137+
"body": [
138+
"Class ${1:${TM_DIRECTORY/^.+\\/(.*)$/$1/}.$TM_FILENAME_BASE} Extends Ens.BusinessService",
139+
"{",
140+
"",
141+
"Property Adapter As ${2:Ens.InboundAdapter};",
142+
"",
143+
"Parameter ADAPTER = \"$2\";",
144+
"",
145+
"Method OnProcessInput(pInput As %RegisteredObject, pOutput As %RegisteredObject) As %Status",
146+
"{",
147+
"\t$3",
148+
"\tReturn \\$\\$\\$ERROR(\\$\\$\\$NotImplemented)",
149+
"}",
150+
"}"
151+
],
152+
"description": "Business Service Definition"
153+
},
154+
"BusinessOperation": {
155+
"prefix":["BusinessOperation","Interoperability","ClassOperation"],
156+
"body": [
157+
"Class ${1:${TM_DIRECTORY/^.+\\/(.*)$/$1/}.$TM_FILENAME_BASE} Extends Ens.BusinessOperation",
158+
"{",
159+
"",
160+
"Property Adapter As ${2:Ens.OutboundAdapter};",
161+
"",
162+
"Parameter ADAPTER = \"$2\";",
163+
"",
164+
"Parameter INVOCATION = \"Queue\";",
165+
"",
166+
"Method SampleCall(pRequest As ${3:Ens.Request}, Output pResponse As ${4:Ens.Response} ) As %Status",
167+
"{",
168+
"\t$5",
169+
"\tReturn \\$\\$\\$ERROR(\\$\\$\\$NotImplemented)",
170+
"}",
171+
"",
172+
"XData MessageMap",
173+
"{",
174+
"<MapItems>",
175+
"\t<MapItem MessageType=\"$3\">",
176+
"\t\t<Method>SampleCall</Method>",
177+
"\t</MapItem>",
178+
"</MapItems>",
179+
"}",
180+
"}"
181+
],
182+
"description": "Business Operation Definition"
183+
},
184+
"Production": {
185+
"prefix": ["Production","Interoperability","ClassProduction"],
186+
"body": [
187+
"Class ${1:${TM_DIRECTORY/^.+\\/(.*)$/$1/}.$TM_FILENAME_BASE} Extends Ens.Production",
188+
"{",
189+
"",
190+
"XData ProductionDefinition",
191+
"{",
192+
"\t<Production Name=\"$1\">",
193+
"\t\t<ActorPoolSize>2</ActorPoolSize>",
194+
"\t\t<Item ClassName=\"$2\" Name=\"$3\" PoolSize=\"1\"/>",
195+
"\t</Production>",
196+
"}",
197+
"}"
198+
],
199+
"description": "Production Definition"
200+
},
201+
"Request": {
202+
"prefix": ["Request","Interoperability","ClassRequest"],
203+
"body": [
204+
"Class ${1:${TM_DIRECTORY/^.+\\/(.*)$/$1/}.$TM_FILENAME_BASE} Extends Ens.Request",
205+
"{",
206+
"$0",
207+
"}"
208+
],
209+
"description": "Request Message Definition"
210+
},
211+
"Response": {
212+
"prefix": ["Response","Interoperability","ClassResponse"],
213+
"body": [
214+
"Class ${1:${TM_DIRECTORY/^.+\\/(.*)$/$1/}.$TM_FILENAME_BASE} Extends Ens.Response",
215+
"{",
216+
"$0",
217+
"}"
218+
],
219+
"description": "Response Message Definition"
220+
}
161221
}

0 commit comments

Comments
 (0)