Use native maps when they're available

This commit is contained in:
Andy Hanson committed 2016-10-06 13:29:18 -07:00
1 parent 3212e25a3a
commit aadcbcc083
66 files changed
+1678 -1326

No files matched your search

+9 -10
View File
@@ -10,23 +10,22 @@ namespace ts.NavigateTo {
const baseSensitivity: Intl.CollatorOptions = { sensitivity: "base" };
// Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[]
forEach(sourceFiles, sourceFile => {
for (const sourceFile of sourceFiles) {
cancellationToken.throwIfCancellationRequested();
if (excludeDtsFiles && fileExtensionIs(sourceFile.fileName, ".d.ts")) {
return;
continue;
}
const nameToDeclarations = sourceFile.getNamedDeclarations();
for (const name in nameToDeclarations) {
const declarations = nameToDeclarations[name];
// Use `someInMap` to break out early.
someInMap(sourceFile.getNamedDeclarations(), (declarations, name) => {
if (declarations) {
// First do a quick check to see if the name of the declaration matches the
// last portion of the (possibly) dotted name they're searching for.
let matches = patternMatcher.getMatchesForLastSegmentOfPattern(name);
if (!matches) {
continue;
return false;
}
for (const declaration of declarations) {
@@ -35,13 +34,13 @@ namespace ts.NavigateTo {
if (patternMatcher.patternContainsDots) {
const containers = getContainers(declaration);
if (!containers) {
return undefined;
return true; // Go to the next source file.
}
matches = patternMatcher.getMatches(containers, name);
if (!matches) {
continue;
return false;
}
}
@@ -50,8 +49,8 @@ namespace ts.NavigateTo {
rawItems.push({ name, fileName, matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration });
}
}
}
});
});
}
// Remove imports when the imported declaration is already in the list and has the same name.
rawItems = filter(rawItems, item => {