also allow handling compiled __importStar() call

This commit is contained in:
Connor Peet 2020-06-17 14:53:52 -07:00
Родитель 1d913f4fc9
Коммит fe9e66a490
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: CF8FD2EA0DBC61BD
4 изменённых файлов: 27 добавлений и 8 удалений

12
package-lock.json сгенерированный
Просмотреть файл

@ -67,9 +67,9 @@
"dev": true
},
"@types/node": {
"version": "9.3.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-9.3.0.tgz",
"integrity": "sha512-wNBfvNjzsJl4tswIZKXCFQY0lss9nKUyJnG6T94X/eqjRgI2jHZ4evdjhQYBSan/vGtF6XVXPApOmNH2rf0KKw==",
"version": "12.12.47",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.47.tgz",
"integrity": "sha512-yzBInQFhdY8kaZmqoL2+3U5dSTMrKaYcb561VU+lDzAYvqt+2lojvBEy+hmpSNuXnPTx7m9+04CzWYOUqWME2A==",
"dev": true
},
"@types/source-map": {
@ -1135,9 +1135,9 @@
"integrity": "sha1-dkpaEa9QVhkhsTPztE5hhofg9cM="
},
"typescript": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-2.6.2.tgz",
"integrity": "sha1-PFtv1/beCRQmkCfwPAlGdY92c6Q="
"version": "3.9.5",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.5.tgz",
"integrity": "sha512-hSAifV3k+i6lEoCJ2k6R2Z/rp/H3+8sdmcn5NrS3/3kE7+RyZXm9aqvxWqjEXHAd8b0pShatpcdMTvEdvAJltQ=="
},
"util-deprecate": {
"version": "1.0.2",

Просмотреть файл

@ -24,7 +24,7 @@
"@types/iconv-lite": "^0.0.1",
"@types/minimatch": "^3.0.3",
"@types/mocha": "^2.2.46",
"@types/node": "^9.3.0",
"@types/node": "^12.0.0",
"@types/source-map": "^0.5.7",
"@types/through": "^0.0.29",
"@types/vinyl": "^2.0.2",
@ -42,7 +42,7 @@
"iconv-lite": "^0.4.19",
"is": "^3.2.1",
"source-map": "^0.6.1",
"typescript": "^2.6.2",
"typescript": "^3.9.5",
"vinyl": "^2.1.0",
"xml2js": "^0.4.19",
"yargs": "^13.2.4"

Просмотреть файл

@ -466,6 +466,9 @@ function analyze(contents: string, relativeFilename: string, options: ts.Compile
if (ts.isCallExpression(node)) {
let parent = node.parent;
if (ts.isCallExpression(parent) && ts.isIdentifier(parent.expression) && parent.expression.text === '__importStar') {
parent = node.parent.parent;
}
if (ts.isVariableDeclaration(parent)) {
references = service.getReferencesAtPosition(filename, parent.name.pos + 1);
}

Просмотреть файл

@ -128,6 +128,22 @@ describe('Localize', () => {
assert.strictEqual(result.contents, expected.join('\n'));
})
it('works with compiled __importStar', () => {
let code: string[] = [
"const nls = __importStar(require('vscode-nls'))",
"var localize = nls.loadMessageBundle();",
"localize('keyOne', '{0} {1}', 'Hello', 'World');"
];
let result = nlsDev.processFile(code.join('\n'), 'foo.js');
let expected: string[] = [
"const nls = __importStar(require('vscode-nls'))",
"var localize = nls.loadMessageBundle(require('path').join(__dirname, 'foo.js'));",
"localize(0, null, 'Hello', 'World');"
];
assert.strictEqual(result.contents, expected.join('\n'));
})
it('https://github.com/Microsoft/vscode/issues/56792', () => {
let code: string[] = [
"var nls = require('vscode-nls');",