Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions src/services/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ namespace ts.Completions {
}

// Get all entities in the current scope.
completionKind = CompletionKind.None;
completionKind = CompletionKind.Global;
isNewIdentifierLocation = isNewIdentifierDefinitionLocation(contextToken);

if (previousToken !== contextToken) {
Expand Down Expand Up @@ -1123,9 +1123,6 @@ namespace ts.Completions {
position;

const scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile;
if (isGlobalCompletionScope(scopeNode)) {
completionKind = CompletionKind.Global;
}

const symbolMeanings = SymbolFlags.Type | SymbolFlags.Value | SymbolFlags.Namespace | SymbolFlags.Alias;

Expand All @@ -1150,18 +1147,6 @@ namespace ts.Completions {
return true;
}

function isGlobalCompletionScope(scopeNode: Node): boolean {
switch (scopeNode.kind) {
case SyntaxKind.SourceFile:
case SyntaxKind.TemplateExpression:
case SyntaxKind.JsxExpression:
case SyntaxKind.Block:
return true;
default:
return isStatement(scopeNode);
}
}

function filterGlobalCompletion(symbols: Symbol[]): void {
filterMutate(symbols, symbol => {
if (!isSourceFile(location)) {
Expand Down
6 changes: 3 additions & 3 deletions tests/cases/fourslash/completionListIsGlobalCompletion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
////}
/////*11*/ // insert globals
////const y = <div /*12*/ />; // no globals in jsx attribute found
////const z = <div =/*13*/ />; // no globals in jsx attribute with syntax error
////const z = <div =/*13*/ />; // Syntax error makes it looks like an expression position, so globals
////const x = `/*14*/ ${/*15*/}`; // globals only in template expression
////var user = </*16*/User name=/*17*/{ /*18*/window.isLoggedIn ? window.name : '/*19*/'} />; // globals only in JSX expression (but not in JSX expression strings)
goTo.marker("1");
Expand Down Expand Up @@ -59,15 +59,15 @@ verify.completionListIsGlobal(true);
goTo.marker("12");
verify.completionListIsGlobal(false);
goTo.marker("13");
verify.completionListIsGlobal(false);
verify.completionListIsGlobal(true);
goTo.marker("14");
verify.completionListIsGlobal(false);
goTo.marker("15");
verify.completionListIsGlobal(true);
goTo.marker("16");
verify.completionListIsGlobal(false);
goTo.marker("17");
verify.completionListIsGlobal(false);
verify.completionListIsGlobal(true); // TODO: GH#21341
goTo.marker("18");
verify.completionListIsGlobal(true);
goTo.marker("19");
Expand Down