(existingImports, symbolName, position, checker)
| 153199 | }; |
| 153200 | } |
| 153201 | function tryUseExistingNamespaceImport(existingImports, symbolName, position, checker) { |
| 153202 | // It is possible that multiple import statements with the same specifier exist in the file. |
| 153203 | // e.g. |
| 153204 | // |
| 153205 | // import * as ns from "foo"; |
| 153206 | // import { member1, member2 } from "foo"; |
| 153207 | // |
| 153208 | // member3/**/ <-- cusor here |
| 153209 | // |
| 153210 | // in this case we should provie 2 actions: |
| 153211 | // 1. change "member3" to "ns.member3" |
| 153212 | // 2. add "member3" to the second import statement's import list |
| 153213 | // and it is up to the user to decide which one fits best. |
| 153214 | return ts.firstDefined(existingImports, function (_a) { |
| 153215 | var _b; |
| 153216 | var declaration = _a.declaration; |
| 153217 | var namespacePrefix = getNamespaceLikeImportText(declaration); |
| 153218 | var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text; |
| 153219 | if (namespacePrefix && moduleSpecifier) { |
| 153220 | var moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker); |
| 153221 | if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) { |
| 153222 | return { kind: 0 /* ImportFixKind.UseNamespace */, namespacePrefix: namespacePrefix, position: position, moduleSpecifier: moduleSpecifier }; |
| 153223 | } |
| 153224 | } |
| 153225 | }); |
| 153226 | } |
| 153227 | function getTargetModuleFromNamespaceLikeImport(declaration, checker) { |
| 153228 | var _a; |
| 153229 | switch (declaration.kind) { |
no test coverage detected