Clean up getJavaScriptCompletionEntries (#16750)
* Clean up getJavaScriptCompletionEntries * Move each parameter to its own line
This commit is contained in:
parent
dbbf051886
commit
33836f891c
1 changed files with 22 additions and 21 deletions
|
@ -57,7 +57,7 @@ namespace ts.Completions {
|
|||
|
||||
if (isSourceFileJavaScript(sourceFile)) {
|
||||
const uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log);
|
||||
addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target));
|
||||
getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target, entries);
|
||||
}
|
||||
else {
|
||||
if ((!symbols || symbols.length === 0) && keywordFilters === KeywordCompletionFilters.None) {
|
||||
|
@ -79,33 +79,34 @@ namespace ts.Completions {
|
|||
return { isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, entries };
|
||||
}
|
||||
|
||||
function getJavaScriptCompletionEntries(sourceFile: SourceFile, position: number, uniqueNames: Map<true>, target: ScriptTarget): CompletionEntry[] {
|
||||
const entries: CompletionEntry[] = [];
|
||||
|
||||
const nameTable = getNameTable(sourceFile);
|
||||
nameTable.forEach((pos, name) => {
|
||||
function getJavaScriptCompletionEntries(
|
||||
sourceFile: SourceFile,
|
||||
position: number,
|
||||
uniqueNames: Map<true>,
|
||||
target: ScriptTarget,
|
||||
entries: Push<CompletionEntry>): void {
|
||||
getNameTable(sourceFile).forEach((pos, name) => {
|
||||
// Skip identifiers produced only from the current location
|
||||
if (pos === position) {
|
||||
return;
|
||||
}
|
||||
const realName = unescapeLeadingUnderscores(name);
|
||||
|
||||
if (!uniqueNames.get(realName)) {
|
||||
uniqueNames.set(realName, true);
|
||||
const displayName = getCompletionEntryDisplayName(realName, target, /*performCharacterChecks*/ true);
|
||||
if (displayName) {
|
||||
const entry = {
|
||||
name: displayName,
|
||||
kind: ScriptElementKind.warning,
|
||||
kindModifiers: "",
|
||||
sortText: "1"
|
||||
};
|
||||
entries.push(entry);
|
||||
}
|
||||
if (uniqueNames.has(realName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
uniqueNames.set(realName, true);
|
||||
const displayName = getCompletionEntryDisplayName(realName, target, /*performCharacterChecks*/ true);
|
||||
if (displayName) {
|
||||
entries.push({
|
||||
name: displayName,
|
||||
kind: ScriptElementKind.warning,
|
||||
kindModifiers: "",
|
||||
sortText: "1"
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
function createCompletionEntry(symbol: Symbol, location: Node, performCharacterChecks: boolean, typeChecker: TypeChecker, target: ScriptTarget): CompletionEntry {
|
||||
|
@ -141,7 +142,7 @@ namespace ts.Completions {
|
|||
const entry = createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target);
|
||||
if (entry) {
|
||||
const id = entry.name;
|
||||
if (!uniqueNames.get(id)) {
|
||||
if (!uniqueNames.has(id)) {
|
||||
entries.push(entry);
|
||||
uniqueNames.set(id, true);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue