@@ -9,20 +9,19 @@ namespace ts.refactor.generateGetAccessorAndSetAccessor {
9
9
type ContainerDeclaration = ClassLikeDeclaration | ObjectLiteralExpression ;
10
10
11
11
interface Info {
12
- container : ContainerDeclaration ;
13
- isStatic : boolean ;
14
- isReadonly : boolean ;
15
- type : TypeNode | undefined ;
16
- declaration : AcceptedDeclaration ;
17
- fieldName : AcceptedNameType ;
18
- accessorName : AcceptedNameType ;
19
- originalName : AcceptedNameType ;
20
- renameAccessor : boolean ;
12
+ readonly container : ContainerDeclaration ;
13
+ readonly isStatic : boolean ;
14
+ readonly isReadonly : boolean ;
15
+ readonly type : TypeNode | undefined ;
16
+ readonly declaration : AcceptedDeclaration ;
17
+ readonly fieldName : AcceptedNameType ;
18
+ readonly accessorName : AcceptedNameType ;
19
+ readonly originalName : AcceptedNameType ;
20
+ readonly renameAccessor : boolean ;
21
21
}
22
22
23
23
function getAvailableActions ( context : RefactorContext ) : ApplicableRefactorInfo [ ] | undefined {
24
- const { file } = context ;
25
- if ( ! getConvertibleFieldAtPosition ( context , file ) ) return undefined ;
24
+ if ( ! getConvertibleFieldAtPosition ( context ) ) return undefined ;
26
25
27
26
return [ {
28
27
name : actionName ,
@@ -39,7 +38,7 @@ namespace ts.refactor.generateGetAccessorAndSetAccessor {
39
38
function getEditsForAction ( context : RefactorContext , _actionName : string ) : RefactorEditInfo | undefined {
40
39
const { file } = context ;
41
40
42
- const fieldInfo = getConvertibleFieldAtPosition ( context , file ) ;
41
+ const fieldInfo = getConvertibleFieldAtPosition ( context ) ;
43
42
if ( ! fieldInfo ) return undefined ;
44
43
45
44
const isJS = isSourceFileJavaScript ( file ) ;
@@ -117,14 +116,14 @@ namespace ts.refactor.generateGetAccessorAndSetAccessor {
117
116
return name . charCodeAt ( 0 ) === CharacterCodes . _ ;
118
117
}
119
118
120
- function getConvertibleFieldAtPosition ( context : RefactorContext , file : SourceFile ) : Info | undefined {
121
- const { startPosition, endPosition } = context ;
119
+ function getConvertibleFieldAtPosition ( context : RefactorContext ) : Info | undefined {
120
+ const { file , startPosition, endPosition } = context ;
122
121
123
122
const node = getTokenAtPosition ( file , startPosition , /*includeJsDocComment*/ false ) ;
124
123
const declaration = findAncestor ( node . parent , isAcceptedDeclaration ) ;
125
124
// make sure declaration have AccessibilityModifier or Static Modifier or Readonly Modifier
126
125
const meaning = ModifierFlags . AccessibilityModifier | ModifierFlags . Static | ModifierFlags . Readonly ;
127
- if ( ! declaration || ! rangeOverlapsWithStartEnd ( declaration . name , startPosition , endPosition ! ) // TODO: GH#18217
126
+ if ( ! declaration || ! nodeOverlapsWithStartEnd ( declaration . name , file , startPosition , endPosition ! ) // TODO: GH#18217
128
127
|| ! isConvertibleName ( declaration . name ) || ( getModifierFlags ( declaration ) | meaning ) !== meaning ) return undefined ;
129
128
130
129
const name = declaration . name . text ;
0 commit comments