mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-09 20:51:43 -06:00
Merge branch 'master' into cleanup
This commit is contained in:
commit
27e233e595
@ -1810,13 +1810,21 @@ module ts {
|
||||
}
|
||||
|
||||
/// Completion
|
||||
function getValidCompletionEntryDisplayName(displayName: string, target: ScriptTarget): string {
|
||||
function getValidCompletionEntryDisplayName(symbol: Symbol, target: ScriptTarget): string {
|
||||
var displayName = symbol.getName();
|
||||
if (displayName && displayName.length > 0) {
|
||||
var firstCharCode = displayName.charCodeAt(0);
|
||||
// First check of the displayName is not external module; if it is an external module, it is not valid entry
|
||||
if ((symbol.flags & SymbolFlags.Namespace) && (firstCharCode === CharacterCodes.singleQuote || firstCharCode === CharacterCodes.doubleQuote)) {
|
||||
// If the symbol is external module, don't show it in the completion list
|
||||
// (i.e declare module "http" { var x; } | // <= request completion here, "http" should not be there)
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (displayName && displayName.length >= 2 && firstCharCode === displayName.charCodeAt(displayName.length - 1) &&
|
||||
(firstCharCode === CharacterCodes.singleQuote || firstCharCode === CharacterCodes.doubleQuote)) {
|
||||
// If the user entered name for the symbol was quoted, removing the quotes is not enough, as the name could be an
|
||||
// invalid identifer name. We need to check if whatever was inside the quotes is actually a valid identifier name.
|
||||
// invalid identifier name. We need to check if whatever was inside the quotes is actually a valid identifier name.
|
||||
displayName = displayName.substring(1, displayName.length - 1);
|
||||
}
|
||||
|
||||
@ -1825,6 +1833,7 @@ module ts {
|
||||
isValid = isIdentifierPart(displayName.charCodeAt(i), target);
|
||||
}
|
||||
|
||||
|
||||
if (isValid) {
|
||||
return displayName;
|
||||
}
|
||||
@ -1837,7 +1846,7 @@ module ts {
|
||||
// Try to get a valid display name for this symbol, if we could not find one, then ignore it.
|
||||
// We would like to only show things that can be added after a dot, so for instance numeric properties can
|
||||
// not be accessed with a dot (a.1 <- invalid)
|
||||
var displayName = getValidCompletionEntryDisplayName(symbol.getName(), program.getCompilerOptions().target);
|
||||
var displayName = getValidCompletionEntryDisplayName(symbol, program.getCompilerOptions().target);
|
||||
if (!displayName) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
//// declare module "http" {
|
||||
//// var x;
|
||||
//// /*1*/
|
||||
//// }
|
||||
//// declare module 'https' {
|
||||
//// }
|
||||
//// /*2*/
|
||||
|
||||
goTo.marker("1");
|
||||
verify.not.completionListContains("http");
|
||||
goTo.marker("2");
|
||||
verify.not.completionListContains("http");
|
||||
verify.not.completionListContains("https");
|
||||
Loading…
x
Reference in New Issue
Block a user