Skip to content

Commit db0a223

Browse files
author
Yui
committed
Merge pull request #732 from Microsoft/notShowModuleNames
Not show module names
2 parents c72e157 + f5b3409 commit db0a223

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

src/services/services.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1851,13 +1851,21 @@ module ts {
18511851
}
18521852

18531853
/// Completion
1854-
function getValidCompletionEntryDisplayName(displayName: string, target: ScriptTarget): string {
1854+
function getValidCompletionEntryDisplayName(symbol: Symbol, target: ScriptTarget): string {
1855+
var displayName = symbol.getName();
18551856
if (displayName && displayName.length > 0) {
18561857
var firstCharCode = displayName.charCodeAt(0);
1858+
// First check of the displayName is not external module; if it is an external module, it is not valid entry
1859+
if ((symbol.flags & SymbolFlags.Namespace) && (firstCharCode === CharacterCodes.singleQuote || firstCharCode === CharacterCodes.doubleQuote)) {
1860+
// If the symbol is external module, don't show it in the completion list
1861+
// (i.e declare module "http" { var x; } | // <= request completion here, "http" should not be there)
1862+
return undefined;
1863+
}
1864+
18571865
if (displayName && displayName.length >= 2 && firstCharCode === displayName.charCodeAt(displayName.length - 1) &&
18581866
(firstCharCode === CharacterCodes.singleQuote || firstCharCode === CharacterCodes.doubleQuote)) {
18591867
// If the user entered name for the symbol was quoted, removing the quotes is not enough, as the name could be an
1860-
// invalid identifer name. We need to check if whatever was inside the quotes is actually a valid identifier name.
1868+
// invalid identifier name. We need to check if whatever was inside the quotes is actually a valid identifier name.
18611869
displayName = displayName.substring(1, displayName.length - 1);
18621870
}
18631871

@@ -1866,6 +1874,7 @@ module ts {
18661874
isValid = isIdentifierPart(displayName.charCodeAt(i), target);
18671875
}
18681876

1877+
18691878
if (isValid) {
18701879
return displayName;
18711880
}
@@ -1878,7 +1887,7 @@ module ts {
18781887
// Try to get a valid display name for this symbol, if we could not find one, then ignore it.
18791888
// We would like to only show things that can be added after a dot, so for instance numeric properties can
18801889
// not be accessed with a dot (a.1 <- invalid)
1881-
var displayName = getValidCompletionEntryDisplayName(symbol.getName(), program.getCompilerOptions().target);
1890+
var displayName = getValidCompletionEntryDisplayName(symbol, program.getCompilerOptions().target);
18821891
if (!displayName) {
18831892
return undefined;
18841893
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/// <reference path="fourslash.ts"/>
2+
3+
//// declare module "http" {
4+
//// var x;
5+
//// /*1*/
6+
//// }
7+
//// declare module 'https' {
8+
//// }
9+
//// /*2*/
10+
11+
goTo.marker("1");
12+
verify.not.completionListContains("http");
13+
goTo.marker("2");
14+
verify.not.completionListContains("http");
15+
verify.not.completionListContains("https");

0 commit comments

Comments
 (0)