Skip to content

Commit c051fae

Browse files
committed
New live template for attributes
1 parent 0dfba49 commit c051fae

1 file changed

Lines changed: 67 additions & 57 deletions

File tree

  • resources/de/halirutan/mathematica/codeinsight/livetemplates

resources/de/halirutan/mathematica/codeinsight/livetemplates/mathematica.xml

Lines changed: 67 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -4,87 +4,87 @@
44
<!-- Localization/scoping constructs -->
55
<template name="blk" description="Block[{vars}, body]" toReformat="true"
66
value="Block[{$VARS$}, $SELECTION$$END$]">
7-
<variable name="VARS" expression="" defaultValue="&quot;vars&quot;" alwaysStopAt="true" />
7+
<variable name="VARS" expression="" defaultValue="&quot;vars&quot;" alwaysStopAt="true"/>
88
<context>
99
<option name="Mathematica" value="true"/>
1010
</context>
1111
</template>
1212

1313
<template name="mdl" description="Module[{vars}, body]" toReformat="true"
1414
value="Module[{$VARS$}, $SELECTION$$END$]">
15-
<variable name="VARS" expression="" defaultValue="&quot;vars&quot;" alwaysStopAt="true" />
15+
<variable name="VARS" expression="" defaultValue="&quot;vars&quot;" alwaysStopAt="true"/>
1616
<context>
1717
<option name="Mathematica" value="true"/>
1818
</context>
1919
</template>
2020

2121
<template name="wth" description="With[{vars}, body]" toReformat="true"
2222
value="With[{$VARS$}, $SELECTION$$END$]">
23-
<variable name="VARS" expression="" defaultValue="&quot;vars&quot;" alwaysStopAt="true" />
24-
<variable name="SELECTION" expression="" defaultValue="&quot;body&quot;" alwaysStopAt="true" />
23+
<variable name="VARS" expression="" defaultValue="&quot;vars&quot;" alwaysStopAt="true"/>
24+
<variable name="SELECTION" expression="" defaultValue="&quot;body&quot;" alwaysStopAt="true"/>
2525
<context>
2626
<option name="Mathematica" value="true"/>
2727
</context>
2828
</template>
2929

30-
<template name="cmpl" description="Compile[{vars}, body]" toReformat="true"
31-
value="Compile[{$VARS$}, $SELECTION$$END$]">
32-
<variable name="VARS" expression="" defaultValue="&quot;{x, _Real}&quot;" alwaysStopAt="true" />
33-
<context>
34-
<option name="Mathematica" value="true"/>
35-
</context>
36-
</template>
30+
<template name="cmpl" description="Compile[{vars}, body]" toReformat="true"
31+
value="Compile[{$VARS$}, $SELECTION$$END$]">
32+
<variable name="VARS" expression="" defaultValue="&quot;{x, _Real}&quot;" alwaysStopAt="true"/>
33+
<context>
34+
<option name="Mathematica" value="true"/>
35+
</context>
36+
</template>
3737

38-
<template name="fnct" description="Function[{vars}, body]" toReformat="true"
39-
value="Function[{$VARS$}, $SELECTION$$END$]">
40-
<variable name="VARS" expression="" defaultValue="&quot;var&quot;" alwaysStopAt="true" />
41-
<context>
42-
<option name="Mathematica" value="true"/>
43-
</context>
44-
</template>
38+
<template name="fnct" description="Function[{vars}, body]" toReformat="true"
39+
value="Function[{$VARS$}, $SELECTION$$END$]">
40+
<variable name="VARS" expression="" defaultValue="&quot;var&quot;" alwaysStopAt="true"/>
41+
<context>
42+
<option name="Mathematica" value="true"/>
43+
</context>
44+
</template>
4545

4646

47-
<!-- Iteration -->
47+
<!-- Iteration -->
4848
<template name="do" description="Do[body, {iter}]" toReformat="true"
4949
value="Do[$SELECTION$$END$, {$ITER$}]">
50-
<variable name="ITER" expression="" defaultValue="&quot;iter&quot;" alwaysStopAt="true" />
50+
<variable name="ITER" expression="" defaultValue="&quot;iter&quot;" alwaysStopAt="true"/>
5151
<context>
5252
<option name="Mathematica" value="true"/>
5353
</context>
5454
</template>
5555

