Skip to content

Commit 951abb3

Browse files
committed
Merge branch 'master' into joao/scm-view
2 parents bdcb290 + 43faa69 commit 951abb3

126 files changed

Lines changed: 3484 additions & 2232 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/latest-release-monitor.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Latest Release Monitor
22
on:
33
schedule:
44
- cron: 0/5 * * * *
5+
repository_dispatch:
6+
types: [trigger-latest-release-monitor]
57

68
jobs:
79
main:

extensions/css-language-features/server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"main": "./out/node/cssServerMain",
1111
"browser": "./dist/browser/cssServerMain",
1212
"dependencies": {
13-
"vscode-css-languageservice": "4.3.0-next.2",
13+
"vscode-css-languageservice": "^4.3.0-next.3",
1414
"vscode-languageserver": "7.0.0-next.3",
1515
"vscode-uri": "^2.1.2"
1616
},

extensions/css-language-features/server/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -701,10 +701,10 @@ to-regex-range@^5.0.1:
701701
dependencies:
702702
is-number "^7.0.0"
703703

704-
vscode-css-languageservice@4.3.0-next.2:
705-
version "4.3.0-next.2"
706-
resolved "https://registry.yarnpkg.com/vscode-css-languageservice/-/vscode-css-languageservice-4.3.0-next.2.tgz#a7a1289d8d68ddcdee55d4f18b12a455acaf5962"
707-
integrity sha512-4h/s/N7wt6If/5EUNMtfAbwWwImH6EvveqZMf9SmQdMMMqekZkRLA68E98hGzuzI13rHEiLckwlAC+RNLq6FXg==
704+
vscode-css-languageservice@^4.3.0-next.3:
705+
version "4.3.0-next.3"
706+
resolved "https://registry.yarnpkg.com/vscode-css-languageservice/-/vscode-css-languageservice-4.3.0-next.3.tgz#0c19ebcc7df5c41104c86f5f2bb9b4537924a33b"
707+
integrity sha512-ILm9qONhfeCV+XZs93w9c1U8GFb67KXpbUS1i8aw2kYcuVME2XunUy5XsVlxDUzUyuWBAw+OWvcP+aTRwPaeyA==
708708
dependencies:
709709
vscode-languageserver-textdocument "^1.0.1"
710710
vscode-languageserver-types "3.16.0-next.2"
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
const path = require('path');
7+
const fs = require('fs');
8+
const child_process = require('child_process');
9+
10+
const generatedNote = `//
11+
// **NOTE**: Do not edit directly! This file is generated using \`npm run import-typescript\`
12+
//
13+
`;
14+
15+
const TYPESCRIPT_LIB_SOURCE = path.join(__dirname, '../../node_modules/typescript/lib');
16+
const TYPESCRIPT_LIB_DESTINATION = path.join(__dirname, '../server/build');
17+
18+
(function () {
19+
try {
20+
fs.statSync(TYPESCRIPT_LIB_DESTINATION);
21+
} catch (err) {
22+
fs.mkdirSync(TYPESCRIPT_LIB_DESTINATION);
23+
}
24+
importLibs('es6');
25+
})();
26+
27+
28+
function importLibs(startLib) {
29+
function getFileName(name) {
30+
return (name === '' ? 'lib.d.ts' : `lib.${name}.d.ts`);
31+
}
32+
function getVariableName(name) {
33+
return (name === '' ? 'lib_dts' : `lib_${name.replace(/\./g, '_')}_dts`);
34+
}
35+
function readLibFile(name) {
36+
var srcPath = path.join(TYPESCRIPT_LIB_SOURCE, getFileName(name));
37+
return fs.readFileSync(srcPath).toString();
38+
}
39+
40+
var queue = [];
41+
var in_queue = {};
42+
43+
var enqueue = function (name) {
44+
if (in_queue[name]) {
45+
return;
46+
}
47+
in_queue[name] = true;
48+
queue.push(name);
49+
};
50+
51+
enqueue(startLib);
52+
53+
var result = [];
54+
while (queue.length > 0) {
55+
var name = queue.shift();
56+
var contents = readLibFile(name);
57+
var lines = contents.split(/\r\n|\r|\n/);
58+
59+
var output = '';
60+
var writeOutput = function (text) {
61+
if (output.length === 0) {
62+
output = text;
63+
} else {
64+
output += ` + ${text}`;
65+
}
66+
};
67+
var outputLines = [];
68+
var flushOutputLines = function () {
69+
writeOutput(`"${escapeText(outputLines.join('\n'))}"`);
70+
outputLines = [];
71+
};
72+
var deps = [];
73+
for (let i = 0; i < lines.length; i++) {
74+
let m = lines[i].match(/\/\/\/\s*<reference\s*lib="([^"]+)"/);
75+
if (m) {
76+
flushOutputLines();
77+
writeOutput(getVariableName(m[1]));
78+
deps.push(getVariableName(m[1]));
79+
enqueue(m[1]);
80+
continue;
81+
}
82+
outputLines.push(lines[i]);
83+
}
84+
flushOutputLines();
85+
86+
result.push({
87+
name: getVariableName(name),
88+
deps: deps,
89+
output: output
90+
});
91+
}
92+
93+
var strResult = `/*---------------------------------------------------------------------------------------------
94+
* Copyright (c) Microsoft Corporation. All rights reserved.
95+
* Licensed under the MIT License. See License.txt in the project root for license information.
96+
*--------------------------------------------------------------------------------------------*/
97+
${generatedNote}`;
98+
// Do a topological sort
99+
while (result.length > 0) {
100+
for (let i = result.length - 1; i >= 0; i--) {
101+
if (result[i].deps.length === 0) {
102+
// emit this node
103+
strResult += `\nexport const ${result[i].name}: string = ${result[i].output};\n`;
104+
105+
// mark dep as resolved
106+
for (let j = 0; j < result.length; j++) {
107+
for (let k = 0; k < result[j].deps.length; k++) {
108+
if (result[j].deps[k] === result[i].name) {
109+
result[j].deps.splice(k, 1);
110+
break;
111+
}
112+
}
113+
}
114+
115+
// remove from result
116+
result.splice(i, 1);
117+
break;
118+
}
119+
}
120+
}
121+
122+
var dstPath = path.join(TYPESCRIPT_LIB_DESTINATION, 'lib.ts');
123+
fs.writeFileSync(dstPath, strResult);
124+
}
125+
126+
/**
127+
* Escape text such that it can be used in a javascript string enclosed by double quotes (")
128+
*/
129+
function escapeText(text) {
130+
// See http://www.javascriptkit.com/jsref/escapesequence.shtml
131+
var _backspace = '\b'.charCodeAt(0);
132+
var _formFeed = '\f'.charCodeAt(0);
133+
var _newLine = '\n'.charCodeAt(0);
134+
var _nullChar = 0;
135+
var _carriageReturn = '\r'.charCodeAt(0);
136+
var _tab = '\t'.charCodeAt(0);
137+
var _verticalTab = '\v'.charCodeAt(0);
138+
var _backslash = '\\'.charCodeAt(0);
139+
var _doubleQuote = '"'.charCodeAt(0);
140+
141+
var startPos = 0, chrCode, replaceWith = null, resultPieces = [];
142+
143+
for (var i = 0, len = text.length; i < len; i++) {
144+
chrCode = text.charCodeAt(i);
145+
switch (chrCode) {
146+
case _backspace:
147+
replaceWith = '\\b';
148+
break;
149+
case _formFeed:
150+
replaceWith = '\\f';
151+
break;
152+
case _newLine:
153+
replaceWith = '\\n';
154+
break;
155+
case _nullChar:
156+
replaceWith = '\\0';
157+
break;
158+
case _carriageReturn:
159+
replaceWith = '\\r';
160+
break;
161+
case _tab:
162+
replaceWith = '\\t';
163+
break;
164+
case _verticalTab:
165+
replaceWith = '\\v';
166+
break;
167+
case _backslash:
168+
replaceWith = '\\\\';
169+
break;
170+
case _doubleQuote:
171+
replaceWith = '\\"';
172+
break;
173+
}
174+
if (replaceWith !== null) {
175+
resultPieces.push(text.substring(startPos, i));
176+
resultPieces.push(replaceWith);
177+
startPos = i + 1;
178+
replaceWith = null;
179+
}
180+
}
181+
resultPieces.push(text.substring(startPos, len));
182+
return resultPieces.join('');
183+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import { ExtensionContext } from 'vscode';
7+
import { LanguageClientOptions } from 'vscode-languageclient';
8+
import { startClient, LanguageClientConstructor } from '../htmlClient';
9+
import { LanguageClient } from 'vscode-languageclient/browser';
10+
11+
declare const Worker: {
12+
new(stringUrl: string): any;
13+
};
14+
declare const TextDecoder: {
15+
new(encoding?: string): { decode(buffer: ArrayBuffer): string; };
16+
};
17+
18+
// this method is called when vs code is activated
19+
export function activate(context: ExtensionContext) {
20+
const serverMain = context.asAbsolutePath('server/dist/browser/htmlServerMain.js');
21+
try {
22+
const worker = new Worker(serverMain);
23+
const newLanguageClient: LanguageClientConstructor = (id: string, name: string, clientOptions: LanguageClientOptions) => {
24+
return new LanguageClient(id, name, clientOptions, worker);
25+
};
26+
27+
startClient(context, newLanguageClient, { TextDecoder });
28+
29+
} catch (e) {
30+
console.log(e);
31+
}
32+
}

extensions/html-language-features/client/src/customData.ts

Lines changed: 61 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,55 +3,86 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import * as path from 'path';
7-
import { workspace, WorkspaceFolder, extensions } from 'vscode';
6+
import { workspace, extensions, Uri, EventEmitter, Disposable } from 'vscode';
7+
import { resolvePath, joinPath } from './requests';
88

9-
interface ExperimentalConfig {
10-
customData?: string[];
11-
experimental?: {
12-
customData?: string[];
9+
export function getCustomDataSource(toDispose: Disposable[]) {
10+
let pathsInWorkspace = getCustomDataPathsInAllWorkspaces();
11+
let pathsInExtensions = getCustomDataPathsFromAllExtensions();
12+
13+
const onChange = new EventEmitter<void>();
14+
15+
toDispose.push(extensions.onDidChange(_ => {
16+
const newPathsInExtensions = getCustomDataPathsFromAllExtensions();
17+
if (newPathsInExtensions.length !== pathsInExtensions.length || !newPathsInExtensions.every((val, idx) => val === pathsInExtensions[idx])) {
18+
pathsInExtensions = newPathsInExtensions;
19+
onChange.fire();
20+
}
21+
}));
22+
toDispose.push(workspace.onDidChangeConfiguration(e => {
23+
if (e.affectsConfiguration('html.customData')) {
24+
pathsInWorkspace = getCustomDataPathsInAllWorkspaces();
25+
onChange.fire();
26+
}
27+
}));
28+
29+
return {
30+
get uris() {
31+
return pathsInWorkspace.concat(pathsInExtensions);
32+
},
33+
get onDidChange() {
34+
return onChange.event;
35+
}
1336
};
1437
}
1538

16-
export function getCustomDataPathsInAllWorkspaces(workspaceFolders: readonly WorkspaceFolder[] | undefined): string[] {
39+
40+
function getCustomDataPathsInAllWorkspaces(): string[] {
41+
const workspaceFolders = workspace.workspaceFolders;
42+
1743
const dataPaths: string[] = [];
1844

1945
if (!workspaceFolders) {
2046
return dataPaths;
2147
}
2248

23-
workspaceFolders.forEach(wf => {
24-
const allHtmlConfig = workspace.getConfiguration(undefined, wf.uri);
25-
const wfHtmlConfig = allHtmlConfig.inspect<ExperimentalConfig>('html');
26-
27-
if (wfHtmlConfig && wfHtmlConfig.workspaceFolderValue && wfHtmlConfig.workspaceFolderValue.customData) {
28-
const customData = wfHtmlConfig.workspaceFolderValue.customData;
29-
if (Array.isArray(customData)) {
30-
customData.forEach(t => {
31-
if (typeof t === 'string') {
32-
dataPaths.push(path.resolve(wf.uri.fsPath, t));
33-
}
34-
});
49+
const collect = (paths: string[] | undefined, rootFolder: Uri) => {
50+
if (Array.isArray(paths)) {
51+
for (const path of paths) {
52+
if (typeof path === 'string') {
53+
dataPaths.push(resolvePath(rootFolder, path).toString());
54+
}
3555
}
3656
}
37-
});
57+
};
3858

59+
for (let i = 0; i < workspaceFolders.length; i++) {
60+
const folderUri = workspaceFolders[i].uri;
61+
const allHtmlConfig = workspace.getConfiguration('html', folderUri);
62+
const customDataInspect = allHtmlConfig.inspect<string[]>('customData');
63+
if (customDataInspect) {
64+
collect(customDataInspect.workspaceFolderValue, folderUri);
65+
if (i === 0) {
66+
if (workspace.workspaceFile) {
67+
collect(customDataInspect.workspaceValue, workspace.workspaceFile);
68+
}
69+
collect(customDataInspect.globalValue, folderUri);
70+
}
71+
}
72+
73+
}
3974
return dataPaths;
4075
}
4176

42-
export function getCustomDataPathsFromAllExtensions(): string[] {
77+
function getCustomDataPathsFromAllExtensions(): string[] {
4378
const dataPaths: string[] = [];
44-
4579
for (const extension of extensions.all) {
46-
const contributes = extension.packageJSON && extension.packageJSON.contributes;
47-
48-
if (contributes && contributes.html && contributes.html.customData && Array.isArray(contributes.html.customData)) {
49-
const relativePaths: string[] = contributes.html.customData;
50-
relativePaths.forEach(rp => {
51-
dataPaths.push(path.resolve(extension.extensionPath, rp));
52-
});
80+
const customData = extension.packageJSON?.contributes?.html?.customData;
81+
if (Array.isArray(customData)) {
82+
for (const rp of customData) {
83+
dataPaths.push(joinPath(extension.extensionUri, rp).toString());
84+
}
5385
}
5486
}
55-
5687
return dataPaths;
5788
}

0 commit comments

Comments
 (0)