@@ -46,9 +46,6 @@ function startRenaming(cm, ast, fromPos, newName, oldName) {
4646
4747 const startIndex = node . start ;
4848 const endIndex = node . end ;
49-
50- if ( node . name !== oldName ) return ;
51-
5249 const pos = cm . posFromIndex ( startIndex ) ;
5350
5451 if (
@@ -57,19 +54,15 @@ function startRenaming(cm, ast, fromPos, newName, oldName) {
5754 parent . type === 'ArrowFunctionExpression' ) &&
5855 parent . params . some ( ( p ) => p . type === 'Identifier' && p . name === oldName )
5956 ) {
60- if ( ! parent . params . includes ( node ) ) {
61- return ;
62- }
57+ if ( ! parent . params . includes ( node ) ) return ;
6358 }
6459
6560 if (
6661 parent . type === 'MemberExpression' &&
6762 parent . property === node &&
6863 ! parent . computed
6964 ) {
70- if ( parent . object . type === 'ThisExpression' && ! isBaseThis ) {
71- return ;
72- }
65+ if ( parent . object . type === 'ThisExpression' && ! isBaseThis ) return ;
7366 }
7467
7568 const thisContext = getContext (
@@ -84,6 +77,8 @@ function startRenaming(cm, ast, fromPos, newName, oldName) {
8477 let shouldRenameGlobalVar = false ;
8578 const isThis = isThisReference ( cm , ast , pos , oldName ) ;
8679
80+ shouldRenameGlobalVar = isGlobal && thisContext === 'global' ;
81+
8782 // Handle renaming inside classes
8883 if ( isInsideClassContext ) {
8984 const tempPos = {
@@ -121,14 +116,6 @@ function startRenaming(cm, ast, fromPos, newName, oldName) {
121116 isThis === isBaseThis &&
122117 baseContext === thisContext
123118 ) {
124- Object . entries ( classMeta . methodVars || { } ) . forEach (
125- ( [ methodName , vars ] ) => {
126- if ( ! vars . includes ( oldName ) && thisContext === methodName ) {
127- const shouldRenameMethodVar = true ;
128- }
129- }
130- ) ;
131-
132119 shouldRename =
133120 thisContext === baseContext &&
134121 ( currentMethodName === 'constructor' || shouldRenameGlobalVar ) ;
@@ -162,7 +149,6 @@ function startRenaming(cm, ast, fromPos, newName, oldName) {
162149 isGlobal &&
163150 ! Object . prototype . hasOwnProperty . call ( thisScopeVars , oldName ) ;
164151 }
165- shouldRenameGlobalVar = isGlobal && thisContext === 'global' ;
166152 }
167153 // Handle renaming outside classes
168154 else {
@@ -201,15 +187,13 @@ function startRenaming(cm, ast, fromPos, newName, oldName) {
201187 isBaseThis
202188 ) ;
203189
204- if (
205- isThisGlobal &&
206- thisContext in userDefinedFunctionMetadata &&
207- userDefinedFunctionMetadata [ thisContext ] . params . some (
208- ( param ) => param . p === oldName
209- )
210- ) {
211- return ;
212- }
190+ const params = userDefinedFunctionMetadata [ thisContext ] ?. params || [ ] ;
191+ const hasParamNamedOldName = params . some ( ( param ) =>
192+ typeof param === 'string'
193+ ? param === oldName
194+ : param ?. name === oldName || param ?. p === oldName
195+ ) ;
196+ if ( isThisGlobal && hasParamNamedOldName ) return ;
213197
214198 const methodPath = path . findParent ( ( p ) => p . isClassMethod ( ) ) ;
215199 let currentMethodName = null ;
0 commit comments