Merge remote-tracking branch 'origin/master' into tyriar/hot_exit/15718

This commit is contained in:
Daniel Imms
2016-11-28 13:17:32 -08:00
398 changed files with 12496 additions and 71009 deletions
+4 -4
View File
@@ -38,10 +38,10 @@ install:
- ./scripts/npm.sh install
script:
- gulp hygiene
- gulp electron
- gulp compile
- gulp optimize-vscode
- gulp hygiene --silent
- gulp electron --silent
- gulp compile --silent
- gulp optimize-vscode --silent
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./scripts/test.sh --reporter dot --coverage; else ./scripts/test.sh --reporter dot; fi
- ./scripts/test-integration.sh
+2 -2
View File
@@ -39,8 +39,8 @@ const nodeModules = ['electron', 'original-fs']
// Build
const builtInExtensions = [
{ name: 'ms-vscode.node-debug', version: '1.8.1' },
{ name: 'ms-vscode.node-debug2', version: '1.8.1' }
{ name: 'ms-vscode.node-debug', version: '1.8.5' },
{ name: 'ms-vscode.node-debug2', version: '1.8.2' }
];
const vscodeEntryPoints = _.flatten([
+14 -10
View File
@@ -6,6 +6,19 @@
const cp = require('child_process');
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
function npmInstall(location) {
const result = cp.spawnSync(npm, ['install'], {
cwd: location ,
stdio: 'inherit'
});
if (result.error || result.status !== 0) {
process.exit(1);
}
}
npmInstall('extensions'); // node modules shared by all extensions
const extensions = [
'vscode-api-tests',
'vscode-colorize-tests',
@@ -20,13 +33,4 @@ const extensions = [
'html'
];
extensions.forEach(extension => {
const result = cp.spawnSync(npm, ['install'], {
cwd: `extensions/${extension}`,
stdio: 'inherit'
});
if (result.error || result.status !== 0) {
process.exit(1);
}
});
extensions.forEach(extension => npmInstall(`extensions/${extension}`));
@@ -44,16 +44,29 @@ function registerKeybindingsCompletions(): vscode.Disposable {
});
}
function updateLaunchJsonDecorations(editor: vscode.TextEditor) {
function newCompletionItem(text: string, range: vscode.Range) {
const item = new vscode.CompletionItem(JSON.stringify(text));
item.kind = vscode.CompletionItemKind.Value;
item.textEdit = {
range,
newText: item.label
};
return item;
}
function updateLaunchJsonDecorations(editor: vscode.TextEditor | undefined) {
if (!editor || path.basename(editor.document.fileName) !== 'launch.json') {
return;
}
const ranges = [];
const ranges: vscode.Range[] = [];
let addPropertyAndValue = false;
let depthInArray = 0;
visit(editor.document.getText(), {
onObjectProperty: (property, offset, length) => {
addPropertyAndValue = property === 'version' || property === 'type' || property === 'request' || property === 'configurations';
// Decorate attributes which are unlikely to be edited by the user.
// Only decorate "configurations" if it is not inside an array (compounds have a configurations property which should not be decorated).
addPropertyAndValue = property === 'version' || property === 'type' || property === 'request' || property === 'compounds' || (property === 'configurations' && depthInArray === 0);
if (addPropertyAndValue) {
ranges.push(new vscode.Range(editor.document.positionAt(offset), editor.document.positionAt(offset + length)));
}
@@ -62,19 +75,15 @@ function updateLaunchJsonDecorations(editor: vscode.TextEditor) {
if (addPropertyAndValue) {
ranges.push(new vscode.Range(editor.document.positionAt(offset), editor.document.positionAt(offset + length)));
}
},
onArrayBegin: (offset: number, length: number) => {
depthInArray++;
},
onArrayEnd: (offset: number, length: number) => {
depthInArray--;
}
});
editor.setDecorations(decoration, ranges);
}
function newCompletionItem(text: string, range: vscode.Range, documentation?: string) {
const item = new vscode.CompletionItem(JSON.stringify(text));
item.kind = vscode.CompletionItemKind.Value;
item.documentation = documentation;
item.textEdit = {
range,
newText: item.label
};
return item;
}
@@ -3,9 +3,10 @@
"noLib": true,
"target": "es5",
"module": "commonjs",
"outDir": "./out"
"outDir": "./out",
"strictNullChecks": true
},
"exclude": [
"node_modules"
]
}
}
+18 -18
View File
@@ -7,14 +7,14 @@
import * as path from 'path';
import { languages, window, commands, ExtensionContext } from 'vscode';
import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind, RequestType, Range, TextEdit, Protocol2Code } from 'vscode-languageclient';
import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind, RequestType, Range, TextEdit } from 'vscode-languageclient';
import { activateColorDecorations } from './colorDecorators';
import * as nls from 'vscode-nls';
let localize = nls.loadMessageBundle();
namespace ColorSymbolRequest {
export const type: RequestType<string, Range[], any> = { get method() { return 'css/colorSymbols'; } };
export const type: RequestType<string, Range[], any, any> = { get method() { return 'css/colorSymbols'; }, _: null };
}
// this method is called when vs code is activated
@@ -51,7 +51,7 @@ export function activate(context: ExtensionContext) {
context.subscriptions.push(disposable);
let colorRequestor = (uri: string) => {
return client.sendRequest(ColorSymbolRequest.type, uri).then(ranges => ranges.map(Protocol2Code.asRange));
return client.sendRequest(ColorSymbolRequest.type, uri).then(ranges => ranges.map(client.protocol2CodeConverter.asRange));
};
disposable = activateColorDecorations(colorRequestor, { css: true, scss: true, less: true });
context.subscriptions.push(disposable);
@@ -69,23 +69,23 @@ export function activate(context: ExtensionContext) {
});
commands.registerCommand('_css.applyCodeAction', applyCodeAction);
}
function applyCodeAction(uri: string, documentVersion: number, edits: TextEdit[]) {
let textEditor = window.activeTextEditor;
if (textEditor && textEditor.document.uri.toString() === uri) {
if (textEditor.document.version !== documentVersion) {
window.showInformationMessage(`CSS fix is outdated and can't be applied to the document.`);
function applyCodeAction(uri: string, documentVersion: number, edits: TextEdit[]) {
let textEditor = window.activeTextEditor;
if (textEditor && textEditor.document.uri.toString() === uri) {
if (textEditor.document.version !== documentVersion) {
window.showInformationMessage(`CSS fix is outdated and can't be applied to the document.`);
}
textEditor.edit(mutator => {
for (let edit of edits) {
mutator.replace(client.protocol2CodeConverter.asRange(edit.range), edit.newText);
}
}).then(success => {
if (!success) {
window.showErrorMessage('Failed to apply CSS fix to the document. Please consider opening an issue with steps to reproduce.');
}
});
}
textEditor.edit(mutator => {
for (let edit of edits) {
mutator.replace(Protocol2Code.asRange(edit.range), edit.newText);
}
}).then(success => {
if (!success) {
window.showErrorMessage('Failed to apply CSS fix to the document. Please consider opening an issue with steps to reproduce.');
}
});
}
}
+1 -6
View File
@@ -3,9 +3,4 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/// <reference path='../../../../../src/vs/vscode.d.ts'/>
/// <reference path='../../../../../src/typings/mocha.d.ts'/>
/// <reference path='../../../../../extensions/node.d.ts'/>
/// <reference path='../../../../../extensions/lib.core.d.ts'/>
/// <reference path='../../../../../extensions/declares.d.ts'/>
/// <reference path='../../../node_modules/vscode-languageclient/lib/main.d.ts'/>
/// <reference path='../../../../../src/vs/vscode.d.ts'/>
+4 -2
View File
@@ -1,9 +1,11 @@
{
"compilerOptions": {
"noLib": true,
"target": "es5",
"module": "commonjs",
"outDir": "./out"
"outDir": "./out",
"lib": [
"es5", "es2015.promise"
]
},
"exclude": [
"node_modules"
+8 -8
View File
@@ -3,19 +3,19 @@
"version": "0.1.0",
"dependencies": {
"vscode-jsonrpc": {
"version": "2.3.2-next.5",
"from": "vscode-jsonrpc@>=2.3.2-next.2 <3.0.0",
"resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-2.3.2-next.5.tgz"
"version": "3.0.1-alpha.2",
"from": "vscode-jsonrpc@>=3.0.1-alpha.2 <4.0.0",
"resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-3.0.1-alpha.2.tgz"
},
"vscode-languageclient": {
"version": "2.4.2-next.22",
"version": "3.0.1-alpha.2",
"from": "vscode-languageclient@next",
"resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-2.4.2-next.22.tgz"
"resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-3.0.1-alpha.2.tgz"
},
"vscode-languageserver-types": {
"version": "1.0.3",
"from": "vscode-languageserver-types@>=1.0.3 <2.0.0",
"resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-1.0.3.tgz"
"version": "3.0.1-alpha.2",
"from": "vscode-languageserver-types@>=3.0.1-alpha.2 <4.0.0",
"resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.0.1-alpha.2.tgz"
},
"vscode-nls": {
"version": "1.0.7",
+4 -1
View File
@@ -646,7 +646,10 @@
}
},
"dependencies": {
"vscode-languageclient": "^2.4.2-next.22",
"vscode-languageclient": "^3.0.1-alpha.2",
"vscode-nls": "^1.0.7"
},
"devDependencies": {
"@types/node": "^6.0.51"
}
}
+10 -22
View File
@@ -3,41 +3,29 @@
"version": "1.0.0",
"dependencies": {
"vscode-css-languageservice": {
"version": "1.1.0",
"version": "2.0.0-next.5",
"from": "vscode-css-languageservice@next",
"resolved": "https://registry.npmjs.org/vscode-css-languageservice/-/vscode-css-languageservice-1.1.0.tgz"
"resolved": "https://registry.npmjs.org/vscode-css-languageservice/-/vscode-css-languageservice-2.0.0-next.5.tgz"
},
"vscode-jsonrpc": {
"version": "2.3.2-next.5",
"from": "vscode-jsonrpc@>=2.3.2-next.2 <3.0.0",
"resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-2.3.2-next.5.tgz"
"version": "3.0.1-alpha.2",
"from": "vscode-jsonrpc@>=3.0.1-alpha.2 <4.0.0",
"resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-3.0.1-alpha.2.tgz"
},
"vscode-languageserver": {
"version": "2.4.0-next.12",
"version": "3.0.1-alpha.2",
"from": "vscode-languageserver@next",
"resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-2.4.0-next.12.tgz",
"dependencies": {
"vscode-languageserver-types": {
"version": "1.0.3",
"from": "vscode-languageserver-types@>=1.0.3 <2.0.0",
"resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-1.0.3.tgz"
}
}
"resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-3.0.1-alpha.2.tgz"
},
"vscode-languageserver-types": {
"version": "1.0.3",
"from": "vscode-languageserver-types@>=1.0.3 <2.0.0",
"resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-1.0.3.tgz"
"version": "3.0.1-alpha.2",
"from": "vscode-languageserver-types@>=3.0.1-alpha.2 <4.0.0",
"resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.0.1-alpha.2.tgz"
},
"vscode-nls": {
"version": "1.0.7",
"from": "vscode-nls@>=1.0.4 <2.0.0",
"resolved": "https://registry.npmjs.org/vscode-nls/-/vscode-nls-1.0.7.tgz"
},
"vscode-uri": {
"version": "1.0.0",
"from": "vscode-uri@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-1.0.0.tgz"
}
}
}
+5 -2
View File
@@ -8,8 +8,11 @@
"node": "*"
},
"dependencies": {
"vscode-css-languageservice": "^1.1.0",
"vscode-languageserver": "^2.4.0-next.12"
"vscode-css-languageservice": "^2.0.0-next.5",
"vscode-languageserver": "^3.0.1-alpha.2"
},
"devDependencies": {
"@types/node": "^6.0.51"
},
"scripts": {
"compile": "gulp compile-extension:css-server",
+1 -1
View File
@@ -13,7 +13,7 @@ import { getCSSLanguageService, getSCSSLanguageService, getLESSLanguageService,
import { getLanguageModelCache } from './languageModelCache';
namespace ColorSymbolRequest {
export const type: RequestType<string, Range[], any> = { get method() { return 'css/colorSymbols'; } };
export const type: RequestType<string, Range[], any, any> = { get method() { return 'css/colorSymbols'; }, _: null };
}
export interface Settings {
-112
View File
@@ -1,112 +0,0 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/**
* The Thenable (E.g. PromiseLike) and Promise declarions are taken from TypeScript's
* lib.core.es6.d.ts file. See above Copyright notice.
*/
/**
* Thenable is a common denominator between ES6 promises, Q, jquery.Deferred, WinJS.Promise,
* and others. This API makes no assumption about what promise libary is being used which
* enables reusing existing code without migrating to a specific promise implementation. Still,
* we recommand the use of native promises which are available in VS Code.
*/
interface Thenable<T> {
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => TResult | Thenable<TResult>): Thenable<TResult>;
then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => void): Thenable<TResult>;
}
/**
* Represents the completion of an asynchronous operation
*/
interface Promise<T> extends Thenable<T> {
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => TResult | Thenable<TResult>): Promise<TResult>;
then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => void): Promise<TResult>;
/**
* Attaches a callback for only the rejection of the Promise.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of the callback.
*/
catch(onrejected?: (reason: any) => T | Thenable<T>): Promise<T>;
}
interface PromiseConstructor {
/**
* Creates a new Promise.
* @param executor A callback used to initialize the promise. This callback is passed two arguments:
* a resolve callback used resolve the promise with a value or the result of another promise,
* and a reject callback used to reject the promise with a provided reason or error.
*/
new <T>(executor: (resolve: (value?: T | Thenable<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
all<T>(values: Array<T | Thenable<T>>): Promise<T[]>;
/**
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
* or rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
race<T>(values: Array<T | Thenable<T>>): Promise<T>;
/**
* Creates a new rejected promise for the provided reason.
* @param reason The reason the promise was rejected.
* @returns A new rejected Promise.
*/
reject(reason: any): Promise<void>;
/**
* Creates a new rejected promise for the provided reason.
* @param reason The reason the promise was rejected.
* @returns A new rejected Promise.
*/
reject<T>(reason: any): Promise<T>;
/**
* Creates a new resolved promise for the provided value.
* @param value A promise.
* @returns A promise whose internal state matches the provided promise.
*/
resolve<T>(value: T | Thenable<T>): Promise<T>;
/**
* Creates a new resolved promise .
* @returns A resolved promise.
*/
resolve(): Promise<void>;
}
declare var Promise: PromiseConstructor;
+4 -2
View File
@@ -1,9 +1,11 @@
{
"compilerOptions": {
"noLib": true,
"target": "es5",
"module": "commonjs",
"outDir": "./out"
"outDir": "./out",
"lib": [
"es5"
]
},
"exclude": [
"node_modules"
-5
View File
@@ -2,10 +2,5 @@
"name": "extension-editing",
"version": "0.0.1",
"dependencies": {
"typescript": {
"version": "1.8.10",
"from": "typescript@>=1.8.10 <2.0.0",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-1.8.10.tgz"
}
}
}
@@ -13,13 +13,9 @@
],
"main": "./out/extension",
"scripts": {
"postinstall": "node ./postinstall",
"compile": "gulp compile-extension:extension-editing",
"watch": "gulp watch-extension:extension-editing"
},
"dependencies": {
"typescript": "^1.8.10"
},
"contributes": {
"jsonValidation": [
{
@@ -1,23 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
const fs = require('fs');
const path = require('path');
// delete unused typescript stuff
const root = path.dirname(require.resolve('typescript'));
for (let name of fs.readdirSync(root)) {
if (name !== 'typescript.d.ts' && name !== 'typescript.js') {
try {
fs.unlinkSync(path.join(root, name));
console.log(`removed '${path.join(root, name)}'`);
} catch (e) {
console.warn(e);
}
}
}
@@ -83,7 +83,7 @@ namespace ast {
let end = Number.MAX_VALUE;
for (let name of dottedName.split('.')) {
let idx: number;
let idx: number = -1;
while ((idx = identifiers.indexOf(name, idx + 1)) >= 0) {
let myStart = spans[2 * idx];
let myEnd = spans[2 * idx + 1];
+1 -1
View File
@@ -1,7 +1,7 @@
// ATTENTION - THIS DIRECTORY CONTAINS THIRD PARTY OPEN SOURCE MATERIALS:
[{
"name": "js-beautify",
"version": "1.6.2",
"version": "1.6.4",
"license": "MIT",
"repositoryURL": "https://github.com/beautify-web/js-beautify"
},{
+9 -12
View File
@@ -7,7 +7,7 @@
import * as path from 'path';
import { languages, workspace, ExtensionContext, IndentAction } from 'vscode';
import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind, Range, RequestType, Protocol2Code } from 'vscode-languageclient';
import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind, Range, RequestType } from 'vscode-languageclient';
import { EMPTY_ELEMENTS } from './htmlEmptyTagsShared';
import { activateColorDecorations } from './colorDecorators';
@@ -15,7 +15,7 @@ import * as nls from 'vscode-nls';
let localize = nls.loadMessageBundle();
namespace ColorSymbolRequest {
export const type: RequestType<string, Range[], any> = { get method() { return 'css/colorSymbols'; } };
export const type: RequestType<string, Range[], any, any> = { get method() { return 'css/colorSymbols'; }, _: null };
}
export function activate(context: ExtensionContext) {
@@ -50,17 +50,14 @@ export function activate(context: ExtensionContext) {
// Create the language client and start the client.
let client = new LanguageClient('html', localize('htmlserver.name', 'HTML Language Server'), serverOptions, clientOptions, true);
let disposable = client.start();
// Push the disposable to the context's subscriptions so that the
// client can be deactivated on extension deactivation
context.subscriptions.push(disposable);
let colorRequestor = (uri: string) => {
return client.sendRequest(ColorSymbolRequest.type, uri).then(ranges => ranges.map(Protocol2Code.asRange));
};
disposable = activateColorDecorations(colorRequestor, { html: true, handlebars: true, razor: true });
context.subscriptions.push(disposable);
client.onReady().then(() => {
let colorRequestor = (uri: string) => {
return client.sendRequest(ColorSymbolRequest.type, uri).then(ranges => ranges.map(client.protocol2CodeConverter.asRange));
};
let disposable = activateColorDecorations(colorRequestor, { html: true, handlebars: true, razor: true });
context.subscriptions.push(disposable);
});
languages.setLanguageConfiguration('html', {
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\$\^\&\*\(\)\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\s]+)/g,
+1 -6
View File
@@ -3,9 +3,4 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/// <reference path='../../../../../src/vs/vscode.d.ts'/>
/// <reference path='../../../../../src/typings/mocha.d.ts'/>
/// <reference path='../../../../../extensions/node.d.ts'/>
/// <reference path='../../../../../extensions/lib.core.d.ts'/>
/// <reference path='../../../../../extensions/declares.d.ts'/>
/// <reference path='../../../node_modules/vscode-languageclient/lib/main.d.ts'/>
/// <reference path='../../../../../src/vs/vscode.d.ts'/>
+5 -6
View File
@@ -1,11 +1,10 @@
{
"compilerOptions": {
"noLib": true,
"target": "es5",
"module": "commonjs",
"outDir": "./out"
},
"exclude": [
"node_modules"
]
"outDir": "./out",
"lib": [
"es5", "es2015.promise"
]
}
}
+7 -7
View File
@@ -3,19 +3,19 @@
"version": "0.1.0",
"dependencies": {
"vscode-jsonrpc": {
"version": "2.4.0",
"from": "vscode-jsonrpc@>=2.4.0 <3.0.0",
"resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-2.4.0.tgz"
"version": "3.0.1-alpha.2",
"from": "vscode-jsonrpc@>=3.0.1-alpha.2 <4.0.0",
"resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-3.0.1-alpha.2.tgz"
},
"vscode-languageclient": {
"version": "2.6.4-next.1",
"version": "3.0.1-alpha.2",
"from": "vscode-languageclient@next",
"resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-2.6.4-next.1.tgz"
"resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-3.0.1-alpha.2.tgz"
},
"vscode-languageserver-types": {
"version": "1.0.5-next.1",
"version": "3.0.1-alpha.2",
"from": "vscode-languageserver-types@next",
"resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-1.0.5-next.1.tgz"
"resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.0.1-alpha.2.tgz"
},
"vscode-nls": {
"version": "1.0.7",
+6 -2
View File
@@ -143,8 +143,12 @@
}
},
"dependencies": {
"vscode-languageclient": "^2.6.4-next.1",
"vscode-languageserver-types": "^1.0.5-next.1",
"vscode-languageclient": "^3.0.1-alpha.2",
"vscode-languageserver-types": "^3.0.1-alpha.2",
"vscode-nls": "^1.0.7"
},
"devDependencies": {
"@types/node": "^6.0.51",
"@types/mocha": "^2.2.33"
}
}
@@ -0,0 +1,6 @@
// ATTENTION - THIS DIRECTORY CONTAINS THIRD PARTY OPEN SOURCE MATERIALS:
[{
"name": "definitelytyped",
"repositoryURL": "https://github.com/DefinitelyTyped/DefinitelyTyped",
"license": "MIT"
}]
File diff suppressed because it is too large Load Diff
+12 -12
View File
@@ -3,29 +3,29 @@
"version": "1.0.0",
"dependencies": {
"vscode-css-languageservice": {
"version": "2.0.0-next.3",
"version": "2.0.0-next.5",
"from": "vscode-css-languageservice@next",
"resolved": "https://registry.npmjs.org/vscode-css-languageservice/-/vscode-css-languageservice-2.0.0-next.3.tgz"
"resolved": "https://registry.npmjs.org/vscode-css-languageservice/-/vscode-css-languageservice-2.0.0-next.5.tgz"
},
"vscode-html-languageservice": {
"version": "1.0.1-next.4",
"version": "2.0.0-next.1",
"from": "vscode-html-languageservice@next",
"resolved": "https://registry.npmjs.org/vscode-html-languageservice/-/vscode-html-languageservice-1.0.1-next.4.tgz"
"resolved": "https://registry.npmjs.org/vscode-html-languageservice/-/vscode-html-languageservice-2.0.0-next.1.tgz"
},
"vscode-jsonrpc": {
"version": "2.4.0",
"from": "vscode-jsonrpc@>=2.4.0 <3.0.0",
"resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-2.4.0.tgz"
"version": "3.0.1-alpha.2",
"from": "vscode-jsonrpc@>=3.0.1-alpha.2 <4.0.0",
"resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-3.0.1-alpha.2.tgz"
},
"vscode-languageserver": {
"version": "2.6.2-next.1",
"version": "3.0.1-alpha.2",
"from": "vscode-languageserver@next",
"resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-2.6.2-next.1.tgz"
"resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-3.0.1-alpha.2.tgz"
},
"vscode-languageserver-types": {
"version": "1.0.5-next.1",
"from": "vscode-languageserver-types@>=1.0.5-next.1 <2.0.0",
"resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-1.0.5-next.1.tgz"
"version": "3.0.1-alpha.2",
"from": "vscode-languageserver-types@>=3.0.1-alpha.2 <4.0.0",
"resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.0.1-alpha.2.tgz"
},
"vscode-nls": {
"version": "1.0.7",
+10 -6
View File
@@ -8,15 +8,19 @@
"node": "*"
},
"dependencies": {
"vscode-css-languageservice": "^2.0.0-next.3",
"vscode-html-languageservice": "^1.0.1-next.4",
"vscode-languageserver": "^2.6.2-next.1",
"vscode-nls": "^1.0.4",
"vscode-css-languageservice": "^2.0.0-next.5",
"vscode-html-languageservice": "^2.0.0-next.1",
"vscode-languageserver": "^3.0.1-alpha.2",
"vscode-nls": "^1.0.7",
"vscode-uri": "^1.0.0"
},
"devDependencies": {
"@types/node": "^6.0.51",
"@types/mocha": "^2.2.33"
},
"scripts": {
"compile": "gulp compile-extension:json-server",
"watch": "gulp watch-extension:json-server",
"compile": "gulp compile-extension:html-server",
"watch": "gulp watch-extension:html-server",
"install-service-next": "npm install vscode-css-languageservice@next -f -S && npm install vscode-html-languageservice@next -f -S",
"install-service-local": "npm install ../../../../vscode-css-languageservice -f -S && npm install ../../../../vscode-html-languageservice -f -S",
"install-server-next": "npm install vscode-languageserver@next -f -S",
+18 -5
View File
@@ -5,7 +5,8 @@
'use strict';
import { createConnection, IConnection, TextDocuments, InitializeParams, InitializeResult, RequestType } from 'vscode-languageserver';
import { DocumentContext, TextDocument, Diagnostic, DocumentLink, Range, TextEdit } from 'vscode-html-languageservice';
import { DocumentContext } from 'vscode-html-languageservice';
import { TextDocument, Diagnostic, DocumentLink, Range, TextEdit, SymbolInformation } from 'vscode-languageserver-types';
import { getLanguageModes, LanguageModes } from './modes/languageModes';
import * as url from 'url';
@@ -16,7 +17,7 @@ import * as nls from 'vscode-nls';
nls.config(process.env['VSCODE_NLS_CONFIG']);
namespace ColorSymbolRequest {
export const type: RequestType<string, Range[], any> = { get method() { return 'css/colorSymbols'; } };
export const type: RequestType<string, Range[], any, any> = { get method() { return 'css/colorSymbols'; }, _: null };
}
// Create a connection for the server
@@ -44,10 +45,10 @@ connection.onInitialize((params: InitializeParams): InitializeResult => {
languageModes = getLanguageModes(initializationOptions ? initializationOptions.embeddedLanguages : { css: true, javascript: true });
documents.onDidClose(e => {
languageModes.getAllModes().forEach(m => m.onDocumentRemoved(e.document));
languageModes.onDocumentRemoved(e.document);
});
connection.onShutdown(() => {
languageModes.getAllModes().forEach(m => m.dispose());
languageModes.dispose();
});
return {
@@ -59,6 +60,7 @@ connection.onInitialize((params: InitializeParams): InitializeResult => {
documentHighlightProvider: true,
documentRangeFormattingProvider: initializationOptions && initializationOptions['format.enable'],
documentLinkProvider: true,
documentSymbolProvider: true,
definitionProvider: true,
signatureHelpProvider: { triggerCharacters: ['('] },
referencesProvider: true
@@ -198,7 +200,7 @@ connection.onDocumentRangeFormatting(formatParams => {
let result: TextEdit[] = [];
ranges.forEach(r => {
let mode = r.mode;
if (mode && mode.format) {
if (mode && mode.format && !r.attributeValue) {
let edits = mode.format(document, r, formatParams.options);
pushAll(result, edits);
}
@@ -225,6 +227,17 @@ connection.onDocumentLinks(documentLinkParam => {
return links;
});
connection.onDocumentSymbol(documentSymbolParms => {
let document = documents.get(documentSymbolParms.textDocument.uri);
let symbols: SymbolInformation[] = [];
languageModes.getAllModesInDocument(document).forEach(m => {
if (m.findDocumentSymbols) {
pushAll(symbols, m.findDocumentSymbols(document));
}
});
return symbols;
});
connection.onRequest(ColorSymbolRequest.type, uri => {
let ranges: Range[] = [];
let document = documents.get(uri);
+16 -11
View File
@@ -5,16 +5,15 @@
'use strict';
import { LanguageModelCache, getLanguageModelCache } from '../languageModelCache';
import { LanguageService as HTMLLanguageService, HTMLDocument } from 'vscode-html-languageservice';
import { TextDocument, Position } from 'vscode-languageserver-types';
import { getCSSLanguageService, Stylesheet } from 'vscode-css-languageservice';
import { getEmbeddedDocument } from './embeddedSupport';
import { LanguageMode } from './languageModes';
import { HTMLDocumentRegions, CSS_STYLE_RULE } from './embeddedSupport';
export function getCSSMode(htmlLanguageService: HTMLLanguageService, htmlDocuments: LanguageModelCache<HTMLDocument>): LanguageMode {
export function getCSSMode(documentRegions: LanguageModelCache<HTMLDocumentRegions>): LanguageMode {
let cssLanguageService = getCSSLanguageService();
let embeddedCSSDocuments = getLanguageModelCache<TextDocument>(10, 60, document => documentRegions.get(document).getEmbeddedDocument('css'));
let cssStylesheets = getLanguageModelCache<Stylesheet>(10, 60, document => cssLanguageService.parseStylesheet(document));
let getEmbeddedCSSDocument = (document: TextDocument) => getEmbeddedDocument(htmlLanguageService, document, htmlDocuments.get(document), 'css');
return {
getId() {
@@ -24,37 +23,43 @@ export function getCSSMode(htmlLanguageService: HTMLLanguageService, htmlDocumen
cssLanguageService.configure(options && options.css);
},
doValidation(document: TextDocument) {
let embedded = getEmbeddedCSSDocument(document);
let embedded = embeddedCSSDocuments.get(document);
return cssLanguageService.doValidation(embedded, cssStylesheets.get(embedded));
},
doComplete(document: TextDocument, position: Position) {
let embedded = getEmbeddedCSSDocument(document);
let embedded = embeddedCSSDocuments.get(document);
return cssLanguageService.doComplete(embedded, position, cssStylesheets.get(embedded));
},
doHover(document: TextDocument, position: Position) {
let embedded = getEmbeddedCSSDocument(document);
let embedded = embeddedCSSDocuments.get(document);
return cssLanguageService.doHover(embedded, position, cssStylesheets.get(embedded));
},
findDocumentHighlight(document: TextDocument, position: Position) {
let embedded = getEmbeddedCSSDocument(document);
let embedded = embeddedCSSDocuments.get(document);
return cssLanguageService.findDocumentHighlights(embedded, position, cssStylesheets.get(embedded));
},
findDocumentSymbols(document: TextDocument) {
let embedded = embeddedCSSDocuments.get(document);
return cssLanguageService.findDocumentSymbols(embedded, cssStylesheets.get(embedded)).filter(s => s.name !== CSS_STYLE_RULE);
},
findDefinition(document: TextDocument, position: Position) {
let embedded = getEmbeddedCSSDocument(document);
let embedded = embeddedCSSDocuments.get(document);
return cssLanguageService.findDefinition(embedded, position, cssStylesheets.get(embedded));
},
findReferences(document: TextDocument, position: Position) {
let embedded = getEmbeddedCSSDocument(document);
let embedded = embeddedCSSDocuments.get(document);
return cssLanguageService.findReferences(embedded, position, cssStylesheets.get(embedded));
},
findColorSymbols(document: TextDocument) {
let embedded = getEmbeddedCSSDocument(document);
let embedded = embeddedCSSDocuments.get(document);
return cssLanguageService.findColorSymbols(embedded, cssStylesheets.get(embedded));
},
onDocumentRemoved(document: TextDocument) {
embeddedCSSDocuments.onDocumentRemoved(document);
cssStylesheets.onDocumentRemoved(document);
},
dispose() {
embeddedCSSDocuments.dispose();
cssStylesheets.dispose();
}
};
@@ -5,143 +5,187 @@
'use strict';
import { TextDocument, Position, HTMLDocument, Node, LanguageService, TokenType, Range, Scanner } from 'vscode-html-languageservice';
import { TextDocument, Position, LanguageService, TokenType, Range } from 'vscode-html-languageservice';
export interface LanguageRange extends Range {
languageId: string;
attributeValue?: boolean;
}
interface EmbeddedContent { languageId: string; start: number; end: number; attributeValue?: boolean; };
export interface HTMLDocumentRegions {
getEmbeddedDocument(languageId: string): TextDocument;
getLanguageRanges(range: Range): LanguageRange[];
getLanguageAtPosition(position: Position): string;
getLanguagesInDocument(): string[];
getImportedScripts(): string[];
}
export function getLanguageAtPosition(languageService: LanguageService, document: TextDocument, htmlDocument: HTMLDocument, position: Position): string {
let offset = document.offsetAt(position);
let node = htmlDocument.findNodeAt(offset);
if (node) {
let embeddedContent = getEmbeddedContentForNode(languageService, document, node);
if (embeddedContent) {
for (let c of embeddedContent) {
if (c.start <= offset && offset <= c.end) {
return c.languageId;
export var CSS_STYLE_RULE = '__';
interface EmbeddedRegion { languageId: string; start: number; end: number; attributeValue?: boolean; };
export function getDocumentRegions(languageService: LanguageService, document: TextDocument): HTMLDocumentRegions {
let regions: EmbeddedRegion[] = [];
let scanner = languageService.createScanner(document.getText());
let lastTagName: string;
let lastAttributeName: string;
let languageIdFromType: string;
let importedScripts = [];
let token = scanner.scan();
while (token !== TokenType.EOS) {
switch (token) {
case TokenType.StartTag:
lastTagName = scanner.getTokenText();
lastAttributeName = null;
languageIdFromType = 'javascript';
break;
case TokenType.Styles:
regions.push({ languageId: 'css', start: scanner.getTokenOffset(), end: scanner.getTokenEnd() });
break;
case TokenType.Script:
regions.push({ languageId: languageIdFromType, start: scanner.getTokenOffset(), end: scanner.getTokenEnd() });
break;
case TokenType.AttributeName:
lastAttributeName = scanner.getTokenText();
break;
case TokenType.AttributeValue:
if (lastAttributeName === 'src' && lastTagName.toLowerCase() === 'script') {
let value = scanner.getTokenText();
if (value[0] === '\'' || value[0] === '"') {
value = value.substr(1, value.length - 1);
}
importedScripts.push(value);
} else if (lastAttributeName === 'type' && lastTagName.toLowerCase() === 'script') {
if (/["'](text|application)\/(java|ecma)script["']/.test(scanner.getTokenText())) {
languageIdFromType = 'javascript';
} else {
languageIdFromType = void 0;
}
} else {
let attributelLanguageId = getAttributeLanguage(lastAttributeName);
if (attributelLanguageId) {
let start = scanner.getTokenOffset();
let end = scanner.getTokenEnd();
let firstChar = document.getText()[start];
if (firstChar === '\'' || firstChar === '"') {
start++;
end--;
}
regions.push({ languageId: attributelLanguageId, start, end, attributeValue: true });
}
}
lastAttributeName = null;
break;
}
token = scanner.scan();
}
return {
getLanguageRanges: (range: Range) => getLanguageRanges(document, regions, range),
getEmbeddedDocument: (languageId: string) => getEmbeddedDocument(document, regions, languageId),
getLanguageAtPosition: (position: Position) => getLanguageAtPosition(document, regions, position),
getLanguagesInDocument: () => getLanguagesInDocument(document, regions),
getImportedScripts: () => importedScripts
};
}
function getLanguageRanges(document: TextDocument, regions: EmbeddedRegion[], range: Range): LanguageRange[] {
let result: LanguageRange[] = [];
let currentPos = range ? range.start : Position.create(0, 0);
let currentOffset = range ? document.offsetAt(range.start) : 0;
let endOffset = range ? document.offsetAt(range.end) : document.getText().length;
for (let region of regions) {
if (region.end > currentOffset && region.start < endOffset) {
let start = Math.max(region.start, currentOffset);
let startPos = document.positionAt(start);
if (currentOffset < region.start) {
result.push({
start: currentPos,
end: startPos,
languageId: 'html'
});
}
let end = Math.min(region.end, endOffset);
let endPos = document.positionAt(end);
if (end > region.start) {
result.push({
start: startPos,
end: endPos,
languageId: region.languageId,
attributeValue: region.attributeValue
});
}
currentOffset = end;
currentPos = endPos;
}
}
if (currentOffset < endOffset) {
let endPos = range ? range.end : document.positionAt(endOffset);
result.push({
start: currentPos,
end: endPos,
languageId: 'html'
});
}
return result;
}
function getLanguagesInDocument(document: TextDocument, regions: EmbeddedRegion[]): string[] {
let result = [];
for (let region of regions) {
if (result.indexOf(region.languageId) === -1) {
result.push(region.languageId);
if (result.length === 3) {
return result;
}
}
}
result.push('html');
return result;
}
function getLanguageAtPosition(document: TextDocument, regions: EmbeddedRegion[], position: Position): string {
let offset = document.offsetAt(position);
for (let region of regions) {
if (region.start <= offset) {
if (offset <= region.end) {
return region.languageId;
}
} else {
break;
}
}
return 'html';
}
export function getLanguagesInContent(languageService: LanguageService, document: TextDocument, htmlDocument: HTMLDocument): string[] {
let embeddedLanguageIds = ['html'];
const maxEmbbeddedLanguages = 3;
function collectEmbeddedLanguages(node: Node): void {
if (embeddedLanguageIds.length < maxEmbbeddedLanguages) {
let embeddedContent = getEmbeddedContentForNode(languageService, document, node);
if (embeddedContent) {
for (let c of embeddedContent) {
if (!isWhitespace(document.getText(), c.start, c.end)) {
if (embeddedLanguageIds.lastIndexOf(c.languageId) === -1) {
embeddedLanguageIds.push(c.languageId);
if (embeddedLanguageIds.length === maxEmbbeddedLanguages) {
return;
}
}
}
}
}
node.children.forEach(collectEmbeddedLanguages);
}
}
htmlDocument.roots.forEach(collectEmbeddedLanguages);
return embeddedLanguageIds;
}
export function getLanguagesInRange(languageService: LanguageService, document: TextDocument, htmlDocument: HTMLDocument, range: Range): LanguageRange[] {
let ranges: LanguageRange[] = [];
let currentPos = range.start;
let currentOffset = document.offsetAt(currentPos);
let rangeEndOffset = document.offsetAt(range.end);
function collectEmbeddedNodes(node: Node): void {
if (node.start < rangeEndOffset && node.end > currentOffset) {
let embeddedContent = getEmbeddedContentForNode(languageService, document, node);
if (embeddedContent) {
for (let c of embeddedContent) {
if (c.start < rangeEndOffset) {
let startPos = document.positionAt(c.start);
if (currentOffset < c.start) {
ranges.push({
start: currentPos,
end: startPos,
languageId: 'html'
});
}
let end = Math.min(c.end, rangeEndOffset);
let endPos = document.positionAt(end);
if (end > c.start) {
ranges.push({
start: startPos,
end: endPos,
languageId: c.languageId
});
}
currentOffset = end;
currentPos = endPos;
}
}
}
}
node.children.forEach(collectEmbeddedNodes);
}
htmlDocument.roots.forEach(collectEmbeddedNodes);
if (currentOffset < rangeEndOffset) {
ranges.push({
start: currentPos,
end: range.end,
languageId: 'html'
});
}
return ranges;
}
export function getEmbeddedDocument(languageService: LanguageService, document: TextDocument, htmlDocument: HTMLDocument, languageId: string): TextDocument {
let contents: EmbeddedContent[] = [];
function collectEmbeddedNodes(node: Node): void {
let embeddedContent = getEmbeddedContentForNode(languageService, document, node);
if (embeddedContent) {
for (let c of embeddedContent) {
if (c.languageId === languageId) {
contents.push(c);
}
}
}
node.children.forEach(collectEmbeddedNodes);
}
htmlDocument.roots.forEach(collectEmbeddedNodes);
function getEmbeddedDocument(document: TextDocument, contents: EmbeddedRegion[], languageId: string): TextDocument {
let currentPos = 0;
let oldContent = document.getText();
let result = '';
let lastSuffix = '';
for (let c of contents) {
result = substituteWithWhitespace(result, currentPos, c.start, oldContent, lastSuffix, getPrefix(c));
result += oldContent.substring(c.start, c.end);
currentPos = c.end;
lastSuffix = getSuffix(c);
if (c.languageId === languageId) {
result = substituteWithWhitespace(result, currentPos, c.start, oldContent, lastSuffix, getPrefix(c));
result += oldContent.substring(c.start, c.end);
currentPos = c.end;
lastSuffix = getSuffix(c);
}
}
result = substituteWithWhitespace(result, currentPos, oldContent.length, oldContent, lastSuffix, '');
return TextDocument.create(document.uri, languageId, document.version, result);
}
function getPrefix(c: EmbeddedContent) {
function getPrefix(c: EmbeddedRegion) {
if (c.attributeValue) {
switch (c.languageId) {
case 'css': return 'x{';
case 'css': return CSS_STYLE_RULE + '{';
}
}
return '';
}
function getSuffix(c: EmbeddedContent) {
function getSuffix(c: EmbeddedRegion) {
if (c.attributeValue) {
switch (c.languageId) {
case 'css': return '}';
@@ -151,7 +195,6 @@ function getSuffix(c: EmbeddedContent) {
return '';
}
function substituteWithWhitespace(result: string, start: number, end: number, oldContent: string, before: string, after: string) {
let accumulatedWS = 0;
result += before;
@@ -181,87 +224,10 @@ function append(result: string, str: string, n: number): string {
return result;
}
function getEmbeddedContentForNode(languageService: LanguageService, document: TextDocument, node: Node): EmbeddedContent[] {
if (node.tag === 'style') {
let scanner = languageService.createScanner(document.getText().substring(node.start, node.end));
let token = scanner.scan();
while (token !== TokenType.EOS) {
if (token === TokenType.Styles) {
return [{ languageId: 'css', start: node.start + scanner.getTokenOffset(), end: node.start + scanner.getTokenEnd() }];
}
token = scanner.scan();
}
} else if (node.tag === 'script') {
let scanner = languageService.createScanner(document.getText().substring(node.start, node.end));
let token = scanner.scan();
let isTypeAttribute = false;
let languageId = 'javascript';
while (token !== TokenType.EOS) {
if (token === TokenType.AttributeName) {
isTypeAttribute = scanner.getTokenText() === 'type';
} else if (token === TokenType.AttributeValue) {
if (isTypeAttribute) {
if (/["'](text|application)\/(java|ecma)script["']/.test(scanner.getTokenText())) {
languageId = 'javascript';
} else {
languageId = void 0;
}
}
isTypeAttribute = false;
} else if (token === TokenType.Script) {
return [{ languageId, start: node.start + scanner.getTokenOffset(), end: node.start + scanner.getTokenEnd() }];
}
token = scanner.scan();
}
} else if (node.attributeNames) {
let scanner: Scanner;
let result;
for (let name of node.attributeNames) {
let languageId = getAttributeLanguage(name);
if (languageId) {
if (!scanner) {
scanner = languageService.createScanner(document.getText().substring(node.start, node.end));
}
let token = scanner.scan();
let lastAttribute;
while (token !== TokenType.EOS) {
if (token === TokenType.AttributeName) {
lastAttribute = scanner.getTokenText();
} else if (token === TokenType.AttributeValue && lastAttribute === name) {
let start = scanner.getTokenOffset() + node.start;
let end = scanner.getTokenEnd() + node.start;
let firstChar = document.getText()[start];
if (firstChar === '\'' || firstChar === '"') {
start++;
end--;
}
if (!result) {
result = [];
}
result.push({ languageId, start, end, attributeValue: true });
lastAttribute = null;
break;
}
token = scanner.scan();
}
}
}
return result;
}
return void 0;
}
function getAttributeLanguage(attributeName: string): string {
let match = attributeName.match(/^(style)|(on\w+)$/i);
let match = attributeName.match(/^(style)$|^(on\w+)$/i);
if (!match) {
return null;
}
return match[1] ? 'css' : 'javascript';
}
function isWhitespace(str: string, start: number, end: number): boolean {
if (start === end) {
return true;
}
return !!str.substring(start, end).match(/^\s*$/);
}
+3 -3
View File
@@ -4,14 +4,14 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import { LanguageModelCache } from '../languageModelCache';
import { getLanguageModelCache } from '../languageModelCache';
import { LanguageService as HTMLLanguageService, HTMLDocument, DocumentContext, FormattingOptions } from 'vscode-html-languageservice';
import { TextDocument, Position, Range } from 'vscode-languageserver-types';
import { LanguageMode } from './languageModes';
export function getHTMLMode(htmlLanguageService: HTMLLanguageService, htmlDocuments: LanguageModelCache<HTMLDocument>): LanguageMode {
export function getHTMLMode(htmlLanguageService: HTMLLanguageService): LanguageMode {
let settings: any = {};
let htmlDocuments = getLanguageModelCache<HTMLDocument>(10, 60, document => htmlLanguageService.parseHTMLDocument(document));
return {
getId() {
return 'html';
@@ -5,37 +5,35 @@
'use strict';
import { LanguageModelCache, getLanguageModelCache } from '../languageModelCache';
import { LanguageService as HTMLLanguageService, HTMLDocument } from 'vscode-html-languageservice';
import { getEmbeddedDocument } from './embeddedSupport';
import { CompletionItem, Location, SignatureHelp, SignatureInformation, ParameterInformation, Definition, TextEdit, TextDocument, Diagnostic, DiagnosticSeverity, Range, CompletionItemKind, Hover, MarkedString, DocumentHighlight, DocumentHighlightKind, CompletionList, Position, FormattingOptions } from 'vscode-languageserver-types';
import { SymbolInformation, SymbolKind, CompletionItem, Location, SignatureHelp, SignatureInformation, ParameterInformation, Definition, TextEdit, TextDocument, Diagnostic, DiagnosticSeverity, Range, CompletionItemKind, Hover, MarkedString, DocumentHighlight, DocumentHighlightKind, CompletionList, Position, FormattingOptions } from 'vscode-languageserver-types';
import { LanguageMode } from './languageModes';
import { getWordAtText } from '../utils/words';
import { HTMLDocumentRegions } from './embeddedSupport';
import ts = require('./typescript/typescriptServices');
import { contents as libdts } from './typescript/lib-ts';
import * as ts from 'typescript';
import { join } from 'path';
const DEFAULT_LIB = {
NAME: 'defaultLib:lib.d.ts',
CONTENTS: libdts
};
const FILE_NAME = 'typescript://singlefile/1'; // the same 'file' is used for all contents
const FILE_NAME = 'vscode://javascript/1'; // the same 'file' is used for all contents
const JQUERY_D_TS = join(__dirname, '../../lib/jquery.d.ts');
const JS_WORD_REGEX = /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g;
export function getJavascriptMode(htmlLanguageService: HTMLLanguageService, htmlDocuments: LanguageModelCache<HTMLDocument>): LanguageMode {
export function getJavascriptMode(documentRegions: LanguageModelCache<HTMLDocumentRegions>): LanguageMode {
let jsDocuments = getLanguageModelCache<TextDocument>(10, 60, document => documentRegions.get(document).getEmbeddedDocument('javascript'));
let compilerOptions = { allowNonTsExtensions: true, allowJs: true, target: ts.ScriptTarget.Latest };
let currentTextDocument: TextDocument;
let host = {
getCompilationSettings: () => compilerOptions,
getScriptFileNames: () => [FILE_NAME],
getScriptFileNames: () => [FILE_NAME, JQUERY_D_TS],
getScriptVersion: (fileName: string) => {
if (fileName === FILE_NAME) {
return String(currentTextDocument.version);
}
return '1'; // default lib is static
return '1'; // default lib an jquery.d.ts are static
},
getScriptSnapshot: (fileName: string) => {
let text = fileName === FILE_NAME ? currentTextDocument.getText() : DEFAULT_LIB.CONTENTS;
let text = fileName === FILE_NAME ? currentTextDocument.getText() : ts.sys.readFile(fileName);
return {
getText: (start, end) => text.substring(start, end),
getLength: () => text.length,
@@ -43,13 +41,10 @@ export function getJavascriptMode(htmlLanguageService: HTMLLanguageService, html
};
},
getCurrentDirectory: () => '',
getDefaultLibFileName: options => DEFAULT_LIB.NAME
getDefaultLibFileName: (options) => ts.getDefaultLibFilePath(options)
};
let jsLanguageService = ts.createLanguageService(host);
let jsDocuments = getLanguageModelCache<TextDocument>(10, 60, document => {
return getEmbeddedDocument(htmlLanguageService, document, htmlDocuments.get(document), 'javascript');
});
let settings: any = {};
return {
@@ -169,6 +164,42 @@ export function getJavascriptMode(htmlLanguageService: HTMLLanguageService, html
};
return null;
},
findDocumentSymbols(document: TextDocument): SymbolInformation[] {
currentTextDocument = jsDocuments.get(document);
let items = jsLanguageService.getNavigationBarItems(FILE_NAME);
if (items) {
let result: SymbolInformation[] = [];
let existing = {};
let collectSymbols = (item: ts.NavigationBarItem, containerLabel?: string) => {
let sig = item.text + item.kind + item.spans[0].start;
if (item.kind !== 'script' && !existing[sig]) {
let symbol: SymbolInformation = {
name: item.text,
kind: convertSymbolKind(item.kind),
location: {
uri: document.uri,
range: convertRange(currentTextDocument, item.spans[0])
},
containerName: containerLabel
};
existing[sig] = true;
result.push(symbol);
containerLabel = item.text;
}
if (item.childItems && item.childItems.length > 0) {
for (let child of item.childItems) {
collectSymbols(child, containerLabel);
}
}
};
items.forEach(item => collectSymbols(item));
return result;
}
return null;
},
findDefinition(document: TextDocument, position: Position): Definition {
currentTextDocument = jsDocuments.get(document);
let definition = jsLanguageService.getDefinitionAtPosition(FILE_NAME, currentTextDocument.offsetAt(position));
@@ -220,8 +251,8 @@ export function getJavascriptMode(htmlLanguageService: HTMLLanguageService, html
jsDocuments.onDocumentRemoved(document);
},
dispose() {
jsDocuments.dispose();
jsLanguageService.dispose();
jsDocuments.dispose();
}
};
};
@@ -265,6 +296,33 @@ function convertKind(kind: string): CompletionItemKind {
return CompletionItemKind.Property;
}
function convertSymbolKind(kind: string): SymbolKind {
switch (kind) {
case 'var':
case 'local var':
case 'const':
return SymbolKind.Variable;
case 'function':
case 'local function':
return SymbolKind.Function;
case 'enum':
return SymbolKind.Enum;
case 'module':
return SymbolKind.Module;
case 'class':
return SymbolKind.Class;
case 'interface':
return SymbolKind.Interface;
case 'method':
return SymbolKind.Method;
case 'property':
case 'getter':
case 'setter':
return SymbolKind.Property;
}
return SymbolKind.Variable;
}
function convertOptions(options: FormattingOptions, formatSettings: any, initialIndentLevel: number): ts.FormatCodeOptions {
return {
ConvertTabsToSpaces: options.insertSpaces,
@@ -4,14 +4,14 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import { HTMLDocument, getLanguageService as getHTMLLanguageService, DocumentContext } from 'vscode-html-languageservice';
import { getLanguageService as getHTMLLanguageService, DocumentContext } from 'vscode-html-languageservice';
import {
CompletionItem, Location, SignatureHelp, Definition, TextEdit, TextDocument, Diagnostic, DocumentLink, Range,
Hover, DocumentHighlight, CompletionList, Position, FormattingOptions
Hover, DocumentHighlight, CompletionList, Position, FormattingOptions, SymbolInformation
} from 'vscode-languageserver-types';
import { getLanguageModelCache } from '../languageModelCache';
import { getLanguageAtPosition, getLanguagesInContent, getLanguagesInRange } from './embeddedSupport';
import { getLanguageModelCache, LanguageModelCache } from '../languageModelCache';
import { getDocumentRegions, HTMLDocumentRegions } from './embeddedSupport';
import { getCSSMode } from './cssMode';
import { getJavascriptMode } from './javascriptMode';
import { getHTMLMode } from './htmlMode';
@@ -25,6 +25,7 @@ export interface LanguageMode {
doHover?: (document: TextDocument, position: Position) => Hover;
doSignatureHelp?: (document: TextDocument, position: Position) => SignatureHelp;
findDocumentHighlight?: (document: TextDocument, position: Position) => DocumentHighlight[];
findDocumentSymbols?: (document: TextDocument) => SymbolInformation[];
findDocumentLinks?: (document: TextDocument, documentContext: DocumentContext) => DocumentLink[];
findDefinition?: (document: TextDocument, position: Position) => Definition;
findReferences?: (document: TextDocument, position: Position) => Location[];
@@ -37,53 +38,55 @@ export interface LanguageMode {
export interface LanguageModes {
getModeAtPosition(document: TextDocument, position: Position): LanguageMode;
getModesInRange(document: TextDocument, range: Range): LanguageModeRange[];
getAllModesInDocument(document: TextDocument): LanguageMode[];
getAllModes(): LanguageMode[];
getAllModesInDocument(document: TextDocument): LanguageMode[];
getMode(languageId: string): LanguageMode;
onDocumentRemoved(document: TextDocument): void;
dispose(): void;
}
export interface LanguageModeRange extends Range {
mode: LanguageMode;
attributeValue?: boolean;
}
export function getLanguageModes(supportedLanguages: { [languageId: string]: boolean; }): LanguageModes {
var htmlLanguageService = getHTMLLanguageService();
let htmlDocuments = getLanguageModelCache<HTMLDocument>(10, 60, document => htmlLanguageService.parseHTMLDocument(document));
let documentRegions = getLanguageModelCache<HTMLDocumentRegions>(10, 60, document => getDocumentRegions(htmlLanguageService, document));
let modes = {
'html': getHTMLMode(htmlLanguageService, htmlDocuments),
'css': supportedLanguages['css'] && getCSSMode(htmlLanguageService, htmlDocuments),
'javascript': supportedLanguages['javascript'] && getJavascriptMode(htmlLanguageService, htmlDocuments)
};
let modelCaches: LanguageModelCache<any>[] = [];
modelCaches.push(documentRegions);
let modes = {};
modes['html'] = getHTMLMode(htmlLanguageService);
if (supportedLanguages['css']) {
modes['css'] = getCSSMode(documentRegions);
}
if (supportedLanguages['javascript']) {
modes['javascript'] = getJavascriptMode(documentRegions);
}
return {
getModeAtPosition(document: TextDocument, position: Position): LanguageMode {
let languageId = getLanguageAtPosition(htmlLanguageService, document, htmlDocuments.get(document), position);
let languageId = documentRegions.get(document).getLanguageAtPosition(position);;
if (languageId) {
return modes[languageId];
}
return null;
},
getAllModesInDocument(document: TextDocument): LanguageMode[] {
let result = [];
let languageIds = getLanguagesInContent(htmlLanguageService, document, htmlDocuments.get(document));
for (let languageId of languageIds) {
let mode = modes[languageId];
if (mode) {
result.push(mode);
}
}
return result;
},
getModesInRange(document: TextDocument, range: Range): LanguageModeRange[] {
return getLanguagesInRange(htmlLanguageService, document, htmlDocuments.get(document), range).map(r => {
return documentRegions.get(document).getLanguageRanges(range).map(r => {
return {
start: r.start,
end: r.end,
mode: modes[r.languageId]
mode: modes[r.languageId],
attributeValue: r.attributeValue
};
});
},
getAllModesInDocument(document: TextDocument): LanguageMode[] {
return documentRegions.get(document).getLanguagesInDocument().map(languageId => modes[languageId]);
},
getAllModes(): LanguageMode[] {
let result = [];
for (let languageId in modes) {
@@ -96,6 +99,20 @@ export function getLanguageModes(supportedLanguages: { [languageId: string]: boo
},
getMode(languageId: string): LanguageMode {
return modes[languageId];
},
onDocumentRemoved(document: TextDocument) {
modelCaches.forEach(mc => mc.onDocumentRemoved(document));
for (let mode in modes) {
modes[mode].onDocumentRemoved(document);
}
},
dispose(): void {
modelCaches.forEach(mc => mc.dispose());
modelCaches = [];
for (let mode in modes) {
modes[mode].dispose();
}
modes = {};
}
};
}
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
@@ -20,21 +20,18 @@ suite('HTML Embedded Support', () => {
let document = TextDocument.create('test://test/test.html', 'html', 0, value);
let position = document.positionAt(offset);
let ls = getLanguageService();
let htmlDoc = ls.parseHTMLDocument(document);
let languageId = embeddedSupport.getLanguageAtPosition(htmlLanguageService, document, htmlDoc, position);
let docRegions = embeddedSupport.getDocumentRegions(htmlLanguageService, document);
let languageId = docRegions.getLanguageAtPosition(position);
assert.equal(languageId, expectedLanguageId);
}
function assertEmbeddedLanguageContent(value: string, languageId: string, expectedContent: string): void {
let document = TextDocument.create('test://test/test.html', 'html', 0, value);
let ls = getLanguageService();
let htmlDoc = ls.parseHTMLDocument(document);
let content = embeddedSupport.getEmbeddedDocument(ls, document, htmlDoc, languageId);
let docRegions = embeddedSupport.getDocumentRegions(htmlLanguageService, document);
let content = docRegions.getEmbeddedDocument(languageId);
assert.equal(content.getText(), expectedContent);
}
@@ -70,8 +67,8 @@ suite('HTML Embedded Support', () => {
assertEmbeddedLanguageContent('<html><style>foo { }</style>Hello<style>foo { }</style></html>', 'css', ' foo { } foo { } ');
assertEmbeddedLanguageContent('<html>\n <style>\n foo { } \n </style>\n</html>\n', 'css', '\n \n foo { } \n \n\n');
assertEmbeddedLanguageContent('<div style="color: red"></div>', 'css', ' x{color: red} ');
assertEmbeddedLanguageContent('<div style=color:red></div>', 'css', ' x{color:red} ');
assertEmbeddedLanguageContent('<div style="color: red"></div>', 'css', ' __{color: red} ');
assertEmbeddedLanguageContent('<div style=color:red></div>', 'css', ' __{color:red} ');
});
test('Scripts', function (): any {
@@ -109,6 +106,9 @@ suite('HTML Embedded Support', () => {
assertLanguageId('<DIV ONKEYUP=foo(|)</DIV>', 'javascript');
assertLanguageId('<DIV ONKEYUP=foo()|</DIV>', 'javascript');
assertLanguageId('<DIV ONKEYUP=foo()<|/DIV>', 'html');
assertLanguageId('<label data-content="|Checkbox"/>', 'html');
assertLanguageId('<label on="|Checkbox"/>', 'html');
});
test('Script content', function (): any {
@@ -58,7 +58,7 @@ suite('HTML Embedded Formatting', () => {
assertFormat('<html><head>\n <script>\nvar x=1;\nconsole.log("Hi");\n</script></head></html>', '<html>\n\n<head>\n <script>\n var x = 1;\n console.log("Hi");\n</script>\n</head>\n\n</html>');
assertFormat('<html><head>\n |<script>\nvar x=1;\n</script>|</head></html>', '<html><head>\n <script>\n var x = 1;\n</script></head></html>');
assertFormat('<html><head>\n <script>\n|var x=1;|\n</script></head></html>', '<html><head>\n <script>\n var x = 1;\n</script></head></html>');
assertFormat('<html><head>\n <script>\n|var x=1;|\n</script></head></html>', '<html><head>\n <script>\n var x = 1;\n</script></head></html>');
});
test('HTML & Multiple Scripts', function (): any {
@@ -0,0 +1,44 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as assert from 'assert';
import { getJavascriptMode } from '../modes/javascriptMode';
import { TextDocument, Range, TextEdit, FormattingOptions } from 'vscode-languageserver-types';
import { getLanguageModelCache } from '../languageModelCache';
import { getLanguageService } from 'vscode-html-languageservice';
import * as embeddedSupport from '../modes/embeddedSupport';
suite('HTML Javascript Support', () => {
var htmlLanguageService = getLanguageService();
function assertCompletions(value: string, expectedProposals: string[]): void {
let offset = value.indexOf('|');
value = value.substr(0, offset) + value.substr(offset + 1);
let document = TextDocument.create('test://test/test.html', 'html', 0, value);
let documentRegions = getLanguageModelCache<embeddedSupport.HTMLDocumentRegions>(10, 60, document => embeddedSupport.getDocumentRegions(htmlLanguageService, document));
var mode = getJavascriptMode(documentRegions);
let position = document.positionAt(offset);
let list = mode.doComplete(document, position);
assert.ok(list);
let actualLabels = list.items.map(c => c.label).sort();
for (let expected of expectedProposals) {
assert.ok(actualLabels.indexOf(expected) !== -1, 'Not found:' + expected + ' is ' + actualLabels.join(', '));
}
}
test('Completions', function (): any {
assertCompletions('<html><script>window.|</script></html>', ['location']);
assertCompletions('<html><script>$.|</script></html>', ['getJSON']);
});
});
+1
View File
@@ -0,0 +1 @@
/// <reference path='../../node_modules/@types/mocha/index.d.ts'/>
-112
View File
@@ -1,112 +0,0 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/**
* The Thenable (E.g. PromiseLike) and Promise declarions are taken from TypeScript's
* lib.core.es6.d.ts file. See above Copyright notice.
*/
/**
* Thenable is a common denominator between ES6 promises, Q, jquery.Deferred, WinJS.Promise,
* and others. This API makes no assumption about what promise libary is being used which
* enables reusing existing code without migrating to a specific promise implementation. Still,
* we recommand the use of native promises which are available in VS Code.
*/
interface Thenable<T> {
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => TResult | Thenable<TResult>): Thenable<TResult>;
then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => void): Thenable<TResult>;
}
/**
* Represents the completion of an asynchronous operation
*/
interface Promise<T> extends Thenable<T> {
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => TResult | Thenable<TResult>): Promise<TResult>;
then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => void): Promise<TResult>;
/**
* Attaches a callback for only the rejection of the Promise.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of the callback.
*/
catch(onrejected?: (reason: any) => T | Thenable<T>): Promise<T>;
}
interface PromiseConstructor {
/**
* Creates a new Promise.
* @param executor A callback used to initialize the promise. This callback is passed two arguments:
* a resolve callback used resolve the promise with a value or the result of another promise,
* and a reject callback used to reject the promise with a provided reason or error.
*/
new <T>(executor: (resolve: (value?: T | Thenable<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
all<T>(values: Array<T | Thenable<T>>): Promise<T[]>;
/**
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
* or rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
race<T>(values: Array<T | Thenable<T>>): Promise<T>;
/**
* Creates a new rejected promise for the provided reason.
* @param reason The reason the promise was rejected.
* @returns A new rejected Promise.
*/
reject(reason: any): Promise<void>;
/**
* Creates a new rejected promise for the provided reason.
* @param reason The reason the promise was rejected.
* @returns A new rejected Promise.
*/
reject<T>(reason: any): Promise<T>;
/**
* Creates a new resolved promise for the provided value.
* @param value A promise.
* @returns A promise whose internal state matches the provided promise.
*/
resolve<T>(value: T | Thenable<T>): Promise<T>;
/**
* Creates a new resolved promise .
* @returns A resolved promise.
*/
resolve(): Promise<void>;
}
declare var Promise: PromiseConstructor;
+5 -6
View File
@@ -1,11 +1,10 @@
{
"compilerOptions": {
"noLib": true,
"target": "es5",
"module": "commonjs",
"outDir": "./out"
},
"exclude": [
"node_modules"
]
"outDir": "./out",
"lib": [
"es5", "es2015.promise"
]
}
}
+20
View File
@@ -19,4 +19,24 @@
"to the base-name name of the original file, and an extension of txt, html, or similar. For example",
"\"tidy\" is accompanied by \"tidy-license.txt\"."
]
},{
"name": "textmate/javadoc.tmbundle",
"version": "0.0.0",
"license": "TextMate Bundle License",
"repositoryURL": "https://github.com/textmate/javadoc.tmbundle",
"licenseDetail": [
"Copyright (c) textmate-javadoc.tmbundle project authors",
"",
"If not otherwise specified (see below), files in this repository fall under the following license:",
"",
"Permission to copy, use, modify, sell and distribute this",
"software is granted. This software is provided \"as is\" without",
"express or implied warranty, and with no claim as to its",
"suitability for any purpose.",
"",
"An exception is made for files in readable text which contain their own license information,",
"or files where an accompanying file exists (in the same directory) with a \"-license\" suffix added",
"to the base-name name of the original file, and an extension of txt, html, or similar. For example",
"\"tidy\" is accompanied by \"tidy-license.txt\"."
]
}]
+5 -2
View File
@@ -4,7 +4,7 @@
"publisher": "vscode",
"engines": { "vscode": "*" },
"scripts": {
"update-grammar": "node ../../build/npm/update-grammar.js textmate/java.tmbundle Syntaxes/Java.plist ./syntaxes/java.json"
"update-grammar": "node ../../build/npm/update-grammar.js textmate/java.tmbundle Syntaxes/Java.plist ./syntaxes/java.tmLanguage.json && node ../../build/npm/update-grammar.js textmate/javadoc.tmbundle Syntaxes/JavaDoc.tmLanguage ./syntaxes/javadoc.tmLanguage.json"
},
"contributes": {
"languages": [{
@@ -16,7 +16,10 @@
"grammars": [{
"language": "java",
"scopeName": "source.java",
"path": "./syntaxes/java.json"
"path": "./syntaxes/java.tmLanguage.json"
},{
"scopeName": "text.html.javadoc",
"path": "./syntaxes/javadoc.tmLanguage.json"
}]
}
}
@@ -0,0 +1,432 @@
{
"fileTypes": [],
"name": "JavaDoc",
"patterns": [
{
"begin": "(/\\*\\*)\\s*$",
"beginCaptures": {
"1": {
"name": "punctuation.definition.comment.begin.javadoc"
}
},
"contentName": "text.html",
"end": "\\*/",
"endCaptures": {
"0": {
"name": "punctuation.definition.comment.end.javadoc"
}
},
"name": "comment.block.documentation.javadoc",
"patterns": [
{
"include": "#inline"
},
{
"begin": "((\\@)param)",
"beginCaptures": {
"1": {
"name": "keyword.other.documentation.param.javadoc"
},
"2": {
"name": "punctuation.definition.keyword.javadoc"
}
},
"end": "(?=^\\s*\\*?\\s*@|\\*/)",
"name": "meta.documentation.tag.param.javadoc",
"patterns": [
{
"include": "#inline"
}
]
},
{
"begin": "((\\@)return)",
"beginCaptures": {
"1": {
"name": "keyword.other.documentation.return.javadoc"
},
"2": {
"name": "punctuation.definition.keyword.javadoc"
}
},
"end": "(?=^\\s*\\*?\\s*@|\\*/)",
"name": "meta.documentation.tag.return.javadoc",
"patterns": [
{
"include": "#inline"
}
]
},
{
"begin": "((\\@)throws)",
"beginCaptures": {
"1": {
"name": "keyword.other.documentation.throws.javadoc"
},
"2": {
"name": "punctuation.definition.keyword.javadoc"
}
},
"end": "(?=^\\s*\\*?\\s*@|\\*/)",
"name": "meta.documentation.tag.throws.javadoc",
"patterns": [
{
"include": "#inline"
}
]
},
{
"begin": "((\\@)exception)",
"beginCaptures": {
"1": {
"name": "keyword.other.documentation.exception.javadoc"
},
"2": {
"name": "punctuation.definition.keyword.javadoc"
}
},
"end": "(?=^\\s*\\*?\\s*@|\\*/)",
"name": "meta.documentation.tag.exception.javadoc",
"patterns": [
{
"include": "#inline"
}
]
},
{
"begin": "((\\@)author)",
"beginCaptures": {
"1": {
"name": "keyword.other.documentation.author.javadoc"
},
"2": {
"name": "punctuation.definition.keyword.javadoc"
}
},
"end": "(?=^\\s*\\*?\\s*@|\\*/)",
"name": "meta.documentation.tag.author.javadoc",
"patterns": [
{
"include": "#inline"
}
]
},
{
"begin": "((\\@)version)",
"beginCaptures": {
"1": {
"name": "keyword.other.documentation.version.javadoc"
},
"2": {
"name": "punctuation.definition.keyword.javadoc"
}
},
"end": "(?=^\\s*\\*?\\s*@|\\*/)",
"name": "meta.documentation.tag.version.javadoc",
"patterns": [
{
"include": "#inline"
}
]
},
{
"begin": "((\\@)see)",
"beginCaptures": {
"1": {
"name": "keyword.other.documentation.see.javadoc"
},
"2": {
"name": "punctuation.definition.keyword.javadoc"
}
},
"end": "(?=^\\s*\\*?\\s*@|\\*/)",
"name": "meta.documentation.tag.see.javadoc",
"patterns": [
{
"include": "#inline"
}
]
},
{
"begin": "((\\@)since)",
"beginCaptures": {
"1": {
"name": "keyword.other.documentation.since.javadoc"
},
"2": {
"name": "punctuation.definition.keyword.javadoc"
}
},
"end": "(?=^\\s*\\*?\\s*@|\\*/)",
"name": "meta.documentation.tag.since.javadoc",
"patterns": [
{
"include": "#inline"
}
]
},
{
"begin": "((\\@)serial)",
"beginCaptures": {
"1": {
"name": "keyword.other.documentation.serial.javadoc"
},
"2": {
"name": "punctuation.definition.keyword.javadoc"
}
},
"end": "(?=^\\s*\\*?\\s*@|\\*/)",
"name": "meta.documentation.tag.serial.javadoc",
"patterns": [
{
"include": "#inline"
}
]
},
{
"begin": "((\\@)serialField)",
"beginCaptures": {
"1": {
"name": "keyword.other.documentation.serialField.javadoc"
},
"2": {
"name": "punctuation.definition.keyword.javadoc"
}
},
"end": "(?=^\\s*\\*?\\s*@|\\*/)",
"name": "meta.documentation.tag.serialField.javadoc",
"patterns": [
{
"include": "#inline"
}
]
},
{
"begin": "((\\@)serialData)",
"beginCaptures": {
"1": {
"name": "keyword.other.documentation.serialData.javadoc"
},
"2": {
"name": "punctuation.definition.keyword.javadoc"
}
},
"end": "(?=^\\s*\\*?\\s*@|\\*/)",
"name": "meta.documentation.tag.serialData.javadoc",
"patterns": [
{
"include": "#inline"
}
]
},
{
"begin": "((\\@)deprecated)",
"beginCaptures": {
"1": {
"name": "keyword.other.documentation.deprecated.javadoc"
},
"2": {
"name": "punctuation.definition.keyword.javadoc"
}
},
"end": "(?=^\\s*\\*?\\s*@|\\*/)",
"name": "meta.documentation.tag.deprecated.javadoc",
"patterns": [
{
"include": "#inline"
}
]
},
{
"captures": {
"1": {
"name": "keyword.other.documentation.custom.javadoc"
},
"2": {
"name": "punctuation.definition.keyword.javadoc"
}
},
"match": "((\\@)\\S+)\\s"
}
]
}
],
"repository": {
"inline": {
"patterns": [
{
"include": "#inline-formatting"
},
{
"comment": "This prevents < characters in commented source from starting\n\t\t\t\t\t\t\t\ta tag that will not end. List of allowed tags taken from\n\t\t\t\t\t\t\t\tjava checkstyle.",
"match": "<(?!(a|abbr|acronym|address|area|b|bdo|big|blockquote|br|caption|cite|code|colgroup|dd|del|div|dfn|dl|dt|em|fieldset|font|h1toh6|hr|i|img|ins|kbd|li|ol|p|pre|q|samp|small|span|strong|sub|sup|table|tbody|td|tfoot|th|thread|tr|tt|u|ul)\\b[^>]*>)"
},
{
"include": "text.html.basic"
},
{
"match": "((https?|s?ftp|ftps|file|smb|afp|nfs|(x-)?man|gopher|txmt)://|mailto:)[-:@a-zA-Z0-9_.,~%+/?=&#;]+(?<![-.,?:#;])",
"name": "markup.underline.link"
}
]
},
"inline-formatting": {
"patterns": [
{
"begin": "(\\{)((\\@)code)",
"beginCaptures": {
"1": {
"name": "punctuation.definition.tag.begin.javadoc"
},
"2": {
"name": "keyword.other.documentation.directive.code.javadoc"
},
"3": {
"name": "punctuation.definition.keyword.javadoc"
}
},
"contentName": "markup.raw.code.javadoc",
"end": "\\}",
"endCaptures": {
"0": {
"name": "punctuation.definition.tag.end.javadoc"
}
},
"name": "meta.tag.template.code.javadoc",
"patterns": []
},
{
"begin": "(\\{)((\\@)literal)",
"beginCaptures": {
"1": {
"name": "punctuation.definition.tag.begin.javadoc"
},
"2": {
"name": "keyword.other.documentation.directive.literal.javadoc"
},
"3": {
"name": "punctuation.definition.keyword.javadoc"
}
},
"contentName": "markup.raw.literal.javadoc",
"end": "\\}",
"endCaptures": {
"0": {
"name": "punctuation.definition.tag.end.javadoc"
}
},
"name": "meta.tag.template.literal.javadoc",
"patterns": []
},
{
"captures": {
"1": {
"name": "punctuation.definition.tag.begin.javadoc"
},
"2": {
"name": "keyword.other.documentation.directive.docRoot.javadoc"
},
"3": {
"name": "punctuation.definition.keyword.javadoc"
},
"4": {
"name": "punctuation.definition.tag.end.javadoc"
}
},
"match": "(\\{)((\\@)docRoot)(\\})",
"name": "meta.tag.template.docRoot.javadoc"
},
{
"captures": {
"1": {
"name": "punctuation.definition.tag.begin.javadoc"
},
"2": {
"name": "keyword.other.documentation.directive.inheritDoc.javadoc"
},
"3": {
"name": "punctuation.definition.keyword.javadoc"
},
"4": {
"name": "punctuation.definition.tag.end.javadoc"
}
},
"match": "(\\{)((\\@)inheritDoc)(\\})",
"name": "meta.tag.template.inheritDoc.javadoc"
},
{
"captures": {
"1": {
"name": "punctuation.definition.tag.begin.javadoc"
},
"2": {
"name": "keyword.other.documentation.directive.link.javadoc"
},
"3": {
"name": "punctuation.definition.keyword.javadoc"
},
"4": {
"name": "markup.underline.link.javadoc"
},
"5": {
"name": "string.other.link.title.javadoc"
},
"6": {
"name": "punctuation.definition.tag.end.javadoc"
}
},
"match": "(\\{)((\\@)link)(?:\\s+(\\S+?))?(?:\\s+(.+?))?\\s*(\\})",
"name": "meta.tag.template.link.javadoc"
},
{
"captures": {
"1": {
"name": "punctuation.definition.tag.begin.javadoc"
},
"2": {
"name": "keyword.other.documentation.directive.linkplain.javadoc"
},
"3": {
"name": "punctuation.definition.keyword.javadoc"
},
"4": {
"name": "markup.underline.linkplain.javadoc"
},
"5": {
"name": "string.other.link.title.javadoc"
},
"6": {
"name": "punctuation.definition.tag.end.javadoc"
}
},
"match": "(\\{)((\\@)linkplain)(?:\\s+(\\S+?))?(?:\\s+(.+?))?\\s*(\\})",
"name": "meta.tag.template.linkplain.javadoc"
},
{
"captures": {
"1": {
"name": "punctuation.definition.tag.begin.javadoc"
},
"2": {
"name": "keyword.other.documentation.directive.value.javadoc"
},
"3": {
"name": "punctuation.definition.keyword.javadoc"
},
"4": {
"name": "variable.other.javadoc"
},
"5": {
"name": "punctuation.definition.tag.end.javadoc"
}
},
"match": "(\\{)((\\@)value)\\s*(\\S+?)?\\s*(\\})",
"name": "meta.tag.template.value.javadoc"
}
]
}
},
"scopeName": "text.html.javadoc",
"uuid": "64BB98A4-59D4-474E-9091-C1E1D04BDD03",
"version": "https://github.com/textmate/javadoc.tmbundle/commit/5276d7a93f0cf53b7d425c39c6968b09ea9f2d40"
}
@@ -440,8 +440,8 @@
}
},
{
"c": "/*",
"t": "block.body.class.comment.definition.java.meta.punctuation",
"c": "/**",
"t": "begin.block.body.class.comment.definition.documentation.java.javadoc.meta.punctuation",
"r": {
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.comment rgb(96, 139, 78)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.comment rgb(0, 128, 0)",
@@ -451,8 +451,8 @@
}
},
{
"c": "*",
"t": "block.body.class.comment.java.meta",
"c": "\t * ",
"t": "block.body.class.comment.documentation.html.java.javadoc.meta.text",
"r": {
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.comment rgb(96, 139, 78)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.comment rgb(0, 128, 0)",
@@ -462,8 +462,30 @@
}
},
{
"c": "\t * @param args",
"t": "block.body.class.comment.java.meta",
"c": "@",
"t": "block.body.class.comment.definition.documentation.html.java.javadoc.keyword.meta.other.param.punctuation.tag.text",
"r": {
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.punctuation.definition.tag rgb(128, 128, 128)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.punctuation.definition.tag rgb(128, 0, 0)",
"dark_vs": ".vs-dark.vscode-theme-defaults-themes-dark_vs-json .token.punctuation.definition.tag rgb(128, 128, 128)",
"light_vs": ".vs.vscode-theme-defaults-themes-light_vs-json .token.punctuation.definition.tag rgb(128, 0, 0)",
"hc_black": ".hc-black.vscode-theme-defaults-themes-hc_black-json .token.punctuation.definition.tag rgb(128, 128, 128)"
}
},
{
"c": "param",
"t": "block.body.class.comment.documentation.html.java.javadoc.keyword.meta.other.param.tag.text",
"r": {
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.keyword rgb(86, 156, 214)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.keyword rgb(0, 0, 255)",
"dark_vs": ".vs-dark.vscode-theme-defaults-themes-dark_vs-json .token.keyword rgb(86, 156, 214)",
"light_vs": ".vs.vscode-theme-defaults-themes-light_vs-json .token.keyword rgb(0, 0, 255)",
"hc_black": ".hc-black.vscode-theme-defaults-themes-hc_black-json .token.keyword rgb(86, 156, 214)"
}
},
{
"c": " args",
"t": "block.body.class.comment.documentation.html.java.javadoc.meta.param.tag.text",
"r": {
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.comment rgb(96, 139, 78)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.comment rgb(0, 128, 0)",
@@ -474,7 +496,7 @@
},
{
"c": "\t ",
"t": "block.body.class.comment.java.meta",
"t": "block.body.class.comment.documentation.html.java.javadoc.meta.param.tag.text",
"r": {
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.comment rgb(96, 139, 78)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.comment rgb(0, 128, 0)",
@@ -485,7 +507,7 @@
},
{
"c": "*/",
"t": "block.body.class.comment.definition.java.meta.punctuation",
"t": "block.body.class.comment.definition.documentation.end.java.javadoc.meta.punctuation",
"r": {
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.comment rgb(96, 139, 78)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.comment rgb(0, 128, 0)",
@@ -117,7 +117,7 @@ export class BowerJSONContribution implements IJSONContribution {
if ((location.matches(['dependencies', '*']) || location.matches(['devDependencies', '*']))) {
// not implemented. Could be do done calling the bower command. Waiting for web API: https://github.com/bower/registry/issues/26
let proposal = new CompletionItem(localize('json.bower.latest.version', 'latest'));
proposal.insertText = '"{{latest}}"';
proposal.insertText = new SnippetString('"${1:latest}"');
proposal.filterText = '""';
proposal.kind = CompletionItemKind.Value;
proposal.documentation = 'The latest version of the package';
+20 -19
View File
@@ -14,7 +14,7 @@ import * as nls from 'vscode-nls';
let localize = nls.loadMessageBundle();
namespace VSCodeContentRequest {
export const type: RequestType<string, string, any> = { get method() { return 'vscode/content'; } };
export const type: RequestType<string, string, any, any> = { get method() { return 'vscode/content'; }, _: null };
}
export interface ISchemaAssociations {
@@ -22,7 +22,7 @@ export interface ISchemaAssociations {
}
namespace SchemaAssociationNotification {
export const type: NotificationType<ISchemaAssociations> = { get method() { return 'json/schemaAssociations'; } };
export const type: NotificationType<ISchemaAssociations, any> = { get method() { return 'json/schemaAssociations'; }, _: null };
}
interface IPackageInfo {
@@ -68,25 +68,26 @@ export function activate(context: ExtensionContext) {
// Create the language client and start the client.
let client = new LanguageClient('json', localize('jsonserver.name', 'JSON Language Server'), serverOptions, clientOptions);
client.onTelemetry(e => {
if (telemetryReporter) {
telemetryReporter.sendTelemetryEvent(e.key, e.data);
}
});
// handle content request
client.onRequest(VSCodeContentRequest.type, (uriPath: string) => {
let uri = Uri.parse(uriPath);
return workspace.openTextDocument(uri).then(doc => {
return doc.getText();
}, error => {
return Promise.reject(error);
});
});
let disposable = client.start();
client.onReady().then(() => {
client.onTelemetry(e => {
if (telemetryReporter) {
telemetryReporter.sendTelemetryEvent(e.key, e.data);
}
});
client.sendNotification(SchemaAssociationNotification.type, getSchemaAssociation(context));
// handle content request
client.onRequest(VSCodeContentRequest.type, (uriPath: string) => {
let uri = Uri.parse(uriPath);
return workspace.openTextDocument(uri).then(doc => {
return doc.getText();
}, error => {
return Promise.reject(error);
});
});
client.sendNotification(SchemaAssociationNotification.type, getSchemaAssociation(context));
});
// Push the disposable to the context's subscriptions so that the
// client can be deactivated on extension deactivation
+1 -6
View File
@@ -3,9 +3,4 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/// <reference path='../../../../../src/vs/vscode.d.ts'/>
/// <reference path='../../../../../src/typings/mocha.d.ts'/>
/// <reference path='../../../../../extensions/node.d.ts'/>
/// <reference path='../../../../../extensions/lib.core.d.ts'/>
/// <reference path='../../../../../extensions/declares.d.ts'/>
/// <reference path='../../../node_modules/vscode-languageclient/lib/main.d.ts'/>
/// <reference path='../../../../../src/vs/vscode.d.ts'/>
+5 -6
View File
@@ -1,11 +1,10 @@
{
"compilerOptions": {
"noLib": true,
"target": "es5",
"module": "commonjs",
"outDir": "./out"
},
"exclude": [
"node_modules"
]
"outDir": "./out",
"lib": [
"es5", "es2015.promise"
]
}
}
+8 -8
View File
@@ -13,19 +13,19 @@
"resolved": "https://registry.npmjs.org/vscode-extension-telemetry/-/vscode-extension-telemetry-0.0.5.tgz"
},
"vscode-jsonrpc": {
"version": "2.3.2-next.5",
"from": "vscode-jsonrpc@>=2.3.2-next.2 <3.0.0",
"resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-2.3.2-next.5.tgz"
"version": "3.0.1-alpha.2",
"from": "vscode-jsonrpc@>=3.0.1-alpha.2 <4.0.0",
"resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-3.0.1-alpha.2.tgz"
},
"vscode-languageclient": {
"version": "2.4.2-next.22",
"version": "3.0.1-alpha.3",
"from": "vscode-languageclient@next",
"resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-2.4.2-next.22.tgz"
"resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-3.0.1-alpha.3.tgz"
},
"vscode-languageserver-types": {
"version": "1.0.3",
"from": "vscode-languageserver-types@>=1.0.3 <2.0.0",
"resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-1.0.3.tgz"
"version": "3.0.1-alpha.2",
"from": "vscode-languageserver-types@>=3.0.1-alpha.2 <4.0.0",
"resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.0.1-alpha.2.tgz"
},
"vscode-nls": {
"version": "1.0.7",
+7 -4
View File
@@ -66,9 +66,9 @@
"type": "object",
"default": {
"fileMatch": [
"{{/myfile}}"
"/myfile"
],
"url": "{{schemaURL}}"
"url": "schemaURL"
},
"properties": {
"url": {
@@ -103,7 +103,10 @@
},
"dependencies": {
"vscode-extension-telemetry": "^0.0.5",
"vscode-languageclient": "^2.4.2-next.22",
"vscode-languageclient": "^3.0.1-alpha.3",
"vscode-nls": "^1.0.7"
},
"devDependencies": {
"@types/node": "^6.0.51"
}
}
}
+10 -17
View File
@@ -43,31 +43,24 @@
"resolved": "https://registry.npmjs.org/request-light/-/request-light-0.1.0.tgz"
},
"vscode-json-languageservice": {
"version": "2.0.0-next.2",
"version": "2.0.0-next.4",
"from": "vscode-json-languageservice@next",
"resolved": "https://registry.npmjs.org/vscode-json-languageservice/-/vscode-json-languageservice-2.0.0-next.2.tgz",
"dependencies": {
"vscode-languageserver-types": {
"version": "1.0.4",
"from": "vscode-languageserver-types@>=1.0.4 <2.0.0",
"resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-1.0.4.tgz"
}
}
"resolved": "https://registry.npmjs.org/vscode-json-languageservice/-/vscode-json-languageservice-2.0.0-next.4.tgz"
},
"vscode-jsonrpc": {
"version": "2.3.2-next.5",
"from": "vscode-jsonrpc@>=2.3.2-next.2 <3.0.0",
"resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-2.3.2-next.5.tgz"
"version": "3.0.1-alpha.2",
"from": "vscode-jsonrpc@>=3.0.1-alpha.2 <4.0.0",
"resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-3.0.1-alpha.2.tgz"
},
"vscode-languageserver": {
"version": "2.4.0-next.12",
"version": "3.0.1-alpha.3",
"from": "vscode-languageserver@next",
"resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-2.4.0-next.12.tgz"
"resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-3.0.1-alpha.3.tgz"
},
"vscode-languageserver-types": {
"version": "1.0.3",
"from": "vscode-languageserver-types@>=1.0.3 <2.0.0",
"resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-1.0.3.tgz"
"version": "3.0.1-alpha.2",
"from": "vscode-languageserver-types@>=3.0.1-alpha.2 <4.0.0",
"resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.0.1-alpha.2.tgz"
},
"vscode-nls": {
"version": "1.0.7",
+6 -3
View File
@@ -9,9 +9,12 @@
},
"dependencies": {
"request-light": "^0.1.0",
"vscode-json-languageservice": "^2.0.0-next.2",
"vscode-languageserver": "^2.4.0-next.12",
"vscode-nls": "^1.0.4"
"vscode-json-languageservice": "^2.0.0-next.4",
"vscode-languageserver": "^3.0.1-alpha.3",
"vscode-nls": "^1.0.7"
},
"devDependencies": {
"@types/node": "^6.0.51"
},
"scripts": {
"compile": "gulp compile-extension:json-server",
+2 -2
View File
@@ -29,11 +29,11 @@ interface ISchemaAssociations {
}
namespace SchemaAssociationNotification {
export const type: NotificationType<ISchemaAssociations> = { get method() { return 'json/schemaAssociations'; } };
export const type: NotificationType<ISchemaAssociations, any> = { get method() { return 'json/schemaAssociations'; }, _: null };
}
namespace VSCodeContentRequest {
export const type: RequestType<string, string, any> = { get method() { return 'vscode/content'; } };
export const type: RequestType<string, string, any, any> = { get method() { return 'vscode/content'; }, _: null };
}
// Create a connection for the server
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import { MarkedString, CompletionItemKind, CompletionItem } from 'vscode-languageserver';
import { MarkedString, CompletionItemKind, CompletionItem, SnippetString } from 'vscode-languageserver';
import Strings = require('../utils/strings');
import { JSONWorkerContribution, JSONPath, CompletionsCollector } from 'vscode-json-languageservice';
@@ -12,8 +12,8 @@ import * as nls from 'vscode-nls';
const localize = nls.loadMessageBundle();
let globProperties: CompletionItem[] = [
{ kind: CompletionItemKind.Value, label: localize('assocLabelFile', "Files with Extension"), insertText: '"*.{{extension}}": "{{language}}"', documentation: localize('assocDescriptionFile', "Map all files matching the glob pattern in their filename to the language with the given identifier.") },
{ kind: CompletionItemKind.Value, label: localize('assocLabelPath', "Files with Path"), insertText: '"/{{path to file}}/*.{{extension}}": "{{language}}"', documentation: localize('assocDescriptionPath', "Map all files matching the absolute path glob pattern in their path to the language with the given identifier.") }
{ kind: CompletionItemKind.Value, label: localize('assocLabelFile', "Files with Extension"), insertText: SnippetString.create('"*.${1:extension}": "${2:language}"'), documentation: localize('assocDescriptionFile', "Map all files matching the glob pattern in their filename to the language with the given identifier.") },
{ kind: CompletionItemKind.Value, label: localize('assocLabelPath', "Files with Path"), insertText: SnippetString.create('"/${1:path to file}/*.${2:extension}": "${3:language}"'), documentation: localize('assocDescriptionPath', "Map all files matching the absolute path glob pattern in their path to the language with the given identifier.") }
];
export class FileAssociationContribution implements JSONWorkerContribution {
@@ -37,7 +37,6 @@ export class FileAssociationContribution implements JSONWorkerContribution {
public collectPropertyCompletions(resource: string, location: JSONPath, currentWord: string, addValue: boolean, isLast: boolean, result: CompletionsCollector): Thenable<any> {
if (this.isSettingsFile(resource) && location.length === 1 && location[0] === 'files.associations') {
globProperties.forEach(e => {
e.filterText = e.insertText;
result.add(e);
});
}
@@ -51,7 +50,7 @@ export class FileAssociationContribution implements JSONWorkerContribution {
result.add({
kind: CompletionItemKind.Value,
label: l,
insertText: JSON.stringify('{{' + l + '}}'),
insertText: SnippetString.create(JSON.stringify('${1:' + l + '}')),
filterText: JSON.stringify(l)
});
});
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import { MarkedString, CompletionItemKind, CompletionItem } from 'vscode-languageserver';
import { MarkedString, CompletionItemKind, CompletionItem, SnippetString } from 'vscode-languageserver';
import Strings = require('../utils/strings');
import { JSONWorkerContribution, JSONPath, CompletionsCollector } from 'vscode-json-languageservice';
@@ -12,18 +12,18 @@ import * as nls from 'vscode-nls';
const localize = nls.loadMessageBundle();
let globProperties: CompletionItem[] = [
{ kind: CompletionItemKind.Value, label: localize('fileLabel', "Files by Extension"), insertText: '"**/*.{{extension}}": true', documentation: localize('fileDescription', "Match all files of a specific file extension.") },
{ kind: CompletionItemKind.Value, label: localize('fileLabel', "Files by Extension"), insertText: SnippetString.create('"**/*.${1:extension}": true'), documentation: localize('fileDescription', "Match all files of a specific file extension.") },
{ kind: CompletionItemKind.Value, label: localize('filesLabel', "Files with Multiple Extensions"), insertText: '"**/*.{ext1,ext2,ext3}": true', documentation: localize('filesDescription', "Match all files with any of the file extensions.") },
{ kind: CompletionItemKind.Value, label: localize('derivedLabel', "Files with Siblings by Name"), insertText: '"**/*.{{source-extension}}": { "when": "$(basename).{{target-extension}}" }', documentation: localize('derivedDescription', "Match files that have siblings with the same name but a different extension.") },
{ kind: CompletionItemKind.Value, label: localize('topFolderLabel', "Folder by Name (Top Level)"), insertText: '"{{name}}": true', documentation: localize('topFolderDescription', "Match a top level folder with a specific name.") },
{ kind: CompletionItemKind.Value, label: localize('derivedLabel', "Files with Siblings by Name"), insertText: SnippetString.create('"**/*.${1:source-extension}": { "when": "$(basename).${2:target-extension}" }'), documentation: localize('derivedDescription', "Match files that have siblings with the same name but a different extension.") },
{ kind: CompletionItemKind.Value, label: localize('topFolderLabel', "Folder by Name (Top Level)"), insertText: SnippetString.create('"${1:name}": true'), documentation: localize('topFolderDescription', "Match a top level folder with a specific name.") },
{ kind: CompletionItemKind.Value, label: localize('topFoldersLabel', "Folders with Multiple Names (Top Level)"), insertText: '"{folder1,folder2,folder3}": true', documentation: localize('topFoldersDescription', "Match multiple top level folders.") },
{ kind: CompletionItemKind.Value, label: localize('folderLabel', "Folder by Name (Any Location)"), insertText: '"**/{{name}}": true', documentation: localize('folderDescription', "Match a folder with a specific name in any location.") },
{ kind: CompletionItemKind.Value, label: localize('folderLabel', "Folder by Name (Any Location)"), insertText: SnippetString.create('"**/${1:name}": true'), documentation: localize('folderDescription', "Match a folder with a specific name in any location.") },
];
let globValues: CompletionItem[] = [
{ kind: CompletionItemKind.Value, label: localize('trueLabel', "true"), insertText: 'true', documentation: localize('trueDescription', "Enable the pattern.") },
{ kind: CompletionItemKind.Value, label: localize('falseLabel', "false"), insertText: 'false', documentation: localize('falseDescription', "Disable the pattern.") },
{ kind: CompletionItemKind.Value, label: localize('derivedLabel', "Files with Siblings by Name"), insertText: '{ "when": "$(basename).{{extension}}" }', documentation: localize('siblingsDescription', "Match files that have siblings with the same name but a different extension.") }
{ kind: CompletionItemKind.Value, label: localize('trueLabel', "true"), filterText: 'true', insertText: 'true', documentation: localize('trueDescription', "Enable the pattern.") },
{ kind: CompletionItemKind.Value, label: localize('falseLabel', "false"), filterText: 'false', insertText: 'false', documentation: localize('falseDescription', "Disable the pattern.") },
{ kind: CompletionItemKind.Value, label: localize('derivedLabel', "Files with Siblings by Name"), insertText: SnippetString.create('{ "when": "$(basename).${1:extension}" }'), documentation: localize('siblingsDescription', "Match files that have siblings with the same name but a different extension.") }
];
export class GlobPatternContribution implements JSONWorkerContribution {
@@ -42,7 +42,6 @@ export class GlobPatternContribution implements JSONWorkerContribution {
public collectPropertyCompletions(resource: string, location: JSONPath, currentWord: string, addValue: boolean, isLast: boolean, result: CompletionsCollector): Thenable<any> {
if (this.isSettingsFile(resource) && location.length === 1 && ((location[0] === 'files.exclude') || (location[0] === 'search.exclude'))) {
globProperties.forEach(e => {
e.filterText = e.insertText;
result.add(e);
});
}
@@ -53,7 +52,6 @@ export class GlobPatternContribution implements JSONWorkerContribution {
public collectValueCompletions(resource: string, location: JSONPath, currentKey: string, result: CompletionsCollector): Thenable<any> {
if (this.isSettingsFile(resource) && location.length === 1 && ((location[0] === 'files.exclude') || (location[0] === 'search.exclude'))) {
globValues.forEach(e => {
e.filterText = e.insertText;
result.add(e);
});
}
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import { MarkedString, CompletionItemKind, CompletionItem } from 'vscode-languageserver';
import { MarkedString, CompletionItemKind, CompletionItem, SnippetString } from 'vscode-languageserver';
import Strings = require('../utils/strings');
import { XHRResponse, getErrorStatusDescription, xhr } from 'request-light';
import { JSONWorkerContribution, JSONPath, CompletionsCollector } from 'vscode-json-languageservice';
@@ -47,9 +47,10 @@ export class ProjectJSONContribution implements JSONWorkerContribution {
this.cacheSize--;
return false;
}
let insertTextValue = (<SnippetString>item.insertText).value;
item.detail = entry.version;
item.documentation = entry.description;
item.insertText = item.insertText.replace(/\{\{\}\}/, '{{' + entry.version + '}}');
item.insertText = insertTextValue.replace(/\$1/, '${1:' + entry.version + '}');
return true;
}
return false;
@@ -102,15 +103,15 @@ export class ProjectJSONContribution implements JSONWorkerContribution {
public collectDefaultCompletions(resource: string, result: CompletionsCollector): Thenable<any> {
if (this.isProjectJSONFile(resource)) {
let defaultValue = {
'version': '{{1.0.0-*}}',
let insertText = SnippetString.create(JSON.stringify({
'version': '${1:1.0.0-*}',
'dependencies': {},
'frameworks': {
'net461': {},
'netcoreapp1.0': {}
}
};
result.add({ kind: CompletionItemKind.Class, label: localize('json.project.default', 'Default project.json'), insertText: JSON.stringify(defaultValue, null, '\t'), documentation: '' });
}, null, '\t'));
result.add({ kind: CompletionItemKind.Class, label: localize('json.project.default', 'Default project.json'), insertText, documentation: '' });
}
return null;
}
@@ -149,12 +150,12 @@ export class ProjectJSONContribution implements JSONWorkerContribution {
let name = results[i];
let insertText = JSON.stringify(name);
if (addValue) {
insertText += ': "{{}}"';
insertText += ': "$1"';
if (!isLast) {
insertText += ',';
}
}
let item: CompletionItem = { kind: CompletionItemKind.Property, label: name, insertText: insertText, filterText: JSON.stringify(name) };
let item: CompletionItem = { kind: CompletionItemKind.Property, label: name, insertText: SnippetString.create(insertText), filterText: JSON.stringify(name) };
if (!this.completeWithCache(name, item)) {
item.data = RESOLVE_ID + name;
}
-112
View File
@@ -1,112 +0,0 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/**
* The Thenable (E.g. PromiseLike) and Promise declarions are taken from TypeScript's
* lib.core.es6.d.ts file. See above Copyright notice.
*/
/**
* Thenable is a common denominator between ES6 promises, Q, jquery.Deferred, WinJS.Promise,
* and others. This API makes no assumption about what promise libary is being used which
* enables reusing existing code without migrating to a specific promise implementation. Still,
* we recommand the use of native promises which are available in VS Code.
*/
interface Thenable<T> {
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => TResult | Thenable<TResult>): Thenable<TResult>;
then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => void): Thenable<TResult>;
}
/**
* Represents the completion of an asynchronous operation
*/
interface Promise<T> extends Thenable<T> {
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => TResult | Thenable<TResult>): Promise<TResult>;
then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => void): Promise<TResult>;
/**
* Attaches a callback for only the rejection of the Promise.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of the callback.
*/
catch(onrejected?: (reason: any) => T | Thenable<T>): Promise<T>;
}
interface PromiseConstructor {
/**
* Creates a new Promise.
* @param executor A callback used to initialize the promise. This callback is passed two arguments:
* a resolve callback used resolve the promise with a value or the result of another promise,
* and a reject callback used to reject the promise with a provided reason or error.
*/
new <T>(executor: (resolve: (value?: T | Thenable<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
all<T>(values: Array<T | Thenable<T>>): Promise<T[]>;
/**
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
* or rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
race<T>(values: Array<T | Thenable<T>>): Promise<T>;
/**
* Creates a new rejected promise for the provided reason.
* @param reason The reason the promise was rejected.
* @returns A new rejected Promise.
*/
reject(reason: any): Promise<void>;
/**
* Creates a new rejected promise for the provided reason.
* @param reason The reason the promise was rejected.
* @returns A new rejected Promise.
*/
reject<T>(reason: any): Promise<T>;
/**
* Creates a new resolved promise for the provided value.
* @param value A promise.
* @returns A promise whose internal state matches the provided promise.
*/
resolve<T>(value: T | Thenable<T>): Promise<T>;
/**
* Creates a new resolved promise .
* @returns A resolved promise.
*/
resolve(): Promise<void>;
}
declare var Promise: PromiseConstructor;
+4 -2
View File
@@ -1,11 +1,13 @@
{
"compilerOptions": {
"noLib": true,
"target": "es5",
"module": "commonjs",
"sourceMap": true,
"sourceRoot": "../src",
"outDir": "./out"
"outDir": "./out",
"lib": [
"es5", "es2015.promise"
]
},
"exclude": [
"node_modules"
+6 -5
View File
@@ -45,7 +45,7 @@
{
"command": "markdown.showPreview",
"title": "%markdown.preview.title%",
"category": "%markdown.category%",
"category": "Markdown",
"icon": {
"light": "./media/Preview.svg",
"dark": "./media/Preview_inverse.svg"
@@ -54,7 +54,7 @@
{
"command": "markdown.showPreviewToSide",
"title": "%markdown.previewSide.title%",
"category": "%markdown.category%",
"category": "Markdown",
"icon": {
"light": "./media/PreviewOnRightPane_16x.svg",
"dark": "./media/PreviewOnRightPane_16x_dark.svg"
@@ -63,7 +63,7 @@
{
"command": "markdown.showSource",
"title": "%markdown.showSource.title%",
"category": "%markdown.category%",
"category": "Markdown",
"icon": {
"light": "./media/ViewSource.svg",
"dark": "./media/ViewSource_inverse.svg"
@@ -97,12 +97,13 @@
"command": "markdown.showPreview",
"key": "shift+ctrl+v",
"mac": "shift+cmd+v",
"when": "!terminalFocus"
"when": "editorFocus"
},
{
"command": "markdown.showPreviewToSide",
"key": "ctrl+k v",
"mac": "cmd+k v"
"mac": "cmd+k v",
"when": "editorFocus"
}
],
"snippets": [
-1
View File
@@ -1,5 +1,4 @@
{
"markdown.category" : "Markdown",
"markdown.preview.title" : "Open Preview",
"markdown.previewSide.title" : "Open Preview to the Side",
"markdown.showSource.title" : "Show Source"
@@ -31,7 +31,7 @@
{
"name": "debug",
"repositoryURL": "https://github.com/visionmedia/debug",
"version": "2.2.0",
"version": "2.3.3",
"license": "MIT",
"isProd": true
},
@@ -52,7 +52,7 @@
{
"name": "glob",
"repositoryURL": "https://github.com/isaacs/node-glob",
"version": "7.0.6",
"version": "7.1.1",
"license": "ISC",
"isProd": true
},
@@ -73,7 +73,7 @@
{
"name": "inflight",
"repositoryURL": "https://github.com/npm/inflight",
"version": "1.0.5",
"version": "1.0.6",
"license": "ISC",
"isProd": true
},
@@ -94,7 +94,7 @@
{
"name": "ms",
"repositoryURL": "https://github.com/rauchg/ms.js",
"version": "0.7.1",
"version": "0.7.2",
"license": "MIT",
"isProd": true
},
@@ -108,7 +108,7 @@
{
"name": "path-is-absolute",
"repositoryURL": "https://github.com/sindresorhus/path-is-absolute",
"version": "1.0.0",
"version": "1.0.1",
"license": "MIT",
"isProd": true
},
+11
View File
@@ -0,0 +1,11 @@
{
"name": "vscode-extensions",
"version": "0.0.1",
"dependencies": {
"typescript": {
"version": "2.0.10",
"from": "typescript@>=2.0.10 <3.0.0",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-2.0.10.tgz"
}
}
}
+12
View File
@@ -0,0 +1,12 @@
{
"name": "vscode-extensions",
"version": "0.0.1",
"private": true,
"description": "Dependencies shared by all extensions",
"dependencies": {
"typescript": "^2.0.10"
},
"scripts": {
"postinstall": "node ./postinstall"
}
}
+2 -23
View File
@@ -1,29 +1,8 @@
// ATTENTION - THIS DIRECTORY CONTAINS THIRD PARTY OPEN SOURCE MATERIALS:
[{
"name": "language-php",
"version": "0.29.0",
"version": "0.0.0",
"license": "MIT",
"repositoryURL": "https://github.com/atom/language-php",
"description": "The file snippets/php.json was derived from the Atom package https://atom.io/packages/language-php which was originally converted from the PHP TextMate bundle https://github.com/textmate/php.tmbundle."
},
{
"name": "textmate/php.tmbundle",
"version": "0.0.0",
"license": "TextMate Bundle License",
"repositoryURL": "https://github.com/textmate/php.tmbundle",
"licenseDetail": [
"Copyright (c) textmate-php.tmbundle project authors",
"",
"If not otherwise specified (see below), files in this repository fall under the following license:",
"",
"Permission to copy, use, modify, sell and distribute this",
"software is granted. This software is provided \"as is\" without",
"express or implied warranty, and with no claim as to its",
"suitability for any purpose.",
"",
"An exception is made for files in readable text which contain their own license information,",
"or files where an accompanying file exists (in the same directory) with a \"-license\" suffix added",
"to the base-name name of the original file, and an extension of txt, html, or similar. For example",
"\"tidy\" is accompanied by \"tidy-license.txt\"."
]
"description": "The files snippets/php.json & syntaxes/php.tmLanguage.json were derived from the Atom package https://atom.io/packages/language-php which was originally converted from the PHP TextMate bundle https://github.com/textmate/php.tmbundle."
}]
+3 -2
View File
@@ -19,7 +19,7 @@
"grammars": [{
"language": "php",
"scopeName": "text.html.php",
"path": "./syntaxes/php.json",
"path": "./syntaxes/php.tmLanguage.json",
"embeddedLanguages": {
"text.html": "html",
"source.php": "php",
@@ -66,6 +66,7 @@
},
"scripts": {
"compile": "gulp compile-extension:php",
"watch": "gulp watch-extension:php"
"watch": "gulp watch-extension:php",
"update-grammar": "node ../../build/npm/update-grammar.js atom/language-php grammars/php.cson ./syntaxes/php.tmLanguage.json"
}
}
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -223,10 +223,10 @@
"c": "<?php",
"t": "begin.block.embedded.meta.metatag.php.punctuation.section",
"r": {
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.metatag.php rgb(86, 156, 214)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.metatag.php rgb(128, 0, 0)",
"dark_vs": ".vs-dark.vscode-theme-defaults-themes-dark_vs-json .token.metatag.php rgb(86, 156, 214)",
"light_vs": ".vs.vscode-theme-defaults-themes-light_vs-json .token.metatag.php rgb(128, 0, 0)",
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.punctuation.section.embedded.begin.metatag.php rgb(86, 156, 214)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.punctuation.section.embedded.begin.metatag.php rgb(128, 0, 0)",
"dark_vs": ".vs-dark.vscode-theme-defaults-themes-dark_vs-json .token.punctuation.section.embedded.begin.metatag.php rgb(86, 156, 214)",
"light_vs": ".vs.vscode-theme-defaults-themes-light_vs-json .token.punctuation.section.embedded.begin.metatag.php rgb(128, 0, 0)",
"hc_black": ".hc-black .token rgb(255, 255, 255)"
}
},
@@ -3237,10 +3237,10 @@
"c": "?",
"t": "block.embedded.end.meta.metatag.php.punctuation.section.source",
"r": {
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.metatag.php rgb(86, 156, 214)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.metatag.php rgb(128, 0, 0)",
"dark_vs": ".vs-dark.vscode-theme-defaults-themes-dark_vs-json .token.metatag.php rgb(86, 156, 214)",
"light_vs": ".vs.vscode-theme-defaults-themes-light_vs-json .token.metatag.php rgb(128, 0, 0)",
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.punctuation.section.embedded.end.metatag.php rgb(86, 156, 214)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.punctuation.section.embedded.end.metatag.php rgb(128, 0, 0)",
"dark_vs": ".vs-dark.vscode-theme-defaults-themes-dark_vs-json .token.punctuation.section.embedded.end.metatag.php rgb(86, 156, 214)",
"light_vs": ".vs.vscode-theme-defaults-themes-light_vs-json .token.punctuation.section.embedded.end.metatag.php rgb(128, 0, 0)",
"hc_black": ".hc-black .token rgb(255, 255, 255)"
}
},
@@ -3248,10 +3248,10 @@
"c": ">",
"t": "block.embedded.end.meta.metatag.php.punctuation.section",
"r": {
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.metatag.php rgb(86, 156, 214)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.metatag.php rgb(128, 0, 0)",
"dark_vs": ".vs-dark.vscode-theme-defaults-themes-dark_vs-json .token.metatag.php rgb(86, 156, 214)",
"light_vs": ".vs.vscode-theme-defaults-themes-light_vs-json .token.metatag.php rgb(128, 0, 0)",
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.punctuation.section.embedded.end.metatag.php rgb(86, 156, 214)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.punctuation.section.embedded.end.metatag.php rgb(128, 0, 0)",
"dark_vs": ".vs-dark.vscode-theme-defaults-themes-dark_vs-json .token.punctuation.section.embedded.end.metatag.php rgb(86, 156, 214)",
"light_vs": ".vs.vscode-theme-defaults-themes-light_vs-json .token.punctuation.section.embedded.end.metatag.php rgb(128, 0, 0)",
"hc_black": ".hc-black .token rgb(255, 255, 255)"
}
},
+34
View File
@@ -0,0 +1,34 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
const fs = require('fs');
const path = require('path');
function removeFile(filePath) {
try {
fs.unlinkSync(filePath);
console.log(`removed '${filePath}'`);
} catch (e) {
console.warn(e);
}
}
// delete unused typescript stuff in lib folder
const libPath = path.dirname(require.resolve('typescript'));
for (let name of fs.readdirSync(libPath)) {
if (name !== 'typescript.d.ts' && name !== 'typescript.js' && name !== 'lib.es6.d.ts') {
removeFile(path.join(libPath, name));
}
}
// delete unused typescript stuff in bin folder
const binPath = path.join(path.dirname(libPath), 'bin');
for (let name of fs.readdirSync(binPath)) {
removeFile(path.join(binPath, name));
}
removeFile(path.join(path.dirname(libPath), 'Gulpfile.ts'));
@@ -271,7 +271,8 @@
}
},
{
"scope": "metatag.php",
"name": "coloring of the PHP start and end tag (<?php and ?>)",
"scope": ["punctuation.section.embedded.begin.metatag.php", "punctuation.section.embedded.end.metatag.php"],
"settings": {
"foreground": "#569cd6"
}
@@ -268,7 +268,8 @@
}
},
{
"scope": "metatag.php",
"name": "coloring of the PHP start and end tag (<?php and ?>)",
"scope": ["punctuation.section.embedded.begin.metatag.php", "punctuation.section.embedded.end.metatag.php"],
"settings": {
"foreground": "#800000"
}
+5
View File
@@ -2,6 +2,11 @@
"name": "typescript",
"version": "0.10.1",
"dependencies": {
"@types/semver": {
"version": "5.3.30",
"from": "@types/semver@>=5.3.30 <6.0.0",
"resolved": "https://registry.npmjs.org/@types/semver/-/semver-5.3.30.tgz"
},
"applicationinsights": {
"version": "0.15.6",
"from": "applicationinsights@0.15.6",
+1
View File
@@ -11,6 +11,7 @@
"vscode": "*"
},
"dependencies": {
"@types/semver": "^5.3.30",
"semver": "4.3.6",
"vscode-extension-telemetry": "^0.0.5",
"vscode-nls": "^2.0.1",
@@ -464,6 +464,7 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
allowSyntheticDefaultImports: true,
allowNonTsExtensions: true,
allowJs: true,
jsx: 'Preserve'
};
let args: Proto.SetCompilerOptionsForInferredProjectsArgs = {
options: compilerOptions
-11
View File
@@ -1,11 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer;
declare function clearTimeout(timeoutId: NodeJS.Timer): void;
declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer;
declare function clearInterval(intervalId: NodeJS.Timer): void;
declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any;
declare function clearImmediate(immediateId: any): void;
-125
View File
@@ -1,125 +0,0 @@
// Type definitions for semver v2.2.1
// Project: https://github.com/isaacs/node-semver
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module SemVerModule {
/**
* Return the parsed version, or null if it's not valid.
*/
function valid(v: string, loose?: boolean): string;
/**
* Return the version incremented by the release type (major, minor, patch, or prerelease), or null if it's not valid.
*/
function inc(v: string, release: string, loose?: boolean): string;
// Comparison
/**
* v1 > v2
*/
function gt(v1: string, v2: string, loose?: boolean): boolean;
/**
* v1 >= v2
*/
function gte(v1: string, v2: string, loose?: boolean): boolean;
/**
* v1 < v2
*/
function lt(v1: string, v2: string, loose?: boolean): boolean;
/**
* v1 <= v2
*/
function lte(v1: string, v2: string, loose?: boolean): boolean;
/**
* v1 == v2 This is true if they're logically equivalent, even if they're not the exact same string. You already know how to compare strings.
*/
function eq(v1: string, v2: string, loose?: boolean): boolean;
/**
* v1 != v2 The opposite of eq.
*/
function neq(v1: string, v2: string, loose?: boolean): boolean;
/**
* Pass in a comparison string, and it'll call the corresponding semver comparison function. "===" and "!==" do simple string comparison, but are included for completeness. Throws if an invalid comparison string is provided.
*/
function cmp(v1: string, comparator: any, v2: string, loose?: boolean): boolean;
/**
* Return 0 if v1 == v2, or 1 if v1 is greater, or -1 if v2 is greater. Sorts in ascending order if passed to Array.sort().
*/
function compare(v1: string, v2: string, loose?: boolean): number;
/**
* The reverse of compare. Sorts an array of versions in descending order when passed to Array.sort().
*/
function rcompare(v1: string, v2: string, loose?: boolean): number;
// Ranges
/**
* Return the valid range or null if it's not valid
*/
function validRange(range: string, loose?: boolean): string;
/**
* Return true if the version satisfies the range.
*/
function satisfies(version: string, range: string, loose?: boolean): boolean;
/**
* Return the highest version in the list that satisfies the range, or null if none of them do.
*/
function maxSatisfying(versions: string[], range: string, loose?: boolean): string;
/**
* Return true if version is greater than all the versions possible in the range.
*/
function gtr(version: string, range: string, loose?: boolean): boolean;
/**
* Return true if version is less than all the versions possible in the range.
*/
function ltr(version: string, range: string, loose?: boolean): boolean;
/**
* Return true if the version is outside the bounds of the range in either the high or low direction. The hilo argument must be either the string '>' or '<'. (This is the function called by gtr and ltr.)
*/
function outside(version: string, range: string, hilo: string, loose?: boolean): boolean;
class SemVerBase {
raw: string;
loose: boolean;
format(): string;
inspect(): string;
toString(): string;
}
class SemVer extends SemVerBase {
constructor(version: string, loose?: boolean);
major: number;
minor: number;
patch: number;
version: string;
build: string[];
prerelease: string[];
compare(other: SemVer): number;
compareMain(other: SemVer): number;
comparePre(other: SemVer): number;
inc(release: string): SemVer;
}
class Comparator extends SemVerBase {
constructor(comp: string, loose?: boolean);
semver: SemVer;
operator: string;
value: boolean;
parse(comp: string): void;
test(version: SemVer): boolean;
}
class Range extends SemVerBase {
constructor(range: string, loose?: boolean);
set: Comparator[][];
parseRange(range: string): Comparator[];
test(version: SemVer): boolean;
}
}
declare module "semver" {
export = SemVerModule;
}
@@ -8,7 +8,7 @@
import * as vscode from 'vscode';
import { ITypescriptServiceClient } from '../typescriptService';
import { loadMessageBundle } from 'vscode-nls';
import { dirname } from 'path';
import { dirname, join } from 'path';
const localize = loadMessageBundle();
const selector = ['javascript', 'javascriptreact'];
@@ -77,7 +77,6 @@ export function create(client: ITypescriptServiceClient, isOpen: (path: string)
}
if (fileNames.length > fileLimit) {
let largeRoots = computeLargeRoots(configFileName, fileNames).map(f => `'/${f}/'`).join(', ');
currentHint = {
@@ -91,7 +90,14 @@ export function create(client: ITypescriptServiceClient, isOpen: (path: string)
projectHinted[configFileName] = true;
item.hide();
return vscode.workspace.openTextDocument(configFileName)
let configFileUri: vscode.Uri;
if (dirname(configFileName).indexOf(vscode.workspace.rootPath) === 0) {
configFileUri = vscode.Uri.file(configFileName);
} else {
configFileUri = vscode.Uri.parse('untitled://' + join(vscode.workspace.rootPath, 'jsconfig.json'));
}
return vscode.workspace.openTextDocument(configFileUri)
.then(vscode.window.showTextDocument);
}
}]
+2 -2
View File
@@ -62,7 +62,7 @@ export function cleanUp(): Thenable<any> {
}
});
vscode.commands.executeCommand('workbench.action.closeAllEditors').then(null, reject);
vscode.commands.executeCommand('workbench.action.closeAllEditors').then(undefined, reject);
}).then(() => {
assert.equal(vscode.window.visibleTextEditors.length, 0);
@@ -76,4 +76,4 @@ export function cleanUp(): Thenable<any> {
// assert.equal(vscode.workspace.textDocuments.length, 0);
});
}
}
@@ -19,7 +19,7 @@ suite('window namespace tests', () => {
return window.showTextDocument(doc).then((editor) => {
const active = window.activeTextEditor;
assert.ok(active);
assert.ok(pathEquals(active.document.uri.fsPath, doc.uri.fsPath));
assert.ok(pathEquals(active!.document.uri.fsPath, doc.uri.fsPath));
});
});
});
@@ -6,7 +6,7 @@
'use strict';
import * as assert from 'assert';
import { workspace, TextDocument, window, Position, Uri, EventEmitter, WorkspaceEdit } from 'vscode';
import { workspace, TextDocument, window, Position, Uri, EventEmitter, WorkspaceEdit, Disposable } from 'vscode';
import { createRandomFile, deleteFile, cleanUp, pathEquals } from './utils';
import { join, basename } from 'path';
import * as fs from 'fs';
@@ -48,11 +48,13 @@ suite('workspace-namespace', () => {
test('textDocuments', () => {
assert.ok(Array.isArray(workspace.textDocuments));
assert.throws(() => workspace.textDocuments = null);
assert.throws(() => (<any>workspace).textDocuments = null);
});
test('rootPath', () => {
assert.ok(pathEquals(workspace.rootPath, join(__dirname, '../testWorkspace')));
if (workspace.rootPath) {
assert.ok(pathEquals(workspace.rootPath, join(__dirname, '../testWorkspace')));
}
assert.throws(() => workspace.rootPath = 'farboo');
});
@@ -64,23 +66,22 @@ suite('workspace-namespace', () => {
});
});
test('openTextDocument, illegal path', done => {
workspace.openTextDocument('funkydonky.txt').then(doc => {
done(new Error('missing error'));
test('openTextDocument, illegal path', () => {
return workspace.openTextDocument('funkydonky.txt').then(doc => {
throw new Error('missing error');
}, err => {
done();
// good!
});
});
test('openTextDocument, untitled is dirty', function (done) {
test('openTextDocument, untitled is dirty', function () {
if (process.platform === 'win32') {
return done(); // TODO@Joh this test fails on windows
return; // TODO@Joh this test fails on windows
}
workspace.openTextDocument(Uri.parse('untitled:' + join(workspace.rootPath, './newfile.txt'))).then(doc => {
return workspace.openTextDocument(Uri.parse('untitled:' + join(workspace.rootPath, './newfile.txt'))).then(doc => {
assert.equal(doc.uri.scheme, 'untitled');
assert.ok(doc.isDirty);
done();
});
});
@@ -137,7 +138,7 @@ suite('workspace-namespace', () => {
test('events: onDidOpenTextDocument, onDidChangeTextDocument, onDidSaveTextDocument', () => {
return createRandomFile().then(file => {
let disposables = [];
let disposables: Disposable[] = [];
let onDidOpenTextDocument = false;
disposables.push(workspace.onDidOpenTextDocument(e => {
@@ -370,7 +371,7 @@ suite('workspace-namespace', () => {
});
test('findFiles', () => {
return workspace.findFiles('*.js', null).then((res) => {
return workspace.findFiles('*.js').then((res) => {
assert.equal(res.length, 1);
assert.equal(basename(workspace.asRelativePath(res[0])), 'far.js');
});
+3 -2
View File
@@ -4,9 +4,10 @@
"target": "ES5",
"outDir": "out",
"noLib": true,
"sourceMap": true
"sourceMap": true,
"strictNullChecks": true
},
"exclude": [
"node_modules"
]
}
}
+2 -1
View File
@@ -6,7 +6,8 @@
declare function run(): void;
declare function suite(name: string, fn: (err?) => void);
declare function test(name: string, fn: (done?: (err?) => void) => void);
declare function test(name: string, fn: () => void);
declare function test(name: string, fn: (done: (err?) => void) => void);
declare function suiteSetup(fn: (done?: (err?) => void) => void);
declare function suiteTeardown(fn: (done?: (err?) => void) => void);
declare function setup(fn: (done?: (err?) => void) => void);
@@ -27,7 +27,7 @@
"typescript.tsdk.desc": "指定包含要使用的 tsserver 和 lib*.d.ts 文件的文件夹路径。",
"typescript.tsdk_version.desc": "指定 tsserver 的版本。仅在未使用 npm 安装 tsserver 时需要。",
"typescript.tsserver.experimentalAutoBuild": "启用实验性自动生成。要求安装 1.9 dev 或 2.x tsserver 版本并在更改后重启 VS Code。",
"typescript.tsserver.trace": "启用跟踪发送到 TS 服务器的消息。",
"typescript.tsserver.trace": "发送到 TS 服务器的消息启用跟踪。",
"typescript.useCodeSnippetsOnMethodSuggest.dec": "完成函数的参数签名。",
"typescript.validate.enable": "启用/禁用 TypeScript 验证。"
}
@@ -97,6 +97,7 @@
"miToggleDebugConsole": "调试控制台(&&B)",
"miToggleDevTools": "切换开发人员工具(&&T)",
"miToggleEditorLayout": "切换编辑器组布局(&&L)",
"miToggleFocusMode": "切换焦点模式",
"miToggleFullScreen": "切换全屏(&&F)",
"miToggleIntegratedTerminal": "集成终端(&&I)",
"miToggleMenuBar": "切换菜单栏(&&B)",
@@ -9,7 +9,7 @@
"outroMsg": "可以通过按 Esc 消除此工具提示并返回到编辑器。",
"status": "状态:",
"tabFocusModeOffMsg": "在当前编辑器中按 Tab 将插入制表符。通过按 {0} 切换此行为。",
"tabFocusModeOffMsgNoKb": "在当前编辑器中按 Tab 会将焦点移动到下一个可聚焦的元素。当前无法通过键绑定触发命令 {0}。",
"tabFocusModeOffMsgNoKb": "在当前编辑器中按 Tab 会插入制表符。当前无法通过键绑定触发命令 {0}。",
"tabFocusModeOnMsg": "在当前编辑器中按 Tab 会将焦点移动到下一个可聚焦的元素。通过按 {0} 切换此行为。",
"tabFocusModeOnMsgNoKb": "在当前编辑器中按 Tab 会将焦点移动到下一个可聚焦的元素。当前无法通过键绑定触发命令 {0}。"
}
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
// Do not edit this file. It is machine generated.
{
"invalid.embeddedLanguages": "\"contributes.{0}.embeddedLanguages\" 中值无效。必须为从作用域名称到语言的对象映射。给定值: {1}",
"invalid.embeddedLanguages": "\"contributes.{0}.embeddedLanguages\" 中值无效。必须为从作用域名称到语言的对象映射。提供的值: {1}",
"invalid.injectTo": "\"contributes.{0}.injectTo\" 中的值无效。必须为语言范围名称数组。提供的值: {1}",
"invalid.language": "“contributes.{0}.language”中存在未知的语言。提供的值: {1}",
"invalid.path.0": "“contributes.{0}.path”中应为字符串。提供的值: {1}",
@@ -7,5 +7,5 @@
"activationError": "激活扩展“{0}”失败: {1}。",
"failedDep1": "无法激活扩展”{1}“。原因: 无法激活依赖关系”{0}“。",
"failedDep2": "无法激活扩展”{0}“。原因: 依赖关系多于 10 级(最可能是依赖关系循环)。",
"unknownDep": "无法激活扩展”{1}“。原因未知依赖关系{0}。"
"unknownDep": "无法激活扩展”{1}“。原因: 未知依赖关系{0}。"
}
@@ -34,9 +34,10 @@
"navigateNext": "前进",
"navigatePrevious": "后退",
"openNextEditor": "打开下一个编辑器",
"openNextEditorInGroup": "打开组中下一个最近使用的编辑器",
"openNextRecentlyUsedEditorInGroup": "打开组中下一个最近使用的编辑器",
"openPreviousEditor": "打开上一个编辑器",
"openPreviousEditorInGroup": "打开组中上一个最近使用的编辑器",
"openPreviousRecentlyUsedEditorInGroup": "打开组中上一个最近使用的编辑器",
"openToSide": "打开到侧边",
"reopenClosedEditor": "重新打开已关闭的编辑器",
"showAllEditors": "显示所有编辑器",
@@ -32,7 +32,7 @@
"pickEncodingForSave": "选择用于保存的文件编码",
"pickEndOfLine": "选择行尾序列",
"pickLanguage": "选择语言模式",
"pickLanguageToConfigure": "选择语言模式与“{0}”关联",
"pickLanguageToConfigure": "选择与“{0}”关联的语言模式",
"reopenWithEncoding": "通过编码重新打开",
"saveWithEncoding": "通过编码保存",
"selectEOL": "选择行尾序列",
@@ -4,5 +4,6 @@
*--------------------------------------------------------------------------------------------*/
// Do not edit this file. It is machine generated.
{
"telemetry.enableCrashReporting": "启用要发送给 Microsoft 的故障报表。\n\t// 此选项需重启才可生效。"
"telemetry.enableCrashReporting": "启用要发送给 Microsoft 的故障报表。\n\t// 此选项需重启才可生效。",
"telemetryConfigurationTitle": "遥测"
}
@@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
// Do not edit this file. It is machine generated.
{
"notAvailable": "不可用",
"snapshotObj": "仅显示了此对象的基元值。",
"startDebugFirst": "请启动调试会话以评估",
"unknownSource": "未知源",
@@ -5,7 +5,7 @@
// Do not edit this file. It is machine generated.
{
"emmetConfigurationTitle": "Emmet",
"emmetExclude": "其中 emmet 缩写不应展开的语言数组。",
"emmetExclude": "emmet 缩写不应在其中展开的语言数组。",
"emmetPreferences": "用于修改 Emmet 的某些操作和解决程序的首选项。",
"emmetSyntaxProfiles": "为指定的语法定义配置文件或使用带有特定规则的配置文件。",
"triggerExpansionOnTab": "启用后,按 TAB 键时,将展开 Emmet 缩写。"
@@ -5,17 +5,22 @@
// Do not edit this file. It is machine generated.
{
"ConfigureWorkspaceRecommendations.noWorkspace": "建议仅在工作区文件夹上可用。",
"ManageExtensionAction.uninstallingTooltip": "正在卸载",
"OpenExtensionsFile.failed": "无法在 \".vscode\" 文件夹({0})内创建 \"extensions.json\" 文件。",
"Uninstalling": "正在卸载",
"builtin": "内置",
"clearExtensionsInput": "清除扩展输入",
"configureWorkspaceRecommendedExtensions": "配置建议的扩展(工作区)",
"disableAction": "禁用",
"disableAll": "禁用所有已安装的扩展",
"disableAllWorkspace": "禁用此工作区的所有已安装的扩展",
"disableAlwaysAction.label": "禁用",
"disableForWorkspaceAction": "工作区",
"disableForWorkspaceAction.label": "禁用(工作区)",
"disableGloballyAction": "始终",
"enableAction": "启用",
"enableAll": "禁用所有已安装的扩展",
"enableAllWorkspace": "启用此工作区的所有已安装的扩展",
"enableAlwaysAction.label": "启用",
"enableForWorkspaceAction": "工作区",
"enableForWorkspaceAction.label": "启用(工作区)",
@@ -23,7 +28,14 @@
"installAction": "安装",
"installExtensions": "安装扩展",
"installing": "正在安装",
"postDisableMessage": "重载此窗口以停用扩展“{0}”?",
"postDisableTooltip": "重载以停用",
"postEnableMessage": "重载此窗口以激活扩展“{0}”?",
"postEnableTooltip": "重载以激活",
"postUninstallMessage": "重载此窗口以停用未安装的扩展“{0}”?",
"postUninstallTooltip": "重新加载以停用",
"postUpdateMessage": "重载此窗口以激活更新的扩展“{0}”?",
"postUpdateTooltip": "重载以更新",
"reloadAction": "重新加载",
"showDisabledExtensions": "显示已禁用的扩展",
"showInstalledExtensions": "显示已安装扩展",
@@ -14,7 +14,7 @@
"label.sendASmile": "通过 Tweet 向我们发送反馈。",
"other ways to contact us": "联系我们的其他方式",
"patchedVersion1": "安装已损坏。",
"patchedVersion2": "如果 提交了 bug,请指定此项。",
"patchedVersion2": "如果提交了 bug,请指定此项。",
"request a missing feature": "请求缺失功能",
"sendFeedback": "Tweet 反馈",
"sentiment": "您的体验如何?",
@@ -10,6 +10,7 @@
"autoSaveDelay": "控制延迟(以秒为单位),在该延迟后将自动保存更新后的文件。仅在 \"files.autoSave\" 设置为“{0}”时适用。",
"binaryFileEditor": "二进制文件编辑器",
"dynamicHeight": "控制打开的编辑器部分的高度是否应动态适应元素数量。",
"editorConfigurationTitle": "编辑器",
"enableDragAndDrop": "控制资源管理器是否应该允许通过拖放移动文件和文件夹。",
"encoding": "读取和编写文件时将使用的默认字符集编码。",
"eol": "默认行尾字符。",

Some files were not shown because too many files have changed in this diff Show More