Handel export default declaration completions

This commit is contained in:
Mohamed Hegazy
2015-03-30 20:28:24 -07:00
parent bea7221174
commit 383f01dbf6
3 changed files with 30 additions and 1 deletions

View File

@@ -2404,6 +2404,11 @@ module ts {
return undefined;
}
// If this is the default export, get the name of the declaration if it exists
if (displayName === "default" && symbol.valueDeclaration && (symbol.valueDeclaration.flags & NodeFlags.Default) && symbol.valueDeclaration.localSymbol && symbol.valueDeclaration.localSymbol.name) {
displayName = symbol.valueDeclaration.localSymbol.name;
}
let 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)) {
@@ -2620,7 +2625,7 @@ module ts {
previousToken.getStart() :
position;
let scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile);
let scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile;
/// TODO filter meaning based on the current context
let symbolMeanings = SymbolFlags.Type | SymbolFlags.Value | SymbolFlags.Namespace | SymbolFlags.Alias;

View File

@@ -0,0 +1,12 @@
/// <reference path='./fourslash.ts'/>
////export default class C {
//// method() { /*1*/ }
////}
//// /*2*/
goTo.marker('1');
verify.completionListContains("C", "class C", /*documentation*/ undefined, "class");
goTo.marker('2');
verify.completionListContains("C", "class C", /*documentation*/ undefined, "class");

View File

@@ -0,0 +1,12 @@
/// <reference path='./fourslash.ts'/>
////export default function func() {
//// /*1*/
////}
//// /*2*/
goTo.marker('1');
verify.completionListContains("func", "function func(): void", /*documentation*/ undefined, "function");
goTo.marker('2');
verify.completionListContains("func", "function func(): void", /*documentation*/ undefined, "function");