5656
<template name="for" description="For[start, test, inc, body]" toReformat="true"
5757
value="For[$VAR$ = 0, $VAR$ &lt; $MAX$, $VAR$++, $SELECTION$$END$]">
58-
<variable name="VAR" expression="" defaultValue="&quot;i&quot;" alwaysStopAt="true" />
59-
<variable name="MAX" expression="" defaultValue="&quot;max&quot;" alwaysStopAt="true" />
58+
<variable name="VAR" expression="" defaultValue="&quot;i&quot;" alwaysStopAt="true"/>
59+
<variable name="MAX" expression="" defaultValue="&quot;max&quot;" alwaysStopAt="true"/>
6060
<context>
6161
<option name="Mathematica" value="true"/>
6262
</context>
6363
</template>
6464

6565
<template name="tbl" description="Table[body, {var, min, max}]" toReformat="true"
6666
value="Table[$SELECTION$$END$, {$VAR$, $LIMITS$}]">
67-
<variable name="VAR" expression="" defaultValue="&quot;x&quot;" alwaysStopAt="true" />
68-
<variable name="LIMITS" expression="" defaultValue="&quot;min, max, stepSize&quot;" alwaysStopAt="true" />
67+
<variable name="VAR" expression="" defaultValue="&quot;x&quot;" alwaysStopAt="true"/>
68+
<variable name="LIMITS" expression="" defaultValue="&quot;min, max, stepSize&quot;" alwaysStopAt="true"/>
6969
<context>
7070
<option name="Mathematica" value="true"/>
7171
</context>
7272
</template>
7373

7474
<template name="fld" description="Fold[func, firstElement, list]" toReformat="true"
7575
value="Fold[$SELECTION$$END$, $FIRST$, $LIST$]">
76-
<variable name="FIRST" expression="" defaultValue="&quot;x&quot;" alwaysStopAt="true" />
77-
<variable name="LIST" expression="" defaultValue="&quot;list&quot;" alwaysStopAt="true" />
76+
<variable name="FIRST" expression="" defaultValue="&quot;x&quot;" alwaysStopAt="true"/>
77+
<variable name="LIST" expression="" defaultValue="&quot;list&quot;" alwaysStopAt="true"/>
7878
<context>
7979
<option name="Mathematica" value="true"/>
8080
</context>
8181
</template>
8282

8383
<template name="nst" description="Nest[func, expr, n]" toReformat="true"
8484
value="Nest[$FUNC$, $EXPR$, $COUNT$]$END$">
85-
<variable name="FUNC" expression="" defaultValue="&quot;func&quot;" alwaysStopAt="true" />
86-
<variable name="EXPR" expression="" defaultValue="&quot;expr&quot;" alwaysStopAt="true" />
87-
<variable name="COUNT" expression="" defaultValue="&quot;n&quot;" alwaysStopAt="true" />
85+
<variable name="FUNC" expression="" defaultValue="&quot;func&quot;" alwaysStopAt="true"/>
86+
<variable name="EXPR" expression="" defaultValue="&quot;expr&quot;" alwaysStopAt="true"/>
87+
<variable name="COUNT" expression="" defaultValue="&quot;n&quot;" alwaysStopAt="true"/>
8888
<context>
8989
<option name="Mathematica" value="true"/>
9090
</context>
@@ -93,48 +93,48 @@
9393
<!-- Control Flow -->
9494
<template name="if" description="If[cond, then]" toReformat="true"
9595
value="If[$COND$, $SELECTION$$END$]">
96-
<variable name="COND" expression="" defaultValue="&quot;cond&quot;" alwaysStopAt="true" />
96+
<variable name="COND" expression="" defaultValue="&quot;cond&quot;" alwaysStopAt="true"/>
9797
<context>
9898
<option name="Mathematica" value="true"/>
9999
</context>
100100
</template>
101101

