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

@@ -189,7 +189,7 @@ namespace FourSlash {
public formatCodeSettings: ts.FormatCodeSettings;
private inputFiles = new ts.StringMap<string>(); // Map between inputFile's fileName and its content for easily looking up when resolving references
private inputFiles = ts.createMap<string, string>(); // Map between inputFile's fileName and its content for easily looking up when resolving references
private static getDisplayPartsJson(displayParts: ts.SymbolDisplayPart[]) {
let result = "";
@@ -674,7 +674,7 @@ namespace FourSlash {
public noItemsWithSameNameButDifferentKind(): void {
const completions = this.getCompletionListAtCaret();
const uniqueItems = new ts.StringMap<string>();
const uniqueItems = ts.createMap<string, string>();
for (const item of completions.entries) {
if (!ts.setIfNotSet(uniqueItems, item.name, item.kind)) {
const uniqueItem = uniqueItems.get(item.name);
@@ -1777,7 +1777,7 @@ namespace FourSlash {
}
private rangesByTextMap(): ts.Map<string, Range[]> {
const result = new ts.StringMap<Range[]>();
const result = ts.createMap<string, Range[]>();
for (const range of this.getRanges()) {
const text = this.rangeText(range);
ts.multiMapAdd(result, text, range);

View File

@@ -922,7 +922,7 @@ namespace Harness {
export const defaultLibFileName = "lib.d.ts";
export const es2015DefaultLibFileName = "lib.es2015.d.ts";
const libFileNameSourceFileMap = new ts.StringMap<ts.SourceFile>([[
const libFileNameSourceFileMap = ts.createMap<string, ts.SourceFile>([[
defaultLibFileName,
createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + "lib.es5.d.ts"), /*languageVersion*/ ts.ScriptTarget.Latest)
]]);
@@ -1089,7 +1089,7 @@ namespace Harness {
let optionsIndex: ts.Map<string, ts.CommandLineOption>;
function getCommandLineOption(name: string): ts.CommandLineOption {
if (!optionsIndex) {
optionsIndex = new ts.StringMap<ts.CommandLineOption>();
optionsIndex = ts.createMap<string, ts.CommandLineOption>();
const optionDeclarations = harnessOptionDeclarations.concat(ts.optionDeclarations);
for (const option of optionDeclarations) {
optionsIndex.set(option.name.toLowerCase(), option);
@@ -1452,7 +1452,7 @@ namespace Harness {
const fullWalker = new TypeWriterWalker(program, /*fullTypeCheck*/ true);
const fullResults = new ts.StringMap<TypeWriterResult[]>();
const fullResults = ts.createMap<string, TypeWriterResult[]>();
for (const sourceFile of allFiles) {
fullResults.set(sourceFile.unitName, fullWalker.getTypeAndSymbols(sourceFile.unitName));

View File

@@ -91,7 +91,7 @@ namespace Playback {
}
function memoize<T>(func: (s: string) => T): Memoized<T> {
const lookup = new ts.StringMap<T>();
const lookup = ts.createMap<string, T>();
const run: Memoized<T> = <Memoized<T>>((s: string) =>
ts.getOrUpdateAndAllowUndefined(lookup, s, func));
run.reset = () => {

View File

@@ -7,7 +7,7 @@ namespace ts {
}
function createDefaultServerHost(fileMap: Map<string, File>): server.ServerHost {
const existingDirectories = new StringSet();
const existingDirectories = createSet();
forEachKeyInMap(fileMap, name => {
let dir = getDirectoryPath(name);
let previous: string;

View File

@@ -32,7 +32,7 @@ namespace ts {
const map = arrayToMap(files, f => f.name);
if (hasDirectoryExists) {
const directories = new StringSet();
const directories = createSet();
for (const f of files) {
let name = getDirectoryPath(f.name);
while (true) {

View File

@@ -411,8 +411,8 @@ namespace ts.server {
class InProcClient {
private server: InProcSession;
private seq = 0;
private callbacks = new NumberMap<number, (resp: protocol.Response) => void>();
private eventHandlers = new StringMap<(args: any) => void>();
private callbacks = createMap<number, (resp: protocol.Response) => void>();
private eventHandlers = createMap<string, (args: any) => void>();
handle(msg: protocol.Message): void {
if (msg.type === "response") {

View File

@@ -298,7 +298,7 @@ namespace ts.projectSystem {
}
export class Callbacks {
private map = new NumberMap<number, TimeOutCallback>();
private map = createMap<number, TimeOutCallback>();
private nextId = 1;
register(cb: (...args: any[]) => void, args: any[]) {
@@ -335,8 +335,8 @@ namespace ts.projectSystem {
private timeoutCallbacks = new Callbacks();
private immediateCallbacks = new Callbacks();
readonly watchedDirectories = new StringMap<{ cb: DirectoryWatcherCallback, recursive: boolean }[]>();
readonly watchedFiles = new StringMap<FileWatcherCallback[]>();
readonly watchedDirectories = createMap<string, { cb: DirectoryWatcherCallback, recursive: boolean }[]>();
readonly watchedFiles = createMap<string, FileWatcherCallback[]>();
private filesOrFolders: FileOrFolder[];

View File

@@ -955,7 +955,7 @@ namespace ts.projectSystem {
content: ""
};
const host = createServerHost([f]);
const cache = new StringMap<string>();
const cache = createMap<string, string>();
for (const name of JsTyping.nodeCoreModuleList) {
const result = JsTyping.discoverTypings(host, [f.path], getDirectoryPath(<Path>f.path), /*safeListPath*/ undefined, cache, { enableAutoDiscovery: true }, [name, "somename"]);
assert.deepEqual(result.newTypingNames.sort(), ["node", "somename"]);