Minor cleanup for label completions (#20502)
This commit is contained in:
parent
8dca431733
commit
06aeab8f31
|
@ -40,8 +40,9 @@ namespace ts.Completions {
|
||||||
}
|
}
|
||||||
|
|
||||||
const contextToken = findPrecedingToken(position, sourceFile);
|
const contextToken = findPrecedingToken(position, sourceFile);
|
||||||
if (isInBreakOrContinue(contextToken)) {
|
if (contextToken && isBreakOrContinueStatement(contextToken.parent)
|
||||||
return getLabelCompletionAtPosition(contextToken);
|
&& (contextToken.kind === SyntaxKind.BreakKeyword || contextToken.kind === SyntaxKind.ContinueKeyword || contextToken.kind === SyntaxKind.Identifier)) {
|
||||||
|
return getLabelCompletionAtPosition(contextToken.parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
const completionData = getCompletionData(typeChecker, log, sourceFile, position, allSourceFiles, options, compilerOptions.target);
|
const completionData = getCompletionData(typeChecker, log, sourceFile, position, allSourceFiles, options, compilerOptions.target);
|
||||||
|
@ -228,13 +229,8 @@ namespace ts.Completions {
|
||||||
return uniques;
|
return uniques;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isInBreakOrContinue(contextToken: Node): boolean {
|
function getLabelCompletionAtPosition(node: BreakOrContinueStatement): CompletionInfo | undefined {
|
||||||
return contextToken && isBreakOrContinueStatement(contextToken.parent) &&
|
const entries = getLabelStatementCompletions(node);
|
||||||
(contextToken.kind === SyntaxKind.BreakKeyword || contextToken.kind === SyntaxKind.ContinueKeyword || contextToken.kind === SyntaxKind.Identifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getLabelCompletionAtPosition(contextToken: Node): CompletionInfo | undefined {
|
|
||||||
const entries = getLabelStatementCompletions(contextToken.parent);
|
|
||||||
if (entries.length) {
|
if (entries.length) {
|
||||||
return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries };
|
return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries };
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue