417 lines
9.4 KiB
JSON
417 lines
9.4 KiB
JSON
{
|
|
"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"
|
|
},
|
|
"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": [
|
|
"var randomValue = 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)"
|
|
}
|
|
} |