Skip to content

Commit 33b8677

Browse files
author
Andy Hanson
committed
Change "getIsDefinedInLibraryFile" back to just "isDefinedInLibraryFile"
1 parent a478bfd commit 33b8677

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/services/rename.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
/* @internal */
22
namespace ts.Rename {
33
export function getRenameInfo(typeChecker: TypeChecker, defaultLibFileName: string, getCanonicalFileName: (fileName: string) => string, sourceFile: SourceFile, position: number): RenameInfo {
4+
const getCanonicalDefaultLibName = memoize(() => getCanonicalFileName(ts.normalizePath(defaultLibFileName)));
45
const node = getTouchingWord(sourceFile, position, /*includeJsDocComment*/ true);
56
const renameInfo = node && nodeIsEligibleForRename(node)
6-
? getRenameInfoForNode(node, typeChecker, sourceFile, getIsDefinedInLibraryFile(defaultLibFileName, getCanonicalFileName))
7+
? getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile)
78
: undefined;
89
return renameInfo || getRenameInfoError(Diagnostics.You_cannot_rename_this_element);
9-
}
1010

11-
function getIsDefinedInLibraryFile(defaultLibFileName: string, getCanonicalFileName: (fileName: string) => string): (declaration: Node) => boolean {
12-
if (!defaultLibFileName) {
13-
return () => false;
14-
}
11+
function isDefinedInLibraryFile(declaration: Node) {
12+
if (!defaultLibFileName) {
13+
return false;
14+
}
1515

16-
const canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName));
17-
return declaration => {
1816
const sourceFile = declaration.getSourceFile();
1917
const canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile.fileName));
20-
return canonicalName === canonicalDefaultLibName;
18+
return canonicalName === getCanonicalDefaultLibName();
2119
}
2220
}
2321

0 commit comments

Comments
 (0)