2017-08-05 01:10:33 +02:00
|
|
|
/// <reference path='fourslash.ts' />
|
|
|
|
|
|
|
|
// Extracting from a static context should make static methods.
|
|
|
|
// Also checks that we correctly find non-conflicting names in static contexts.
|
|
|
|
|
|
|
|
//// class C {
|
2017-09-07 16:28:12 +02:00
|
|
|
//// static j = /*c*/1 + 1/*d*/;
|
2017-09-15 19:45:15 +02:00
|
|
|
//// constructor(q: string = /*a*/"hello"/*b*/) {
|
2017-08-05 01:10:33 +02:00
|
|
|
//// }
|
|
|
|
//// }
|
|
|
|
|
|
|
|
goTo.select('a', 'b');
|
2017-08-25 18:53:28 +02:00
|
|
|
edit.applyRefactor({
|
2017-09-15 01:04:44 +02:00
|
|
|
refactorName: "Extract Symbol",
|
|
|
|
actionName: "function_scope_0",
|
2017-09-09 14:52:52 +02:00
|
|
|
actionDescription: "Extract to method in class 'C'",
|
2017-09-13 18:02:10 +02:00
|
|
|
newContent:
|
|
|
|
`class C {
|
|
|
|
static j = 1 + 1;
|
2017-09-15 01:04:44 +02:00
|
|
|
constructor(q: string = C./*RENAME*/newMethod()) {
|
2017-09-13 18:02:10 +02:00
|
|
|
}
|
|
|
|
|
2017-09-15 01:04:44 +02:00
|
|
|
private static newMethod(): string {
|
2017-09-15 19:45:15 +02:00
|
|
|
return "hello";
|
2017-09-13 18:02:10 +02:00
|
|
|
}
|
|
|
|
}`
|
2017-08-25 18:53:28 +02:00
|
|
|
});
|
2017-08-05 01:10:33 +02:00
|
|
|
|
2017-09-08 22:07:32 +02:00
|
|
|
verify.currentFileContentIs(`class C {
|
|
|
|
static j = 1 + 1;
|
2017-09-15 01:04:44 +02:00
|
|
|
constructor(q: string = C.newMethod()) {
|
2017-09-08 22:07:32 +02:00
|
|
|
}
|
|
|
|
|
2017-09-15 01:04:44 +02:00
|
|
|
private static newMethod(): string {
|
2017-09-15 19:45:15 +02:00
|
|
|
return "hello";
|
2017-09-08 22:07:32 +02:00
|
|
|
}
|
|
|
|
}`);
|
|
|
|
|
2017-08-05 01:10:33 +02:00
|
|
|
goTo.select('c', 'd');
|
2017-08-25 18:53:28 +02:00
|
|
|
edit.applyRefactor({
|
2017-09-15 01:04:44 +02:00
|
|
|
refactorName: "Extract Symbol",
|
|
|
|
actionName: "function_scope_0",
|
2017-09-09 14:52:52 +02:00
|
|
|
actionDescription: "Extract to method in class 'C'",
|
2017-09-13 18:02:10 +02:00
|
|
|
newContent:
|
|
|
|
`class C {
|
2017-09-15 01:04:44 +02:00
|
|
|
static j = C./*RENAME*/newMethod_1();
|
|
|
|
constructor(q: string = C.newMethod()) {
|
2017-08-05 01:10:33 +02:00
|
|
|
}
|
|
|
|
|
2017-09-15 01:04:44 +02:00
|
|
|
private static newMethod_1() {
|
2017-09-07 16:28:12 +02:00
|
|
|
return 1 + 1;
|
2017-08-05 01:10:33 +02:00
|
|
|
}
|
2017-09-08 22:07:32 +02:00
|
|
|
|
2017-09-15 01:04:44 +02:00
|
|
|
private static newMethod(): string {
|
2017-09-15 19:45:15 +02:00
|
|
|
return "hello";
|
2017-09-08 22:07:32 +02:00
|
|
|
}
|
2017-09-13 18:02:10 +02:00
|
|
|
}`
|
|
|
|
});
|