Respond to PR comments

This commit is contained in:
Andy Hanson
2016-10-27 13:14:56 -07:00
parent 867093707b
commit bcc0807198
48 changed files with 203 additions and 190 deletions

View File

@@ -346,7 +346,7 @@ namespace ts.server {
// Use slice to clone the array to avoid manipulating in place
const queue = fileInfo.referencedBy.slice(0);
const fileNameSet = new StringMap<ScriptInfo>();
const fileNameSet = createMap<string, ScriptInfo>();
fileNameSet.set(scriptInfo.fileName, scriptInfo);
while (queue.length > 0) {
const processingFileInfo = queue.pop();

View File

@@ -15,7 +15,7 @@ namespace ts.server {
export class SessionClient implements LanguageService {
private sequence: number = 0;
private lineMaps = new ts.StringMap<number[]>();
private lineMaps = ts.createMap<string, number[]>();
private messages: string[] = [];
private lastRenameEntry: RenameEntry;

View File

@@ -18,7 +18,7 @@ namespace ts.server {
}
function prepareConvertersForEnumLikeCompilerOptions(commandLineOptions: CommandLineOption[]): Map<string, Map<string, number>> {
const map = new StringMap<Map<string, number>>();
const map = createMap<string, Map<string, number>>();
for (const option of commandLineOptions) {
if (typeof option.type === "object") {
const optionMap = <Map<string, number>>option.type;
@@ -159,12 +159,12 @@ namespace ts.server {
/**
* a path to directory watcher map that detects added tsconfig files
**/
private readonly directoryWatchersForTsconfig = new StringMap<FileWatcher>();
private readonly directoryWatchersForTsconfig = createMap<string, FileWatcher>();
/**
* count of how many projects are using the directory watcher.
* If the number becomes 0 for a watcher, then we should close it.
**/
private readonly directoryWatchersRefCount = new StringMap<number>();
private readonly directoryWatchersRefCount = createMap<string, number>();
constructor(private readonly projectService: ProjectService) {
}
@@ -212,7 +212,7 @@ namespace ts.server {
/**
* maps external project file name to list of config files that were the part of this project
*/
private readonly externalProjectToConfiguredProjectMap = new StringMap<NormalizedPath[]>();
private readonly externalProjectToConfiguredProjectMap = createMap<string, NormalizedPath[]>();
/**
* external projects (configuration and list of root files is not controlled by tsserver)
@@ -902,7 +902,7 @@ namespace ts.server {
private updateNonInferredProject<T>(project: ExternalProject | ConfiguredProject, newUncheckedFiles: T[], propertyReader: FilePropertyReader<T>, newOptions: CompilerOptions, newTypingOptions: TypingOptions, compileOnSave: boolean, configFileErrors: Diagnostic[]) {
const oldRootScriptInfos = project.getRootScriptInfos();
const newRootScriptInfos: ScriptInfo[] = [];
const newRootScriptInfoMap: Map<NormalizedPath, ScriptInfo> = new StringMap<ScriptInfo>();
const newRootScriptInfoMap: Map<NormalizedPath, ScriptInfo> = createMap<string, ScriptInfo>();
let projectErrors: Diagnostic[];
let rootFilesChanged = false;

View File

@@ -63,7 +63,7 @@ namespace ts.server {
const path = toPath(containingFile, this.host.getCurrentDirectory(), this.getCanonicalFileName);
const currentResolutionsInFile = cache.get(path);
const newResolutions = new StringMap<T>();
const newResolutions = createMap<string, T>();
const resolvedModules: R[] = [];
const compilerOptions = this.getCompilationSettings();
const lastDeletedFileName = this.project.projectService.lastDeletedFile && this.project.projectService.lastDeletedFile.fileName;

View File

@@ -603,7 +603,7 @@ namespace ts.server {
// We need to use a set here since the code can contain the same import twice,
// but that will only be one dependency.
// To avoid invernal conversion, the key of the referencedFiles map must be of type Path
const referencedFiles = new StringSet();
const referencedFiles = createSet();
if (sourceFile.imports && sourceFile.imports.length > 0) {
const checker: TypeChecker = this.program.getTypeChecker();
for (const importName of sourceFile.imports) {
@@ -778,7 +778,7 @@ namespace ts.server {
}
const configDirectoryPath = getDirectoryPath(this.configFileName);
this.directoriesWatchedForWildcards = new StringMap<FileWatcher>();
this.directoriesWatchedForWildcards = createMap<string, FileWatcher>();
this.wildcardDirectories.forEach((flag, directory) => {
if (comparePaths(configDirectoryPath, directory, ".", !this.projectService.host.useCaseSensitiveFileNames) !== Comparison.EqualTo) {
const recursive = (flag & WatchDirectoryFlags.Recursive) !== 0;

View File

@@ -31,7 +31,7 @@ namespace ts.server {
if ((arr1 || emptyArray).length === 0 && (arr2 || emptyArray).length === 0) {
return true;
}
const set = new StringMap<boolean>();
const set = createMap<string, boolean>();
let unique = 0;
for (const v of arr1) {
@@ -72,7 +72,7 @@ namespace ts.server {
}
export class TypingsCache {
private readonly perProjectCache = new StringMap<TypingsCacheEntry>();
private readonly perProjectCache = createMap<string, TypingsCacheEntry>();
constructor(private readonly installer: ITypingsInstaller) {
}

View File

@@ -78,10 +78,10 @@ namespace ts.server.typingsInstaller {
};
export abstract class TypingsInstaller {
private readonly packageNameToTypingLocation = new StringMap<string>();
private readonly missingTypingsSet = new StringSet();
private readonly knownCachesSet = new StringSet();
private readonly projectWatchers = new StringMap<FileWatcher[]>();
private readonly packageNameToTypingLocation = createMap<string, string>();
private readonly missingTypingsSet = createSet();
private readonly knownCachesSet = createSet();
private readonly projectWatchers = createMap<string, FileWatcher[]>();
readonly pendingRunRequests: PendingRequest[] = [];
private installRunCount = 1;
@@ -296,7 +296,7 @@ namespace ts.server.typingsInstaller {
if (this.log.isEnabled()) {
this.log.writeLine(`Requested to install typings ${JSON.stringify(typingsToInstall)}, installed typings ${JSON.stringify(installedTypings)}`);
}
const installedPackages = new StringSet();
const installedPackages = createSet();
const installedTypingFiles: string[] = [];
for (const t of installedTypings) {
const packageName = getBaseFileName(t);

View File

@@ -225,7 +225,7 @@ namespace ts.server {
}
export class ThrottledOperations {
private pendingTimeouts = new StringMap<any>();
private pendingTimeouts = createMap<string, any>();
constructor(private readonly host: ServerHost) {
}