mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:33:53 -06:00
parent
22c4862d9e
commit
025418fdb0
@ -546,6 +546,13 @@ var q = /*b*/ //c
|
||||
/*g*/ + /*h*/ //i
|
||||
/*j*/ 2|] /*k*/ //l
|
||||
/*m*/; /*n*/ //o`);
|
||||
|
||||
testExtractFunction("extractFunction_NamelessClass", `
|
||||
export default class {
|
||||
M() {
|
||||
[#|1 + 1|];
|
||||
}
|
||||
}`);
|
||||
});
|
||||
|
||||
function testExtractFunction(caption: string, text: string, includeLib?: boolean) {
|
||||
|
||||
@ -687,7 +687,7 @@ namespace ts.refactor.extractSymbol {
|
||||
}
|
||||
function getDescriptionForClassLikeDeclaration(scope: ClassLikeDeclaration): string {
|
||||
return scope.kind === SyntaxKind.ClassDeclaration
|
||||
? `class '${scope.name.text}'`
|
||||
? scope.name ? `class '${scope.name.text}'` : "anonymous class declaration"
|
||||
: scope.name ? `class expression '${scope.name.text}'` : "anonymous class expression";
|
||||
}
|
||||
function getDescriptionForModuleLikeDeclaration(scope: SourceFile | ModuleBlock): string | SpecialScope {
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
// ==ORIGINAL==
|
||||
|
||||
export default class {
|
||||
M() {
|
||||
/*[#|*/1 + 1/*|]*/;
|
||||
}
|
||||
}
|
||||
// ==SCOPE::Extract to method in anonymous class declaration==
|
||||
|
||||
export default class {
|
||||
M() {
|
||||
this./*RENAME*/newMethod();
|
||||
}
|
||||
|
||||
newMethod() {
|
||||
1 + 1;
|
||||
}
|
||||
}
|
||||
// ==SCOPE::Extract to function in module scope==
|
||||
|
||||
export default class {
|
||||
M() {
|
||||
/*RENAME*/newFunction();
|
||||
}
|
||||
}
|
||||
|
||||
function newFunction() {
|
||||
1 + 1;
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
// ==ORIGINAL==
|
||||
|
||||
export default class {
|
||||
M() {
|
||||
/*[#|*/1 + 1/*|]*/;
|
||||
}
|
||||
}
|
||||
// ==SCOPE::Extract to method in anonymous class declaration==
|
||||
|
||||
export default class {
|
||||
M() {
|
||||
this./*RENAME*/newMethod();
|
||||
}
|
||||
|
||||
private newMethod() {
|
||||
1 + 1;
|
||||
}
|
||||
}
|
||||
// ==SCOPE::Extract to function in module scope==
|
||||
|
||||
export default class {
|
||||
M() {
|
||||
/*RENAME*/newFunction();
|
||||
}
|
||||
}
|
||||
|
||||
function newFunction() {
|
||||
1 + 1;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user