Add structured coroutines and explicit error handling

This commit is contained in:
pavel 2026-08-27 16:26:40 +02:00
commit fe62e81152
31 changed files with 1701 additions and 325 deletions

View file

@ -52,19 +52,6 @@
"body": ["@embed(\"${1:path/to/file}\") val ${2:name}: ${3:ByteSlice}"],
"description": "Embed a file as a top-level value"
},
"Worker": {
"prefix": "worker",
"body": [
"worker ${1:Name} {",
" var ${2:state}: ${3:Int} = ${4:0}",
"",
" fun ${5:run}() {",
" $0",
" }",
"}"
],
"description": "Stateful Gotlin worker"
},
"Rust-style Enum": {
"prefix": "enum",
"body": [
@ -98,14 +85,50 @@
"body": ["val ${1:target} = ${2:source}.mapTo<${3:Target}>()"],
"description": "Recursively map compatible classes or enums"
},
"Go Block": {
"prefix": "go",
"Nullable Safe Access": {
"prefix": "safe",
"body": ["${1:value}?.${2:field}"],
"description": "Safely access a nullable value"
},
"Non-null Assertion": {
"prefix": "nonnull",
"body": ["${1:value}!!"],
"description": "Assert that a nullable value is non-null"
},
"Result Function": {
"prefix": "resultfun",
"body": [
"go {",
" $0",
"fun ${1:name}(${2}): Result<${3:Value}, Error> {",
" val ${4:value} = ${5:operation}()?",
" return Result::Ok(${4:value})",
"}"
],
"description": "Run a block concurrently"
"description": "Function with Rust-style Result propagation"
},
"Result Match": {
"prefix": "resultmatch",
"body": [
"match (${1:result}) {",
" Result::Ok(${2:value}) -> { $3 }",
" Result::Err(${4:error}) -> { $0 }",
"}"
],
"description": "Match a Result value"
},
"Coroutine Scope": {
"prefix": "coroutinescope",
"body": ["coroutineScope {", " $0", "}"],
"description": "Structured child coroutine scope"
},
"Launch Coroutine": {
"prefix": "launch",
"body": ["launch {", " $0", "}"],
"description": "Launch a structured child coroutine"
},
"Async Coroutine": {
"prefix": "async",
"body": ["val ${1:result} = async<${2:Type}> {", " $0", "}"],
"description": "Start a typed deferred coroutine"
},
"Defer Call": {
"prefix": "defer",
@ -124,7 +147,7 @@
"Typed SQL Fetch": {
"prefix": "sqlfetch",
"body": [
"val ${1:rows}: List<*${2:Row}> = sql.from<${2:Row}>()",
"val ${1:rows}: List<${2:Row}> = sql.from<${2:Row}>()",
" .where { ${3:it.id == id} }",
" .fetch(${4:pool}, ${5:ctx})"
],
@ -133,7 +156,7 @@
"Typed SQL Single": {
"prefix": "sqlsingle",
"body": [
"val ${1:row}: *${2:Row} = sql.from<${2:Row}>()",
"val ${1:row}: ${2:Row} = sql.from<${2:Row}>()",
" .where { ${3:it.id == id} }",
" .single(${4:pool}, ${5:ctx})"
],