102102
<template name="ife" description="If[cond, then, else]" toReformat="true"
103103
value="If[$COND$, $THEN$, $ELSE$]$END$">
104-
<variable name="COND" expression="" defaultValue="&quot;cond&quot;" alwaysStopAt="true" />
105-
<variable name="THEN" expression="" defaultValue="&quot;then&quot;" alwaysStopAt="true" />
106-
<variable name="ELSE" expression="" defaultValue="&quot;else&quot;" alwaysStopAt="true" />
104+
<variable name="COND" expression="" defaultValue="&quot;cond&quot;" alwaysStopAt="true"/>
105+
<variable name="THEN" expression="" defaultValue="&quot;then&quot;" alwaysStopAt="true"/>
106+
<variable name="ELSE" expression="" defaultValue="&quot;else&quot;" alwaysStopAt="true"/>
107107
<context>
108108
<option name="Mathematica" value="true"/>
109109
</context>
110110
</template>
111111

112112
<template name="swtch" description="Switch[expr, form1, value1, form2, value2]" toReformat="true"
113113
value="Switch[$EXPR$, $FORM1$, $VAL1$, $FORM2$, $VAL2$$MORE_ARGS$]$END$">
114-
<variable name="EXPR" expression="" defaultValue="&quot;expr&quot;" alwaysStopAt="true" />
115-
<variable name="FORM1" expression="" defaultValue="&quot;form1&quot;" alwaysStopAt="true" />
116-
<variable name="VAL1" expression="" defaultValue="&quot;value1&quot;" alwaysStopAt="true" />
117-
<variable name="FORM2" expression="" defaultValue="&quot;form2&quot;" alwaysStopAt="true" />
118-
<variable name="VAL2" expression="" defaultValue="&quot;value2&quot;" alwaysStopAt="true" />
119-
<variable name="MORE_ARGS" expression="" defaultValue="" alwaysStopAt="true" />
114+
<variable name="EXPR" expression="" defaultValue="&quot;expr&quot;" alwaysStopAt="true"/>
115+
<variable name="FORM1" expression="" defaultValue="&quot;form1&quot;" alwaysStopAt="true"/>
116+
<variable name="VAL1" expression="" defaultValue="&quot;value1&quot;" alwaysStopAt="true"/>
117+
<variable name="FORM2" expression="" defaultValue="&quot;form2&quot;" alwaysStopAt="true"/>
118+
<variable name="VAL2" expression="" defaultValue="&quot;value2&quot;" alwaysStopAt="true"/>
119+
<variable name="MORE_ARGS" expression="" defaultValue="" alwaysStopAt="true"/>
120120
<context>
121121
<option name="Mathematica" value="true"/>
122122
</context>
123123
</template>
124124

125125
<template name="whch" description="Which[test1, value1, test2, value2]" toReformat="true"
126126
value="Which[$BODY$$END$]">
127-
<variable name="BODY" expression="" defaultValue="&quot;test1, val1, test2, val2&quot;" alwaysStopAt="true" />
127+
<variable name="BODY" expression="" defaultValue="&quot;test1, val1, test2, val2&quot;" alwaysStopAt="true"/>
128128
<context>
129129
<option name="Mathematica" value="true"/>
130130
</context>
131131
</template>
132132

133133
<template name="chck" description="Check[expr, fail, msg]" toReformat="true"
134134
value="Check[$EXPR$, $FAIL$, $MSG$]$END$">
135-
<variable name="EXPR" expression="" defaultValue="&quot;expr&quot;" alwaysStopAt="true" />
136-
<variable name="FAIL" expression="" defaultValue="&quot;fail&quot;" alwaysStopAt="true" />
137-
<variable name="MSG" expression="" defaultValue="&quot;symbol::msg&quot;" alwaysStopAt="true" />
135+
<variable name="EXPR" expression="" defaultValue="&quot;expr&quot;" alwaysStopAt="true"/>
136+
<variable name="FAIL" expression="" defaultValue="&quot;fail&quot;" alwaysStopAt="true"/>
137+
<variable name="MSG" expression="" defaultValue="&quot;symbol::msg&quot;" alwaysStopAt="true"/>
138138
<context>
139139
<option name="Mathematica" value="true"/>
140140
</context>
@@ -143,15 +143,15 @@
143143
<!-- Function calls -->
144144
<template name="pre" description="Prefix selection with f@" toReformat="true"
145145
value="$SYM$@($SELECTION$)$END$">
146-
<variable name="SYM" expression="" defaultValue="" alwaysStopAt="true" />
146+
<variable name="SYM" expression="" defaultValue="" alwaysStopAt="true"/>
147147
<context>
148148
<option name="Mathematica" value="true"/>
149149
</context>
150150
</template>
151151

