Skip to content

Commit deda205

Browse files
Merge pull request #493 from intersystems-community/solon-snippets
Solon snippets
2 parents dbfc345 + c7dd41f commit deda205

File tree

2 files changed

+76
-45
lines changed

2 files changed

+76
-45
lines changed

snippets/objectscript-class.json

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,32 @@
55
},
66
"Class Definition with super": {
77
"prefix": "Class",
8-
"body": ["Class $1 Extends ${2:%Persistent}", "{", "$0", "}"]
8+
"body": ["Class $1 Extends ${2|%Persistent,%SerialObject,%RegisteredObject|}", "{", "$0", "}"]
99
},
1010
"ClassMethod definition": {
11-
"prefix": "ClassMethod",
12-
"body": ["ClassMethod $1($2) As ${3:%Status}", "{", "\t$0", "}"]
11+
"prefix": "ClassMethod",
12+
"body": ["ClassMethod $1($2) As ${3:%Status}", "{", "\tset $4 = \\$\\$\\$OK", "\t$0", "\treturn $4","}"]
1313
},
1414
"Method definition": {
15-
"prefix": "Method",
16-
"body": ["Method $1($2) As ${3:%Status}", "{", "\t$0", "}"]
15+
"prefix": "Method",
16+
"body": ["Method $1($2) As ${3:%Status}", "{", "\tset $4 = \\$\\$\\$OK", "\t$0", "\treturn $4", "}"]
1717
},
1818
"Property": {
19-
"prefix": "property",
19+
"prefix": "Property",
2020
"body": "Property $1 As ${2:%String};"
2121
},
22+
"Unique Property": {
23+
"prefix": ["Unique", "Property"],
24+
"body": ["Property $1 As ${2:%String};", "", "Index $1Index On $1 [Unique];"]
25+
},
26+
"Always-Computed Property": {
27+
"prefix": ["Computed", "Property"],
28+
"body" : ["Property $1 As ${2:%String} [Calculated, SqlComputed, SqlComputeCode =", "{set {$1} = {$3}}];"]
29+
},
30+
"Date/Time Property": {
31+
"prefix": ["Date", "Time", "Property"],
32+
"body" : ["Property $1 as ${2|%Date,%Time|}(MINVAL = $3, MAXVAL = $4);"]
33+
},
2234
"Parameter": {
2335
"prefix": "Parameter",
2436
"body": "Parameter $1 = \"$0\";"
@@ -28,34 +40,34 @@
2840
"body": "Index $1 On ${2:Name};"
2941
},
3042
"Unique Index": {
31-
"prefix": "Index",
32-
"body": "Index $1 On ${2:property} [Unique];",
33-
"description": "Unique Index"
34-
},
35-
"Query": {
36-
"prefix":["Query"],
37-
"body":["Query $1($2) As %SQLQuery [ SqlProc ]","{","\t$3","}"],
38-
"description": "Based on SQL statement"
39-
},
40-
"Trigger": {
41-
"prefix": "Trigger",
42-
"body": [
43+
"prefix": "Index",
44+
"body": "Index $1 On ${2:property} [Unique];",
45+
"description": "Unique Index"
46+
},
47+
"Query": {
48+
"prefix":["Query"],
49+
"body":["Query $1($2) As %SQLQuery [ SqlProc ]","{","\tSELECT $3", "\tFROM $4", "\tWHERE $5", "\tORDER BY $6", "}"],
50+
"description": "SQL statement"
51+
},
52+
"Trigger": {
53+
"prefix": "Trigger",
54+
"body": [
4355
"Trigger $1 [Event=${2|INSERT,UPDATE,DELETE|}, Time=${3|BEFORE,AFTER|}, Foreach=${4|row/object,row,statement|}]",
4456
"{",
4557
"\t$5",
4658
"}"
4759
],
48-
"description": "Trigger"
49-
},
50-
"ForeignKey": {
51-
"prefix": "Foreignkey",
52-
"body": "ForeignKey $1 (${2:property}) References ${3:referencedClass}(${4:refIndex});",
53-
"description": "ForeignKey"
54-
},
55-
"Relationship": {
56-
"prefix": ["Relationship"],
57-
"body": "Relationship $1 As ${2:classname} [ Cardinality = ${3|one,many,parent,children|}, Inverse = ${4:correspondingProperty} ];",
58-
"description": "Relationship"
60+
"description": "Trigger"
61+
},
62+
"ForeignKey": {
63+
"prefix": "Foreignkey",
64+
"body": "ForeignKey $1 (${2:property}) References ${3:referencedClass}(${4:refIndex});",
65+
"description": "ForeignKey"
66+
},
67+
"Relationship": {
68+
"prefix": ["Relationship"],
69+
"body": "Relationship $1 As ${2:classname} [ Cardinality = ${3|one,many,parent,children|}, Inverse = ${4:correspondingProperty} ];",
70+
"description": "Relationship"
5971
},
6072
"BusinessService": {
6173
"prefix": ["BusinessService","Interoperability"],

snippets/objectscript.json

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,43 @@
11
{
2-
"ForOrder": {
3-
"prefix": ["For"],
4-
"body": [
2+
"ForOrder": {
3+
"prefix": ["For"],
4+
"body": [
55
"Set ${1:key} = \"\"",
66
"For {",
77
"\tSet ${1:key} = \\$ORDER(${2:array}(${1:key}))",
88
"\tQuit:${1:key}=\"\"",
99
"\t$3 // process ${2:array}(${1:key})",
1010
"}"
11-
],
12-
"description": "Looping Array with $Order"
13-
},
14-
"SQL Statement": {
15-
"prefix": ["sql"],
16-
"body": [
17-
"Set rs = ##class(%SQL.Statement).%ExecDirect(,\"SELECT * FROM\")",
18-
"While rs.%Next() {",
19-
"\twrite rs.ID, !",
20-
"}"],
21-
"description": "Prepare and execute SQL Query"
22-
}
23-
11+
],
12+
"description": "Looping Array with $Order"
13+
},
14+
"SQL Statement": {
15+
"prefix": ["sql"],
16+
"body": [
17+
"Set rs = ##class(%SQL.Statement).%ExecDirect(,\"SELECT * FROM\")",
18+
"While rs.%Next() {",
19+
"\twrite rs.ID, !",
20+
"}"],
21+
"description": "Prepare and execute SQL Query"
22+
},
23+
"For": {
24+
"prefix": ["For"],
25+
"body": ["for $1 = $2:$3:$4 {", "\t$0", "}"],
26+
"description": "Typical for loop"
27+
},
28+
"For Each": {
29+
"prefix": ["For"],
30+
"body": ["for $1 = \"$2\",\"$3\",\"$4\" {", "\t$0", "}"],
31+
"description": "Loop through list of values"
32+
},
33+
"Do While": {
34+
"prefix": ["Do", "While"],
35+
"body": ["do {", "\t$0", "} while ($1)"],
36+
"description": "Do While loop"
37+
},
38+
"While": {
39+
"prefix": ["While"],
40+
"body": ["while ($1) {", "\t$0", "}"],
41+
"description": "While loop"
42+
}
2443
}

0 commit comments

Comments
 (0)