Merge pull request #1089 from Microsoft/completionEntryOfImport
Block completion list on import declaration name and fix the crash in sy...
This commit is contained in:
commit
d634ab8ceb
2 changed files with 34 additions and 4 deletions
|
@ -2634,6 +2634,7 @@ module ts {
|
||||||
case SyntaxKind.VarKeyword:
|
case SyntaxKind.VarKeyword:
|
||||||
case SyntaxKind.GetKeyword:
|
case SyntaxKind.GetKeyword:
|
||||||
case SyntaxKind.SetKeyword:
|
case SyntaxKind.SetKeyword:
|
||||||
|
case SyntaxKind.ImportKeyword:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3081,13 +3082,13 @@ module ts {
|
||||||
displayParts.push(keywordPart(SyntaxKind.ImportKeyword));
|
displayParts.push(keywordPart(SyntaxKind.ImportKeyword));
|
||||||
displayParts.push(spacePart());
|
displayParts.push(spacePart());
|
||||||
addFullSymbolName(symbol);
|
addFullSymbolName(symbol);
|
||||||
displayParts.push(spacePart());
|
|
||||||
displayParts.push(punctuationPart(SyntaxKind.EqualsToken));
|
|
||||||
displayParts.push(spacePart());
|
|
||||||
ts.forEach(symbol.declarations, declaration => {
|
ts.forEach(symbol.declarations, declaration => {
|
||||||
if (declaration.kind === SyntaxKind.ImportDeclaration) {
|
if (declaration.kind === SyntaxKind.ImportDeclaration) {
|
||||||
var importDeclaration = <ImportDeclaration>declaration;
|
var importDeclaration = <ImportDeclaration>declaration;
|
||||||
if (importDeclaration.externalModuleName) {
|
if (importDeclaration.externalModuleName) {
|
||||||
|
displayParts.push(spacePart());
|
||||||
|
displayParts.push(punctuationPart(SyntaxKind.EqualsToken));
|
||||||
|
displayParts.push(spacePart());
|
||||||
displayParts.push(keywordPart(SyntaxKind.RequireKeyword));
|
displayParts.push(keywordPart(SyntaxKind.RequireKeyword));
|
||||||
displayParts.push(punctuationPart(SyntaxKind.OpenParenToken));
|
displayParts.push(punctuationPart(SyntaxKind.OpenParenToken));
|
||||||
displayParts.push(displayPart(getTextOfNode(importDeclaration.externalModuleName), SymbolDisplayPartKind.stringLiteral));
|
displayParts.push(displayPart(getTextOfNode(importDeclaration.externalModuleName), SymbolDisplayPartKind.stringLiteral));
|
||||||
|
@ -3095,7 +3096,12 @@ module ts {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var internalAliasSymbol = typeResolver.getSymbolInfo(importDeclaration.entityName);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
24
tests/cases/fourslash/completionEntryForImportName.ts
Normal file
24
tests/cases/fourslash/completionEntryForImportName.ts
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
///<reference path="fourslash.ts" />
|
||||||
|
|
||||||
|
////import /*1*/ /*2*/
|
||||||
|
|
||||||
|
goTo.marker('1');
|
||||||
|
verify.completionListIsEmpty();
|
||||||
|
edit.insert('q');
|
||||||
|
verify.completionListIsEmpty();
|
||||||
|
verifyIncompleteImportName();
|
||||||
|
|
||||||
|
goTo.marker('2');
|
||||||
|
edit.insert(" = ");
|
||||||
|
verifyIncompleteImportName();
|
||||||
|
|
||||||
|
goTo.marker("2");
|
||||||
|
edit.moveRight(" = ".length);
|
||||||
|
edit.insert("a.");
|
||||||
|
verifyIncompleteImportName();
|
||||||
|
|
||||||
|
function verifyIncompleteImportName() {
|
||||||
|
goTo.marker('1');
|
||||||
|
verify.completionListIsEmpty();
|
||||||
|
verify.quickInfoIs("import q");
|
||||||
|
}
|
Loading…
Reference in a new issue