diff --git a/build/tfs/common/installDistro.js b/build/tfs/common/installDistro.js deleted file mode 100644 index aa6b3429d9..0000000000 --- a/build/tfs/common/installDistro.js +++ /dev/null @@ -1,14 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the Source EULA. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ -var cp = require('child_process'); -function yarnInstall(package) { - cp.execSync("yarn add --no-lockfile " + package); -} -var product = require('../../../product.json'); -var dependencies = product.dependencies || {}; -Object.keys(dependencies).forEach(function (name) { - var url = dependencies[name]; - yarnInstall(url); -}); diff --git a/build/tfs/common/publish.js b/build/tfs/common/publish.js deleted file mode 100644 index 9958e70ee0..0000000000 --- a/build/tfs/common/publish.js +++ /dev/null @@ -1,327 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the Source EULA. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ -'use strict'; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var fs = require("fs"); -var child_process_1 = require("child_process"); -var crypto = require("crypto"); -var azure = require("azure-storage"); -var mime = require("mime"); -var minimist = require("minimist"); -var documentdb_1 = require("documentdb"); -// {{SQL CARBON EDIT}} -if (process.argv.length < 9) { - console.error('Usage: node publish.js [commit_id]'); - process.exit(-1); -} -function hashStream(hashName, stream) { - return new Promise(function (c, e) { - var shasum = crypto.createHash(hashName); - stream - .on('data', shasum.update.bind(shasum)) - .on('error', e) - .on('close', function () { return c(shasum.digest('hex')); }); - }); -} -function createDefaultConfig(quality) { - return { - id: quality, - frozen: false - }; -} -function getConfig(quality) { - var client = new documentdb_1.DocumentClient(process.env['AZURE_DOCUMENTDB_ENDPOINT'], { masterKey: process.env['AZURE_DOCUMENTDB_MASTERKEY'] }); - var collection = 'dbs/builds/colls/config'; - var query = { - query: "SELECT TOP 1 * FROM c WHERE c.id = @quality", - parameters: [ - { name: '@quality', value: quality } - ] - }; - return new Promise(function (c, e) { - client.queryDocuments(collection, query).toArray(function (err, results) { - if (err && err.code !== 409) { - return e(err); - } - c(!results || results.length === 0 ? createDefaultConfig(quality) : results[0]); - }); - }); -} -function createOrUpdate(commit, quality, platform, type, release, asset, isUpdate) { - var client = new documentdb_1.DocumentClient(process.env['AZURE_DOCUMENTDB_ENDPOINT'], { masterKey: process.env['AZURE_DOCUMENTDB_MASTERKEY'] }); - var collection = 'dbs/builds/colls/' + quality; - var updateQuery = { - query: 'SELECT TOP 1 * FROM c WHERE c.id = @id', - parameters: [{ name: '@id', value: commit }] - }; - var updateTries = 0; - function update() { - updateTries++; - return new Promise(function (c, e) { - client.queryDocuments(collection, updateQuery).toArray(function (err, results) { - if (err) { - return e(err); - } - if (results.length !== 1) { - return e(new Error('No documents')); - } - var release = results[0]; - release.assets = release.assets.filter(function (a) { return !(a.platform === platform && a.type === type); }).concat([ - asset - ]); - if (isUpdate) { - release.updates[platform] = type; - } - client.replaceDocument(release._self, release, function (err) { - if (err && err.code === 409 && updateTries < 5) { - return c(update()); - } - if (err) { - return e(err); - } - console.log('Build successfully updated.'); - c(); - }); - }); - }); - } - return new Promise(function (c, e) { - client.createDocument(collection, release, function (err) { - if (err && err.code === 409) { - return c(update()); - } - if (err) { - return e(err); - } - console.log('Build successfully published.'); - c(); - }); - }); -} -function assertContainer(blobService, quality) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, new Promise(function (c, e) { return blobService.createContainerIfNotExists(quality, { publicAccessLevel: 'blob' }, function (err) { return err ? e(err) : c(); }); })]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); -} -function doesAssetExist(blobService, quality, blobName) { - return __awaiter(this, void 0, void 0, function () { - var existsResult; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, new Promise(function (c, e) { return blobService.doesBlobExist(quality, blobName, function (err, r) { return err ? e(err) : c(r); }); })]; - case 1: - existsResult = _a.sent(); - return [2 /*return*/, existsResult.exists]; - } - }); - }); -} -function uploadBlob(blobService, quality, blobName, file) { - return __awaiter(this, void 0, void 0, function () { - var blobOptions; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - blobOptions = { - contentSettings: { - contentType: mime.lookup(file), - cacheControl: 'max-age=31536000, public' - } - }; - return [4 /*yield*/, new Promise(function (c, e) { return blobService.createBlockBlobFromLocalFile(quality, blobName, file, blobOptions, function (err) { return err ? e(err) : c(); }); })]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); -} -function publish(commit, quality, platform, type, name, version, _isUpdate, file, opts) { - return __awaiter(this, void 0, void 0, function () { - var isUpdate, queuedBy, sourceBranch, isReleased, stat, size, stream, _a, sha1hash, sha256hash, blobName, storageAccount, blobService, blobExists, promises, mooncakeBlobService, _b, blobExists_1, moooncakeBlobExists, promises_1, config, asset, release; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - isUpdate = _isUpdate === 'true'; - queuedBy = process.env['BUILD_QUEUEDBY']; - sourceBranch = process.env['BUILD_SOURCEBRANCH']; - isReleased = quality === 'insider' - && /^master$|^refs\/heads\/master$/.test(sourceBranch) - && /Project Collection Service Accounts|Microsoft.VisualStudio.Services.TFS/.test(queuedBy); - console.log('Publishing...'); - console.log('Quality:', quality); - console.log('Platform:', platform); - console.log('Type:', type); - console.log('Name:', name); - console.log('Version:', version); - console.log('Commit:', commit); - console.log('Is Update:', isUpdate); - console.log('Is Released:', isReleased); - console.log('File:', file); - return [4 /*yield*/, new Promise(function (c, e) { return fs.stat(file, function (err, stat) { return err ? e(err) : c(stat); }); })]; - case 1: - stat = _c.sent(); - size = stat.size; - console.log('Size:', size); - stream = fs.createReadStream(file); - return [4 /*yield*/, Promise.all([hashStream('sha1', stream), hashStream('sha256', stream)])]; - case 2: - _a = _c.sent(), sha1hash = _a[0], sha256hash = _a[1]; - console.log('SHA1:', sha1hash); - console.log('SHA256:', sha256hash); - blobName = commit + '/' + name; - storageAccount = process.env['AZURE_STORAGE_ACCOUNT_2']; - blobService = azure.createBlobService(storageAccount, process.env['AZURE_STORAGE_ACCESS_KEY_2']) - .withFilter(new azure.ExponentialRetryPolicyFilter(20)); - // {{SQL CARBON EDIT}} - return [4 /*yield*/, assertContainer(blobService, quality)]; - case 3: - // {{SQL CARBON EDIT}} - _c.sent(); - return [4 /*yield*/, doesAssetExist(blobService, quality, blobName)]; - case 4: - blobExists = _c.sent(); - promises = []; - if (!blobExists) { - promises.push(uploadBlob(blobService, quality, blobName, file)); - } - if (!process.env['MOONCAKE_STORAGE_ACCESS_KEY']) return [3 /*break*/, 7]; - mooncakeBlobService = azure.createBlobService(storageAccount, process.env['MOONCAKE_STORAGE_ACCESS_KEY'], storageAccount + ".blob.core.chinacloudapi.cn") - .withFilter(new azure.ExponentialRetryPolicyFilter(20)); - // mooncake is fussy and far away, this is needed! - mooncakeBlobService.defaultClientRequestTimeoutInMs = 10 * 60 * 1000; - return [4 /*yield*/, Promise.all([ - assertContainer(blobService, quality), - assertContainer(mooncakeBlobService, quality) - ])]; - case 5: - _c.sent(); - return [4 /*yield*/, Promise.all([ - doesAssetExist(blobService, quality, blobName), - doesAssetExist(mooncakeBlobService, quality, blobName) - ])]; - case 6: - _b = _c.sent(), blobExists_1 = _b[0], moooncakeBlobExists = _b[1]; - promises_1 = []; - if (!blobExists_1) { - promises_1.push(uploadBlob(blobService, quality, blobName, file)); - } - if (!moooncakeBlobExists) { - promises_1.push(uploadBlob(mooncakeBlobService, quality, blobName, file)); - } - return [3 /*break*/, 8]; - case 7: - console.log('Skipping Mooncake publishing.'); - _c.label = 8; - case 8: - if (promises.length === 0) { - console.log("Blob " + quality + ", " + blobName + " already exists, not publishing again."); - return [2 /*return*/]; - } - console.log('Uploading blobs to Azure storage...'); - return [4 /*yield*/, Promise.all(promises)]; - case 9: - _c.sent(); - console.log('Blobs successfully uploaded.'); - return [4 /*yield*/, getConfig(quality)]; - case 10: - config = _c.sent(); - console.log('Quality config:', config); - asset = { - platform: platform, - type: type, - url: process.env['AZURE_CDN_URL'] + "/" + quality + "/" + blobName, - // {{SQL CARBON EDIT}} - mooncakeUrl: process.env['MOONCAKE_CDN_URL'] ? process.env['MOONCAKE_CDN_URL'] + "/" + quality + "/" + blobName : undefined, - hash: sha1hash, - sha256hash: sha256hash, - size: size - }; - // Remove this if we ever need to rollback fast updates for windows - if (/win32/.test(platform)) { - asset.supportsFastUpdate = true; - } - console.log('Asset:', JSON.stringify(asset, null, ' ')); - release = { - id: commit, - timestamp: (new Date()).getTime(), - version: version, - isReleased: config.frozen ? false : isReleased, - sourceBranch: sourceBranch, - queuedBy: queuedBy, - assets: [], - updates: {} - }; - if (!opts['upload-only']) { - release.assets.push(asset); - if (isUpdate) { - release.updates[platform] = type; - } - } - return [4 /*yield*/, createOrUpdate(commit, quality, platform, type, release, asset, isUpdate)]; - case 11: - _c.sent(); - return [2 /*return*/]; - } - }); - }); -} -function main() { - var opts = minimist(process.argv.slice(2), { - boolean: ['upload-only'] - }); - // {{SQL CARBON EDIT}} - var _a = opts._, quality = _a[0], platform = _a[1], type = _a[2], name = _a[3], version = _a[4], _isUpdate = _a[5], file = _a[6], commit = _a[7]; - if (!commit) { - commit = child_process_1.execSync('git rev-parse HEAD', { encoding: 'utf8' }).trim(); - } - publish(commit, quality, platform, type, name, version, _isUpdate, file, opts).catch(function (err) { - console.error(err); - process.exit(1); - }); -} -main(); diff --git a/build/tfs/common/symbols.js b/build/tfs/common/symbols.js deleted file mode 100644 index e023b8ca9b..0000000000 --- a/build/tfs/common/symbols.js +++ /dev/null @@ -1,248 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the Source EULA. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ -'use strict'; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var request = require("request"); -var fs_1 = require("fs"); -var github = require("github-releases"); -var path_1 = require("path"); -var os_1 = require("os"); -var util_1 = require("util"); -var BASE_URL = 'https://rink.hockeyapp.net/api/2/'; -var HOCKEY_APP_TOKEN_HEADER = 'X-HockeyAppToken'; -var Platform; -(function (Platform) { - Platform["WIN_32"] = "win32-ia32"; - Platform["WIN_64"] = "win32-x64"; - Platform["LINUX_32"] = "linux-ia32"; - Platform["LINUX_64"] = "linux-x64"; - Platform["MAC_OS"] = "darwin-x64"; -})(Platform || (Platform = {})); -function symbolsZipName(platform, electronVersion, insiders) { - return (insiders ? 'insiders' : 'stable') + "-symbols-v" + electronVersion + "-" + platform + ".zip"; -} -var SEED = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; -function tmpFile(name) { - return __awaiter(this, void 0, void 0, function () { - var res, i, tmpParent; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - res = ''; - for (i = 0; i < 8; i++) { - res += SEED.charAt(Math.floor(Math.random() * SEED.length)); - } - tmpParent = path_1.join(os_1.tmpdir(), res); - return [4 /*yield*/, util_1.promisify(fs_1.mkdir)(tmpParent)]; - case 1: - _a.sent(); - return [2 /*return*/, path_1.join(tmpParent, name)]; - } - }); - }); -} -function getVersions(accessor) { - var _a; - return asyncRequest({ - url: BASE_URL + "/apps/" + accessor.appId + "/app_versions", - method: 'GET', - headers: (_a = {}, - _a[HOCKEY_APP_TOKEN_HEADER] = accessor.accessToken, - _a) - }); -} -function createVersion(accessor, version) { - var _a; - return asyncRequest({ - url: BASE_URL + "/apps/" + accessor.appId + "/app_versions/new", - method: 'POST', - headers: (_a = {}, - _a[HOCKEY_APP_TOKEN_HEADER] = accessor.accessToken, - _a), - formData: { - bundle_version: version - } - }); -} -function updateVersion(accessor, symbolsPath) { - var _a; - return asyncRequest({ - url: BASE_URL + "/apps/" + accessor.appId + "/app_versions/" + accessor.id, - method: 'PUT', - headers: (_a = {}, - _a[HOCKEY_APP_TOKEN_HEADER] = accessor.accessToken, - _a), - formData: { - dsym: fs_1.createReadStream(symbolsPath) - } - }); -} -function asyncRequest(options) { - return new Promise(function (resolve, reject) { - request(options, function (error, response, body) { - if (error) { - reject(error); - } - else { - resolve(JSON.parse(body)); - } - }); - }); -} -function downloadAsset(repository, assetName, targetPath, electronVersion) { - return new Promise(function (resolve, reject) { - repository.getReleases({ tag_name: "v" + electronVersion }, function (err, releases) { - if (err) { - reject(err); - } - else { - var asset = releases[0].assets.filter(function (asset) { return asset.name === assetName; })[0]; - if (!asset) { - reject(new Error("Asset with name " + assetName + " not found")); - } - else { - repository.downloadAsset(asset, function (err, reader) { - if (err) { - reject(err); - } - else { - var writer = fs_1.createWriteStream(targetPath); - writer.on('error', reject); - writer.on('close', resolve); - reader.on('error', reject); - reader.pipe(writer); - } - }); - } - } - }); - }); -} -function ensureVersionAndSymbols(options) { - return __awaiter(this, void 0, void 0, function () { - var versions, symbolsName, symbolsPath, version; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - // Check version does not exist - console.log("HockeyApp: checking for existing version " + options.versions.code + " (" + options.platform + ")"); - return [4 /*yield*/, getVersions({ accessToken: options.access.hockeyAppToken, appId: options.access.hockeyAppId })]; - case 1: - versions = _a.sent(); - if (versions.app_versions.some(function (v) { return v.version === options.versions.code; })) { - console.log("HockeyApp: Returning without uploading symbols because version " + options.versions.code + " (" + options.platform + ") was already found"); - return [2 /*return*/]; - } - symbolsName = symbolsZipName(options.platform, options.versions.electron, options.versions.insiders); - return [4 /*yield*/, tmpFile('symbols.zip')]; - case 2: - symbolsPath = _a.sent(); - console.log("HockeyApp: downloading symbols " + symbolsName + " for electron " + options.versions.electron + " (" + options.platform + ") into " + symbolsPath); - return [4 /*yield*/, downloadAsset(new github({ repo: options.repository, token: options.access.githubToken }), symbolsName, symbolsPath, options.versions.electron)]; - case 3: - _a.sent(); - // Create version - console.log("HockeyApp: creating new version " + options.versions.code + " (" + options.platform + ")"); - return [4 /*yield*/, createVersion({ accessToken: options.access.hockeyAppToken, appId: options.access.hockeyAppId }, options.versions.code)]; - case 4: - version = _a.sent(); - // Upload symbols - console.log("HockeyApp: uploading symbols for version " + options.versions.code + " (" + options.platform + ")"); - return [4 /*yield*/, updateVersion({ id: String(version.id), accessToken: options.access.hockeyAppToken, appId: options.access.hockeyAppId }, symbolsPath)]; - case 5: - _a.sent(); - // Cleanup - return [4 /*yield*/, util_1.promisify(fs_1.unlink)(symbolsPath)]; - case 6: - // Cleanup - _a.sent(); - return [2 /*return*/]; - } - }); - }); -} -// Environment -var pakage = require('../../../package.json'); -var product = require('../../../product.json'); -var repository = product.electronRepository; -var electronVersion = require('../../lib/electron').getElectronVersion(); -var insiders = product.quality !== 'stable'; -var codeVersion = pakage.version; -if (insiders) { - codeVersion = codeVersion + "-insider"; -} -var githubToken = process.argv[2]; -var hockeyAppToken = process.argv[3]; -var is64 = process.argv[4] === 'x64'; -var hockeyAppId = process.argv[5]; -var platform; -if (process.platform === 'darwin') { - platform = Platform.MAC_OS; -} -else if (process.platform === 'win32') { - platform = is64 ? Platform.WIN_64 : Platform.WIN_32; -} -else { - platform = is64 ? Platform.LINUX_64 : Platform.LINUX_32; -} -// Create version and upload symbols in HockeyApp -if (repository && codeVersion && electronVersion && (product.quality === 'stable' || product.quality === 'insider')) { - ensureVersionAndSymbols({ - repository: repository, - platform: platform, - versions: { - code: codeVersion, - insiders: insiders, - electron: electronVersion - }, - access: { - githubToken: githubToken, - hockeyAppToken: hockeyAppToken, - hockeyAppId: hockeyAppId - } - }).then(function () { - console.log('HockeyApp: done'); - }).catch(function (error) { - console.error("HockeyApp: error (" + error + ")"); - }); -} -else { - console.log("HockeyApp: skipping due to unexpected context (repository: " + repository + ", codeVersion: " + codeVersion + ", electronVersion: " + electronVersion + ", quality: " + product.quality + ")"); -} diff --git a/build/tfs/linux/frozen-check.js b/build/tfs/linux/frozen-check.js deleted file mode 100644 index 483af664bd..0000000000 --- a/build/tfs/linux/frozen-check.js +++ /dev/null @@ -1,40 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the Source EULA. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ -'use strict'; -Object.defineProperty(exports, "__esModule", { value: true }); -var documentdb_1 = require("documentdb"); -function createDefaultConfig(quality) { - return { - id: quality, - frozen: false - }; -} -function getConfig(quality) { - var client = new documentdb_1.DocumentClient(process.env['AZURE_DOCUMENTDB_ENDPOINT'], { masterKey: process.env['AZURE_DOCUMENTDB_MASTERKEY'] }); - var collection = 'dbs/builds/colls/config'; - var query = { - query: "SELECT TOP 1 * FROM c WHERE c.id = @quality", - parameters: [ - { name: '@quality', value: quality } - ] - }; - return new Promise(function (c, e) { - client.queryDocuments(collection, query).toArray(function (err, results) { - if (err && err.code !== 409) { - return e(err); - } - c(!results || results.length === 0 ? createDefaultConfig(quality) : results[0]); - }); - }); -} -getConfig(process.argv[2]) - .then(function (config) { - console.log(config.frozen); - process.exit(0); -}) - .catch(function (err) { - console.error(err); - process.exit(1); -}); diff --git a/src/vs/base/browser/ui/tree/media/collapsed-dark.svg b/src/vs/base/browser/ui/tree/media/collapsed-dark.svg old mode 100644 new mode 100755 diff --git a/src/vs/base/browser/ui/tree/media/collapsed.svg b/src/vs/base/browser/ui/tree/media/collapsed.svg old mode 100644 new mode 100755 diff --git a/src/vs/base/browser/ui/tree/media/expanded-dark.svg b/src/vs/base/browser/ui/tree/media/expanded-dark.svg old mode 100644 new mode 100755 diff --git a/src/vs/base/browser/ui/tree/media/expanded.svg b/src/vs/base/browser/ui/tree/media/expanded.svg old mode 100644 new mode 100755 diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 256611434e..04c248a6b7 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -26,7 +26,7 @@ declare namespace monaco { } - export const enum MarkerTag { + export enum MarkerTag { Unnecessary = 1 } @@ -38,25 +38,13 @@ declare namespace monaco { } - export class Promise { - constructor( - executor: ( - resolve: (value: T | PromiseLike) => void, - reject: (reason: any) => void, - progress: (progress: TProgress) => void) => void, - oncancel?: () => void); + export class Promise { + constructor(executor: (resolve: (value: T | PromiseLike) => void, reject: (reason: any) => void) => void); public then( onfulfilled?: ((value: T) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: any) => TResult2 | PromiseLike) | null, - onprogress?: (progress: TProgress) => void): Promise; + onrejected?: ((reason: any) => TResult2 | PromiseLike) | null): Promise; - public done( - onfulfilled?: (value: T) => void, - onrejected?: (reason: any) => void, - onprogress?: (progress: TProgress) => void): void; - - public cancel(): void; public static as(value: null): Promise; public static as(value: undefined): Promise; @@ -64,15 +52,9 @@ declare namespace monaco { public static as>(value: SomePromise): SomePromise; public static as(value: T): Promise; - public static is(value: any): value is PromiseLike; - - public static timeout(delay: number): Promise; - public static join(promises: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; public static join(promises: (T | PromiseLike)[]): Promise; - public static any(promises: (T | PromiseLike)[]): Promise<{ key: string; value: Promise; }>; - public static wrap(value: T | PromiseLike): Promise; public static wrapError(error: Error): Promise; @@ -92,9 +74,10 @@ declare namespace monaco { */ readonly onCancellationRequested: IEvent; } + /** * Uniform Resource Identifier (Uri) http://tools.ietf.org/html/rfc3986. - * This class is a simple parser which creates the basic component paths + * This class is a simple parser which creates the basic component parts * (http://tools.ietf.org/html/rfc3986#section-3) with minimal validation * and encoding. * @@ -105,8 +88,6 @@ declare namespace monaco { * | _____________________|__ * / \ / \ * urn:example:animal:ferret:nose - * - * */ export class Uri implements UriComponents { static isUri(thing: any): thing is Uri; @@ -134,28 +115,80 @@ declare namespace monaco { readonly fragment: string; /** * Returns a string representing the corresponding file system path of this Uri. - * Will handle UNC paths and normalize windows drive letters to lower-case. Also - * uses the platform specific path separator. Will *not* validate the path for - * invalid characters and semantics. Will *not* look at the scheme of this Uri. + * Will handle UNC paths, normalizes windows drive letters to lower-case, and uses the + * platform specific path separator. + * + * * Will *not* validate the path for invalid characters and semantics. + * * Will *not* look at the scheme of this Uri. + * * The result shall *not* be used for display purposes but for accessing a file on disk. + * + * + * The *difference* to `Uri#path` is the use of the platform specific separator and the handling + * of UNC paths. See the below sample of a file-uri with an authority (UNC path). + * + * ```ts + const u = Uri.parse('file://server/c$/folder/file.txt') + u.authority === 'server' + u.path === '/shares/c$/file.txt' + u.fsPath === '\\server\c$\folder\file.txt' + ``` + * + * Using `Uri#path` to read a file (using fs-apis) would not be enough because parts of the path, + * namely the server name, would be missing. Therefore `Uri#fsPath` exists - it's sugar to ease working + * with URIs that represent files on disk (`file` scheme). */ readonly fsPath: string; with(change: { scheme?: string; - authority?: string; - path?: string; - query?: string; - fragment?: string; + authority?: string | null; + path?: string | null; + query?: string | null; + fragment?: string | null; }): Uri; - static parse(value: string): Uri; + /** + * Creates a new Uri from a string, e.g. `http://www.msft.com/some/path`, + * `file:///usr/home`, or `scheme:with/path`. + * + * @param value A string which represents an Uri (see `Uri#toString`). + */ + static parse(value: string, _strict?: boolean): Uri; + /** + * Creates a new Uri from a file system path, e.g. `c:\my\files`, + * `/usr/home`, or `\\server\share\some\path`. + * + * The *difference* between `Uri#parse` and `Uri#file` is that the latter treats the argument + * as path, not as stringified-uri. E.g. `Uri.file(path)` is **not the same as** + * `Uri.parse('file://' + path)` because the path might contain characters that are + * interpreted (# and ?). See the following sample: + * ```ts + const good = Uri.file('/coding/c#/project1'); + good.scheme === 'file'; + good.path === '/coding/c#/project1'; + good.fragment === ''; + const bad = Uri.parse('file://' + '/coding/c#/project1'); + bad.scheme === 'file'; + bad.path === '/coding/c'; // path is now broken + bad.fragment === '/project1'; + ``` + * + * @param path A file system path (see `Uri#fsPath`) + */ static file(path: string): Uri; static from(components: { - scheme?: string; + scheme: string; authority?: string; path?: string; query?: string; fragment?: string; }): Uri; /** + * Creates a string representation for this Uri. It's guaranteed that calling + * `Uri.parse` with the result of this function creates an Uri which is equal + * to this Uri. + * + * * The result shall *not* be used for display purposes but for externalization or transport. + * * The result will be encoded using the percentage encoding and encoding happens mostly + * ignore the scheme-specific encoding rules. * * @param skipEncoding Do not encode the result, default is `false` */ @@ -171,6 +204,187 @@ declare namespace monaco { query: string; fragment: string; } + + /** + * Virtual Key Codes, the value does not hold any inherent meaning. + * Inspired somewhat from https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx + * But these are "more general", as they should work across browsers & OS`s. + */ + export enum KeyCode { + /** + * Placed first to cover the 0 value of the enum. + */ + Unknown = 0, + Backspace = 1, + Tab = 2, + Enter = 3, + Shift = 4, + Ctrl = 5, + Alt = 6, + PauseBreak = 7, + CapsLock = 8, + Escape = 9, + Space = 10, + PageUp = 11, + PageDown = 12, + End = 13, + Home = 14, + LeftArrow = 15, + UpArrow = 16, + RightArrow = 17, + DownArrow = 18, + Insert = 19, + Delete = 20, + KEY_0 = 21, + KEY_1 = 22, + KEY_2 = 23, + KEY_3 = 24, + KEY_4 = 25, + KEY_5 = 26, + KEY_6 = 27, + KEY_7 = 28, + KEY_8 = 29, + KEY_9 = 30, + KEY_A = 31, + KEY_B = 32, + KEY_C = 33, + KEY_D = 34, + KEY_E = 35, + KEY_F = 36, + KEY_G = 37, + KEY_H = 38, + KEY_I = 39, + KEY_J = 40, + KEY_K = 41, + KEY_L = 42, + KEY_M = 43, + KEY_N = 44, + KEY_O = 45, + KEY_P = 46, + KEY_Q = 47, + KEY_R = 48, + KEY_S = 49, + KEY_T = 50, + KEY_U = 51, + KEY_V = 52, + KEY_W = 53, + KEY_X = 54, + KEY_Y = 55, + KEY_Z = 56, + Meta = 57, + ContextMenu = 58, + F1 = 59, + F2 = 60, + F3 = 61, + F4 = 62, + F5 = 63, + F6 = 64, + F7 = 65, + F8 = 66, + F9 = 67, + F10 = 68, + F11 = 69, + F12 = 70, + F13 = 71, + F14 = 72, + F15 = 73, + F16 = 74, + F17 = 75, + F18 = 76, + F19 = 77, + NumLock = 78, + ScrollLock = 79, + /** + * Used for miscellaneous characters; it can vary by keyboard. + * For the US standard keyboard, the ';:' key + */ + US_SEMICOLON = 80, + /** + * For any country/region, the '+' key + * For the US standard keyboard, the '=+' key + */ + US_EQUAL = 81, + /** + * For any country/region, the ',' key + * For the US standard keyboard, the ',<' key + */ + US_COMMA = 82, + /** + * For any country/region, the '-' key + * For the US standard keyboard, the '-_' key + */ + US_MINUS = 83, + /** + * For any country/region, the '.' key + * For the US standard keyboard, the '.>' key + */ + US_DOT = 84, + /** + * Used for miscellaneous characters; it can vary by keyboard. + * For the US standard keyboard, the '/?' key + */ + US_SLASH = 85, + /** + * Used for miscellaneous characters; it can vary by keyboard. + * For the US standard keyboard, the '`~' key + */ + US_BACKTICK = 86, + /** + * Used for miscellaneous characters; it can vary by keyboard. + * For the US standard keyboard, the '[{' key + */ + US_OPEN_SQUARE_BRACKET = 87, + /** + * Used for miscellaneous characters; it can vary by keyboard. + * For the US standard keyboard, the '\|' key + */ + US_BACKSLASH = 88, + /** + * Used for miscellaneous characters; it can vary by keyboard. + * For the US standard keyboard, the ']}' key + */ + US_CLOSE_SQUARE_BRACKET = 89, + /** + * Used for miscellaneous characters; it can vary by keyboard. + * For the US standard keyboard, the ''"' key + */ + US_QUOTE = 90, + /** + * Used for miscellaneous characters; it can vary by keyboard. + */ + OEM_8 = 91, + /** + * Either the angle bracket key or the backslash key on the RT 102-key keyboard. + */ + OEM_102 = 92, + NUMPAD_0 = 93, + NUMPAD_1 = 94, + NUMPAD_2 = 95, + NUMPAD_3 = 96, + NUMPAD_4 = 97, + NUMPAD_5 = 98, + NUMPAD_6 = 99, + NUMPAD_7 = 100, + NUMPAD_8 = 101, + NUMPAD_9 = 102, + NUMPAD_MULTIPLY = 103, + NUMPAD_ADD = 104, + NUMPAD_SEPARATOR = 105, + NUMPAD_SUBTRACT = 106, + NUMPAD_DECIMAL = 107, + NUMPAD_DIVIDE = 108, + /** + * Cover all key codes when IME is processing input. + */ + KEY_IN_COMPOSITION = 109, + ABNT_C1 = 110, + ABNT_C2 = 111, + /** + * Placed last to cover the length of the enum. + * Please do not depend on this value! + */ + MAX_VALUE = 112 + } export class KeyMod { static readonly CtrlCmd: number; static readonly Shift: number; @@ -178,9 +392,13 @@ declare namespace monaco { static readonly WinCtrl: number; static chord(firstPart: number, secondPart: number): number; } + export interface IMarkdownString { value: string; isTrusted?: boolean; + uris?: { + [href: string]: UriComponents; + }; } export interface IKeyboardEvent { @@ -251,6 +469,20 @@ declare namespace monaco { */ readonly column: number; constructor(lineNumber: number, column: number); + /** + * Create a new postion from this position. + * + * @param newLineNumber new line number + * @param newColumn new column + */ + with(newLineNumber?: number, newColumn?: number): Position; + /** + * Derive a new position from this position. + * + * @param deltaLineNumber line number delta + * @param deltaColumn column delta + */ + delta(deltaLineNumber?: number, deltaColumn?: number): Position; /** * Test if this position equals other position */ @@ -381,19 +613,19 @@ declare namespace monaco { /** * A intersection of the two ranges. */ - intersectRanges(range: IRange): Range; + intersectRanges(range: IRange): Range | null; /** * A intersection of the two ranges. */ - static intersectRanges(a: IRange, b: IRange): Range; + static intersectRanges(a: IRange, b: IRange): Range | null; /** * Test if this range equals other. */ - equalsRange(other: IRange): boolean; + equalsRange(other: IRange | null): boolean; /** * Test if range `a` equals `b`. */ - static equalsRange(a: IRange, b: IRange): boolean; + static equalsRange(a: IRange | null, b: IRange | null): boolean; /** * Return the end position (which will be after or equal to the start position) */ @@ -426,6 +658,7 @@ declare namespace monaco { /** * Create a `Range` from an `IRange`. */ + static lift(range: undefined | null): null; static lift(range: IRange): Range; /** * Test if `obj` is an `IRange`. @@ -443,7 +676,7 @@ declare namespace monaco { * A function that compares ranges, useful for sorting ranges * It will first compare ranges on the startPosition and then on the endPosition */ - static compareRangesUsingStarts(a: IRange, b: IRange): number; + static compareRangesUsingStarts(a: IRange | null | undefined, b: IRange | null | undefined): number; /** * A function that compares ranges, useful for sorting ranges * It will first compare ranges on the endPosition and then on the startPosition @@ -966,17 +1199,12 @@ declare namespace monaco.editor { * CSS color to render in the overview ruler. * e.g.: rgba(100, 100, 100, 0.5) or a color from the color registry */ - color: string | ThemeColor; + color: string | ThemeColor | undefined; /** * CSS color to render in the overview ruler. * e.g.: rgba(100, 100, 100, 0.5) or a color from the color registry */ - darkColor: string | ThemeColor; - /** - * CSS color to render in the overview ruler. - * e.g.: rgba(100, 100, 100, 0.5) or a color from the color registry - */ - hcColor?: string | ThemeColor; + darkColor?: string | ThemeColor; /** * The position in the overview ruler. */ @@ -995,15 +1223,15 @@ declare namespace monaco.editor { /** * CSS class name describing the decoration. */ - className?: string; + className?: string | null; /** * Message to be rendered when hovering over the glyph margin decoration. */ - glyphMarginHoverMessage?: IMarkdownString | IMarkdownString[]; + glyphMarginHoverMessage?: IMarkdownString | IMarkdownString[] | null; /** * Array of MarkdownString to render as the decoration message. */ - hoverMessage?: IMarkdownString | IMarkdownString[]; + hoverMessage?: IMarkdownString | IMarkdownString[] | null; /** * Should the decoration expand to encompass a whole line. */ @@ -1016,25 +1244,25 @@ declare namespace monaco.editor { /** * If set, render this decoration in the overview ruler. */ - overviewRuler?: IModelDecorationOverviewRulerOptions; + overviewRuler?: IModelDecorationOverviewRulerOptions | null; /** * If set, the decoration will be rendered in the glyph margin with this CSS class name. */ - glyphMarginClassName?: string; + glyphMarginClassName?: string | null; /** * If set, the decoration will be rendered in the lines decorations with this CSS class name. */ - linesDecorationsClassName?: string; + linesDecorationsClassName?: string | null; /** * If set, the decoration will be rendered in the margin (covering its full width) with this CSS class name. */ - marginClassName?: string; + marginClassName?: string | null; /** * If set, the decoration will be rendered inline with the text with this CSS class name. * Please use this only for CSS rules that must impact the text. For example, use `className` * to have a background color decoration. */ - inlineClassName?: string; + inlineClassName?: string | null; /** * If there is an `inlineClassName` which affects letter spacing. */ @@ -1042,11 +1270,11 @@ declare namespace monaco.editor { /** * If set, the decoration will be rendered before the text with this CSS class name. */ - beforeContentClassName?: string; + beforeContentClassName?: string | null; /** * If set, the decoration will be rendered after the text with this CSS class name. */ - afterContentClassName?: string; + afterContentClassName?: string | null; } /** @@ -1072,7 +1300,7 @@ declare namespace monaco.editor { */ readonly id: string; /** - * Identifier for a decoration's owener. + * Identifier for a decoration's owner. */ readonly ownerId: number; /** @@ -1194,7 +1422,7 @@ declare namespace monaco.editor { /** * The text to replace with. This can be null to emulate a simple delete. */ - text: string; + text: string | null; /** * This indicates that this operation has "insert" semantics. * i.e. forceMoveMarkers = true => if `range` is collapsed, all markers at the position will be moved. @@ -1209,7 +1437,7 @@ declare namespace monaco.editor { /** * A callback that can compute the resulting cursors state after some edit operations have been executed. */ - (inverseEditOperations: IIdentifiedSingleEditOperation[]): Selection[]; + (inverseEditOperations: IIdentifiedSingleEditOperation[]): Selection[] | null; } export class TextModelResolvedOptions { @@ -1229,7 +1457,7 @@ declare namespace monaco.editor { export class FindMatch { _findMatchBrand: void; readonly range: Range; - readonly matches: string[]; + readonly matches: string[] | null; } /** @@ -1343,13 +1571,13 @@ declare namespace monaco.editor { */ validatePosition(position: IPosition): Position; /** - * Advances the given position by the given offest (negative offsets are also accepted) + * Advances the given position by the given offset (negative offsets are also accepted) * and returns it as a new valid position. * * If the offset and position are such that their combination goes beyond the beginning or * end of the model, throws an exception. * - * If the ofsset is such that the new position would be in the middle of a multi-byte + * If the offset is such that the new position would be in the middle of a multi-byte * line terminator, throws an exception. */ modifyPosition(position: IPosition, offset: number): Position; @@ -1415,7 +1643,7 @@ declare namespace monaco.editor { * @param captureMatches The result will contain the captured groups. * @return The range where the next match is. It is null if no next match has been found. */ - findNextMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wordSeparators: string | null, captureMatches: boolean): FindMatch; + findNextMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wordSeparators: string | null, captureMatches: boolean): FindMatch | null; /** * Search the model for the previous match. Loops to the end of the model if needed. * @param searchString The string used to search. If it is a regular expression, set `isRegex` to true. @@ -1426,7 +1654,7 @@ declare namespace monaco.editor { * @param captureMatches The result will contain the captured groups. * @return The range where the previous match is. It is null if no previous match has been found. */ - findPreviousMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wordSeparators: string | null, captureMatches: boolean): FindMatch; + findPreviousMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wordSeparators: string | null, captureMatches: boolean): FindMatch | null; /** * Get the language associated with this model. */ @@ -1434,37 +1662,17 @@ declare namespace monaco.editor { /** * Get the word under or besides `position`. * @param position The position to look for a word. - * @param skipSyntaxTokens Ignore syntax tokens, as identified by the mode. * @return The word under or besides `position`. Might be null. */ - getWordAtPosition(position: IPosition): IWordAtPosition; + getWordAtPosition(position: IPosition): IWordAtPosition | null; /** * Get the word under or besides `position` trimmed to `position`.column * @param position The position to look for a word. - * @param skipSyntaxTokens Ignore syntax tokens, as identified by the mode. * @return The word under or besides `position`. Will never be null. */ getWordUntilPosition(position: IPosition): IWordAtPosition; /** - * Get the language associated with this model. - */ - getModeId(): string; - /** - * Get the word under or besides `position`. - * @param position The position to look for a word. - * @param skipSyntaxTokens Ignore syntax tokens, as identified by the mode. - * @return The word under or besides `position`. Might be null. - */ - getWordAtPosition(position: IPosition): IWordAtPosition; - /** - * Get the word under or besides `position` trimmed to `position`.column - * @param position The position to look for a word. - * @param skipSyntaxTokens Ignore syntax tokens, as identified by the mode. - * @return The word under or besides `position`. Will never be null. - */ - getWordUntilPosition(position: IPosition): IWordAtPosition; - /** - * Perform a minimum ammount of operations, in order to transform the decorations + * Perform a minimum amount of operations, in order to transform the decorations * identified by `oldDecorations` to the decorations described by `newDecorations` * and returns the new identifiers associated with the resulting decorations. * @@ -1479,13 +1687,13 @@ declare namespace monaco.editor { * @param id The decoration id. * @return The decoration options or null if the decoration was not found. */ - getDecorationOptions(id: string): IModelDecorationOptions; + getDecorationOptions(id: string): IModelDecorationOptions | null; /** * Get the range associated with a decoration. * @param id The decoration id. * @return The decoration range or null if the decoration was not found. */ - getDecorationRange(id: string): Range; + getDecorationRange(id: string): Range | null; /** * Gets all the decorations for the line `lineNumber` as an array. * @param lineNumber The line number @@ -1504,7 +1712,7 @@ declare namespace monaco.editor { */ getLinesDecorations(startLineNumber: number, endLineNumber: number, ownerId?: number, filterOutValidation?: boolean): IModelDecoration[]; /** - * Gets all the deocorations in a range as an array. Only `startLineNumber` and `endLineNumber` from `range` are used for filtering. + * Gets all the decorations in a range as an array. Only `startLineNumber` and `endLineNumber` from `range` are used for filtering. * So for now it returns all the decorations on the same line as `range`. * @param range The range to search in * @param ownerId If set, it will ignore decorations belonging to other owners. @@ -1549,12 +1757,12 @@ declare namespace monaco.editor { /** * Push edit operations, basically editing the model. This is the preferred way * of editing the model. The edit operations will land on the undo stack. - * @param beforeCursorState The cursor state before the edit operaions. This cursor state will be returned when `undo` or `redo` are invoked. + * @param beforeCursorState The cursor state before the edit operations. This cursor state will be returned when `undo` or `redo` are invoked. * @param editOperations The edit operations. * @param cursorStateComputer A callback that can compute the resulting cursors state after the edit operations have been executed. * @return The cursor state returned by the `cursorStateComputer`. */ - pushEditOperations(beforeCursorState: Selection[], editOperations: IIdentifiedSingleEditOperation[], cursorStateComputer: ICursorStateComputer): Selection[]; + pushEditOperations(beforeCursorState: Selection[], editOperations: IIdentifiedSingleEditOperation[], cursorStateComputer: ICursorStateComputer): Selection[] | null; /** * Change the end of line sequence. This is the preferred way of * changing the eol sequence. This will land on the undo stack. @@ -1618,14 +1826,14 @@ declare namespace monaco.editor { * @param range The range to replace (delete). May be empty to represent a simple insert. * @param text The text to replace with. May be null to represent a simple delete. */ - addEditOperation(range: Range, text: string): void; + addEditOperation(range: Range, text: string | null): void; /** * Add a new edit operation (a replace operation). * The inverse edits will be accessible in `ICursorStateComputerData.getInverseEditOperations()` * @param range The range to replace (delete). May be empty to represent a simple insert. * @param text The text to replace with. May be null to represent a simple delete. */ - addTrackedEditOperation(range: Range, text: string): void; + addTrackedEditOperation(range: Range, text: string | null): void; /** * Track `selection` when applying edit operations. * A best effort will be made to not grow/expand the selection. @@ -1633,7 +1841,7 @@ declare namespace monaco.editor { * @param selection The selection to track. * @param trackPreviousOnEmpty If set, and the selection is empty, indicates whether the selection * should clamp to the previous or the next character. - * @return A unique identifer. + * @return A unique identifier. */ trackSelection(selection: Selection, trackPreviousOnEmpty?: boolean): string; } @@ -1666,7 +1874,7 @@ declare namespace monaco.editor { getEditOperations(model: ITextModel, builder: IEditOperationBuilder): void; /** * Compute the cursor state after the edit operations were applied. - * @param model The model the commad has executed on. + * @param model The model the command has executed on. * @param helper A helper to get inverse edit operations and to get previously tracked selections. * @return The cursor state after the command executed. */ @@ -1694,11 +1902,11 @@ declare namespace monaco.editor { /** * The `uri` of the previous model or null. */ - readonly oldModelUrl: Uri; + readonly oldModelUrl: Uri | null; /** * The `uri` of the new model or null. */ - readonly newModelUrl: Uri; + readonly newModelUrl: Uri | null; } export interface IDimension { @@ -1730,7 +1938,7 @@ declare namespace monaco.editor { * A line change */ export interface ILineChange extends IChange { - readonly charChanges: ICharChange[]; + readonly charChanges: ICharChange[] | undefined; } export interface INewScrollPosition { @@ -1794,7 +2002,7 @@ declare namespace monaco.editor { */ export type IEditorViewState = ICodeEditorViewState | IDiffEditorViewState; - export const enum ScrollType { + export enum ScrollType { Smooth = 0, Immediate = 1 } @@ -1845,7 +2053,7 @@ declare namespace monaco.editor { /** * Saves current view state of the editor in a serializable object. */ - saveViewState(): IEditorViewState; + saveViewState(): IEditorViewState | null; /** * Restores the view state of the editor from a serializable object generated by `saveViewState`. */ @@ -1857,7 +2065,7 @@ declare namespace monaco.editor { /** * Returns the primary position of the cursor. */ - getPosition(): Position; + getPosition(): Position | null; /** * Set the primary position of the cursor. This will remove any secondary cursors. * @param position New primary cursor's position @@ -1890,11 +2098,11 @@ declare namespace monaco.editor { /** * Returns the primary selection of the editor. */ - getSelection(): Selection; + getSelection(): Selection | null; /** * Returns all the selections of the editor. */ - getSelections(): Selection[]; + getSelections(): Selection[] | null; /** * Set the primary selection of the editor. This will remove any secondary cursors. * @param selection The new selection @@ -1958,7 +2166,7 @@ declare namespace monaco.editor { /** * Gets the current model attached to this editor. */ - getModel(): IEditorModel; + getModel(): IEditorModel | null; /** * Sets the current model attached to this editor. * If the previous model was created by the editor via the value key in the options @@ -1967,7 +2175,7 @@ declare namespace monaco.editor { * will not be destroyed. * It is safe to call setModel(null) to simply detach the current model from the editor. */ - setModel(model: IEditorModel): void; + setModel(model: IEditorModel | null): void; } /** @@ -2184,16 +2392,14 @@ declare namespace monaco.editor { arrowSize?: number; /** * Render vertical scrollbar. - * Accepted values: 'auto', 'visible', 'hidden'. * Defaults to 'auto'. */ - vertical?: string; + vertical?: 'auto' | 'visible' | 'hidden'; /** * Render horizontal scrollbar. - * Accepted values: 'auto', 'visible', 'hidden'. * Defaults to 'auto'. */ - horizontal?: string; + horizontal?: 'auto' | 'visible' | 'hidden'; /** * Cast horizontal and vertical shadows when the content is scrolled. * Defaults to true. @@ -2250,13 +2456,23 @@ declare namespace monaco.editor { autoFindInSelection: boolean; } + /** + * Configuration options for auto closing quotes and brackets + */ + export type EditorAutoClosingStrategy = 'always' | 'languageDefined' | 'beforeWhitespace' | 'never'; + + /** + * Configuration options for auto wrapping quotes and brackets + */ + export type EditorAutoSurroundStrategy = 'languageDefined' | 'quotes' | 'brackets' | 'never'; + /** * Configuration options for editor minimap */ export interface IEditorMinimapOptions { /** * Enable the rendering of the minimap. - * Defaults to false. + * Defaults to true. */ enabled?: boolean; /** @@ -2313,6 +2529,22 @@ declare namespace monaco.editor { sticky?: boolean; } + /** + * Configuration options for parameter hints + */ + export interface IEditorParameterHintOptions { + /** + * Enable parameter hints. + * Defaults to true. + */ + enabled?: boolean; + /** + * Enable cycling of parameter hints. + * Defaults to false. + */ + cycle?: boolean; + } + export interface ISuggestOptions { /** * Enable graceful matching. Defaults to true. @@ -2322,6 +2554,14 @@ declare namespace monaco.editor { * Prevent quick suggestions when a snippet is active. Defaults to true. */ snippetsPreventQuickSuggestions?: boolean; + /** + * Favours words that appear close to the cursor. + */ + localityBonus?: boolean; + /** + * Enable using global storage for remembering suggestions. + */ + useGlobalStorageForSuggestions?: boolean; } /** @@ -2441,6 +2681,11 @@ declare namespace monaco.editor { * Defaults to false. */ mouseWheelZoom?: boolean; + /** + * Enable smooth caret animation. + * Defaults to false. + */ + cursorSmoothCaretAnimation?: boolean; /** * Control the cursor style, either 'block' or 'line'. * Defaults to 'line'. @@ -2598,19 +2843,29 @@ declare namespace monaco.editor { */ quickSuggestionsDelay?: number; /** - * Enables parameter hints + * Parameter hint options. */ - parameterHints?: boolean; + parameterHints?: IEditorParameterHintOptions; /** * Render icons in suggestions box. * Defaults to true. */ iconsInSuggestions?: boolean; /** - * Enable auto closing brackets. - * Defaults to true. + * Options for auto closing brackets. + * Defaults to language defined behavior. */ - autoClosingBrackets?: boolean; + autoClosingBrackets?: EditorAutoClosingStrategy; + /** + * Options for auto closing quotes. + * Defaults to language defined behavior. + */ + autoClosingQuotes?: EditorAutoClosingStrategy; + /** + * Options for auto surrounding. + * Defaults to always allowing auto surrounding. + */ + autoSurround?: EditorAutoSurroundStrategy; /** * Enable auto indentation adjustment. * Defaults to false. @@ -2654,6 +2909,10 @@ declare namespace monaco.editor { * Copying without a selection copies the current line. */ emptySelectionClipboard?: boolean; + /** + * Syntax highlighting is copied. + */ + copyWithSyntaxHighlighting?: boolean; /** * Enable word based suggestions. Defaults to 'true' */ @@ -2672,6 +2931,10 @@ declare namespace monaco.editor { * Defaults to the editor line height. */ suggestLineHeight?: number; + /** + * Enable tab completion. + */ + tabCompletion?: boolean | 'on' | 'off' | 'onlySnippets'; /** * Enable selection highlight. * Defaults to true. @@ -2933,6 +3196,13 @@ declare namespace monaco.editor { readonly filterGraceful: boolean; readonly snippets: 'top' | 'bottom' | 'inline' | 'none'; readonly snippetsPreventQuickSuggestions: boolean; + readonly localityBonus: boolean; + readonly shareSuggestSelections: boolean; + } + + export interface InternalParameterHintOptions { + readonly enabled: boolean; + readonly cycle: boolean; } export interface EditorWrappingInfo { @@ -2947,7 +3217,7 @@ declare namespace monaco.editor { readonly wordWrapBreakObtrusiveCharacters: string; } - export const enum RenderLineNumbersType { + export enum RenderLineNumbersType { Off = 0, On = 1, Relative = 2, @@ -2961,7 +3231,7 @@ declare namespace monaco.editor { readonly rulers: number[]; readonly ariaLabel: string; readonly renderLineNumbers: RenderLineNumbersType; - readonly renderCustomLineNumbers: (lineNumber: number) => string; + readonly renderCustomLineNumbers: ((lineNumber: number) => string) | null; readonly selectOnLineNumbers: boolean; readonly glyphMargin: boolean; readonly revealHorizontalRightPadding: number; @@ -2970,6 +3240,7 @@ declare namespace monaco.editor { readonly overviewRulerBorder: boolean; readonly cursorBlinking: TextEditorCursorBlinkingStyle; readonly mouseWheelZoom: boolean; + readonly cursorSmoothCaretAnimation: boolean; readonly cursorStyle: TextEditorCursorStyle; readonly cursorWidth: number; readonly hideCursorInOverviewRuler: boolean; @@ -2999,7 +3270,7 @@ declare namespace monaco.editor { strings: boolean; }; readonly quickSuggestionsDelay: number; - readonly parameterHints: boolean; + readonly parameterHints: InternalParameterHintOptions; readonly iconsInSuggestions: boolean; readonly formatOnType: boolean; readonly formatOnPaste: boolean; @@ -3010,6 +3281,7 @@ declare namespace monaco.editor { readonly suggestSelection: 'first' | 'recentlyUsed' | 'recentlyUsedByPrefix'; readonly suggestFontSize: number; readonly suggestLineHeight: number; + readonly tabCompletion: 'on' | 'off' | 'onlySnippets'; readonly suggest: InternalSuggestOptions; readonly selectionHighlight: boolean; readonly occurrencesHighlight: boolean; @@ -3039,12 +3311,15 @@ declare namespace monaco.editor { readonly multiCursorMergeOverlapping: boolean; readonly showUnused: boolean; readonly wordSeparators: string; - readonly autoClosingBrackets: boolean; + readonly autoClosingBrackets: EditorAutoClosingStrategy; + readonly autoClosingQuotes: EditorAutoClosingStrategy; + readonly autoSurround: EditorAutoSurroundStrategy; readonly autoIndent: boolean; readonly useTabStops: boolean; readonly tabFocusMode: boolean; readonly dragAndDrop: boolean; readonly emptySelectionClipboard: boolean; + readonly copyWithSyntaxHighlighting: boolean; readonly layoutInfo: EditorLayoutInfo; readonly fontInfo: FontInfo; readonly viewInfo: InternalEditorViewOptions; @@ -3178,11 +3453,14 @@ declare namespace monaco.editor { readonly multiCursorMergeOverlapping: boolean; readonly wordSeparators: boolean; readonly autoClosingBrackets: boolean; + readonly autoClosingQuotes: boolean; + readonly autoSurround: boolean; readonly autoIndent: boolean; readonly useTabStops: boolean; readonly tabFocusMode: boolean; readonly dragAndDrop: boolean; readonly emptySelectionClipboard: boolean; + readonly copyWithSyntaxHighlighting: boolean; readonly layoutInfo: boolean; readonly fontInfo: boolean; readonly viewInfo: boolean; @@ -3235,7 +3513,7 @@ declare namespace monaco.editor { /** * An optional dom node for the view zone that will be placed in the margin area. */ - marginDomNode?: HTMLElement; + marginDomNode?: HTMLElement | null; /** * Callback which gives the relative top of the view zone as it appears (taking scrolling into account). */ @@ -3294,7 +3572,12 @@ declare namespace monaco.editor { * Desired position for the content widget. * `preference` will also affect the placement. */ - position: IPosition; + position: IPosition | null; + /** + * Optionally, a range can be provided to further + * define the position of the content widget. + */ + range?: IRange | null; /** * Placement preference for position, in order of preference. */ @@ -3322,7 +3605,7 @@ declare namespace monaco.editor { * Get the placement of the content widget. * If null is returned, the content widget will be placed off screen. */ - getPosition(): IContentWidgetPosition; + getPosition(): IContentWidgetPosition | null; } /** @@ -3350,7 +3633,7 @@ declare namespace monaco.editor { /** * The position preference for the overlay widget. */ - preference: OverlayWidgetPositionPreference; + preference: OverlayWidgetPositionPreference | null; } /** @@ -3369,7 +3652,7 @@ declare namespace monaco.editor { * Get the placement of the overlay widget. * If null is returned, the overlay widget is responsible to place itself. */ - getPosition(): IOverlayWidgetPosition; + getPosition(): IOverlayWidgetPosition | null; } /** @@ -3441,7 +3724,7 @@ declare namespace monaco.editor { /** * The target element */ - readonly element: Element; + readonly element: Element | null; /** * The target type */ @@ -3449,7 +3732,7 @@ declare namespace monaco.editor { /** * The 'approximate' editor position */ - readonly position: Position; + readonly position: Position | null; /** * Desired mouse column (e.g. when position.column gets clamped to text length -- clicking after text on a line). */ @@ -3457,7 +3740,7 @@ declare namespace monaco.editor { /** * The 'approximate' editor range */ - readonly range: Range; + readonly range: Range | null; /** * Some extra detail. */ @@ -3472,6 +3755,11 @@ declare namespace monaco.editor { readonly target: IMouseTarget; } + export interface IPartialEditorMouseEvent { + readonly event: IMouseEvent; + readonly target: IMouseTarget | null; + } + /** * A rich code editor. */ @@ -3541,6 +3829,14 @@ declare namespace monaco.editor { * @event */ onDidBlurEditorWidget(listener: () => void): IDisposable; + /** + * An event emitted after composition has started. + */ + onCompositionStart(listener: () => void): IDisposable; + /** + * An event emitted after composition has ended. + */ + onCompositionEnd(listener: () => void): IDisposable; /** * An event emitted on a "mouseup". * @event @@ -3565,7 +3861,7 @@ declare namespace monaco.editor { * An event emitted on a "mouseleave". * @event */ - onMouseLeave(listener: (e: IEditorMouseEvent) => void): IDisposable; + onMouseLeave(listener: (e: IPartialEditorMouseEvent) => void): IDisposable; /** * An event emitted on a "keyup". * @event @@ -3589,7 +3885,7 @@ declare namespace monaco.editor { /** * Saves current view state of the editor in a serializable object. */ - saveViewState(): ICodeEditorViewState; + saveViewState(): ICodeEditorViewState | null; /** * Restores the view state of the editor from a serializable object generated by `saveViewState`. */ @@ -3607,7 +3903,16 @@ declare namespace monaco.editor { /** * Type the getModel() of IEditor. */ - getModel(): ITextModel; + getModel(): ITextModel | null; + /** + * Sets the current model attached to this editor. + * If the previous model was created by the editor via the value key in the options + * literal object, it will be destroyed. Otherwise, if the previous model was set + * via setModel, or the model key in the options literal object, the previous model + * will not be destroyed. + * It is safe to call setModel(null) to simply detach the current model from the editor. + */ + setModel(model: ITextModel | null): void; /** * Returns the current editor's configuration */ @@ -3679,15 +3984,15 @@ declare namespace monaco.editor { */ executeEdits(source: string, edits: IIdentifiedSingleEditOperation[], endCursorState?: Selection[]): boolean; /** - * Execute multiple (concommitent) commands on the editor. + * Execute multiple (concomitant) commands on the editor. * @param source The source of the call. * @param command The commands to execute */ - executeCommands(source: string, commands: ICommand[]): void; + executeCommands(source: string, commands: (ICommand | null)[]): void; /** * Get all the decorations on a line (filtering out decorations from other editors). */ - getLineDecorations(lineNumber: number): IModelDecoration[]; + getLineDecorations(lineNumber: number): IModelDecoration[] | null; /** * All decorations added through this call will get the ownerId of this editor. * @see `ITextModel.deltaDecorations` @@ -3713,14 +4018,14 @@ declare namespace monaco.editor { /** * Returns the editor's dom node */ - getDomNode(): HTMLElement; + getDomNode(): HTMLElement | null; /** * Add a content widget. Widgets must have unique ids, otherwise they will be overwritten. */ addContentWidget(widget: IContentWidget): void; /** * Layout/Reposition a content widget. This is a ping to the editor to call widget.getPosition() - * and update appropiately. + * and update appropriately. */ layoutContentWidget(widget: IContentWidget): void; /** @@ -3733,7 +4038,7 @@ declare namespace monaco.editor { addOverlayWidget(widget: IOverlayWidget): void; /** * Layout/Reposition an overlay widget. This is a ping to the editor to call widget.getPosition() - * and update appropiately. + * and update appropriately. */ layoutOverlayWidget(widget: IOverlayWidget): void; /** @@ -3760,19 +4065,19 @@ declare namespace monaco.editor { * * @returns Hit test target or null if the coordinates fall outside the editor or the editor has no model. */ - getTargetAtClientPoint(clientX: number, clientY: number): IMouseTarget; + getTargetAtClientPoint(clientX: number, clientY: number): IMouseTarget | null; /** * Get the visible position for `position`. * The result position takes scrolling into account and is relative to the top left corner of the editor. * Explanation 1: the results of this method will change for the same `position` if the user scrolls the editor. * Explanation 2: the results of this method will not change if the container of the editor gets repositioned. - * Warning: the results of this method are innacurate for positions that are outside the current editor viewport. + * Warning: the results of this method are inaccurate for positions that are outside the current editor viewport. */ getScrolledVisiblePosition(position: IPosition): { top: number; left: number; height: number; - }; + } | null; /** * Apply the same font settings as the editor to `target`. */ @@ -3802,7 +4107,7 @@ declare namespace monaco.editor { /** * Saves current view state of the editor in a serializable object. */ - saveViewState(): IDiffEditorViewState; + saveViewState(): IDiffEditorViewState | null; /** * Restores the view state of the editor from a serializable object generated by `saveViewState`. */ @@ -3810,7 +4115,16 @@ declare namespace monaco.editor { /** * Type the getModel() of IEditor. */ - getModel(): IDiffEditorModel; + getModel(): IDiffEditorModel | null; + /** + * Sets the current model attached to this editor. + * If the previous model was created by the editor via the value key in the options + * literal object, it will be destroyed. Otherwise, if the previous model was set + * via setModel, or the model key in the options literal object, the previous model + * will not be destroyed. + * It is safe to call setModel(null) to simply detach the current model from the editor. + */ + setModel(model: IDiffEditorModel | null): void; /** * Get the `original` editor. */ @@ -3822,17 +4136,17 @@ declare namespace monaco.editor { /** * Get the computed diff information. */ - getLineChanges(): ILineChange[]; + getLineChanges(): ILineChange[] | null; /** * Get information based on computed diff about a line number from the original model. * If the diff computation is not finished or the model is missing, will return null. */ - getDiffLineInformationForOriginal(lineNumber: number): IDiffLineInformation; + getDiffLineInformationForOriginal(lineNumber: number): IDiffLineInformation | null; /** * Get information based on computed diff about a line number from the modified model. * If the diff computation is not finished or the model is missing, will return null. */ - getDiffLineInformationForModified(lineNumber: number): IDiffLineInformation; + getDiffLineInformationForModified(lineNumber: number): IDiffLineInformation | null; } export class FontInfo extends BareFontInfo { @@ -3841,6 +4155,7 @@ declare namespace monaco.editor { readonly isMonospace: boolean; readonly typicalHalfwidthCharacterWidth: number; readonly typicalFullwidthCharacterWidth: number; + readonly canUseHalfwidthRightwardsArrow: boolean; readonly spaceWidth: number; readonly maxDigitWidth: number; } @@ -4103,11 +4418,11 @@ declare namespace monaco.languages { /** * The line comment token, like `// this is a comment` */ - lineComment?: string; + lineComment?: string | null; /** * The block comment character pair, like `/* block comment */` */ - blockComment?: CharacterPair; + blockComment?: CharacterPair | null; } /** @@ -4151,6 +4466,12 @@ declare namespace monaco.languages { * settings will be used. */ surroundingPairs?: IAutoClosingPair[]; + /** + * Defines what characters must be after the cursor for bracket or quote autoclosing to occur when using the \'languageDefined\' autoclosing setting. + * + * This is typically the set of characters which can not start an expression, such as whitespace, closing brackets, non-unary operators, etc. + */ + autoCloseBefore?: string; /** * The language's folding rules. */ @@ -4168,7 +4489,7 @@ declare namespace monaco.languages { */ export interface IndentationRule { /** - * If a line matches this pattern, then all the lines after it should be unindendented once (until another rule matches). + * If a line matches this pattern, then all the lines after it should be unindented once (until another rule matches). */ decreaseIndentPattern: RegExp; /** @@ -4178,11 +4499,11 @@ declare namespace monaco.languages { /** * If a line matches this pattern, then **only the next line** after it should be indented once. */ - indentNextLinePattern?: RegExp; + indentNextLinePattern?: RegExp | null; /** * If a line matches this pattern, then its indentation should not be changed and it should not be evaluated against the other rules. */ - unIndentedLinePattern?: RegExp; + unIndentedLinePattern?: RegExp | null; } /** @@ -4201,7 +4522,7 @@ declare namespace monaco.languages { */ export interface FoldingRules { /** - * Used by the indentation based strategy to decide wheter empty lines belong to the previous or the next block. + * Used by the indentation based strategy to decide whether empty lines belong to the previous or the next block. * A language adheres to the off-side rule if blocks in that language are expressed by their indentation. * See [wikipedia](https://en.wikipedia.org/wiki/Off-side_rule) for more information. * If not set, `false` is used and empty lines belong to the previous block. @@ -4225,6 +4546,10 @@ declare namespace monaco.languages { * This rule will only execute if the text after the cursor matches this regular expression. */ afterText?: RegExp; + /** + * This rule will only execute if the text above the this line matches this regular expression. + */ + oneLineAboveText?: RegExp; /** * The action to execute. */ @@ -4296,10 +4621,6 @@ declare namespace monaco.languages { * Describe what to do with the indentation. */ indentAction: IndentAction; - /** - * Describe whether to outdent current line. - */ - outdentCurrentLine?: boolean; /** * Describes text to be appended after the new line and after the indentation. */ @@ -4320,6 +4641,14 @@ declare namespace monaco.languages { equals(other: IState): boolean; } + /** + * A provider result represents the values a provider, like the [`HoverProvider`](#HoverProvider), + * may return. For once this is the actual result type `T`, like `Hover`, or a thenable that resolves + * to that type `T`. In addition, `null` and `undefined` can be returned - either directly or from a + * thenable. + */ + export type ProviderResult = T | undefined | null | Thenable; + /** * A hover represents additional information for a symbol or word. Hovers are * rendered in a tooltip-like widget. @@ -4347,18 +4676,190 @@ declare namespace monaco.languages { * position will be merged by the editor. A hover can have a range which defaults * to the word range at the position when omitted. */ - provideHover(model: editor.ITextModel, position: Position, token: CancellationToken): Hover | Thenable; + provideHover(model: editor.ITextModel, position: Position, token: CancellationToken): ProviderResult; + } + + export enum CompletionItemKind { + Method = 0, + Function = 1, + Constructor = 2, + Field = 3, + Variable = 4, + Class = 5, + Struct = 6, + Interface = 7, + Module = 8, + Property = 9, + Event = 10, + Operator = 11, + Unit = 12, + Value = 13, + Constant = 14, + Enum = 15, + EnumMember = 16, + Keyword = 17, + Text = 18, + Color = 19, + File = 20, + Reference = 21, + Customcolor = 22, + Folder = 23, + TypeParameter = 24, + Snippet = 25 + } + + export enum CompletionItemInsertTextRule { + /** + * Adjust whitespace/indentation of multiline insert texts to + * match the current line indentation. + */ + KeepWhitespace = 1, + /** + * `insertText` is a snippet. + */ + InsertAsSnippet = 4 + } + + /** + * A completion item represents a text snippet that is + * proposed to complete text that is being typed. + */ + export interface CompletionItem { + /** + * The label of this completion item. By default + * this is also the text that is inserted when selecting + * this completion. + */ + label: string; + /** + * The kind of this completion item. Based on the kind + * an icon is chosen by the editor. + */ + kind: CompletionItemKind; + /** + * A human-readable string with additional information + * about this item, like type or symbol information. + */ + detail?: string; + /** + * A human-readable string that represents a doc-comment. + */ + documentation?: string | IMarkdownString; + /** + * A string that should be used when comparing this item + * with other items. When `falsy` the [label](#CompletionItem.label) + * is used. + */ + sortText?: string; + /** + * A string that should be used when filtering a set of + * completion items. When `falsy` the [label](#CompletionItem.label) + * is used. + */ + filterText?: string; + /** + * Select this item when showing. *Note* that only one completion item can be selected and + * that the editor decides which item that is. The rule is that the *first* item of those + * that match best is selected. + */ + preselect?: boolean; + /** + * A string or snippet that should be inserted in a document when selecting + * this completion. + * is used. + */ + insertText: string; + /** + * Addition rules (as bitmask) that should be applied when inserting + * this completion. + */ + insertTextRules?: CompletionItemInsertTextRule; + /** + * A range of text that should be replaced by this completion item. + * + * Defaults to a range from the start of the [current word](#TextDocument.getWordRangeAtPosition) to the + * current position. + * + * *Note:* The range must be a [single line](#Range.isSingleLine) and it must + * [contain](#Range.contains) the position at which completion has been [requested](#CompletionItemProvider.provideCompletionItems). + */ + range?: IRange; + /** + * An optional set of characters that when pressed while this completion is active will accept it first and + * then type that character. *Note* that all commit characters should have `length=1` and that superfluous + * characters will be ignored. + */ + commitCharacters?: string[]; + /** + * An optional array of additional text edits that are applied when + * selecting this completion. Edits must not overlap with the main edit + * nor with themselves. + */ + additionalTextEdits?: editor.ISingleEditOperation[]; + /** + * A command that should be run upon acceptance of this item. + */ + command?: Command; + } + + export interface CompletionList { + suggestions: CompletionItem[]; + incomplete?: boolean; + dispose?(): void; } /** * How a suggest provider was triggered. */ - export enum SuggestTriggerKind { + export enum CompletionTriggerKind { Invoke = 0, TriggerCharacter = 1, TriggerForIncompleteCompletions = 2 } + /** + * Contains additional information about the context in which + * [completion provider](#CompletionItemProvider.provideCompletionItems) is triggered. + */ + export interface CompletionContext { + /** + * How the completion was triggered. + */ + triggerKind: CompletionTriggerKind; + /** + * Character that triggered the completion item provider. + * + * `undefined` if provider was not triggered by a character. + */ + triggerCharacter?: string; + } + + /** + * The completion item provider interface defines the contract between extensions and + * the [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense). + * + * When computing *complete* completion items is expensive, providers can optionally implement + * the `resolveCompletionItem`-function. In that case it is enough to return completion + * items with a [label](#CompletionItem.label) from the + * [provideCompletionItems](#CompletionItemProvider.provideCompletionItems)-function. Subsequently, + * when a completion item is shown in the UI and gains focus this provider is asked to resolve + * the item, like adding [doc-comment](#CompletionItem.documentation) or [details](#CompletionItem.detail). + */ + export interface CompletionItemProvider { + triggerCharacters?: string[]; + /** + * Provide completion items for the given position and document. + */ + provideCompletionItems(model: editor.ITextModel, position: Position, context: CompletionContext, token: CancellationToken): ProviderResult; + /** + * Given a completion item fill in more data, like [doc-comment](#CompletionItem.documentation) + * or [details](#CompletionItem.detail). + * + * The editor will only resolve a completion item once. + */ + resolveCompletionItem?(model: editor.ITextModel, position: Position, item: CompletionItem, token: CancellationToken): ProviderResult; + } + export interface CodeAction { title: string; command?: Command; @@ -4376,7 +4877,7 @@ declare namespace monaco.languages { * The label of this signature. Will be shown in * the UI. */ - label: string; + label: string | [number, number]; /** * The human-readable doc-comment of this signature. Will be shown * in the UI but can be omitted. @@ -4426,16 +4927,29 @@ declare namespace monaco.languages { activeParameter: number; } + export enum SignatureHelpTriggerKind { + Invoke = 1, + TriggerCharacter = 2, + ContentChange = 3 + } + + export interface SignatureHelpContext { + readonly triggerKind: SignatureHelpTriggerKind; + readonly triggerCharacter?: string; + readonly isRetrigger: boolean; + } + /** * The signature help provider interface defines the contract between extensions and * the [parameter hints](https://code.visualstudio.com/docs/editor/intellisense)-feature. */ export interface SignatureHelpProvider { - signatureHelpTriggerCharacters: string[]; + readonly signatureHelpTriggerCharacters?: ReadonlyArray; + readonly signatureHelpRetriggerCharacters?: ReadonlyArray; /** * Provide help for the signature at the given position and document. */ - provideSignatureHelp(model: editor.ITextModel, position: Position, token: CancellationToken): SignatureHelp | Thenable; + provideSignatureHelp(model: editor.ITextModel, position: Position, token: CancellationToken, context: SignatureHelpContext): ProviderResult; } /** @@ -4481,7 +4995,7 @@ declare namespace monaco.languages { * Provide a set of document highlights, like all occurrences of a variable or * all exit-points of a function. */ - provideDocumentHighlights(model: editor.ITextModel, position: Position, token: CancellationToken): DocumentHighlight[] | Thenable; + provideDocumentHighlights(model: editor.ITextModel, position: Position, token: CancellationToken): ProviderResult; } /** @@ -4503,7 +5017,7 @@ declare namespace monaco.languages { /** * Provide a set of project-wide references for the given position and document. */ - provideReferences(model: editor.ITextModel, position: Position, context: ReferenceContext, token: CancellationToken): Location[] | Thenable; + provideReferences(model: editor.ITextModel, position: Position, context: ReferenceContext, token: CancellationToken): ProviderResult; } /** @@ -4544,7 +5058,19 @@ declare namespace monaco.languages { /** * Provide the definition of the symbol at the given position and document. */ - provideDefinition(model: editor.ITextModel, position: Position, token: CancellationToken): Definition | DefinitionLink[] | Thenable; + provideDefinition(model: editor.ITextModel, position: Position, token: CancellationToken): ProviderResult; + } + + /** + * The definition provider interface defines the contract between extensions and + * the [go to definition](https://code.visualstudio.com/docs/editor/editingevolved#_go-to-definition) + * and peek definition features. + */ + export interface DeclarationProvider { + /** + * Provide the declaration of the symbol at the given position and document. + */ + provideDeclaration(model: editor.ITextModel, position: Position, token: CancellationToken): ProviderResult; } /** @@ -4555,7 +5081,7 @@ declare namespace monaco.languages { /** * Provide the implementation of the symbol at the given position and document. */ - provideImplementation(model: editor.ITextModel, position: Position, token: CancellationToken): Definition | DefinitionLink[] | Thenable; + provideImplementation(model: editor.ITextModel, position: Position, token: CancellationToken): ProviderResult; } /** @@ -4566,7 +5092,7 @@ declare namespace monaco.languages { /** * Provide the type definition of the symbol at the given position and document. */ - provideTypeDefinition(model: editor.ITextModel, position: Position, token: CancellationToken): Definition | DefinitionLink[] | Thenable; + provideTypeDefinition(model: editor.ITextModel, position: Position, token: CancellationToken): ProviderResult; } /** @@ -4620,14 +5146,14 @@ declare namespace monaco.languages { /** * Provide symbol information for the given document. */ - provideDocumentSymbols(model: editor.ITextModel, token: CancellationToken): DocumentSymbol[] | Thenable; + provideDocumentSymbols(model: editor.ITextModel, token: CancellationToken): ProviderResult; } - export interface TextEdit { + export type TextEdit = { range: IRange; text: string; eol?: editor.EndOfLineSequence; - } + }; /** * Interface used to format a model @@ -4651,7 +5177,7 @@ declare namespace monaco.languages { /** * Provide formatting edits for a whole document. */ - provideDocumentFormattingEdits(model: editor.ITextModel, options: FormattingOptions, token: CancellationToken): TextEdit[] | Thenable; + provideDocumentFormattingEdits(model: editor.ITextModel, options: FormattingOptions, token: CancellationToken): ProviderResult; } /** @@ -4666,7 +5192,7 @@ declare namespace monaco.languages { * or larger range. Often this is done by adjusting the start and end * of the range to full syntax nodes. */ - provideDocumentRangeFormattingEdits(model: editor.ITextModel, range: Range, options: FormattingOptions, token: CancellationToken): TextEdit[] | Thenable; + provideDocumentRangeFormattingEdits(model: editor.ITextModel, range: Range, options: FormattingOptions, token: CancellationToken): ProviderResult; } /** @@ -4682,7 +5208,7 @@ declare namespace monaco.languages { * what range the position to expand to, like find the matching `{` * when `}` has been entered. */ - provideOnTypeFormattingEdits(model: editor.ITextModel, position: Position, ch: string, options: FormattingOptions, token: CancellationToken): TextEdit[] | Thenable; + provideOnTypeFormattingEdits(model: editor.ITextModel, position: Position, ch: string, options: FormattingOptions, token: CancellationToken): ProviderResult; } /** @@ -4697,8 +5223,8 @@ declare namespace monaco.languages { * A provider of links. */ export interface LinkProvider { - provideLinks(model: editor.ITextModel, token: CancellationToken): ILink[] | Thenable; - resolveLink?: (link: ILink, token: CancellationToken) => ILink | Thenable; + provideLinks(model: editor.ITextModel, token: CancellationToken): ProviderResult; + resolveLink?: (link: ILink, token: CancellationToken) => ProviderResult; } /** @@ -4766,11 +5292,18 @@ declare namespace monaco.languages { /** * Provides the color ranges for a specific model. */ - provideDocumentColors(model: editor.ITextModel, token: CancellationToken): IColorInformation[] | Thenable; + provideDocumentColors(model: editor.ITextModel, token: CancellationToken): ProviderResult; /** * Provide the string representations for a color. */ - provideColorPresentations(model: editor.ITextModel, colorInfo: IColorInformation, token: CancellationToken): IColorPresentation[] | Thenable; + provideColorPresentations(model: editor.ITextModel, colorInfo: IColorInformation, token: CancellationToken): ProviderResult; + } + + export interface SelectionRangeProvider { + /** + * Provide ranges that should be selected from the given position. + */ + provideSelectionRanges(model: editor.ITextModel, position: Position, token: CancellationToken): ProviderResult; } export interface FoldingContext { @@ -4783,16 +5316,16 @@ declare namespace monaco.languages { /** * Provides the color ranges for a specific model. */ - provideFoldingRanges(model: editor.ITextModel, context: FoldingContext, token: CancellationToken): FoldingRange[] | Thenable; + provideFoldingRanges(model: editor.ITextModel, context: FoldingContext, token: CancellationToken): ProviderResult; } export interface FoldingRange { /** - * The zero-based start line of the range to fold. The folded area starts after the line's last character. + * The one-based start line of the range to fold. The folded area starts after the line's last character. */ start: number; /** - * The zero-based end line of the range to fold. The folded area ends with the line's last character. + * The one-based end line of the range to fold. The folded area ends with the line's last character. */ end: number; /** @@ -4845,7 +5378,10 @@ declare namespace monaco.languages { } export interface WorkspaceEdit { - edits: Array; + edits?: Array; + } + + export interface Rejection { rejectReason?: string; } @@ -4855,8 +5391,8 @@ declare namespace monaco.languages { } export interface RenameProvider { - provideRenameEdits(model: editor.ITextModel, position: Position, newName: string, token: CancellationToken): WorkspaceEdit | Thenable; - resolveRenameLocation?(model: editor.ITextModel, position: Position, token: CancellationToken): RenameLocation | Thenable; + provideRenameEdits(model: editor.ITextModel, position: Position, newName: string, token: CancellationToken): ProviderResult; + resolveRenameLocation?(model: editor.ITextModel, position: Position, token: CancellationToken): ProviderResult; } export interface Command { @@ -4866,76 +5402,6 @@ declare namespace monaco.languages { arguments?: any[]; } - export interface CommentInfo { - owner: number; - threads: CommentThread[]; - commentingRanges?: IRange[]; - reply?: Command; - } - - export enum CommentThreadCollapsibleState { - /** - * Determines an item is collapsed - */ - Collapsed = 0, - /** - * Determines an item is expanded - */ - Expanded = 1 - } - - export interface CommentThread { - threadId: string; - resource: string; - range: IRange; - comments: Comment[]; - collapsibleState?: CommentThreadCollapsibleState; - reply?: Command; - } - - export interface NewCommentAction { - ranges: IRange[]; - actions: Command[]; - } - - export interface Comment { - readonly commentId: string; - readonly body: IMarkdownString; - readonly userName: string; - readonly gravatar: string; - readonly command?: Command; - } - - export interface CommentThreadChangedEvent { - readonly owner: number; - /** - * Added comment threads. - */ - readonly added: CommentThread[]; - /** - * Removed comment threads. - */ - readonly removed: CommentThread[]; - /** - * Changed comment threads. - */ - readonly changed: CommentThread[]; - } - - export interface DocumentCommentProvider { - provideDocumentComments(resource: Uri, token: CancellationToken): Promise; - createNewCommentThread(resource: Uri, range: Range, text: string, token: CancellationToken): Promise; - replyToCommentThread(resource: Uri, range: Range, thread: CommentThread, text: string, token: CancellationToken): Promise; - onDidChangeCommentThreads(): IEvent; - } - - export interface WorkspaceCommentProvider { - provideWorkspaceComments(token: CancellationToken): Promise; - createNewCommentThread(resource: Uri, range: Range, text: string, token: CancellationToken): Promise; - replyToCommentThread(resource: Uri, range: Range, thread: CommentThread, text: string, token: CancellationToken): Promise; - onDidChangeCommentThreads(): IEvent; - } - export interface ICodeLensSymbol { range: IRange; id?: string; @@ -4944,8 +5410,8 @@ declare namespace monaco.languages { export interface CodeLensProvider { onDidChange?: IEvent; - provideCodeLenses(model: editor.ITextModel, token: CancellationToken): ICodeLensSymbol[] | Thenable; - resolveCodeLens?(model: editor.ITextModel, codeLens: ICodeLensSymbol, token: CancellationToken): ICodeLensSymbol | Thenable; + provideCodeLenses(model: editor.ITextModel, token: CancellationToken): ProviderResult; + resolveCodeLens?(model: editor.ITextModel, codeLens: ICodeLensSymbol, token: CancellationToken): ProviderResult; } export interface ILanguageExtensionPoint { diff --git a/src/vs/workbench/browser/parts/editor/media/paragraph-disabled-inverse.svg b/src/vs/workbench/browser/parts/editor/media/paragraph-disabled-inverse.svg old mode 100644 new mode 100755 diff --git a/src/vs/workbench/browser/parts/editor/media/paragraph-disabled.svg b/src/vs/workbench/browser/parts/editor/media/paragraph-disabled.svg old mode 100644 new mode 100755