Skip to content

Commit 56d45b2

Browse files
authored
Merge branch 'main' into notebookMultiMove
2 parents 74c0ed7 + a810804 commit 56d45b2

File tree

35 files changed

+372
-148
lines changed

35 files changed

+372
-148
lines changed

build/azure-pipelines/cli/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ parameters:
77
default: stable
88

99
steps:
10-
- template: ./install-rust.yml
10+
- template: ./install-rust-posix.yml
1111
parameters:
1212
targets: []
1313
channel: ${{ parameters.VSCODE_CLI_RUST_CHANNEL }}

build/lib/i18n.js

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Licensed under the MIT License. See License.txt in the project root for license information.
55
*--------------------------------------------------------------------------------------------*/
66
Object.defineProperty(exports, "__esModule", { value: true });
7-
exports.prepareIslFiles = exports.prepareI18nPackFiles = exports.createXlfFilesForIsl = exports.createXlfFilesForExtensions = exports.createXlfFilesForCoreBundle = exports.getResource = exports.processNlsFiles = exports.XLF = exports.Line = exports.externalExtensionsWithTranslations = exports.extraLanguages = exports.defaultLanguages = void 0;
7+
exports.prepareIslFiles = exports.prepareI18nPackFiles = exports.createXlfFilesForIsl = exports.createXlfFilesForExtensions = exports.createXlfFilesForCoreBundle = exports.getResource = exports.processNlsFiles = exports.XLF = exports.Line = exports.extraLanguages = exports.defaultLanguages = void 0;
88
const path = require("path");
99
const fs = require("fs");
1010
const event_stream_1 = require("event-stream");
@@ -37,7 +37,7 @@ exports.extraLanguages = [
3737
{ id: 'tr', folderName: 'trk' }
3838
];
3939
// non built-in extensions also that are transifex and need to be part of the language packs
40-
exports.externalExtensionsWithTranslations = {
40+
const externalExtensionsWithTranslations = {
4141
'vscode-chrome-debug': 'msjsdiag.debugger-for-chrome',
4242
'vscode-node-debug': 'ms-vscode.node-debug',
4343
'vscode-node-debug2': 'ms-vscode.node-debug2'
@@ -508,6 +508,28 @@ function createXlfFilesForCoreBundle() {
508508
});
509509
}
510510
exports.createXlfFilesForCoreBundle = createXlfFilesForCoreBundle;
511+
function createL10nBundleForExtension(extensionName) {
512+
const result = (0, event_stream_1.through)();
513+
gulp.src([
514+
`extensions/${extensionName}/src/**/*.ts`,
515+
]).pipe((0, event_stream_1.writeArray)((err, files) => {
516+
if (err) {
517+
result.emit('error', err);
518+
return;
519+
}
520+
const json = (0, l10n_dev_1.getL10nJson)(files.map(file => {
521+
return file.contents.toString('utf8');
522+
}));
523+
if (Object.keys(json)) {
524+
result.emit('data', new File({
525+
path: `${extensionName}/bundle.l10n.json`,
526+
contents: Buffer.from(JSON.stringify(json), 'utf8')
527+
}));
528+
}
529+
result.emit('end');
530+
}));
531+
return result;
532+
}
511533
function createXlfFilesForExtensions() {
512534
let counter = 0;
513535
let folderStreamEnded = false;
@@ -530,7 +552,7 @@ function createXlfFilesForExtensions() {
530552
}
531553
return _l10nMap;
532554
}
533-
gulp.src([`.build/extensions/${extensionName}/package.nls.json`, `.build/extensions/${extensionName}/**/nls.metadata.json`], { allowEmpty: true }).pipe((0, event_stream_1.through)(function (file) {
555+
(0, event_stream_1.merge)(gulp.src([`.build/extensions/${extensionName}/package.nls.json`, `.build/extensions/${extensionName}/**/nls.metadata.json`], { allowEmpty: true }), createL10nBundleForExtension(extensionName)).pipe((0, event_stream_1.through)(function (file) {
534556
if (file.isBuffer()) {
535557
const buffer = file.contents;
536558
const basename = path.basename(file.path);
@@ -554,6 +576,10 @@ function createXlfFilesForExtensions() {
554576
getL10nMap().set(`extensions/${extensionName}/${relPath}/${file}`, info);
555577
}
556578
}
579+
else if (basename === 'bundle.l10n.json') {
580+
const json = JSON.parse(buffer.toString('utf8'));
581+
getL10nMap().set(`extensions/${extensionName}/bundle`, json);
582+
}
557583
else {
558584
this.emit('error', new Error(`${file.path} is not a valid extension nls file`));
559585
return;
@@ -664,7 +690,7 @@ function getRecordFromL10nJsonFormat(l10nJsonFormat) {
664690
}
665691
return record;
666692
}
667-
function prepareI18nPackFiles(externalExtensions, resultingTranslationPaths) {
693+
function prepareI18nPackFiles(resultingTranslationPaths) {
668694
const parsePromises = [];
669695
const mainPack = { version: i18nPackVersion, contents: {} };
670696
const extensionsPacks = {};
@@ -685,7 +711,7 @@ function prepareI18nPackFiles(externalExtensions, resultingTranslationPaths) {
685711
if (!extPack) {
686712
extPack = extensionsPacks[resource] = { version: i18nPackVersion, contents: {} };
687713
}
688-
const externalId = externalExtensions[resource];
714+
const externalId = externalExtensionsWithTranslations[resource];
689715
if (!externalId) { // internal extension: remove 'extensions/extensionId/' segnent
690716
const secondSlash = path.indexOf('/', firstSlash + 1);
691717
extPack.contents[path.substring(secondSlash + 1)] = getRecordFromL10nJsonFormat(file.messages);
@@ -713,7 +739,7 @@ function prepareI18nPackFiles(externalExtensions, resultingTranslationPaths) {
713739
for (const extension in extensionsPacks) {
714740
const translatedExtFile = createI18nFile(`extensions/${extension}`, extensionsPacks[extension]);
715741
this.queue(translatedExtFile);
716-
const externalExtensionId = externalExtensions[extension];
742+
const externalExtensionId = externalExtensionsWithTranslations[extension];
717743
if (externalExtensionId) {
718744
resultingTranslationPaths.push({ id: externalExtensionId, resourceName: `extensions/${extension}.i18n.json` });
719745
}

build/lib/i18n.ts

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
import * as path from 'path';
77
import * as fs from 'fs';
88

9-
import { through, ThroughStream } from 'event-stream';
9+
import { merge, through, ThroughStream, writeArray } from 'event-stream';
1010
import * as File from 'vinyl';
1111
import * as Is from 'is';
1212
import * as xml2js from 'xml2js';
1313
import * as gulp from 'gulp';
1414
import * as fancyLog from 'fancy-log';
1515
import * as ansiColors from 'ansi-colors';
1616
import * as iconv from '@vscode/iconv-lite-umd';
17-
import { l10nJsonFormat, getL10nXlf, l10nJsonDetails, getL10nFilesFromXlf } from '@vscode/l10n-dev';
17+
import { l10nJsonFormat, getL10nXlf, l10nJsonDetails, getL10nFilesFromXlf, getL10nJson } from '@vscode/l10n-dev';
1818

1919
function log(message: any, ...rest: any[]): void {
2020
fancyLog(ansiColors.green('[i18n]'), message, ...rest);
@@ -50,7 +50,7 @@ export const extraLanguages: Language[] = [
5050
];
5151

5252
// non built-in extensions also that are transifex and need to be part of the language packs
53-
export const externalExtensionsWithTranslations = {
53+
const externalExtensionsWithTranslations: Record<string, string> = {
5454
'vscode-chrome-debug': 'msjsdiag.debugger-for-chrome',
5555
'vscode-node-debug': 'ms-vscode.node-debug',
5656
'vscode-node-debug2': 'ms-vscode.node-debug2'
@@ -586,6 +586,32 @@ export function createXlfFilesForCoreBundle(): ThroughStream {
586586
});
587587
}
588588

589+
function createL10nBundleForExtension(extensionName: string): ThroughStream {
590+
const result = through();
591+
gulp.src([
592+
`extensions/${extensionName}/src/**/*.ts`,
593+
]).pipe(writeArray((err, files: File[]) => {
594+
if (err) {
595+
result.emit('error', err);
596+
return;
597+
}
598+
599+
const json = getL10nJson(files.map(file => {
600+
return file.contents.toString('utf8');
601+
}));
602+
603+
if (Object.keys(json)) {
604+
result.emit('data', new File({
605+
path: `${extensionName}/bundle.l10n.json`,
606+
contents: Buffer.from(JSON.stringify(json), 'utf8')
607+
}));
608+
}
609+
result.emit('end');
610+
}));
611+
612+
return result;
613+
}
614+
589615
export function createXlfFilesForExtensions(): ThroughStream {
590616
let counter: number = 0;
591617
let folderStreamEnded: boolean = false;
@@ -608,7 +634,10 @@ export function createXlfFilesForExtensions(): ThroughStream {
608634
}
609635
return _l10nMap;
610636
}
611-
gulp.src([`.build/extensions/${extensionName}/package.nls.json`, `.build/extensions/${extensionName}/**/nls.metadata.json`], { allowEmpty: true }).pipe(through(function (file: File) {
637+
merge(
638+
gulp.src([`.build/extensions/${extensionName}/package.nls.json`, `.build/extensions/${extensionName}/**/nls.metadata.json`], { allowEmpty: true }),
639+
createL10nBundleForExtension(extensionName)
640+
).pipe(through(function (file: File) {
612641
if (file.isBuffer()) {
613642
const buffer: Buffer = file.contents as Buffer;
614643
const basename = path.basename(file.path);
@@ -631,6 +660,9 @@ export function createXlfFilesForExtensions(): ThroughStream {
631660
}
632661
getL10nMap().set(`extensions/${extensionName}/${relPath}/${file}`, info);
633662
}
663+
} else if (basename === 'bundle.l10n.json') {
664+
const json: l10nJsonFormat = JSON.parse(buffer.toString('utf8'));
665+
getL10nMap().set(`extensions/${extensionName}/bundle`, json);
634666
} else {
635667
this.emit('error', new Error(`${file.path} is not a valid extension nls file`));
636668
return;
@@ -762,7 +794,7 @@ function getRecordFromL10nJsonFormat(l10nJsonFormat: l10nJsonFormat): Record<str
762794
return record;
763795
}
764796

765-
export function prepareI18nPackFiles(externalExtensions: Record<string, string>, resultingTranslationPaths: TranslationPath[]): NodeJS.ReadWriteStream {
797+
export function prepareI18nPackFiles(resultingTranslationPaths: TranslationPath[]): NodeJS.ReadWriteStream {
766798
const parsePromises: Promise<l10nJsonDetails[]>[] = [];
767799
const mainPack: I18nPack = { version: i18nPackVersion, contents: {} };
768800
const extensionsPacks: Record<string, I18nPack> = {};
@@ -785,7 +817,7 @@ export function prepareI18nPackFiles(externalExtensions: Record<string, string>,
785817
if (!extPack) {
786818
extPack = extensionsPacks[resource] = { version: i18nPackVersion, contents: {} };
787819
}
788-
const externalId = externalExtensions[resource];
820+
const externalId = externalExtensionsWithTranslations[resource];
789821
if (!externalId) { // internal extension: remove 'extensions/extensionId/' segnent
790822
const secondSlash = path.indexOf('/', firstSlash + 1);
791823
extPack.contents[path.substring(secondSlash + 1)] = getRecordFromL10nJsonFormat(file.messages);
@@ -814,7 +846,7 @@ export function prepareI18nPackFiles(externalExtensions: Record<string, string>,
814846
const translatedExtFile = createI18nFile(`extensions/${extension}`, extensionsPacks[extension]);
815847
this.queue(translatedExtFile);
816848

817-
const externalExtensionId = externalExtensions[extension];
849+
const externalExtensionId = externalExtensionsWithTranslations[extension];
818850
if (externalExtensionId) {
819851
resultingTranslationPaths.push({ id: externalExtensionId, resourceName: `extensions/${extension}.i18n.json` });
820852
} else {

build/npm/update-localization-extension.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function update(options) {
6868
console.log(`Importing translations for ${languageId} form '${location}' to '${translationDataFolder}' ...`);
6969
let translationPaths = [];
7070
gulp.src(path.join(location, '**', languageId, '*.xlf'), { silent: false })
71-
.pipe(i18n.prepareI18nPackFiles(i18n.externalExtensionsWithTranslations, translationPaths))
71+
.pipe(i18n.prepareI18nPackFiles(translationPaths))
7272
.on('error', (error) => {
7373
console.log(`Error occurred while importing translations:`);
7474
translationPaths = undefined;

extensions/github-authentication/src/githubServer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export class GitHubServer implements IGitHubServer {
156156

157157
// Used for showing a friendlier message to the user when the explicitly cancel a flow.
158158
let userCancelled: boolean | undefined;
159-
const yes = localize('yes', "Yes");
159+
const yes = vscode.l10n.t('Yes');
160160
const no = localize('no', "No");
161161
const promptToContinue = async () => {
162162
if (userCancelled === undefined) {

extensions/typescript-language-features/src/languageFeatures/completions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ class MyCompletionItem extends vscode.CompletionItem {
521521
}
522522
}
523523

524-
function getScriptKindDetails(tsEntry: protocol.CompletionEntry,): string | undefined {
524+
function getScriptKindDetails(tsEntry: Proto.CompletionEntry,): string | undefined {
525525
if (!tsEntry.kindModifiers || tsEntry.kind !== PConst.Kind.script) {
526526
return;
527527
}
Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1-
import * as Proto from 'typescript/lib/protocol';
2-
export = Proto;
1+
import * as ts from 'typescript/lib/tsserverlibrary';
2+
export = ts.server.protocol;
3+
34

45
declare enum ServerType {
56
Syntax = 'syntax',
67
Semantic = 'semantic',
78
}
8-
declare module 'typescript/lib/protocol' {
99

10-
interface Response {
11-
readonly _serverType?: ServerType;
10+
declare module 'typescript/lib/tsserverlibrary' {
11+
namespace server.protocol {
12+
type TextInsertion = ts.TextInsertion;
13+
type ScriptElementKind = ts.ScriptElementKind;
14+
15+
interface Response {
16+
readonly _serverType?: ServerType;
17+
}
1218
}
1319
}

extensions/typescript-language-features/src/utils/configuration.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import * as vscode from 'vscode';
77
import * as objects from '../utils/objects';
8+
import * as Proto from '../protocol';
89

910
export enum TsServerLogLevel {
1011
Off,
@@ -112,7 +113,7 @@ export interface TypeScriptServiceConfiguration {
112113
readonly enableProjectDiagnostics: boolean;
113114
readonly maxTsServerMemory: number;
114115
readonly enablePromptUseWorkspaceTsdk: boolean;
115-
readonly watchOptions: protocol.WatchOptions | undefined;
116+
readonly watchOptions: Proto.WatchOptions | undefined;
116117
readonly includePackageJsonAutoImports: 'auto' | 'on' | 'off' | undefined;
117118
readonly enableTsServerTracing: boolean;
118119
}
@@ -196,8 +197,8 @@ export abstract class BaseServiceConfigurationProvider implements ServiceConfigu
196197
return configuration.get<boolean>('typescript.tsserver.experimental.enableProjectDiagnostics', false);
197198
}
198199

199-
protected readWatchOptions(configuration: vscode.WorkspaceConfiguration): protocol.WatchOptions | undefined {
200-
return configuration.get<protocol.WatchOptions>('typescript.tsserver.watchOptions');
200+
protected readWatchOptions(configuration: vscode.WorkspaceConfiguration): Proto.WatchOptions | undefined {
201+
return configuration.get<Proto.WatchOptions>('typescript.tsserver.watchOptions');
201202
}
202203

203204
protected readIncludePackageJsonAutoImports(configuration: vscode.WorkspaceConfiguration): 'auto' | 'on' | 'off' | undefined {

extensions/typescript-language-features/src/utils/tsconfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export async function openProjectConfigForFile(
163163
return;
164164
}
165165

166-
let res: ServerResponse.Response<protocol.ProjectInfoResponse> | undefined;
166+
let res: ServerResponse.Response<Proto.ProjectInfoResponse> | undefined;
167167
try {
168168
res = await client.execute('projectInfo', { file, needFileNameList: false }, nulToken);
169169
} catch {

0 commit comments

Comments
 (0)