Add expression functions with context boundaries

This commit is contained in:
pavel 2026-08-27 23:05:49 +02:00
commit 773c34f3f4
18 changed files with 391 additions and 52 deletions

View file

@ -82,7 +82,7 @@ for (const declaration of [
const prefixes = new Set(Object.values(snippets).map((snippet) => snippet.prefix));
for (const prefix of [
"dataclass", "genericfun", "genericclass", "tablerow", "embed", "coroutinescope", "launch", "async", "enum", "match", "matchvalue", "mapto", "safe", "nonnull", "resultfun", "resultmatch", "defer", "foreach", "sqlfetch",
"dataclass", "exprfun", "withcontext", "genericfun", "genericclass", "tablerow", "embed", "coroutinescope", "launch", "async", "enum", "match", "matchvalue", "mapto", "safe", "nonnull", "resultfun", "resultmatch", "defer", "foreach", "sqlfetch",
"sqlsingle", "sqliterator", "sqlinsertnothing", "sqlinsertupdate", "sqlupdatereturning"
]) {
assert(prefixes.has(prefix), `snippets are missing prefix ${prefix}`);

View file

@ -8,6 +8,16 @@
],
"description": "Gotlin function"
},
"Expression Function": {
"prefix": "exprfun",
"body": ["fun ${1:name}(${2}) = ${3:expression}"],
"description": "Gotlin expression-bodied function"
},
"With Go Context": {
"prefix": "withcontext",
"body": ["withContext(${1:request}.context()) {", " $0", "}"],
"description": "Establish an ambient coroutine context from a Go context"
},
"Main Function": {
"prefix": "main",
"body": [