Major changes: 1) Instead of skipping undesirable scopes, include them and mark them with errors. Constants can be extracted into more scopes. 2) Update the tests to call through the "public" API. This caused some baseline changes. 3) Rename refactoring to "Extract Symbol" for generality. 4) Return a second ApplicableRefactorInfo for constants. Distinguish the two by splitting the action name.
36 lines
810 B
TypeScript
36 lines
810 B
TypeScript
/// <reference path='fourslash.ts' />
|
|
|
|
//// class Foo {
|
|
//// someMethod(m: number) {
|
|
//// /*start*/var x = m;
|
|
//// x = x * 3;
|
|
//// var y = 30;
|
|
//// var z = y + x;
|
|
//// console.log(z);/*end*/
|
|
//// var q = 10;
|
|
//// return q;
|
|
//// }
|
|
//// }
|
|
|
|
goTo.select('start', 'end')
|
|
edit.applyRefactor({
|
|
refactorName: "Extract Symbol",
|
|
actionName: "function_scope_1",
|
|
actionDescription: "Extract to method in class 'Foo'",
|
|
newContent:
|
|
`class Foo {
|
|
someMethod(m: number) {
|
|
this./*RENAME*/newMethod(m);
|
|
var q = 10;
|
|
return q;
|
|
}
|
|
|
|
private newMethod(m: number) {
|
|
var x = m;
|
|
x = x * 3;
|
|
var y = 30;
|
|
var z = y + x;
|
|
console.log(z);
|
|
}
|
|
}`
|
|
});
|