{ "Function Definition": { "prefix": "func", "body": [ "func ${1:functionName}(${2:parameters}) {", "\t$0", "}" ], "description": "Create a new function" }, "If Statement": { "prefix": "if", "body": [ "if (${1:condition}) {", "\t$0", "}" ], "description": "Create an if statement" }, "If-Else Statement": { "prefix": "ifelse", "body": [ "if (${1:condition}) {", "\t$2", "} else {", "\t$0", "}" ], "description": "Create an if-else statement" }, "While Loop": { "prefix": "while", "body": [ "while (${1:condition}) {", "\t$0", "}" ], "description": "Create a while loop" }, "For Loop": { "prefix": "for", "body": [ "for (${1:initialization}; ${2:condition}; ${3:increment}) {", "\t$0", "}" ], "description": "Create a for loop" }, "Variable Declaration": { "prefix": "var", "body": [ "var ${1:variableName} = ${2:value};" ], "description": "Declare a variable" }, "Class Declaration": { "prefix": "class", "body": [ "class ${1:ClassName} ${2:extends ${3:Parent}} {", " var ${4:field} = ${5:none};", " func init(${6:args}) {", " this.${4:field} = ${7:value};", " }", " func ${8:method}(${9:params}) {", " $0", " }", "}" ], "description": "Create a class with optional extends, fields, init, and method" }, "Extension Block": { "prefix": "extension", "body": [ "extension ${1:Target} {", " func ${2:method}(${3:params}) {", " $0", " }", "}" ], "description": "Create an extension for a class or builtin (string, array, dict, number, any)" } "Print Statement": { "prefix": "print", "body": [ "print(${1:expression});" ], "description": "Print a value" }, "Assert Statement": { "prefix": "assert", "body": [ "assert(${1:condition}, \"${2:message}\");" ], "description": "Create an assertion" }, "Anonymous Function": { "prefix": "anon", "body": [ "func(${1:parameters}) {", "\t$0", "}" ], "description": "Create an anonymous function" }, "Return Statement": { "prefix": "return", "body": [ "return ${1:value};" ], "description": "Return a value from function" }, "Break Statement": { "prefix": "break", "body": [ "break;" ], "description": "Break out of loop" }, "Continue Statement": { "prefix": "continue", "body": [ "continue;" ], "description": "Continue to next iteration" }, "Comment Block": { "prefix": "comment", "body": [ "/*", " * ${1:comment}", " */" ], "description": "Create a comment block" }, "Test Function": { "prefix": "test", "body": [ "func test${1:TestName}() {", "\tvar result = ${2:testExpression};", "\tassert(result == ${3:expectedValue}, \"${4:test message}\");", "\tprint(\"${1:TestName}: PASS\");", "}" ], "description": "Create a test function" }, "Higher-Order Function": { "prefix": "hof", "body": [ "func ${1:functionName}(${2:callback}) {", "\treturn func(${3:params}) {", "\t\t$0", "\t};", "}" ], "description": "Create a higher-order function" }, "Closure": { "prefix": "closure", "body": [ "func ${1:outerFunction}(${2:param}) {", "\tvar ${3:capturedVar} = ${4:value};", "\treturn func(${5:innerParam}) {", "\t\treturn ${3:capturedVar} + ${5:innerParam};", "\t};", "}" ], "description": "Create a closure" }, "Counter Pattern": { "prefix": "counter", "body": [ "func createCounter() {", "\tvar count = 0;", "\treturn func() {", "\t\tcount = count + 1;", "\t\treturn count;", "\t};", "}" ], "description": "Create a counter function" }, "Loop with Break": { "prefix": "loopbreak", "body": [ "while (${1:condition}) {", "\tif (${2:breakCondition}) {", "\t\tbreak;", "\t}", "\t$0", "}" ], "description": "Create a loop with break condition" }, "Loop with Continue": { "prefix": "loopcontinue", "body": [ "for (${1:initialization}; ${2:condition}; ${3:increment}) {", "\tif (${4:continueCondition}) {", "\t\tcontinue;", "\t}", "\t$0", "}" ], "description": "Create a loop with continue condition" }, "Nested Loop": { "prefix": "nestedloop", "body": [ "for (var i = 0; i < ${1:outerLimit}; i = i + 1) {", "\tfor (var j = 0; j < ${2:innerLimit}; j = j + 1) {", "\t\t$0", "\t}", "}" ], "description": "Create nested loops" }, "Function with Early Return": { "prefix": "earlyreturn", "body": [ "func ${1:functionName}(${2:param}) {", "\tif (${3:condition}) {", "\t\treturn ${4:earlyValue};", "\t}", "\t$0", "\treturn ${5:defaultValue};", "}" ], "description": "Create a function with early return" }, "String Concatenation": { "prefix": "concat", "body": [ "var result = \"${1:first}\" + \"${2:second}\";" ], "description": "Concatenate strings" }, "Number Operations": { "prefix": "math", "body": [ "var result = ${1:expression};" ], "description": "Mathematical expression" }, "Boolean Logic": { "prefix": "bool", "body": [ "var result = ${1:condition} == ${2:value};" ], "description": "Boolean comparison" }, "Type Check": { "prefix": "type", "body": [ "var typeResult = type(${1:expression});" ], "description": "Check type of expression" }, "Array Declaration": { "prefix": "array", "body": [ "var ${1:arrayName} = [${2:element1}, ${3:element2}];" ], "description": "Declare an array" }, "Array Access": { "prefix": "arrayaccess", "body": [ "var element = ${1:arrayName}[${2:index}];" ], "description": "Access array element" }, "Array Assignment": { "prefix": "arrayassign", "body": [ "${1:arrayName}[${2:index}] = ${3:value};" ], "description": "Assign value to array element" }, "Array Length": { "prefix": "len", "body": [ "var length = len(${1:arrayName});" ], "description": "Get array length" }, "Array Push": { "prefix": "push", "body": [ "push(${1:arrayName}, ${2:value});" ], "description": "Add element to array" }, "Array Pop": { "prefix": "pop", "body": [ "var element = pop(${1:arrayName});" ], "description": "Remove and return last element" }, "Random Number": { "prefix": "random", "body": [ "import rand; var randomValue = rand.random();" ], "description": "Generate random number" }, "Sleep": { "prefix": "sleep", "body": [ "sleep(${1:milliseconds});" ], "description": "Sleep for specified milliseconds" }, "Print Raw": { "prefix": "printraw", "body": [ "printRaw(${1:expression});" ], "description": "Print without newline" }, "Eval": { "prefix": "eval", "body": [ "eval(\"${1:code}\");" ], "description": "Evaluate dynamic code" }, "ToString": { "prefix": "tostring", "body": [ "var stringResult = toString(${1:expression});" ], "description": "Convert to string" }, "Test Suite Header": { "prefix": "testsuite", "body": [ "// ========================================", "// ${1:TEST SUITE NAME}", "// ========================================", "// ${2:Description}", "", "print(\"${1:TEST SUITE NAME}\");", "print(\"Running tests...\");", "", "$0", "", "print(\"All tests passed!\");" ], "description": "Create a test suite header" }, "Test Section": { "prefix": "testsection", "body": [ "// ========================================", "// TEST ${1:NUMBER}: ${2:TEST NAME}", "// ========================================", "print(\"\\n--- Test ${1:NUMBER}: ${2:TEST NAME} ---\");", "", "$0", "", "print(\"${2:TEST NAME}: PASS\");" ], "description": "Create a test section" }, "Debug Print": { "prefix": "debug", "body": [ "print(\"DEBUG: ${1:variable} = \" + toString(${1:variable}));" ], "description": "Debug print statement" }, "Error Message": { "prefix": "error", "body": [ "print(\"ERROR: ${1:error message}\");" ], "description": "Error message print" }, "Success Message": { "prefix": "success", "body": [ "print(\"SUCCESS: ${1:success message}\");" ], "description": "Success message print" }, "ToInt": { "prefix": "toint", "body": [ "var intValue = toInt(${1:floatValue});" ], "description": "Convert float to integer" }, "Compound Assignment": { "prefix": "compound", "body": [ "${1:variable} += ${2:value};" ], "description": "Compound assignment operator" }, "Increment": { "prefix": "inc", "body": [ "${1:variable}++;" ], "description": "Increment variable" }, "Decrement": { "prefix": "dec", "body": [ "${1:variable}--;" ], "description": "Decrement variable" }, "Array Increment": { "prefix": "arrayinc", "body": [ "${1:arrayName}[${2:index}]++;" ], "description": "Increment array element" }, "Array Decrement": { "prefix": "arraydec", "body": [ "${1:arrayName}[${2:index}]--;" ], "description": "Decrement array element" }, "Cross-Type Comparison": { "prefix": "crosscomp", "body": [ "var result = ${1:value1} == ${2:value2}; // Works with any types" ], "description": "Cross-type comparison" }, "Float Array Index": { "prefix": "floatindex", "body": [ "var element = ${1:arrayName}[${2:floatIndex}]; // Auto-truncates to int" ], "description": "Array access with float index (auto-truncates)" }, "Dictionary Literal": { "prefix": "dict", "body": [ "var ${1:dictName} = {", "\t\"${2:key1}\": ${3:value1},", "\t\"${4:key2}\": ${5:value2}", "};" ], "description": "Create a dictionary literal" }, "Dictionary Access": { "prefix": "dictaccess", "body": [ "var value = ${1:dictName}[\"${2:key}\"];" ], "description": "Access dictionary value" }, "Dictionary Assignment": { "prefix": "dictassign", "body": [ "${1:dictName}[\"${2:key}\"] = ${3:value};" ], "description": "Assign value to dictionary key" }, "Dictionary Keys": { "prefix": "keys", "body": [ "var keys = keys(${1:dictionary});" ], "description": "Get all keys from dictionary" }, "Dictionary Values": { "prefix": "values", "body": [ "var values = values(${1:dictionary});" ], "description": "Get all values from dictionary" }, "Dictionary Has": { "prefix": "has", "body": [ "var exists = has(${1:dictionary}, \"${2:key}\");" ], "description": "Check if dictionary has key" } }