mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-10 18:04:18 -05:00
Block completion list on import declaration name and fix the crash in symbol display name when import declaration is incomplete
Fixes #991
This commit is contained in:
@@ -2614,6 +2614,7 @@ module ts {
|
||||
case SyntaxKind.VarKeyword:
|
||||
case SyntaxKind.GetKeyword:
|
||||
case SyntaxKind.SetKeyword:
|
||||
case SyntaxKind.ImportKeyword:
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3061,13 +3062,13 @@ module ts {
|
||||
displayParts.push(keywordPart(SyntaxKind.ImportKeyword));
|
||||
displayParts.push(spacePart());
|
||||
addFullSymbolName(symbol);
|
||||
displayParts.push(spacePart());
|
||||
displayParts.push(punctuationPart(SyntaxKind.EqualsToken));
|
||||
displayParts.push(spacePart());
|
||||
ts.forEach(symbol.declarations, declaration => {
|
||||
if (declaration.kind === SyntaxKind.ImportDeclaration) {
|
||||
var importDeclaration = <ImportDeclaration>declaration;
|
||||
if (importDeclaration.externalModuleName) {
|
||||
displayParts.push(spacePart());
|
||||
displayParts.push(punctuationPart(SyntaxKind.EqualsToken));
|
||||
displayParts.push(spacePart());
|
||||
displayParts.push(keywordPart(SyntaxKind.RequireKeyword));
|
||||
displayParts.push(punctuationPart(SyntaxKind.OpenParenToken));
|
||||
displayParts.push(displayPart(getTextOfNode(importDeclaration.externalModuleName), SymbolDisplayPartKind.stringLiteral));
|
||||
@@ -3075,7 +3076,12 @@ module ts {
|
||||
}
|
||||
else {
|
||||
var internalAliasSymbol = typeResolver.getSymbolInfo(importDeclaration.entityName);
|
||||
addFullSymbolName(internalAliasSymbol, enclosingDeclaration);
|
||||
if (internalAliasSymbol) {
|
||||
displayParts.push(spacePart());
|
||||
displayParts.push(punctuationPart(SyntaxKind.EqualsToken));
|
||||
displayParts.push(spacePart());
|
||||
addFullSymbolName(internalAliasSymbol, enclosingDeclaration);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
14
tests/cases/fourslash/completionEntryForImportName.ts
Normal file
14
tests/cases/fourslash/completionEntryForImportName.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
///<reference path="fourslash.ts" />
|
||||
|
||||
////import /*1*/q = /*2*/
|
||||
|
||||
verifyIncompleteImport();
|
||||
goTo.marker('2');
|
||||
edit.insert("a.");
|
||||
verifyIncompleteImport();
|
||||
|
||||
function verifyIncompleteImport() {
|
||||
goTo.marker('1');
|
||||
verify.completionListIsEmpty();
|
||||
verify.quickInfoIs("import q");
|
||||
}
|
||||
Reference in New Issue
Block a user