Skip to content

Commit 1521cc3

Browse files
committed
Merge remote-tracking branch 'source/master' into feature/keychords
2 parents 50670b9 + 780d15a commit 1521cc3

371 files changed

Lines changed: 7994 additions & 6979 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.

.vscode/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,7 @@
4848
}, {
4949
"fileMatch": [ "cglicenses.json" ],
5050
"url": "./.vscode/cglicenses.schema.json"
51-
}]
51+
}
52+
],
53+
"git.ignoreLimitWarning": true
5254
}

CONTRIBUTING.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ If you find your issue already exists, make relevant comments and add your [reac
3737
* 👍 - upvote
3838
* 👎 - downvote
3939

40-
4140
If you cannot find an existing issue that describes your bug or feature, create a new issue using the guidelines below.
4241

4342
### Writing Good Bug Reports and Feature Requests
@@ -52,7 +51,9 @@ The built-in tool for reporting an issue, which you can access by using `Report
5251

5352
Please include the following with each issue:
5453

55-
* Version of VS Code
54+
* Version of VS Code
55+
56+
* Your operating system
5657

5758
* List of extensions that you have installed
5859

build/lib/i18n.resources.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,10 @@
238238
"name": "vs/workbench/services/decorations",
239239
"project": "vscode-workbench"
240240
},
241+
{
242+
"name": "vs/workbench/services/label",
243+
"project": "vscode-workbench"
244+
},
241245
{
242246
"name": "vs/workbench/services/preferences",
243247
"project": "vscode-preferences"

extensions/css-language-features/client/src/cssMain.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import * as fs from 'fs';
99
import * as nls from 'vscode-nls';
1010
const localize = nls.loadMessageBundle();
1111

12-
import { languages, window, commands, ExtensionContext, Range, Position, CompletionItem, CompletionItemKind, TextEdit, SnippetString } from 'vscode';
12+
import { languages, window, commands, ExtensionContext, Range, Position, CompletionItem, CompletionItemKind, TextEdit, SnippetString, workspace } from 'vscode';
1313
import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind, Disposable } from 'vscode-languageclient';
14+
import { getCustomDataPathsInAllWorkspaces, getCustomDataPathsFromAllExtensions } from './customData';
1415

1516
// this method is called when vs code is activated
1617
export function activate(context: ExtensionContext) {
@@ -30,13 +31,19 @@ export function activate(context: ExtensionContext) {
3031

3132
let documentSelector = ['css', 'scss', 'less'];
3233

34+
let dataPaths = [
35+
...getCustomDataPathsInAllWorkspaces(workspace.workspaceFolders),
36+
...getCustomDataPathsFromAllExtensions()
37+
];
38+
3339
// Options to control the language client
3440
let clientOptions: LanguageClientOptions = {
3541
documentSelector,
3642
synchronize: {
3743
configurationSection: ['css', 'scss', 'less']
3844
},
3945
initializationOptions: {
46+
dataPaths
4047
}
4148
};
4249

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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 * as path from 'path';
7+
import { workspace, WorkspaceFolder, extensions } from 'vscode';
8+
9+
interface ExperimentalConfig {
10+
experimental?: {
11+
customData?: string[];
12+
};
13+
}
14+
15+
export function getCustomDataPathsInAllWorkspaces(workspaceFolders: WorkspaceFolder[] | undefined): string[] {
16+
const dataPaths: string[] = [];
17+
18+
if (!workspaceFolders) {
19+
return dataPaths;
20+
}
21+
22+
workspaceFolders.forEach(wf => {
23+
const allCssConfig = workspace.getConfiguration(undefined, wf.uri);
24+
const wfCSSConfig = allCssConfig.inspect<ExperimentalConfig>('css');
25+
if (
26+
wfCSSConfig &&
27+
wfCSSConfig.workspaceFolderValue &&
28+
wfCSSConfig.workspaceFolderValue.experimental &&
29+
wfCSSConfig.workspaceFolderValue.experimental.customData
30+
) {
31+
wfCSSConfig.workspaceFolderValue.experimental.customData.forEach(p => [
32+
dataPaths.push(path.resolve(wf.uri.fsPath, p))
33+
]);
34+
}
35+
});
36+
37+
return dataPaths;
38+
}
39+
40+
export function getCustomDataPathsFromAllExtensions(): string[] {
41+
const dataPaths: string[] = [];
42+
43+
for (const extension of extensions.all) {
44+
const contributes = extension.packageJSON && extension.packageJSON.contributes;
45+
46+
if (contributes && contributes.css && contributes.css.customData && Array.isArray(contributes.css.customData)) {
47+
const relativePaths: string[] = contributes.css.customData;
48+
relativePaths.forEach(rp => {
49+
dataPaths.push(path.resolve(extension.extensionPath, rp));
50+
});
51+
}
52+
}
53+
54+
return dataPaths;
55+
}

extensions/css-language-features/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
"id": "css",
3333
"title": "%css.title%",
3434
"properties": {
35+
"css.experimental.customData": {
36+
"type": "array",
37+
"description": "A list of JSON file paths that define custom CSS data that loads custom properties, at directives, pseudo classes / elements.",
38+
"default": [],
39+
"scope": "resource"
40+
},
3541
"css.validate": {
3642
"type": "boolean",
3743
"scope": "resource",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"main": "./out/cssServerMain",
1111
"dependencies": {
12-
"vscode-css-languageservice": "^3.0.13-next.3",
12+
"vscode-css-languageservice": "^3.0.13-next.6",
1313
"vscode-languageserver": "^5.1.0"
1414
},
1515
"devDependencies": {

extensions/css-language-features/server/src/cssServerMain.ts

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ import {
77
createConnection, IConnection, TextDocuments, InitializeParams, InitializeResult, ServerCapabilities, ConfigurationRequest, WorkspaceFolder
88
} from 'vscode-languageserver';
99
import URI from 'vscode-uri';
10+
import * as fs from 'fs';
1011
import { TextDocument, CompletionList } from 'vscode-languageserver-types';
1112

12-
import { getCSSLanguageService, getSCSSLanguageService, getLESSLanguageService, LanguageSettings, LanguageService, Stylesheet } from 'vscode-css-languageservice';
13+
import { getCSSLanguageService, getSCSSLanguageService, getLESSLanguageService, LanguageSettings, LanguageService, Stylesheet, CSSData } from 'vscode-css-languageservice';
1314
import { getLanguageModelCache } from './languageModelCache';
1415
import { getPathCompletionParticipant } from './pathCompletion';
1516
import { formatError, runSafe } from './utils/runner';
1617
import { getDocumentContext } from './utils/documentContext';
18+
import { parseCSSData } from './utils/languageFacts';
1719

1820
export interface Settings {
1921
css: LanguageSettings;
@@ -50,6 +52,8 @@ let scopedSettingsSupport = false;
5052
let foldingRangeLimit = Number.MAX_VALUE;
5153
let workspaceFolders: WorkspaceFolder[];
5254

55+
const languageServices: { [id: string]: LanguageService } = {};
56+
5357
// After the server has started the client sends an initialize request. The server receives
5458
// in the passed params the rootPath of the workspace plus the client capabilities.
5559
connection.onInitialize((params: InitializeParams): InitializeResult => {
@@ -61,6 +65,19 @@ connection.onInitialize((params: InitializeParams): InitializeResult => {
6165
}
6266
}
6367

68+
const dataPaths: string[] = params.initializationOptions.dataPaths;
69+
70+
const customDataCollections: CSSData[] = [];
71+
72+
dataPaths.forEach(p => {
73+
if (fs.existsSync(p)) {
74+
const data = parseCSSData(fs.readFileSync(p, 'utf-8'));
75+
customDataCollections.push(data);
76+
} else {
77+
return;
78+
}
79+
});
80+
6481
function getClientCapability<T>(name: string, def: T) {
6582
const keys = name.split('.');
6683
let c: any = params.capabilities;
@@ -76,6 +93,10 @@ connection.onInitialize((params: InitializeParams): InitializeResult => {
7693
scopedSettingsSupport = !!getClientCapability('workspace.configuration', false);
7794
foldingRangeLimit = getClientCapability('textDocument.foldingRange.rangeLimit', Number.MAX_VALUE);
7895

96+
languageServices.css = getCSSLanguageService({ customDataCollections });
97+
languageServices.scss = getSCSSLanguageService({ customDataCollections });
98+
languageServices.less = getLESSLanguageService({ customDataCollections });
99+
79100
const capabilities: ServerCapabilities = {
80101
// Tell the client that the server works in FULL text document sync mode
81102
textDocumentSync: documents.syncKind,
@@ -96,12 +117,6 @@ connection.onInitialize((params: InitializeParams): InitializeResult => {
96117
return { capabilities };
97118
});
98119

99-
const languageServices: { [id: string]: LanguageService } = {
100-
css: getCSSLanguageService(),
101-
scss: getSCSSLanguageService(),
102-
less: getLESSLanguageService()
103-
};
104-
105120
function getLanguageService(document: TextDocument) {
106121
let service = languageServices[document.languageId];
107122
if (!service) {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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 { CSSData } from 'vscode-css-languageservice';
7+
8+
export function parseCSSData(source: string): CSSData {
9+
let rawData: any;
10+
11+
try {
12+
rawData = JSON.parse(source);
13+
} catch (err) {
14+
return {};
15+
}
16+
17+
return {
18+
properties: rawData.properties || [],
19+
atDirectives: rawData.atdirectives || [],
20+
pseudoClasses: rawData.pseudoclasses || [],
21+
pseudoElements: rawData.pseudoelements || []
22+
};
23+
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,10 @@ supports-color@5.4.0:
229229
dependencies:
230230
has-flag "^3.0.0"
231231

232-
vscode-css-languageservice@^3.0.13-next.3:
233-
version "3.0.13-next.3"
234-
resolved "https://registry.yarnpkg.com/vscode-css-languageservice/-/vscode-css-languageservice-3.0.13-next.3.tgz#b9e6f253cace52fbb749d2fe194ae4b196f3543e"
235-
integrity sha512-7+7JddZRt8zFRLbqygxJw+GHtbQ5o2YvgEFvi4ixvbUAX6KlY3Yw6CgUUbg9dmBla7h+GbtoDjwiLFV6Oy+SBQ==
232+
vscode-css-languageservice@^3.0.13-next.6:
233+
version "3.0.13-next.6"
234+
resolved "https://registry.yarnpkg.com/vscode-css-languageservice/-/vscode-css-languageservice-3.0.13-next.6.tgz#0329ea1da29ca84d1821cd32ee10bca0ee4c50cd"
235+
integrity sha512-wC8zaFWHNnqIaOT4LXByy3NyTl916uHxGy3U3cpV7Gw7F8ENylSGM2RAO+l7NohIbP0WZlet441HEwSbb+bZbQ==
236236
dependencies:
237237
vscode-languageserver-types "^3.13.0"
238238
vscode-nls "^4.0.0"

0 commit comments

Comments
 (0)