@inst/vscode-bin-darwin
Version:
BINARY ONLY - VSCode binary deployment for macOS
71 lines (70 loc) • 3 kB
JavaScript
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
;
Object.defineProperty(exports, "__esModule", { value: true });
const vscode_1 = require("vscode");
const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
class ConfigurationFeature {
constructor(_client) {
this._client = _client;
}
fillClientCapabilities(capabilities) {
capabilities.workspace = capabilities.workspace || {};
let configCapabilities = capabilities;
configCapabilities.workspace.configuration = true;
}
initialize() {
let client = this._client;
client.onRequest(vscode_languageserver_protocol_1.Proposed.ConfigurationRequest.type, (params, token) => {
let configuration = (params) => {
let result = [];
for (let item of params.items) {
let resource = item.scopeUri !== void 0 && item.scopeUri !== null ? this._client.protocol2CodeConverter.asUri(item.scopeUri) : undefined;
result.push(this.getConfiguration(resource, item.section !== null ? item.section : undefined));
}
return result;
};
let middleware = this.getConfigurationMiddleware();
return middleware.configuration
? middleware.configuration(params, token, configuration)
: configuration(params, token);
});
}
getConfiguration(resource, section) {
let result = null;
if (section) {
let index = section.lastIndexOf('.');
if (index === -1) {
result = vscode_1.workspace.getConfiguration(undefined, resource).get(section);
}
else {
let config = vscode_1.workspace.getConfiguration(section.substr(0, index));
if (config) {
result = config.get(section.substr(index + 1));
}
}
}
else {
let config = vscode_1.workspace.getConfiguration(undefined, resource);
result = {};
for (let key of Object.keys(config)) {
if (config.has(key)) {
result[key] = config.get(key);
}
}
}
if (!result) {
return null;
}
return result;
}
getConfigurationMiddleware() {
let middleware = this._client.clientOptions.middleware;
return middleware && middleware.workspace
? middleware.workspace
: {};
}
}
exports.ConfigurationFeature = ConfigurationFeature;