mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-14 19:16:17 -06:00
Remove the specialized type UnresolvedImportsMap which is just a redirection and helps only in test only
This commit is contained in:
parent
b0fb73c47c
commit
c9479f7263
@ -999,7 +999,7 @@ namespace ts.projectSystem {
|
||||
proj.updateGraph();
|
||||
|
||||
assert.deepEqual(
|
||||
proj.getCachedUnresolvedImportsPerFile_TestOnly().get(<Path>f1.path),
|
||||
proj.cachedUnresolvedImportsPerFile.get(<Path>f1.path),
|
||||
["foo", "foo", "foo", "@bar/router", "@bar/common", "@bar/common"]
|
||||
);
|
||||
|
||||
@ -1029,7 +1029,7 @@ namespace ts.projectSystem {
|
||||
const projectService = session.getProjectService();
|
||||
checkNumberOfProjects(projectService, { inferredProjects: 1 });
|
||||
const proj = projectService.inferredProjects[0];
|
||||
const version1 = proj.getCachedUnresolvedImportsPerFile_TestOnly().getVersion();
|
||||
const version1 = proj.lastCachedUnresolvedImportsList;
|
||||
|
||||
// make a change that should not affect the structure of the program
|
||||
const changeRequest: server.protocol.ChangeRequest = {
|
||||
@ -1047,7 +1047,7 @@ namespace ts.projectSystem {
|
||||
};
|
||||
session.executeCommand(changeRequest);
|
||||
host.checkTimeoutQueueLengthAndRun(2); // This enqueues the updategraph and refresh inferred projects
|
||||
const version2 = proj.getCachedUnresolvedImportsPerFile_TestOnly().getVersion();
|
||||
const version2 = proj.lastCachedUnresolvedImportsList;
|
||||
assert.notEqual(version1, version2, "set of unresolved imports should change");
|
||||
});
|
||||
|
||||
|
||||
@ -55,34 +55,6 @@ namespace ts.server {
|
||||
projectErrors: ReadonlyArray<Diagnostic>;
|
||||
}
|
||||
|
||||
export class UnresolvedImportsMap {
|
||||
readonly perFileMap = createMap<ReadonlyArray<string>>();
|
||||
private version = 0;
|
||||
|
||||
public clear() {
|
||||
this.perFileMap.clear();
|
||||
this.version = 0;
|
||||
}
|
||||
|
||||
public getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
public remove(path: Path) {
|
||||
this.perFileMap.delete(path);
|
||||
this.version++;
|
||||
}
|
||||
|
||||
public get(path: Path) {
|
||||
return this.perFileMap.get(path);
|
||||
}
|
||||
|
||||
public set(path: Path, value: ReadonlyArray<string>) {
|
||||
this.perFileMap.set(path, value);
|
||||
this.version++;
|
||||
}
|
||||
}
|
||||
|
||||
export interface PluginCreateInfo {
|
||||
project: Project;
|
||||
languageService: LanguageService;
|
||||
@ -116,8 +88,10 @@ namespace ts.server {
|
||||
private missingFilesMap: Map<FileWatcher>;
|
||||
private plugins: PluginModule[] = [];
|
||||
|
||||
private cachedUnresolvedImportsPerFile = new UnresolvedImportsMap();
|
||||
private lastCachedUnresolvedImportsList: SortedReadonlyArray<string>;
|
||||
/*@internal*/
|
||||
cachedUnresolvedImportsPerFile = createMap<ReadonlyArray<string>>();
|
||||
/*@internal*/
|
||||
lastCachedUnresolvedImportsList: SortedReadonlyArray<string>;
|
||||
|
||||
private lastFileExceededProgramSize: string | undefined;
|
||||
|
||||
@ -181,10 +155,6 @@ namespace ts.server {
|
||||
return hasOneOrMoreJsAndNoTsFiles(this);
|
||||
}
|
||||
|
||||
public getCachedUnresolvedImportsPerFile_TestOnly() {
|
||||
return this.cachedUnresolvedImportsPerFile;
|
||||
}
|
||||
|
||||
public static resolveModule(moduleName: string, initialDir: string, host: ServerHost, log: (message: string) => void): {} {
|
||||
const resolvedPath = normalizeSlashes(host.resolvePath(combinePaths(initialDir, "node_modules")));
|
||||
log(`Loading ${moduleName} from ${initialDir} (resolved to ${resolvedPath})`);
|
||||
@ -742,7 +712,7 @@ namespace ts.server {
|
||||
else {
|
||||
this.resolutionCache.invalidateResolutionOfFile(info.path);
|
||||
}
|
||||
this.cachedUnresolvedImportsPerFile.remove(info.path);
|
||||
this.cachedUnresolvedImportsPerFile.delete(info.path);
|
||||
|
||||
if (detachFromProject) {
|
||||
info.detachFromProject(this);
|
||||
@ -812,7 +782,7 @@ namespace ts.server {
|
||||
|
||||
for (const file of changedFiles) {
|
||||
// delete cached information for changed files
|
||||
this.cachedUnresolvedImportsPerFile.remove(file);
|
||||
this.cachedUnresolvedImportsPerFile.delete(file);
|
||||
}
|
||||
|
||||
// update builder only if language service is enabled
|
||||
|
||||
@ -7611,15 +7611,6 @@ declare namespace ts.server {
|
||||
}
|
||||
function allRootFilesAreJsOrDts(project: Project): boolean;
|
||||
function allFilesAreJsOrDts(project: Project): boolean;
|
||||
class UnresolvedImportsMap {
|
||||
readonly perFileMap: Map<ReadonlyArray<string>>;
|
||||
private version;
|
||||
clear(): void;
|
||||
getVersion(): number;
|
||||
remove(path: Path): void;
|
||||
get(path: Path): ReadonlyArray<string>;
|
||||
set(path: Path, value: ReadonlyArray<string>): void;
|
||||
}
|
||||
interface PluginCreateInfo {
|
||||
project: Project;
|
||||
languageService: LanguageService;
|
||||
@ -7652,8 +7643,6 @@ declare namespace ts.server {
|
||||
private externalFiles;
|
||||
private missingFilesMap;
|
||||
private plugins;
|
||||
private cachedUnresolvedImportsPerFile;
|
||||
private lastCachedUnresolvedImportsList;
|
||||
private lastFileExceededProgramSize;
|
||||
protected languageService: LanguageService;
|
||||
languageServiceEnabled: boolean;
|
||||
@ -7688,7 +7677,6 @@ declare namespace ts.server {
|
||||
private readonly cancellationToken;
|
||||
isNonTsProject(): boolean;
|
||||
isJsOnlyProject(): boolean;
|
||||
getCachedUnresolvedImportsPerFile_TestOnly(): UnresolvedImportsMap;
|
||||
static resolveModule(moduleName: string, initialDir: string, host: ServerHost, log: (message: string) => void): {};
|
||||
isKnownTypesPackageName(name: string): boolean;
|
||||
installPackage(options: InstallPackageOptions): Promise<ApplyCodeActionCommandResult>;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user