152152
<template name="pst" description="Postfix selection with //f" toReformat="true"
153153
value="($SELECTION$ // $SYM$)$END$">
154-
<variable name="SYM" expression="" defaultValue="" alwaysStopAt="true" />
154+
<variable name="SYM" expression="" defaultValue="" alwaysStopAt="true"/>
155155
<context>
156156
<option name="Mathematica" value="true"/>
157157
</context>
@@ -170,26 +170,36 @@
170170
<!-- Messages -->
171171
<template name="usg" description="Create usage message" toReformat="true"
172172
value="$SYM$::usage = &quot;$SYM$[$END$]&quot;;">
173-
<variable name="SYM" expression="" defaultValue="&quot;sym&quot;" alwaysStopAt="true" />
173+
<variable name="SYM" expression="" defaultValue="&quot;sym&quot;" alwaysStopAt="true"/>
174+
<context>
175+
<option name="Mathematica" value="true"/>
176+
</context>
177+
</template>
178+
179+
<template name="opt" description="Create options for a symbol" toReformat="true"
180+
value="Options[$SYM$] = { $LHS$ -> $END$}">
181+
<variable name="SYM" expression="" defaultValue="&quot;sym&quot;" alwaysStopAt="true"/>
182+
<variable name="LHS" expression="" defaultValue="&quot;optionName&quot;" alwaysStopAt="true"/>
183+
<variable name="END" expression="" defaultValue="&quot;Automatic&quot;" alwaysStopAt="true"/>
184+
<context>
185+
<option name="Mathematica" value="true"/>
186+
</context>
187+
</template>
188+
189+
<template name="att" description="Create attributes for a symbol" toReformat="true"
190+
value="Attributes[$SYM$] = { $END$}">
191+
<variable name="SYM" expression="" defaultValue="&quot;sym&quot;" alwaysStopAt="true"/>
192+
<variable name="END" expression="" defaultValue="&quot;Flat, HoldAll, Listable, NumericFunction&quot;" alwaysStopAt="true"/>
174193
<context>
175194
<option name="Mathematica" value="true"/>
176195
</context>
177196
</template>
178197

179-
<template name="opt" description="Create options for a symbol" toReformat="true"
180-
value="Options[$SYM$] = { $LHS$ -> $END$}">
181-
<variable name="SYM" expression="" defaultValue="&quot;sym&quot;" alwaysStopAt="true" />
182-
<variable name="LHS" expression="" defaultValue="&quot;optionName&quot;" alwaysStopAt="true" />
183-
<variable name="END" expression="" defaultValue="&quot;Automatic&quot;" alwaysStopAt="true" />
184-
<context>
185-
<option name="Mathematica" value="true"/>
186-
</context>
187-
</template>
188198

189199
<template name="msg" description="Create usage message" toReformat="true"
190200
value="$SYM$::$TAG$ = &quot;$END$&quot;;">
191-
<variable name="SYM" expression="" defaultValue="&quot;sym&quot;" alwaysStopAt="true" />
192-
<variable name="TAG" expression="" defaultValue="&quot;tag&quot;" alwaysStopAt="true" />
201+
<variable name="SYM" expression="" defaultValue="&quot;sym&quot;" alwaysStopAt="true"/>
202+
<variable name="TAG" expression="" defaultValue="&quot;tag&quot;" alwaysStopAt="true"/>
193203
<context>
194204
<option name="Mathematica" value="true"/>
195205
</context>

0 commit comments

Comments
 (0)