mirror of
https://github.com/placeholder-soft/libs.git
synced 2026-04-29 04:55:48 +08:00
feat: case function declaration & completion test
This commit is contained in:
committed by
keyp-dev
parent
d74493b854
commit
efb00e9c88
@@ -62,3 +62,44 @@ switch (typedEnv('swticch')){
|
||||
do {
|
||||
typedEnv('do');
|
||||
} while (typedEnv('while'));
|
||||
|
||||
|
||||
while (typedEnv('while');) {
|
||||
typedEnv('while-block');
|
||||
}
|
||||
|
||||
for (let i = typedEnv('for-let'); i < 9; i++) {
|
||||
typedEnv('for-let-block')
|
||||
}
|
||||
|
||||
const object = { a: 1, b: 2, c: 3 };
|
||||
|
||||
for (const property in object) {
|
||||
typedEnv('for-in')
|
||||
}
|
||||
|
||||
const array1 = ['a', 'b', 'c'];
|
||||
|
||||
for (const element of array1) {
|
||||
typedEnv('for-of')
|
||||
}
|
||||
|
||||
function fun(fun: string = typedEnv('fun-arg')) {
|
||||
typedEnv('fun-block');
|
||||
|
||||
return typedEnv('fun-return');
|
||||
}
|
||||
|
||||
try {
|
||||
typedEnv('try');
|
||||
} catch(e){
|
||||
typedEnv('catch');
|
||||
}
|
||||
|
||||
function useThrow() {
|
||||
throw new Error(typedEnv('throw').toString());
|
||||
}
|
||||
|
||||
with (typedEnv('with')) {
|
||||
typedEnv('with-block')
|
||||
}
|
||||
@@ -22,6 +22,19 @@ Array [
|
||||
"else-block=",
|
||||
"swticch-case-block=",
|
||||
"swticch-case-2-block=",
|
||||
"while-block=",
|
||||
"for-let-block=",
|
||||
"for-in=",
|
||||
"for-of=",
|
||||
"fun-block=",
|
||||
"try=",
|
||||
"catch=",
|
||||
"with-block=",
|
||||
"for-let=",
|
||||
"fun-return=",
|
||||
"with=",
|
||||
"throw=",
|
||||
"fun-arg=",
|
||||
]
|
||||
`;
|
||||
|
||||
@@ -33,11 +46,19 @@ Object {
|
||||
"DOCKER_COMPOSE_POSTGRES_PORT": "DOCKER_COMPOSE_POSTGRES_PORT",
|
||||
"UNIWHALE_DB_NAME": "UNIWHALE_DB_NAME",
|
||||
"aaa": "aaa",
|
||||
"catch": "catch",
|
||||
"ccc": "ccc",
|
||||
"do": "do",
|
||||
"else-block": "else-block",
|
||||
"elseif": "elseif",
|
||||
"elseif-block": "elseif-block",
|
||||
"for-in": "for-in",
|
||||
"for-let": "for-let",
|
||||
"for-let-block": "for-let-block",
|
||||
"for-of": "for-of",
|
||||
"fun-arg": "fun-arg",
|
||||
"fun-block": "fun-block",
|
||||
"fun-return": "fun-return",
|
||||
"if": "if",
|
||||
"if-block": "if-block",
|
||||
"swticch": "swticch",
|
||||
@@ -46,6 +67,32 @@ Object {
|
||||
"swticch-case-2-block": "swticch-case-2-block",
|
||||
"swticch-case-block": "swticch-case-block",
|
||||
"swticch-default-block": "swticch-default-block",
|
||||
"throw": "throw",
|
||||
"try": "try",
|
||||
"while": "while",
|
||||
"while-block": "while-block",
|
||||
"with": "with",
|
||||
"with-block": "with-block",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`call chaining generate env 1`] = `
|
||||
Array [
|
||||
"// default=['111','222','333']",
|
||||
"bbb='111'",
|
||||
"// default=['111','222','333']",
|
||||
"ccc='111'",
|
||||
"ddd=",
|
||||
"// default=['']",
|
||||
"eee=",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`call chaining generate env name 1`] = `
|
||||
Object {
|
||||
"bbb": "bbb",
|
||||
"ccc": "ccc",
|
||||
"ddd": "ddd",
|
||||
"eee": "eee",
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -40,6 +40,7 @@ function allSingleStatment(source: TSource): TStatement[] {
|
||||
...source.getDescendantsOfKind(SyntaxKind.ThrowStatement),
|
||||
...source.getDescendantsOfKind(SyntaxKind.TryStatement),
|
||||
...source.getDescendantsOfKind(SyntaxKind.DebuggerStatement),
|
||||
...source.getDescendantsOfKind(SyntaxKind.FunctionDeclaration),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
TemplateSpan,
|
||||
CaseClause,
|
||||
DefaultClause,
|
||||
FunctionDeclaration,
|
||||
} from 'ts-morph';
|
||||
|
||||
export type TStatement =
|
||||
@@ -45,7 +46,8 @@ export type TStatement =
|
||||
| LabeledStatement
|
||||
| ThrowStatement
|
||||
| TryStatement
|
||||
| DebuggerStatement;
|
||||
| DebuggerStatement
|
||||
| FunctionDeclaration;
|
||||
|
||||
export type TSingleSource =
|
||||
| SourceFile
|
||||
|
||||
Reference in New Issue
Block a user