@@ -43,7 +43,7 @@ namespace ts.refactor.extractSymbol {
43
43
// Don't issue refactorings with duplicated names.
44
44
// Scopes come back in "innermost first" order, so extractions will
45
45
// preferentially go into nearer scopes
46
- const description = formatStringFromArgs ( Diagnostics . Extract_to_0 . message , [ extraction . functionDescription ] ) ;
46
+ const description = formatStringFromArgs ( Diagnostics . Extract_to_0_in_1 . message , [ extraction . functionDescription , extraction . scopeDescription ] ) ;
47
47
if ( ! usedFunctionNames . has ( description ) ) {
48
48
usedFunctionNames . set ( description , true ) ;
49
49
functionActions . push ( {
@@ -58,7 +58,7 @@ namespace ts.refactor.extractSymbol {
58
58
// Don't issue refactorings with duplicated names.
59
59
// Scopes come back in "innermost first" order, so extractions will
60
60
// preferentially go into nearer scopes
61
- const description = formatStringFromArgs ( Diagnostics . Extract_to_0 . message , [ extraction . constantDescription ] ) ;
61
+ const description = formatStringFromArgs ( Diagnostics . Extract_to_0_in_1 . message , [ extraction . constantDescription , extraction . scopeDescription ] ) ;
62
62
if ( ! usedConstantNames . has ( description ) ) {
63
63
usedConstantNames . set ( description , true ) ;
64
64
constantActions . push ( {
@@ -547,6 +547,7 @@ namespace ts.refactor.extractSymbol {
547
547
readonly functionErrors : ReadonlyArray < Diagnostic > ;
548
548
readonly constantDescription : string ;
549
549
readonly constantErrors : ReadonlyArray < Diagnostic > ;
550
+ readonly scopeDescription : string ;
550
551
}
551
552
/**
552
553
* Given a piece of text to extract ('targetRange'), computes a list of possible extractions.
@@ -561,6 +562,11 @@ namespace ts.refactor.extractSymbol {
561
562
functionErrors : functionErrorsPerScope [ i ] ,
562
563
constantDescription : getDescriptionForConstantInScope ( scope ) ,
563
564
constantErrors : constantErrorsPerScope [ i ] ,
565
+ scopeDescription : isFunctionLikeDeclaration ( scope )
566
+ ? getDescriptionForFunctionLikeDeclaration ( scope )
567
+ : isClassLike ( scope )
568
+ ? getDescriptionForClassLikeDeclaration ( scope )
569
+ : getDescriptionForModuleLikeDeclaration ( scope )
564
570
} ) ) ;
565
571
return extractions ;
566
572
}
@@ -590,17 +596,15 @@ namespace ts.refactor.extractSymbol {
590
596
591
597
function getDescriptionForFunctionInScope ( scope : Scope ) : string {
592
598
return isFunctionLikeDeclaration ( scope )
593
- ? ` inner function in ${ getDescriptionForFunctionLikeDeclaration ( scope ) } `
599
+ ? " inner function"
594
600
: isClassLike ( scope )
595
- ? ` method in ${ getDescriptionForClassLikeDeclaration ( scope ) } `
596
- : ` function in ${ getDescriptionForModuleLikeDeclaration ( scope ) } ` ;
601
+ ? " method"
602
+ : " function" ;
597
603
}
598
604
function getDescriptionForConstantInScope ( scope : Scope ) : string {
599
- return isFunctionLikeDeclaration ( scope )
600
- ? `constant in ${ getDescriptionForFunctionLikeDeclaration ( scope ) } `
601
- : isClassLike ( scope )
602
- ? `readonly field in ${ getDescriptionForClassLikeDeclaration ( scope ) } `
603
- : `constant in ${ getDescriptionForModuleLikeDeclaration ( scope ) } ` ;
605
+ return isClassLike ( scope )
606
+ ? "readonly field"
607
+ : "constant" ;
604
608
}
605
609
function getDescriptionForFunctionLikeDeclaration ( scope : FunctionLikeDeclaration ) : string {
606
610
switch ( scope . kind ) {
0 commit comments