@@ -3255,11 +3255,6 @@ namespace ts {
3255
3255
* @returns true if 'symbols' was successfully populated; false otherwise.
3256
3256
*/
3257
3257
function tryGetImportOrExportClauseCompletionSymbols ( namedImportsOrExports : NamedImportsOrExports ) : boolean {
3258
- // cursor is in import clause
3259
- // try to show exported member for imported module
3260
- isMemberCompletion = true ;
3261
- isNewIdentifierLocation = false ;
3262
-
3263
3258
let declarationKind = namedImportsOrExports . kind === SyntaxKind . NamedImports ?
3264
3259
SyntaxKind . ImportDeclaration :
3265
3260
SyntaxKind . ExportDeclaration ;
@@ -3270,13 +3265,16 @@ namespace ts {
3270
3265
return false ;
3271
3266
}
3272
3267
3268
+ isMemberCompletion = true ;
3269
+ isNewIdentifierLocation = false ;
3270
+
3273
3271
let exports : Symbol [ ] ;
3274
3272
let moduleSpecifierSymbol = typeChecker . getSymbolAtLocation ( importOrExportDeclaration . moduleSpecifier ) ;
3275
3273
if ( moduleSpecifierSymbol ) {
3276
3274
exports = typeChecker . getExportsOfModule ( moduleSpecifierSymbol ) ;
3277
3275
}
3278
3276
3279
- symbols = exports ? filterModuleExports ( exports , namedImportsOrExports ) : emptyArray ;
3277
+ symbols = exports ? filterNamedImportOrExportCompletionItems ( exports , namedImportsOrExports . elements ) : emptyArray ;
3280
3278
3281
3279
return true ;
3282
3280
}
@@ -3474,26 +3472,41 @@ namespace ts {
3474
3472
return false ;
3475
3473
}
3476
3474
3477
- function filterModuleExports ( exports : Symbol [ ] , namedImportsOrExports : NamedImportsOrExports ) : Symbol [ ] {
3478
- let exisingImports : Map < boolean > = { } ;
3475
+ /**
3476
+ * Filters out completion suggestions for named imports or exports.
3477
+ *
3478
+ * @param exportsOfModule The list of symbols which a module exposes.
3479
+ * @param namedImportsOrExports The list of existing import/export specifiers in the import/export clause.
3480
+ *
3481
+ * @returns Symbols to be suggested at an import/export clause, barring those whose named imports/exports
3482
+ * do not occur at the current position and have not otherwise been typed.
3483
+ */
3484
+ function filterNamedImportOrExportCompletionItems ( exportsOfModule : Symbol [ ] , namedImportsOrExports : ImportOrExportSpecifier [ ] ) : Symbol [ ] {
3485
+ let exisingImportsOrExports : Map < boolean > = { } ;
3479
3486
3480
- for ( let element of namedImportsOrExports . elements ) {
3487
+ for ( let element of namedImportsOrExports ) {
3481
3488
// If this is the current item we are editing right now, do not filter it out
3482
3489
if ( element . getStart ( ) <= position && position <= element . getEnd ( ) ) {
3483
3490
continue ;
3484
3491
}
3485
3492
3486
3493
let name = element . propertyName || element . name ;
3487
- exisingImports [ name . text ] = true ;
3494
+ exisingImportsOrExports [ name . text ] = true ;
3488
3495
}
3489
3496
3490
- if ( isEmpty ( exisingImports ) ) {
3491
- return exports ;
3497
+ if ( isEmpty ( exisingImportsOrExports ) ) {
3498
+ return exportsOfModule ;
3492
3499
}
3493
3500
3494
- return filter ( exports , e => ! lookUp ( exisingImports , e . name ) ) ;
3501
+ return filter ( exportsOfModule , e => ! lookUp ( exisingImportsOrExports , e . name ) ) ;
3495
3502
}
3496
3503
3504
+ /**
3505
+ * Filters out completion suggestions for named imports or exports.
3506
+ *
3507
+ * @returns Symbols to be suggested in an object binding pattern or object literal expression, barring those whose declarations
3508
+ * do not occur at the current position and have not otherwise been typed.
3509
+ */
3497
3510
function filterObjectMembersList ( contextualMemberSymbols : Symbol [ ] , existingMembers : Declaration [ ] ) : Symbol [ ] {
3498
3511
if ( ! existingMembers || existingMembers . length === 0 ) {
3499
3512
return contextualMemberSymbols ;
@@ -3538,6 +3551,12 @@ namespace ts {
3538
3551
return filteredMembers ;
3539
3552
}
3540
3553
3554
+ /**
3555
+ * Filters out completion suggestions from 'symbols' according to existing JSX attributes.
3556
+ *
3557
+ * @returns Symbols to be suggested in a JSX element, barring those whose attributes
3558
+ * do not occur at the current position and have not otherwise been typed.
3559
+ */
3541
3560
function filterJsxAttributes ( attributes : NodeArray < JsxAttribute | JsxSpreadAttribute > , symbols : Symbol [ ] ) : Symbol [ ] {
3542
3561
let seenNames : Map < boolean > = { } ;
3543
3562
for ( let attr of attributes ) {
0 commit comments