Merge branch 'master' into misolori/a11y

This commit is contained in:
Miguel Solorio 2018-07-26 10:25:15 -07:00 committed by GitHub
commit e32ea43fcb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
339 changed files with 13264 additions and 8606 deletions

View file

@ -1,3 +1,3 @@
disturl "https://atom.io/download/electron"
target "1.7.12"
target "2.0.5"
runtime "electron"

View file

@ -6,7 +6,7 @@
},
{
"name": "ms-vscode.node-debug2",
"version": "1.26.5",
"version": "1.26.6",
"repo": "https://github.com/Microsoft/vscode-node-debug2"
}
]

View file

@ -8,9 +8,8 @@ import * as path from 'path';
import * as nls from 'vscode-nls';
const localize = nls.loadMessageBundle();
import { languages, window, commands, ExtensionContext, Range, Position, TextDocument, CompletionItem, CompletionItemKind, TextEdit, SnippetString, FoldingRangeKind, FoldingRange, FoldingContext, CancellationToken } from 'vscode';
import { languages, window, commands, ExtensionContext, Range, Position, CompletionItem, CompletionItemKind, TextEdit, SnippetString } from 'vscode';
import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind, Disposable } from 'vscode-languageclient';
import { FoldingRangeRequest, FoldingRangeRequestParam, FoldingRangeClientCapabilities, FoldingRangeKind as LSFoldingRangeKind } from 'vscode-languageserver-protocol-foldingprovider';
// this method is called when vs code is activated
export function activate(context: ExtensionContext) {
@ -42,21 +41,6 @@ export function activate(context: ExtensionContext) {
// Create the language client and start the client.
let client = new LanguageClient('css', localize('cssserver.name', 'CSS Language Server'), serverOptions, clientOptions);
client.registerProposedFeatures();
client.registerFeature({
fillClientCapabilities(capabilities: FoldingRangeClientCapabilities): void {
let textDocumentCap = capabilities.textDocument;
if (!textDocumentCap) {
textDocumentCap = capabilities.textDocument = {};
}
textDocumentCap.foldingRange = {
dynamicRegistration: false,
rangeLimit: 5000,
lineFoldingOnly: true
};
},
initialize(capabilities, documentSelector): void {
}
});
let disposable = client.start();
// Push the disposable to the context's subscriptions so that the
@ -85,7 +69,6 @@ export function activate(context: ExtensionContext) {
client.onReady().then(() => {
context.subscriptions.push(initCompletionProvider());
context.subscriptions.push(initFoldingProvider());
});
function initCompletionProvider(): Disposable {
@ -116,38 +99,6 @@ export function activate(context: ExtensionContext) {
});
}
function initFoldingProvider(): Disposable {
function getKind(kind: string | undefined): FoldingRangeKind | undefined {
if (kind) {
switch (kind) {
case LSFoldingRangeKind.Comment:
return FoldingRangeKind.Comment;
case LSFoldingRangeKind.Imports:
return FoldingRangeKind.Imports;
case LSFoldingRangeKind.Region:
return FoldingRangeKind.Region;
}
}
return void 0;
}
return languages.registerFoldingRangeProvider(documentSelector, {
provideFoldingRanges(document: TextDocument, context: FoldingContext, token: CancellationToken) {
const param: FoldingRangeRequestParam = {
textDocument: client.code2ProtocolConverter.asTextDocumentIdentifier(document)
};
return client.sendRequest(FoldingRangeRequest.type, param, token).then(ranges => {
if (Array.isArray(ranges)) {
return ranges.map(r => new FoldingRange(r.startLine, r.endLine, getKind(r.kind)));
}
return null;
}, error => {
client.logFailedRequest(FoldingRangeRequest.type, error);
return null;
});
}
});
}
commands.registerCommand('_css.applyCodeAction', applyCodeAction);
function applyCodeAction(uri: string, documentVersion: number, edits: TextEdit[]) {

View file

@ -707,12 +707,11 @@
]
},
"dependencies": {
"vscode-languageclient": "^4.1.4",
"vscode-languageserver-protocol-foldingprovider": "^2.0.1",
"vscode-languageclient": "^4.4.0",
"vscode-nls": "^3.2.4"
},
"devDependencies": {
"@types/node": "7.0.43",
"mocha": "^5.2.0"
}
}
}

View file

@ -8,7 +8,7 @@
"css.lint.duplicateProperties.desc": "Do not use duplicate style definitions",
"css.lint.emptyRules.desc": "Do not use empty rulesets",
"css.lint.float.desc": "Avoid using 'float'. Floats lead to fragile CSS that is easy to break if one aspect of the layout changes.",
"css.lint.fontFaceProperties.desc": "@font-face rule must define 'src' and 'font-family' properties",
"css.lint.fontFaceProperties.desc": "`@font-face` rule must define `src` and `font-family` properties",
"css.lint.hexColorLength.desc": "Hex colors must consist of three or six hex numbers",
"css.lint.idSelector.desc": "Selectors should not contain IDs because these rules are too tightly coupled with the HTML.",
"css.lint.ieHack.desc": "IE hacks are only necessary when supporting IE7 and older",
@ -31,7 +31,7 @@
"less.lint.duplicateProperties.desc": "Do not use duplicate style definitions",
"less.lint.emptyRules.desc": "Do not use empty rulesets",
"less.lint.float.desc": "Avoid using 'float'. Floats lead to fragile CSS that is easy to break if one aspect of the layout changes.",
"less.lint.fontFaceProperties.desc": "@font-face rule must define 'src' and 'font-family' properties",
"less.lint.fontFaceProperties.desc": "`@font-face` rule must define `src` and `font-family` properties",
"less.lint.hexColorLength.desc": "Hex colors must consist of three or six hex numbers",
"less.lint.idSelector.desc": "Selectors should not contain IDs because these rules are too tightly coupled with the HTML.",
"less.lint.ieHack.desc": "IE hacks are only necessary when supporting IE7 and older",
@ -52,7 +52,7 @@
"scss.lint.duplicateProperties.desc": "Do not use duplicate style definitions",
"scss.lint.emptyRules.desc": "Do not use empty rulesets",
"scss.lint.float.desc": "Avoid using 'float'. Floats lead to fragile CSS that is easy to break if one aspect of the layout changes.",
"scss.lint.fontFaceProperties.desc": "@font-face rule must define 'src' and 'font-family' properties",
"scss.lint.fontFaceProperties.desc": "`@font-face` rule must define `src` and `font-family` properties",
"scss.lint.hexColorLength.desc": "Hex colors must consist of three or six hex numbers",
"scss.lint.idSelector.desc": "Selectors should not contain IDs because these rules are too tightly coupled with the HTML.",
"scss.lint.ieHack.desc": "IE hacks are only necessary when supporting IE7 and older",

View file

@ -8,9 +8,8 @@
"node": "*"
},
"dependencies": {
"vscode-css-languageservice": "^3.0.9-next.20",
"vscode-languageserver": "^4.1.3",
"vscode-languageserver-protocol-foldingprovider": "^2.0.1"
"vscode-css-languageservice": "^3.0.9",
"vscode-languageserver": "^4.4.0"
},
"devDependencies": {
"@types/mocha": "2.2.33",

View file

@ -15,7 +15,6 @@ import { getLanguageModelCache } from './languageModelCache';
import { formatError, runSafe } from './utils/runner';
import URI from 'vscode-uri';
import { getPathCompletionParticipant } from './pathCompletion';
import { FoldingRangeServerCapabilities, FoldingRangeRequest } from 'vscode-languageserver-protocol-foldingprovider';
export interface Settings {
css: LanguageSettings;
@ -78,7 +77,7 @@ connection.onInitialize((params: InitializeParams): InitializeResult => {
scopedSettingsSupport = !!getClientCapability('workspace.configuration', false);
foldingRangeLimit = getClientCapability('textDocument.foldingRange.rangeLimit', Number.MAX_VALUE);
const capabilities: ServerCapabilities & FoldingRangeServerCapabilities = {
const capabilities: ServerCapabilities = {
// Tell the client that the server works in FULL text document sync mode
textDocumentSync: documents.syncKind,
completionProvider: snippetSupport ? { resolveProvider: false, triggerCharacters: ['/'] } : undefined,
@ -306,7 +305,7 @@ connection.onRenameRequest((renameParameters, token) => {
}, null, `Error while computing renames for ${renameParameters.textDocument.uri}`, token);
});
connection.onRequest(FoldingRangeRequest.type, (params, token) => {
connection.onFoldingRanges((params, token) => {
return runSafe(() => {
const document = documents.get(params.textDocument.uri);
if (document) {

View file

@ -194,49 +194,42 @@ supports-color@5.4.0:
dependencies:
has-flag "^3.0.0"
vscode-css-languageservice@^3.0.9-next.20:
version "3.0.9-next.20"
resolved "https://registry.yarnpkg.com/vscode-css-languageservice/-/vscode-css-languageservice-3.0.9-next.20.tgz#8229aee66aa877929af5d2fd81a21731b415c92e"
vscode-css-languageservice@^3.0.9:
version "3.0.9"
resolved "https://registry.yarnpkg.com/vscode-css-languageservice/-/vscode-css-languageservice-3.0.9.tgz#770471350120c5bcf6918632a125638fc0ece3be"
dependencies:
vscode-languageserver-types "^3.7.2"
vscode-nls "^3.2.2"
vscode-languageserver-types "^3.10.0"
vscode-nls "^3.2.4"
vscode-jsonrpc@^3.6.2:
version "3.6.2"
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-3.6.2.tgz#3b5eef691159a15556ecc500e9a8a0dd143470c8"
vscode-languageserver-protocol-foldingprovider@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol-foldingprovider/-/vscode-languageserver-protocol-foldingprovider-2.0.1.tgz#051d0d9e58d1b79dc4681acd48f21797f5515bfd"
dependencies:
vscode-languageserver-protocol "^3.7.2"
vscode-languageserver-types "^3.7.2"
vscode-languageserver-protocol@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.7.2.tgz#df58621c032139010888b6a9ddc969423f9ba9d6"
vscode-languageserver-protocol@^3.10.0:
version "3.10.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.10.0.tgz#f8dcdf987687f64a26e7c32d498fc781a0e886dc"
dependencies:
vscode-jsonrpc "^3.6.2"
vscode-languageserver-types "^3.7.2"
vscode-languageserver-types "^3.10.0"
vscode-languageserver-types@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.7.2.tgz#aad8846f8e3e27962648554de5a8417e358f34eb"
vscode-languageserver-types@^3.10.0:
version "3.10.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.10.0.tgz#944e5308f3b36a3f372c766f1a344e903ec9c389"
vscode-languageserver@^4.1.3:
version "4.1.3"
resolved "https://registry.yarnpkg.com/vscode-languageserver/-/vscode-languageserver-4.1.3.tgz#937d37c955b6b9c2409388413cd6f54d1eb9fe7d"
vscode-languageserver@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver/-/vscode-languageserver-4.4.0.tgz#b6e8b37a739ccb629d92f3635f0099d191c856fa"
dependencies:
vscode-languageserver-protocol "^3.7.2"
vscode-uri "^1.0.1"
vscode-languageserver-protocol "^3.10.0"
vscode-uri "^1.0.3"
vscode-nls@^3.2.2:
version "3.2.2"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-3.2.2.tgz#3817eca5b985c2393de325197cf4e15eb2aa5350"
vscode-nls@^3.2.4:
version "3.2.4"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-3.2.4.tgz#2166b4183c8aea884d20727f5449e62be69fd398"
vscode-uri@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-1.0.1.tgz#11a86befeac3c4aa3ec08623651a3c81a6d0bbc8"
vscode-uri@^1.0.3:
version "1.0.5"
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-1.0.5.tgz#3b899a8ef71c37f3054d79bdbdda31c7bf36f20d"
wrappy@1:
version "1.0.2"

View file

@ -137,29 +137,22 @@ vscode-jsonrpc@^3.6.2:
version "3.6.2"
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-3.6.2.tgz#3b5eef691159a15556ecc500e9a8a0dd143470c8"
vscode-languageclient@^4.1.4:
version "4.1.4"
resolved "https://registry.yarnpkg.com/vscode-languageclient/-/vscode-languageclient-4.1.4.tgz#fff1a6bca4714835dca7fce35bc4ce81442fdf2c"
vscode-languageclient@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/vscode-languageclient/-/vscode-languageclient-4.4.0.tgz#b05868f6477b6f0c9910b24daae4f3e8c4b65902"
dependencies:
vscode-languageserver-protocol "^3.7.2"
vscode-languageserver-protocol "^3.10.0"
vscode-languageserver-protocol-foldingprovider@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol-foldingprovider/-/vscode-languageserver-protocol-foldingprovider-2.0.1.tgz#051d0d9e58d1b79dc4681acd48f21797f5515bfd"
dependencies:
vscode-languageserver-protocol "^3.7.2"
vscode-languageserver-types "^3.7.2"
vscode-languageserver-protocol@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.7.2.tgz#df58621c032139010888b6a9ddc969423f9ba9d6"
vscode-languageserver-protocol@^3.10.0:
version "3.10.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.10.0.tgz#f8dcdf987687f64a26e7c32d498fc781a0e886dc"
dependencies:
vscode-jsonrpc "^3.6.2"
vscode-languageserver-types "^3.7.2"
vscode-languageserver-types "^3.10.0"
vscode-languageserver-types@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.7.2.tgz#aad8846f8e3e27962648554de5a8417e358f34eb"
vscode-languageserver-types@^3.10.0:
version "3.10.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.10.0.tgz#944e5308f3b36a3f372c766f1a344e903ec9c389"
vscode-nls@^3.2.4:
version "3.2.4"

View file

@ -25,10 +25,10 @@
"command.decrementNumberByTen": "Decrement by 10",
"emmetSyntaxProfiles": "Define profile for specified syntax or use your own profile with specific rules.",
"emmetExclude": "An array of languages where Emmet abbreviations should not be expanded.",
"emmetExtensionsPath": "Path to a folder containing Emmet profiles and snippets.'",
"emmetShowExpandedAbbreviation": "Shows expanded Emmet abbreviations as suggestions.\nThe option \"inMarkupAndStylesheetFilesOnly\" applies to html, haml, jade, slim, xml, xsl, css, scss, sass, less and stylus.\nThe option \"always\" applies to all parts of the file regardless of markup/css.",
"emmetShowAbbreviationSuggestions": "Shows possible Emmet abbreviations as suggestions. Not applicable in stylesheets or when emmet.showExpandedAbbreviation is set to \"never\".",
"emmetIncludeLanguages": "Enable Emmet abbreviations in languages that are not supported by default. Add a mapping here between the language and emmet supported language.\n E.g.: {\"vue-html\": \"html\", \"javascript\": \"javascriptreact\"}",
"emmetExtensionsPath": "Path to a folder containing Emmet profiles and snippets.",
"emmetShowExpandedAbbreviation": "Shows expanded Emmet abbreviations as suggestions.\nThe option `\"inMarkupAndStylesheetFilesOnly\"` applies to html, haml, jade, slim, xml, xsl, css, scss, sass, less and stylus.\nThe option `\"always\"` applies to all parts of the file regardless of markup/css.",
"emmetShowAbbreviationSuggestions": "Shows possible Emmet abbreviations as suggestions. Not applicable in stylesheets or when emmet.showExpandedAbbreviation is set to `\"never\"`.",
"emmetIncludeLanguages": "Enable Emmet abbreviations in languages that are not supported by default. Add a mapping here between the language and emmet supported language.\n E.g.: `{\"vue-html\": \"html\", \"javascript\": \"javascriptreact\"}`",
"emmetVariables": "Variables to be used in Emmet snippets",
"emmetTriggerExpansionOnTab": "When enabled, Emmet abbreviations are expanded when pressing TAB.",
"emmetPreferences": "Preferences used to modify behavior of some actions and resolvers of Emmet.",
@ -40,7 +40,7 @@
"emmetPreferencesCssBetween": "Symbol to be placed at the between CSS property and value when expanding CSS abbreviations",
"emmetPreferencesSassBetween": "Symbol to be placed at the between CSS property and value when expanding CSS abbreviations in Sass files",
"emmetPreferencesStylusBetween": "Symbol to be placed at the between CSS property and value when expanding CSS abbreviations in Stylus files",
"emmetShowSuggestionsAsSnippets": "If true, then Emmet suggestions will show up as snippets allowing you to order them as per editor.snippetSuggestions setting.",
"emmetShowSuggestionsAsSnippets": "If `true`, then Emmet suggestions will show up as snippets allowing you to order them as per `#editor.snippetSuggestions#` setting.",
"emmetPreferencesBemElementSeparator": "Element separator used for classes when using the BEM filter",
"emmetPreferencesBemModifierSeparator": "Modifier separator used for classes when using the BEM filter",
"emmetPreferencesFilterCommentBefore": "A definition of comment that should be placed before matched element when comment filter is applied.",
@ -54,5 +54,5 @@
"emmetPreferencesCssOProperties": "Comma separated CSS properties that get the 'o' vendor prefix when used in Emmet abbreviation that starts with `-`. Set to empty string to always avoid the 'o' prefix.",
"emmetPreferencesCssMsProperties": "Comma separated CSS properties that get the 'ms' vendor prefix when used in Emmet abbreviation that starts with `-`. Set to empty string to always avoid the 'ms' prefix.",
"emmetPreferencesCssFuzzySearchMinScore": "The minimum score (from 0 to 1) that fuzzy-matched abbreviation should achieve. Lower values may produce many false-positive matches, higher values may reduce possible matches.",
"emmetOptimizeStylesheetParsing": "When set to false, the whole file is parsed to determine if current position is valid for expanding Emmet abbreviations. When set to true, only the content around the current position in css/scss/less files is parsed."
"emmetOptimizeStylesheetParsing": "When set to `false`, the whole file is parsed to determine if current position is valid for expanding Emmet abbreviations. When set to `true`, only the content around the current position in css/scss/less files is parsed."
}

View file

@ -1,4 +1,4 @@
{
"displayName": "Package File Editing",
"description": "Provides IntelliSense for VS Code extension points and linting capabilities in package.json files."
"displayName": "Extension Authoring",
"description": "Provides linting capabilities for authoring extensions."
}

View file

@ -4,19 +4,19 @@
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
"Once accepted there, we are happy to receive an update request."
],
"version": "https://github.com/ionide/ionide-fsgrammar/commit/bd8d1225f93894a50bc8da6f5a76409b024d3d22",
"version": "https://github.com/ionide/ionide-fsgrammar/commit/67c9f45ebbbd5a12d89ffad1661caf8452f1d552",
"name": "fsharp",
"scopeName": "source.fsharp",
"patterns": [
{
"include": "#compiler_directives"
},
{
"include": "#comments"
},
{
"include": "#constants"
},
{
"include": "#structure"
},
{
"include": "#strings"
},
@ -30,10 +30,10 @@
"include": "#definition"
},
{
"include": "#attributes"
"include": "#abstract_definition"
},
{
"include": "#method_calls"
"include": "#attributes"
},
{
"include": "#modules"
@ -44,6 +44,9 @@
{
"include": "#du_declaration"
},
{
"include": "#record_declaration"
},
{
"include": "#keywords"
},
@ -58,6 +61,96 @@
}
],
"repository": {
"generic_declaration": {
"patterns": [
{
"match": "([^<>,])",
"captures": {
"1": {
"name": "entity.name.type.fsharp"
}
}
},
{
"begin": "(<)",
"end": "(>)",
"beginCaptures": {
"1": {
"name": "keyword.symbol.fsharp"
}
},
"endCaptures": {
"1": {
"name": "keyword.symbol.fsharp"
}
},
"patterns": [
{
"match": "([^<>,])",
"captures": {
"1": {
"name": "entity.name.type.fsharp"
}
}
},
{
"include": "#generic_declaration"
}
]
},
{
"include": "#keywords"
}
]
},
"record_signature": {
"patterns": [
{
"match": "[[:alpha:]0-9'`^_ ]+(=)([[:alpha:]0-9'`^_ ]+)",
"captures": {
"1": {
"name": "keyword.symbol.fsharp"
},
"2": {
"name": "variable.parameter.fsharp"
}
}
},
{
"begin": "({)",
"end": "(})",
"beginCaptures": {
"1": {
"name": "keyword.symbol.fsharp"
}
},
"endCaptures": {
"1": {
"name": "keyword.symbol.fsharp"
}
},
"patterns": [
{
"match": "[[:alpha:]0-9'`^_ ]+(=)([[:alpha:]0-9'`^_ ]+)",
"captures": {
"1": {
"name": "keyword.symbol.fsharp"
},
"2": {
"name": "variable.parameter.fsharp"
}
}
},
{
"include": "#record_signature"
}
]
},
{
"include": "#keywords"
}
]
},
"anonymous_functions": {
"patterns": [
{
@ -66,15 +159,32 @@
"end": "(->)",
"beginCaptures": {
"1": {
"name": "keyword.other.function-definition.fsharp"
"name": "keyword.fsharp"
}
},
"endCaptures": {
"1": {
"name": "keyword.other.fsharp"
"name": "keyword.fsharp"
}
},
"patterns": [
{
"include": "#comments"
},
{
"include": "#member_declaration"
},
{
"match": "(:)(\\s*([?[:alpha:]0-9'`<>^._ ]+))*",
"captures": {
"1": {
"name": "keyword.symbol.fsharp"
},
"2": {
"name": "entity.name.type.fsharp"
}
}
},
{
"include": "#variables"
}
@ -87,7 +197,7 @@
{
"name": "support.function.attribute.fsharp",
"begin": "\\[\\<",
"end": "\\>\\]",
"end": "\\>\\]|\\]",
"patterns": [
{
"include": "$self"
@ -178,57 +288,189 @@
}
]
},
"abstract_definition": {
"name": "abstract.definition.fsharp",
"begin": "\\b(abstract)\\s+(member)?(\\s+\\[\\<.*\\>\\])?\\s*([_[:alpha:]0-9,\\._`\\s]+)(:)",
"end": "\\s*(with)\\b|=|$",
"beginCaptures": {
"1": {
"name": "keyword.fsharp"
},
"2": {
"name": "keyword.fsharp"
},
"3": {
"name": "support.function.attribute.fsharp"
},
"5": {
"name": "keyword.fsharp"
}
},
"endCaptures": {
"1": {
"name": "keyword.fsharp"
}
},
"patterns": [
{
"include": "#comments"
},
{
"include": "#common_declaration"
},
{
"match": "\\?{0,1}([[:alpha:]0-9'`^._ ]+)\\s*(:)(\\s*([?[:alpha:]0-9'`^._ ]+)){0,1}",
"captures": {
"1": {
"name": "variable.parameter.fsharp"
},
"2": {
"name": "keyword.symbol.fsharp"
},
"3": {
"name": "entity.name.type.fsharp"
}
}
},
{
"match": "(?!with|get|set\\b)\\b([\\w0-9'`^._]+)",
"comments": "Here we need the \\w modifier in order to check that the words isn't blacklisted",
"captures": {
"1": {
"name": "entity.name.type.fsharp"
}
}
},
{
"include": "#keywords"
}
]
},
"definition": {
"patterns": [
{
"name": "binding.fsharp",
"begin": "\\b(val mutable|val|let mutable|let inline|let|member|static member|override|let!)(\\s+rec|mutable)?(\\s+\\[\\<.*\\>\\])?\\s*(private|internal|public)?\\s+(\\[[^-=]*\\]|[_[:alpha:]]([_[:alpha:]0-9,\\._]|(?<=,)\\s)*|``[_[:alpha:]]([_[:alpha:]0-9,\\._`\\s]|(?<=,)\\s)*)?",
"end": "((``.*``)|(with)\\b|=|$)",
"begin": "\\b(val mutable|val|let mutable|let inline|let|member val|member|static member|override|let!)(\\s+rec|mutable)?(\\s+\\[\\<.*\\>\\])?\\s*(private|internal|public)?\\s+(\\[[^-=]*\\]|[_[:alpha:]]([_[:alpha:]0-9,\\._]+)*|``[_[:alpha:]]([_[:alpha:]0-9,\\._`\\s]+|(?<=,)\\s)*)?",
"end": "\\s*(with\\b|=|\\n+=)",
"beginCaptures": {
"1": {
"name": "keyword.other.binding.fsharp"
"name": "keyword.fsharp"
},
"2": {
"name": "keyword.other.function-recursive.fsharp"
"name": "keyword.fsharp"
},
"3": {
"name": "support.function.attribute.fsharp"
},
"4": {
"name": "keyword.other.access.fsharp"
"name": "keyword.fsharp"
},
"5": {
"name": "variable.other.binding.fsharp"
"name": "variable.fsharp"
}
},
"endCaptures": {
"1": {
"name": "keyword.other.fsharp"
},
"2": {
"name": "variable.other.binding.fsharp"
},
"3": {
"name": "keyword.other.fsharp"
"name": "keyword.fsharp"
}
},
"patterns": [
{
"include": "#variables"
"include": "#comments"
},
{
"include": "#member_declaration"
},
{
"match": "(:)(\\s*([?[:alpha:]0-9'<>^._ ]+))*",
"match": "(:)\\s*(\\()?\\s*(([?[:alpha:]0-9'`^._ ]+))*",
"captures": {
"1": {
"name": "keyword.other.fsharp"
"name": "keyword.symbol.fsharp"
},
"2": {
"name": "keyword.symbol.fsharp"
},
"3": {
"name": "entity.name.type.fsharp"
}
}
},
{
"match": "(\\*\\s*\\()\\s*(([?[:alpha:]0-9'`^._ ]+))*",
"captures": {
"1": {
"name": "keyword.symbol.fsharp"
},
"2": {
"name": "entity.name.type.fsharp"
}
}
},
{
"match": "(->)\\s*(\\()?\\s*([?[:alpha:]0-9'`^._ ]+)*",
"captures": {
"1": {
"name": "keyword.symbol.fsharp"
},
"2": {
"name": "keyword.symbol.fsharp"
},
"3": {
"name": "entity.name.type.fsharp"
}
}
},
{
"match": "(\\*)(\\s*([?[:alpha:]0-9'`^._ ]+))*",
"captures": {
"1": {
"name": "keyword.symbol.fsharp"
},
"2": {
"name": "entity.name.type.fsharp"
}
}
},
{
"begin": "(<)",
"end": "(>)",
"beginCaptures": {
"1": {
"name": "keyword.symbol.fsharp"
}
},
"endCaptures": {
"1": {
"name": "keyword.symbol.fsharp"
}
},
"patterns": [
{
"include": "#generic_declaration"
}
]
},
{
"begin": "({)",
"end": "(})",
"beginCaptures": {
"1": {
"name": "keyword.symbol.fsharp"
}
},
"endCaptures": {
"1": {
"name": "keyword.symbol.fsharp"
}
},
"patterns": [
{
"include": "#record_signature"
}
]
},
{
"include": "#variables"
},
{
"include": "#keywords"
}
]
}
@ -242,23 +484,26 @@
"end": "$|(\\|)",
"beginCaptures": {
"1": {
"name": "keyword.other.fsharp"
"name": "keyword.fsharp"
}
},
"endCaptures": {
"1": {
"name": "keyword.other.fsharp"
"name": "keyword.symbol.fsharp"
}
},
"patterns": [
{
"match": "([[:alpha:]0-9'`<>^._]+)\\s*(:)\\s*([[:alpha:]0-9'`<>^._]+)",
"include": "#comments"
},
{
"match": "([[:alpha:]0-9'`<>^._]+|``[[:alpha:]0-9' <>^._]+``)\\s*(:)\\s*([[:alpha:]0-9'`<>^._]+|``[[:alpha:]0-9' <>^._]+``)",
"captures": {
"1": {
"name": "variable.parameter.fsharp"
},
"2": {
"name": "keyword.other.fsharp"
"name": "keyword.symbol.fsharp"
},
"3": {
"name": "entity.name.type.fsharp"
@ -266,17 +511,7 @@
}
},
{
"match": "([[:alpha:]0-9'`<>^._]+)",
"captures": {
"1": {
"name": "entity.name.type.fsharp"
}
}
},
{
"begin": "\\(",
"end": "\\)",
"match": "([[:alpha:]0-9'`<>^._]+)",
"match": "([[:alpha:]0-9'`^._]+)|``([[:alpha:]0-9'^._ ]+)``",
"captures": {
"1": {
"name": "entity.name.type.fsharp"
@ -293,17 +528,12 @@
"keywords": {
"patterns": [
{
"name": "keyword.other.fsharp",
"name": "keyword.fsharp",
"match": "\\b(private|to|public|internal|function|yield!|yield|class|exception|match|delegate|of|new|in|as|if|then|else|elif|for|begin|end|inherit|do|let\\!|return\\!|return|interface|with|abstract|property|union|enum|member|try|finally|and|when|use|use\\!|struct|while|mutable)(?!')\\b"
},
{
"name": "meta.preprocessor.fsharp",
"begin": "^\\s*#\\s*(light)\\b",
"end": "(\\s|$)"
},
{
"name": "keyword.other.fsharp",
"match": "(&&&|\\|\\|\\||\\^\\^\\^|~~~|<<<|>>>|\\|>|\\->|\\<\\-|:>|:\\?>|:|\\[|\\]|\\;|<>|=|@|\\|\\||&&|{|}|\\||_|\\.\\.|\\+|\\-|\\*|\\/|\\^|\\!|\\>|\\>\\=|\\>\\>|\\<|\\<\\=|\\<\\<)"
"name": "keyword.symbol.fsharp",
"match": "(&&&|\\|\\|\\||\\^\\^\\^|~~~|<<<|>>>|\\|>|\\->|\\<\\-|:>|:\\?>|:|\\[|\\]|\\;|<>|=|@|\\|\\||&&|{|}|\\||_|\\.\\.|\\,|\\+|\\-|\\*|\\/|\\^|\\!|\\>|\\>\\=|\\>\\>|\\<|\\<\\=|\\(|\\)|\\<\\<)"
}
]
},
@ -312,18 +542,23 @@
{
"name": "entity.name.section.fsharp",
"begin": "\\b(namespace|module)\\s*(public|internal|private)?\\s+([[:alpha:]][[:alpha:]0-9'_. ]*)",
"end": "(\\s|$)",
"end": "(\\s?=|\\s|$)",
"beginCaptures": {
"1": {
"name": "keyword.other.fsharp"
"name": "keyword.fsharp"
},
"2": {
"name": "keyword.other.fsharp"
"name": "keyword.fsharp"
},
"3": {
"name": "entity.name.section.fsharp"
}
},
"endCaptures": {
"1": {
"name": "keyword.symbol.fsharp"
}
},
"patterns": [
{
"name": "entity.name.section.fsharp",
@ -345,7 +580,7 @@
"end": "(\\s|$)",
"beginCaptures": {
"1": {
"name": "keyword.other.fsharp"
"name": "keyword.fsharp"
},
"2": {
"name": "entity.name.section.fsharp"
@ -372,7 +607,7 @@
"end": "(\\s|$)",
"beginCaptures": {
"1": {
"name": "keyword.other.namespace-definition.fsharp"
"name": "keyword.fsharp"
},
"2": {
"name": "entity.name.type.namespace.fsharp"
@ -485,7 +720,7 @@
"match": "(%0?-?(\\d+)?((a|t)|(\\.\\d+)?(f|F|e|E|g|G|M)|(b|c|s|d|i|x|X|o)|(s|b|O)|(\\+?A)))",
"captures": {
"1": {
"name": "keyword.other.format.specifier.fsharp"
"name": "keyword.format.specifier.fsharp"
}
}
}
@ -499,29 +734,132 @@
},
{
"name": "variable.parameter.fsharp",
"match": "[[:alpha:]'_]\\w*"
"match": "[[:alpha:]0-9'`<>^._ ]\\w*"
}
]
},
"common_declaration": {
"patterns": [
{
"begin": "\\s*(->)\\s*([[:alpha:]0-9'`^._ ]+)(<)",
"end": "(>)",
"beginCaptures": {
"1": {
"name": "keyword.symbol.fsharp"
},
"2": {
"name": "entity.name.type.fsharp"
},
"3": {
"name": "keyword.symbol.fsharp"
}
},
"endCaptures": {
"1": {
"name": "keyword.symbol.fsharp"
}
},
"patterns": [
{
"match": "([[:alpha:]0-9'`^._ ]+)",
"captures": {
"1": {
"name": "entity.name.type.fsharp"
}
}
},
{
"include": "#keywords"
}
]
},
{
"match": "\\s*(->)\\s*([[:alpha:]0-9'`^._ ]+)",
"captures": {
"1": {
"name": "keyword.symbol.fsharp"
},
"2": {
"name": "entity.name.type.fsharp"
}
}
},
{
"begin": "\\?{0,1}([[:alpha:]0-9'`^._ ]+)\\s*(:)(\\s*([?[:alpha:]0-9'`^._ ]+)(<))",
"end": "(>)",
"beginCaptures": {
"1": {
"name": "variable.parameter.fsharp"
},
"2": {
"name": "keyword.symbol.fsharp"
},
"3": {
"name": "keyword.symbol.fsharp"
},
"4": {
"name": "entity.name.type.fsharp"
}
},
"endCaptures": {
"1": {
"name": "keyword.symbol.fsharp"
}
},
"patterns": [
{
"match": "([[:alpha:]0-9'`^._ ]+)",
"captures": {
"1": {
"name": "entity.name.type.fsharp"
}
}
},
{
"include": "#keywords"
}
]
}
]
},
"member_declaration": {
"patterns": [
{
"begin": "\\(",
"end": "\\)",
"begin": "(\\()",
"end": "(\\))",
"beginCaptures": {
"1": {
"name": "keyword.symbol.fsharp"
}
},
"endCaptures": {
"1": {
"name": "keyword.symbol.fsharp"
}
},
"patterns": [
{
"match": "\\?{0,1}([[:alpha:]0-9'`<>^._]+)\\s*(:{0,1})(\\s*([?[:alpha:]0-9'<>^._ ]+)){0,1}",
"include": "#comments"
},
{
"include": "#common_declaration"
},
{
"match": "\\?{0,1}([[:alpha:]0-9'`^._ ]+)\\s*(:{0,1})(\\s*([?[:alpha:]0-9'`<>^._ ]+)){0,1}",
"captures": {
"1": {
"name": "variable.parameter.fsharp"
},
"2": {
"name": "keyword.other.fsharp"
"name": "keyword.symbol.fsharp"
},
"3": {
"name": "entity.name.type.fsharp"
}
}
},
{
"include": "#keywords"
}
]
}
@ -550,45 +888,210 @@
"patterns": [
{
"name": "record.fsharp",
"begin": "(type)[\\s]+(private|internal|public)?[\\s]*([[:alpha:]0-9'<>^:,._]+)[\\s]?(private|internal|public)?[\\s]*",
"end": "[\\s]*((with)|((as) ([[:alpha:]0-9']+))|(=)|[\\n=]|(\\(\\)))",
"begin": "\\b(type)[\\s]+(private|internal|public)?(\\s*\\[\\<.*\\>\\])?[\\s]*([[:alpha:]0-9'`^:,._]+|``[[:alpha:]0-9'`^:,._ ]+``)(<)",
"end": "\\s*((with)|((as)\\s*([[:alpha:]0-9']+))|(=)|[\\n=]|(\\(\\)))",
"beginCaptures": {
"1": {
"name": "keyword.other.fsharp"
"name": "keyword.fsharp"
},
"2": {
"name": "keyword.other.fsharp"
"name": "keyword.fsharp"
},
"3": {
"name": "entity.name.type.fsharp"
"name": "support.function.attribute.fsharp"
},
"4": {
"name": "keyword.other.fsharp"
"name": "entity.name.type.fsharp"
},
"5": {
"name": "keyword.symbol.fsharp"
}
},
"endCaptures": {
"2": {
"name": "keyword.other.fsharp"
"name": "keyword.fsharp"
},
"3": {
"name": "keyword.other.fsharp"
"name": "keyword.fsharp"
},
"4": {
"name": "keyword.other.fsharp"
"name": "keyword.fsharp"
},
"5": {
"name": "variable.parameter.fsharp"
},
"6": {
"name": "keyword.other.fsharp"
"name": "keyword.symbol.fsharp"
},
"7": {
"name": "constant.language.unit.fsharp"
}
},
"patterns": [
{
"include": "#comments"
},
{
"match": "\\s*(>)\\s*(private|internal|public)?",
"captures": {
"1": {
"name": "keyword.symbol.fsharp"
},
"2": {
"name": "keyword.fsharp"
}
}
},
{
"match": "([[:alpha:]0-9'`^._ ]+)",
"captures": {
"1": {
"name": "entity.name.type.fsharp"
}
}
},
{
"include": "#member_declaration"
},
{
"include": "#keywords"
}
]
},
{
"name": "record.fsharp",
"begin": "\\b(type)[\\s]+(private|internal|public)?(\\s*\\[\\<.*\\>\\])?[\\s]*([[:alpha:]0-9'`^:,._]+<(.*)>|[[:alpha:]0-9'^:,._]+|``[[:alpha:]0-9'`^:,._ ]+``)[\\s]?(private|internal|public)?[\\s]*",
"end": "\\s*((with)|((as)\\s*([[:alpha:]0-9']+))|(=)|[\\n=]|(\\(\\)))",
"beginCaptures": {
"1": {
"name": "keyword.fsharp"
},
"2": {
"name": "keyword.fsharp"
},
"3": {
"name": "support.function.attribute.fsharp"
},
"4": {
"name": "entity.name.type.fsharp"
},
"6": {
"name": "keyword.fsharp"
}
},
"endCaptures": {
"2": {
"name": "keyword.fsharp"
},
"3": {
"name": "keyword.fsharp"
},
"4": {
"name": "keyword.fsharp"
},
"5": {
"name": "variable.parameter.fsharp"
},
"6": {
"name": "keyword.symbol.fsharp"
},
"7": {
"name": "constant.language.unit.fsharp"
}
},
"patterns": [
{
"include": "#comments"
},
{
"include": "#member_declaration"
}
]
}
]
},
"record_declaration": {
"patterns": [
{
"begin": "(\\{)",
"beginCaptures": {
"1": {
"name": "keyword.symbol.fsharp"
}
},
"end": "(?<=\\})",
"patterns": [
{
"include": "#comments"
},
{
"begin": "(((mutable)\\s[[:alpha:]]+)|[[:alpha:]0-9'`<>^._]*)\\s*((?<!:):(?!:))\\s*",
"beginCaptures": {
"3": {
"name": "keyword.fsharp"
},
"4": {
"name": "keyword.symbol.fsharp"
}
},
"end": "$|(;|\\})",
"endCaptures": {
"1": {
"name": "keyword.symbol.fsharp"
}
},
"patterns": [
{
"include": "#comments"
},
{
"match": "([[:alpha:]0-9'`^_ ]+)",
"captures": {
"1": {
"name": "entity.name.type.fsharp"
}
}
},
{
"include": "#keywords"
}
]
},
{
"include": "#chars"
},
{
"include": "#compiler_directives"
},
{
"include": "#constants"
},
{
"include": "#strings"
},
{
"include": "#chars"
},
{
"include": "#double_tick"
},
{
"include": "#definition"
},
{
"include": "#attributes"
},
{
"include": "#anonymous_functions"
},
{
"include": "#keywords"
},
{
"include": "#cexprs"
},
{
"include": "#text"
}
]
}
@ -601,7 +1104,7 @@
"match": "\\b(async|seq|promise|task|maybe|asyncMaybe|controller|scope|application|pipeline)\\s*\\{",
"captures": {
"0": {
"name": "keyword.other.fsharp"
"name": "keyword.fsharp"
}
}
}
@ -627,6 +1130,15 @@
"match": "\\\\"
}
]
},
"compiler_directives": {
"patterns": [
{
"name": "compiler_directive.fsharp",
"match": "\\s?(#if|#elif|#else|#elseif|#endif|#light|#nowarn)",
"captures": {}
}
]
}
}
}

View file

@ -23,7 +23,7 @@
},
{
"c": "type",
"t": "source.fsharp record.fsharp keyword.other.fsharp",
"t": "source.fsharp record.fsharp keyword.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
@ -56,13 +56,13 @@
},
{
"c": "(",
"t": "source.fsharp record.fsharp",
"t": "source.fsharp record.fsharp keyword.symbol.fsharp",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF"
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
"dark_vs": "keyword: #569CD6",
"light_vs": "keyword: #0000FF",
"hc_black": "keyword: #569CD6"
}
},
{
@ -78,7 +78,7 @@
},
{
"c": ":",
"t": "source.fsharp record.fsharp keyword.other.fsharp",
"t": "source.fsharp record.fsharp keyword.symbol.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
@ -99,18 +99,18 @@
}
},
{
"c": ", ",
"t": "source.fsharp record.fsharp",
"c": ",",
"t": "source.fsharp record.fsharp keyword.symbol.fsharp",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF"
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
"dark_vs": "keyword: #569CD6",
"light_vs": "keyword: #0000FF",
"hc_black": "keyword: #569CD6"
}
},
{
"c": "age",
"c": " age",
"t": "source.fsharp record.fsharp variable.parameter.fsharp",
"r": {
"dark_plus": "variable: #9CDCFE",
@ -122,7 +122,7 @@
},
{
"c": ":",
"t": "source.fsharp record.fsharp keyword.other.fsharp",
"t": "source.fsharp record.fsharp keyword.symbol.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
@ -143,7 +143,18 @@
}
},
{
"c": ") ",
"c": ")",
"t": "source.fsharp record.fsharp keyword.symbol.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
"dark_vs": "keyword: #569CD6",
"light_vs": "keyword: #0000FF",
"hc_black": "keyword: #569CD6"
}
},
{
"c": " ",
"t": "source.fsharp record.fsharp",
"r": {
"dark_plus": "default: #D4D4D4",
@ -155,7 +166,7 @@
},
{
"c": "=",
"t": "source.fsharp record.fsharp keyword.other.fsharp",
"t": "source.fsharp record.fsharp keyword.symbol.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
@ -177,7 +188,7 @@
},
{
"c": "let mutable",
"t": "source.fsharp binding.fsharp keyword.other.binding.fsharp",
"t": "source.fsharp binding.fsharp keyword.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
@ -199,7 +210,7 @@
},
{
"c": "internalAge",
"t": "source.fsharp binding.fsharp variable.other.binding.fsharp",
"t": "source.fsharp binding.fsharp variable.fsharp",
"r": {
"dark_plus": "variable: #9CDCFE",
"light_plus": "variable: #001080",
@ -221,7 +232,7 @@
},
{
"c": "=",
"t": "source.fsharp binding.fsharp keyword.other.fsharp",
"t": "source.fsharp binding.fsharp keyword.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
@ -254,7 +265,7 @@
},
{
"c": "new",
"t": "source.fsharp keyword.other.fsharp",
"t": "source.fsharp keyword.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
@ -264,7 +275,18 @@
}
},
{
"c": "(name",
"c": "(",
"t": "source.fsharp keyword.symbol.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
"dark_vs": "keyword: #569CD6",
"light_vs": "keyword: #0000FF",
"hc_black": "keyword: #569CD6"
}
},
{
"c": "name",
"t": "source.fsharp",
"r": {
"dark_plus": "default: #D4D4D4",
@ -276,7 +298,7 @@
},
{
"c": ":",
"t": "source.fsharp keyword.other.fsharp",
"t": "source.fsharp keyword.symbol.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
@ -286,7 +308,29 @@
}
},
{
"c": "string) ",
"c": "string",
"t": "source.fsharp",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF"
}
},
{
"c": ")",
"t": "source.fsharp keyword.symbol.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
"dark_vs": "keyword: #569CD6",
"light_vs": "keyword: #0000FF",
"hc_black": "keyword: #569CD6"
}
},
{
"c": " ",
"t": "source.fsharp",
"r": {
"dark_plus": "default: #D4D4D4",
@ -298,7 +342,7 @@
},
{
"c": "=",
"t": "source.fsharp keyword.other.fsharp",
"t": "source.fsharp keyword.symbol.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
@ -308,7 +352,51 @@
}
},
{
"c": " Person(name, ",
"c": " Person",
"t": "source.fsharp",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF"
}
},
{
"c": "(",
"t": "source.fsharp keyword.symbol.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
"dark_vs": "keyword: #569CD6",
"light_vs": "keyword: #0000FF",
"hc_black": "keyword: #569CD6"
}
},
{
"c": "name",
"t": "source.fsharp",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF"
}
},
{
"c": ",",
"t": "source.fsharp keyword.symbol.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
"dark_vs": "keyword: #569CD6",
"light_vs": "keyword: #0000FF",
"hc_black": "keyword: #569CD6"
}
},
{
"c": " ",
"t": "source.fsharp",
"r": {
"dark_plus": "default: #D4D4D4",
@ -331,13 +419,13 @@
},
{
"c": ")",
"t": "source.fsharp",
"t": "source.fsharp keyword.symbol.fsharp",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF"
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
"dark_vs": "keyword: #569CD6",
"light_vs": "keyword: #0000FF",
"hc_black": "keyword: #569CD6"
}
},
{
@ -353,7 +441,7 @@
},
{
"c": "member",
"t": "source.fsharp binding.fsharp keyword.other.binding.fsharp",
"t": "source.fsharp binding.fsharp keyword.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
@ -375,7 +463,7 @@
},
{
"c": "this.Name",
"t": "source.fsharp binding.fsharp variable.other.binding.fsharp",
"t": "source.fsharp binding.fsharp variable.fsharp",
"r": {
"dark_plus": "variable: #9CDCFE",
"light_plus": "variable: #001080",
@ -397,7 +485,7 @@
},
{
"c": "=",
"t": "source.fsharp binding.fsharp keyword.other.fsharp",
"t": "source.fsharp binding.fsharp keyword.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
@ -452,7 +540,7 @@
},
{
"c": "member",
"t": "source.fsharp binding.fsharp keyword.other.binding.fsharp",
"t": "source.fsharp binding.fsharp keyword.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
@ -474,7 +562,7 @@
},
{
"c": "this.Age",
"t": "source.fsharp binding.fsharp variable.other.binding.fsharp",
"t": "source.fsharp binding.fsharp variable.fsharp",
"r": {
"dark_plus": "variable: #9CDCFE",
"light_plus": "variable: #001080",
@ -485,7 +573,7 @@
},
{
"c": " ",
"t": "source.fsharp",
"t": "source.fsharp binding.fsharp",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
@ -496,7 +584,7 @@
},
{
"c": "with",
"t": "source.fsharp keyword.other.fsharp",
"t": "source.fsharp binding.fsharp keyword.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
@ -540,7 +628,7 @@
},
{
"c": "=",
"t": "source.fsharp keyword.other.fsharp",
"t": "source.fsharp keyword.symbol.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
@ -573,7 +661,7 @@
},
{
"c": "and",
"t": "source.fsharp keyword.other.fsharp",
"t": "source.fsharp keyword.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
@ -583,7 +671,51 @@
}
},
{
"c": " set(value) ",
"c": " set",
"t": "source.fsharp",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF"
}
},
{
"c": "(",
"t": "source.fsharp keyword.symbol.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
"dark_vs": "keyword: #569CD6",
"light_vs": "keyword: #0000FF",
"hc_black": "keyword: #569CD6"
}
},
{
"c": "value",
"t": "source.fsharp",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF"
}
},
{
"c": ")",
"t": "source.fsharp keyword.symbol.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
"dark_vs": "keyword: #569CD6",
"light_vs": "keyword: #0000FF",
"hc_black": "keyword: #569CD6"
}
},
{
"c": " ",
"t": "source.fsharp",
"r": {
"dark_plus": "default: #D4D4D4",
@ -595,7 +727,7 @@
},
{
"c": "=",
"t": "source.fsharp keyword.other.fsharp",
"t": "source.fsharp keyword.symbol.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
@ -617,7 +749,7 @@
},
{
"c": "<-",
"t": "source.fsharp keyword.other.fsharp",
"t": "source.fsharp keyword.symbol.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
@ -650,7 +782,7 @@
},
{
"c": "member",
"t": "source.fsharp binding.fsharp keyword.other.binding.fsharp",
"t": "source.fsharp binding.fsharp keyword.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
@ -672,7 +804,7 @@
},
{
"c": "this.HasABirthday",
"t": "source.fsharp binding.fsharp variable.other.binding.fsharp",
"t": "source.fsharp binding.fsharp variable.fsharp",
"r": {
"dark_plus": "variable: #9CDCFE",
"light_plus": "variable: #001080",
@ -683,13 +815,13 @@
},
{
"c": " ",
"t": "source.fsharp binding.fsharp",
"t": "source.fsharp binding.fsharp variable.parameter.fsharp",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_plus": "variable: #9CDCFE",
"light_plus": "variable: #001080",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF"
"hc_black": "variable: #9CDCFE"
}
},
{
@ -716,7 +848,7 @@
},
{
"c": "=",
"t": "source.fsharp binding.fsharp keyword.other.fsharp",
"t": "source.fsharp binding.fsharp keyword.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
@ -738,7 +870,7 @@
},
{
"c": "<-",
"t": "source.fsharp keyword.other.fsharp",
"t": "source.fsharp keyword.symbol.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
@ -760,7 +892,7 @@
},
{
"c": "+",
"t": "source.fsharp keyword.other.fsharp",
"t": "source.fsharp keyword.symbol.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
@ -804,7 +936,7 @@
},
{
"c": "member",
"t": "source.fsharp binding.fsharp keyword.other.binding.fsharp",
"t": "source.fsharp binding.fsharp keyword.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
@ -826,7 +958,7 @@
},
{
"c": "this.IsOfAge",
"t": "source.fsharp binding.fsharp variable.other.binding.fsharp",
"t": "source.fsharp binding.fsharp variable.fsharp",
"r": {
"dark_plus": "variable: #9CDCFE",
"light_plus": "variable: #001080",
@ -836,18 +968,7 @@
}
},
{
"c": " ",
"t": "source.fsharp binding.fsharp",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF"
}
},
{
"c": "targetAge",
"c": " targetAge",
"t": "source.fsharp binding.fsharp variable.parameter.fsharp",
"r": {
"dark_plus": "variable: #9CDCFE",
@ -870,7 +991,7 @@
},
{
"c": "=",
"t": "source.fsharp binding.fsharp keyword.other.fsharp",
"t": "source.fsharp binding.fsharp keyword.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
@ -892,7 +1013,7 @@
},
{
"c": ">=",
"t": "source.fsharp keyword.other.fsharp",
"t": "source.fsharp keyword.symbol.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
@ -925,7 +1046,7 @@
},
{
"c": "override",
"t": "source.fsharp binding.fsharp keyword.other.binding.fsharp",
"t": "source.fsharp binding.fsharp keyword.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
@ -947,7 +1068,7 @@
},
{
"c": "this.ToString",
"t": "source.fsharp binding.fsharp variable.other.binding.fsharp",
"t": "source.fsharp binding.fsharp variable.fsharp",
"r": {
"dark_plus": "variable: #9CDCFE",
"light_plus": "variable: #001080",
@ -958,13 +1079,13 @@
},
{
"c": " ",
"t": "source.fsharp binding.fsharp",
"t": "source.fsharp binding.fsharp variable.parameter.fsharp",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_plus": "variable: #9CDCFE",
"light_plus": "variable: #001080",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF"
"hc_black": "variable: #9CDCFE"
}
},
{
@ -991,7 +1112,7 @@
},
{
"c": "=",
"t": "source.fsharp binding.fsharp keyword.other.fsharp",
"t": "source.fsharp binding.fsharp keyword.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
@ -1057,7 +1178,7 @@
},
{
"c": "+",
"t": "source.fsharp keyword.other.fsharp",
"t": "source.fsharp keyword.symbol.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
@ -1079,7 +1200,7 @@
},
{
"c": "+",
"t": "source.fsharp keyword.other.fsharp",
"t": "source.fsharp keyword.symbol.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
@ -1145,7 +1266,7 @@
},
{
"c": "+",
"t": "source.fsharp keyword.other.fsharp",
"t": "source.fsharp keyword.symbol.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
@ -1211,7 +1332,7 @@
},
{
"c": "+",
"t": "source.fsharp keyword.other.fsharp",
"t": "source.fsharp keyword.symbol.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
@ -1221,7 +1342,51 @@
}
},
{
"c": " (string)internalAge",
"c": " ",
"t": "source.fsharp",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF"
}
},
{
"c": "(",
"t": "source.fsharp keyword.symbol.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
"dark_vs": "keyword: #569CD6",
"light_vs": "keyword: #0000FF",
"hc_black": "keyword: #569CD6"
}
},
{
"c": "string",
"t": "source.fsharp",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF"
}
},
{
"c": ")",
"t": "source.fsharp keyword.symbol.fsharp",
"r": {
"dark_plus": "keyword: #569CD6",
"light_plus": "keyword: #0000FF",
"dark_vs": "keyword: #569CD6",
"light_vs": "keyword: #0000FF",
"hc_black": "keyword: #569CD6"
}
},
{
"c": "internalAge",
"t": "source.fsharp",
"r": {
"dark_plus": "default: #D4D4D4",

View file

@ -911,7 +911,8 @@
"git.autofetch": {
"type": "boolean",
"description": "%config.autofetch%",
"default": false
"default": false,
"tags": ["backgroundOnlineFeature"]
},
"git.confirmSync": {
"type": "boolean",
@ -925,6 +926,11 @@
"tracked",
"off"
],
"enumDescriptions": [
"%config.countBadge.all%",
"%config.countBadge.tracked%",
"%config.countBadge.off%"
],
"description": "%config.countBadge%",
"default": "all"
},
@ -936,6 +942,12 @@
"tags",
"remote"
],
"enumDescriptions": [
"%config.checkoutType.all%",
"%config.checkoutType.local%",
"%config.checkoutType.tags%",
"%config.checkoutType.remote%"
],
"description": "%config.checkoutType%",
"default": "all"
},

View file

@ -50,23 +50,30 @@
"command.stash": "Stash",
"command.stashPop": "Pop Stash...",
"command.stashPopLatest": "Pop Latest Stash",
"config.enabled": "Whether git is enabled",
"config.path": "Path to the git executable",
"config.enabled": "Whether git is enabled.",
"config.path": "Path to the git executable.",
"config.autoRepositoryDetection": "Configures when repositories should be automatically detected.",
"config.autorefresh": "Whether auto refreshing is enabled",
"config.autofetch": "Whether auto fetching is enabled",
"config.enableLongCommitWarning": "Whether long commit messages should be warned about",
"config.confirmSync": "Confirm before synchronizing git repositories",
"config.countBadge": "Controls the git badge counter. `all` counts all changes. `tracked` counts only the tracked changes. `off` turns it off.",
"config.checkoutType": "Controls what type of branches are listed when running `Checkout to...`. `all` shows all refs, `local` shows only the local branches, `tags` shows only tags and `remote` shows only remote branches.",
"config.ignoreLegacyWarning": "Ignores the legacy Git warning",
"config.confirmSync": "Confirm before synchronizing git repositories.",
"config.countBadge": "Controls the git badge counter.",
"config.countBadge.all": "Count all changes.",
"config.countBadge.tracked": "Count only tracked changes.",
"config.countBadge.off": "Turn off counter.",
"config.checkoutType": "Controls what type of branches are listed when running `Checkout to...`.",
"config.checkoutType.all": "Show all references.",
"config.checkoutType.local": "Show only local branches.",
"config.checkoutType.tags": "Show only tags.",
"config.checkoutType.remote": "Show only remote branches.",
"config.ignoreLegacyWarning": "Ignores the legacy Git warning.",
"config.ignoreMissingGitWarning": "Ignores the warning when Git is missing",
"config.ignoreLimitWarning": "Ignores the warning when there are too many changes in a repository",
"config.defaultCloneDirectory": "The default location where to clone a git repository",
"config.defaultCloneDirectory": "The default location to clone a git repository.",
"config.enableSmartCommit": "Commit all changes when there are no staged changes.",
"config.enableCommitSigning": "Enables commit signing with GPG.",
"config.discardAllScope": "Controls what changes are discarded by the `Discard all changes` command. `all` discards all changes. `tracked` discards only tracked files. `prompt` shows a prompt dialog every time the action is run.",
"config.decorations.enabled": "Controls if Git contributes colors and badges to the explorer and the open editors view.",
"config.decorations.enabled": "Controls whether Git contributes colors and badges to the explorer and the open editors view.",
"config.promptToSaveFilesBeforeCommit": "Controls whether Git should check for unsaved files before committing.",
"config.showInlineOpenFileAction": "Controls whether to show an inline Open File action in the Git changes view.",
"config.showPushSuccessNotification": "Controls whether to show a notification when a push is successful.",

View file

@ -4,7 +4,7 @@
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
"Once accepted there, we are happy to receive an update request."
],
"version": "https://github.com/textmate/git.tmbundle/commit/d1db42c2d71948662098183a6df519fb53a7a15b",
"version": "https://github.com/textmate/git.tmbundle/commit/3f6ad2138200db14b57a090ecb2d2e733275ca3e",
"name": "Git Rebase Message",
"scopeName": "text.git-rebase",
"patterns": [
@ -29,7 +29,23 @@
"name": "meta.commit-message.git-rebase"
}
},
"match": "^\\s*(pick|p|reword|r|edit|e|squash|s|fixup|f|exec|x|drop|d)\\s+([0-9a-f]+)\\s+(.*)$",
"match": "^\\s*(pick|p|reword|r|edit|e|squash|s|fixup|f|drop|d)\\s+([0-9a-f]+)\\s+(.*)$",
"name": "meta.commit-command.git-rebase"
},
{
"captures": {
"1": {
"name": "support.function.git-rebase"
},
"2": {
"patterns": [
{
"include": "source.shell"
}
]
}
},
"match": "^\\s*(exec|x)\\s+(.*)$",
"name": "meta.commit-command.git-rebase"
}
]

View file

@ -8,14 +8,12 @@ import * as path from 'path';
import * as nls from 'vscode-nls';
const localize = nls.loadMessageBundle();
import { languages, ExtensionContext, IndentAction, Position, TextDocument, Range, CompletionItem, CompletionItemKind, SnippetString, FoldingRangeKind, FoldingRange, FoldingContext } from 'vscode';
import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind, RequestType, TextDocumentPositionParams, Disposable, CancellationToken } from 'vscode-languageclient';
import { languages, ExtensionContext, IndentAction, Position, TextDocument, Range, CompletionItem, CompletionItemKind, SnippetString } from 'vscode';
import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind, RequestType, TextDocumentPositionParams } from 'vscode-languageclient';
import { EMPTY_ELEMENTS } from './htmlEmptyTagsShared';
import { activateTagClosing } from './tagClosing';
import TelemetryReporter from 'vscode-extension-telemetry';
import { FoldingRangeRequest, FoldingRangeRequestParam, FoldingRangeClientCapabilities, FoldingRangeKind as LSFoldingRangeKind } from 'vscode-languageserver-protocol-foldingprovider';
namespace TagCloseRequest {
export const type: RequestType<TextDocumentPositionParams, string, any, any> = new RequestType('html/tag');
}
@ -64,21 +62,6 @@ 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);
client.registerProposedFeatures();
client.registerFeature({
fillClientCapabilities(capabilities: FoldingRangeClientCapabilities): void {
let textDocumentCap = capabilities.textDocument;
if (!textDocumentCap) {
textDocumentCap = capabilities.textDocument = {};
}
textDocumentCap.foldingRange = {
dynamicRegistration: false,
rangeLimit: 5000,
lineFoldingOnly: true
};
},
initialize(capabilities, documentSelector): void {
}
});
let disposable = client.start();
toDispose.push(disposable);
@ -96,7 +79,6 @@ export function activate(context: ExtensionContext) {
}
});
toDispose.push(disposable);
toDispose.push(initFoldingProvider());
});
languages.setLanguageConfiguration('html', {
@ -172,38 +154,6 @@ export function activate(context: ExtensionContext) {
return null;
}
});
function initFoldingProvider(): Disposable {
function getKind(kind: string | undefined): FoldingRangeKind | undefined {
if (kind) {
switch (kind) {
case LSFoldingRangeKind.Comment:
return FoldingRangeKind.Comment;
case LSFoldingRangeKind.Imports:
return FoldingRangeKind.Imports;
case LSFoldingRangeKind.Region:
return FoldingRangeKind.Region;
}
}
return void 0;
}
return languages.registerFoldingRangeProvider('html', {
provideFoldingRanges(document: TextDocument, context: FoldingContext, token: CancellationToken) {
const param: FoldingRangeRequestParam = {
textDocument: client.code2ProtocolConverter.asTextDocumentIdentifier(document)
};
return client.sendRequest(FoldingRangeRequest.type, param, token).then(ranges => {
if (Array.isArray(ranges)) {
return ranges.map(r => new FoldingRange(r.startLine, r.endLine, getKind(r.kind)));
}
return null;
}, error => {
client.logFailedRequest(FoldingRangeRequest.type, error);
return null;
});
}
});
}
}
function getPackageInfo(context: ExtensionContext): IPackageInfo | null {

View file

@ -174,8 +174,7 @@
},
"dependencies": {
"vscode-extension-telemetry": "0.0.17",
"vscode-languageclient": "^4.1.4",
"vscode-languageserver-protocol-foldingprovider": "^2.0.1",
"vscode-languageclient": "^4.4.0",
"vscode-nls": "^3.2.4"
},
"devDependencies": {

View file

@ -1,12 +1,12 @@
{
"displayName": "HTML Language Features",
"description": "Provides rich language support for HTML, Razor, and Handlebar files",
"html.format.enable.desc": "Enable/disable default HTML formatter",
"html.format.enable.desc": "Enable/disable default HTML formatter.",
"html.format.wrapLineLength.desc": "Maximum amount of characters per line (0 = disable).",
"html.format.unformatted.desc": "List of tags, comma separated, that shouldn't be reformatted. 'null' defaults to all tags listed at https://www.w3.org/TR/html5/dom.html#phrasing-content.",
"html.format.contentUnformatted.desc": "List of tags, comma separated, where the content shouldn't be reformatted. 'null' defaults to the 'pre' tag.",
"html.format.indentInnerHtml.desc": "Indent <head> and <body> sections.",
"html.format.preserveNewLines.desc": "Whether existing line breaks before elements should be preserved. Only works before elements, not inside tags or for text.",
"html.format.preserveNewLines.desc": "Controls whether existing line breaks before elements should be preserved. Only works before elements, not inside tags or for text.",
"html.format.maxPreserveNewLines.desc": "Maximum number of line breaks to be preserved in one chunk. Use 'null' for unlimited.",
"html.format.indentHandlebars.desc": "Format and indent {{#foo}} and {{/foo}}.",
"html.format.endWithNewline.desc": "End with a newline.",
@ -16,11 +16,11 @@
"html.format.wrapAttributes.force": "Wrap each attribute except first.",
"html.format.wrapAttributes.forcealign": "Wrap each attribute except first and keep aligned.",
"html.format.wrapAttributes.forcemultiline": "Wrap each attribute.",
"html.suggest.angular1.desc": "Configures if the built-in HTML language support suggests Angular V1 tags and properties.",
"html.suggest.ionic.desc": "Configures if the built-in HTML language support suggests Ionic tags, properties and values.",
"html.suggest.html5.desc":"Configures if the built-in HTML language support suggests HTML5 tags, properties and values.",
"html.suggest.angular1.desc": "Controls whether the built-in HTML language support suggests Angular V1 tags and properties.",
"html.suggest.ionic.desc": "Controls whether the built-in HTML language support suggests Ionic tags, properties and values.",
"html.suggest.html5.desc": "Controls whether the built-in HTML language support suggests HTML5 tags, properties and values.",
"html.trace.server.desc": "Traces the communication between VS Code and the HTML language server.",
"html.validate.scripts": "Configures if the built-in HTML language support validates embedded scripts.",
"html.validate.styles": "Configures if the built-in HTML language support validates embedded styles.",
"html.validate.scripts": "Controls whether the built-in HTML language support validates embedded scripts.",
"html.validate.styles": "Controls whether the built-in HTML language support validates embedded styles.",
"html.autoClosingTags": "Enable/disable autoclosing of HTML tags."
}

View file

@ -8,13 +8,12 @@
"node": "*"
},
"dependencies": {
"vscode-css-languageservice": "^3.0.9-next.20",
"vscode-html-languageservice": "^2.1.3-next.5",
"vscode-languageserver": "^4.1.3",
"vscode-languageserver-protocol-foldingprovider": "^2.0.1",
"vscode-languageserver-types": "^3.7.2",
"vscode-css-languageservice": "^3.0.9",
"vscode-html-languageservice": "^2.1.3",
"vscode-languageserver": "^4.4.0",
"vscode-languageserver-types": "^3.10.0",
"vscode-nls": "^3.2.4",
"vscode-uri": "^1.0.3"
"vscode-uri": "^1.0.5"
},
"devDependencies": {
"@types/mocha": "2.2.33",

View file

@ -19,7 +19,6 @@ import { getDocumentContext } from './utils/documentContext';
import uri from 'vscode-uri';
import { formatError, runSafe, runSafeAsync } from './utils/runner';
import { FoldingRangeRequest, FoldingRangeServerCapabilities } from 'vscode-languageserver-protocol-foldingprovider';
import { getFoldingRanges } from './modes/htmlFolding';
namespace TagCloseRequest {
@ -119,7 +118,7 @@ connection.onInitialize((params: InitializeParams): InitializeResult => {
scopedSettingsSupport = getClientCapability('workspace.configuration', false);
workspaceFoldersSupport = getClientCapability('workspace.workspaceFolders', false);
foldingRangeLimit = getClientCapability('textDocument.foldingRange.rangeLimit', Number.MAX_VALUE);
const capabilities: ServerCapabilities & FoldingRangeServerCapabilities = {
const capabilities: ServerCapabilities = {
// Tell the client that the server works in FULL text document sync mode
textDocumentSync: documents.syncKind,
completionProvider: clientSnippetSupport ? { resolveProvider: true, triggerCharacters: ['.', ':', '<', '"', '=', '/'] } : undefined,
@ -441,7 +440,7 @@ connection.onRequest(TagCloseRequest.type, (params, token) => {
}, null, `Error while computing tag close actions for ${params.textDocument.uri}`, token);
});
connection.onRequest(FoldingRangeRequest.type, (params, token) => {
connection.onFoldingRanges((params, token) => {
return runSafe(() => {
const document = documents.get(params.textDocument.uri);
if (document) {

View file

@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import { TextDocument, CancellationToken, Position, Range } from 'vscode-languageserver';
import { FoldingRange } from 'vscode-languageserver-protocol-foldingprovider';
import { FoldingRange } from 'vscode-languageserver-types';
import { LanguageModes } from './languageModes';
export function getFoldingRanges(languageModes: LanguageModes, document: TextDocument, maxRanges: number | undefined, cancellationToken: CancellationToken | null): FoldingRange[] {

View file

@ -6,10 +6,8 @@
import { getLanguageModelCache } from '../languageModelCache';
import { LanguageService as HTMLLanguageService, HTMLDocument, DocumentContext, FormattingOptions, HTMLFormatConfiguration } from 'vscode-html-languageservice';
import { TextDocument, Position, Range, CompletionItem } from 'vscode-languageserver-types';
import { TextDocument, Position, Range, CompletionItem, FoldingRange } from 'vscode-languageserver-types';
import { LanguageMode, Workspace } from './languageModes';
import { FoldingRange } from 'vscode-languageserver-protocol-foldingprovider';
import { getPathCompletionParticipant } from './pathCompletion';
export function getHTMLMode(htmlLanguageService: HTMLLanguageService, workspace: Workspace): LanguageMode {

View file

@ -5,14 +5,17 @@
'use strict';
import { LanguageModelCache, getLanguageModelCache } from '../languageModelCache';
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 {
SymbolInformation, SymbolKind, CompletionItem, Location, SignatureHelp, SignatureInformation, ParameterInformation,
Definition, TextEdit, TextDocument, Diagnostic, DiagnosticSeverity, Range, CompletionItemKind, Hover, MarkedString,
DocumentHighlight, DocumentHighlightKind, CompletionList, Position, FormattingOptions, FoldingRange, FoldingRangeKind
} from 'vscode-languageserver-types';
import { LanguageMode, Settings, Workspace } from './languageModes';
import { getWordAtText, startsWith, isWhitespaceOnly, repeat } from '../utils/strings';
import { HTMLDocumentRegions } from './embeddedSupport';
import * as ts from 'typescript';
import { join } from 'path';
import { FoldingRange, FoldingRangeKind } from 'vscode-languageserver-protocol-foldingprovider';
const FILE_NAME = 'vscode://javascript/1'; // the same 'file' is used for all contents
const JQUERY_D_TS = join(__dirname, '../../lib/jquery.d.ts');

View file

@ -7,10 +7,9 @@
import { getLanguageService as getHTMLLanguageService, DocumentContext } from 'vscode-html-languageservice';
import {
CompletionItem, Location, SignatureHelp, Definition, TextEdit, TextDocument, Diagnostic, DocumentLink, Range,
Hover, DocumentHighlight, CompletionList, Position, FormattingOptions, SymbolInformation
Hover, DocumentHighlight, CompletionList, Position, FormattingOptions, SymbolInformation, FoldingRange
} from 'vscode-languageserver-types';
import { ColorInformation, ColorPresentation, Color, WorkspaceFolder } from 'vscode-languageserver';
import { FoldingRange } from 'vscode-languageserver-protocol-foldingprovider';
import { getLanguageModelCache, LanguageModelCache } from '../languageModelCache';
import { getDocumentRegions, HTMLDocumentRegions } from './embeddedSupport';

View file

@ -194,66 +194,55 @@ supports-color@5.4.0:
dependencies:
has-flag "^3.0.0"
vscode-css-languageservice@^3.0.9-next.20:
version "3.0.9-next.20"
resolved "https://registry.yarnpkg.com/vscode-css-languageservice/-/vscode-css-languageservice-3.0.9-next.20.tgz#8229aee66aa877929af5d2fd81a21731b415c92e"
vscode-css-languageservice@^3.0.9:
version "3.0.9"
resolved "https://registry.yarnpkg.com/vscode-css-languageservice/-/vscode-css-languageservice-3.0.9.tgz#770471350120c5bcf6918632a125638fc0ece3be"
dependencies:
vscode-languageserver-types "^3.7.2"
vscode-nls "^3.2.2"
vscode-languageserver-types "^3.10.0"
vscode-nls "^3.2.4"
vscode-html-languageservice@^2.1.3-next.5:
version "2.1.3-next.5"
resolved "https://registry.yarnpkg.com/vscode-html-languageservice/-/vscode-html-languageservice-2.1.3-next.5.tgz#cfbf4ffed96845ad13999d572ce0b5c2aeee84af"
vscode-html-languageservice@^2.1.3:
version "2.1.3"
resolved "https://registry.yarnpkg.com/vscode-html-languageservice/-/vscode-html-languageservice-2.1.3.tgz#c999c39e37adc632be8003a5e82075cf75dbb9bc"
dependencies:
vscode-languageserver-types "^3.7.2"
vscode-nls "^3.2.2"
vscode-uri "^1.0.3"
vscode-languageserver-types "^3.10.0"
vscode-nls "^3.2.4"
vscode-uri "^1.0.5"
vscode-jsonrpc@^3.6.2:
version "3.6.2"
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-3.6.2.tgz#3b5eef691159a15556ecc500e9a8a0dd143470c8"
vscode-languageserver-protocol-foldingprovider@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol-foldingprovider/-/vscode-languageserver-protocol-foldingprovider-2.0.1.tgz#051d0d9e58d1b79dc4681acd48f21797f5515bfd"
dependencies:
vscode-languageserver-protocol "^3.7.2"
vscode-languageserver-types "^3.7.2"
vscode-languageserver-protocol@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.7.2.tgz#df58621c032139010888b6a9ddc969423f9ba9d6"
vscode-languageserver-protocol@^3.10.0:
version "3.10.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.10.0.tgz#f8dcdf987687f64a26e7c32d498fc781a0e886dc"
dependencies:
vscode-jsonrpc "^3.6.2"
vscode-languageserver-types "^3.7.2"
vscode-languageserver-types "^3.10.0"
vscode-languageserver-types@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.7.2.tgz#aad8846f8e3e27962648554de5a8417e358f34eb"
vscode-languageserver-types@^3.10.0:
version "3.10.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.10.0.tgz#944e5308f3b36a3f372c766f1a344e903ec9c389"
vscode-languageserver@^4.1.3:
version "4.1.3"
resolved "https://registry.yarnpkg.com/vscode-languageserver/-/vscode-languageserver-4.1.3.tgz#937d37c955b6b9c2409388413cd6f54d1eb9fe7d"
vscode-languageserver@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver/-/vscode-languageserver-4.4.0.tgz#b6e8b37a739ccb629d92f3635f0099d191c856fa"
dependencies:
vscode-languageserver-protocol "^3.7.2"
vscode-uri "^1.0.1"
vscode-nls@^3.2.2:
version "3.2.2"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-3.2.2.tgz#3817eca5b985c2393de325197cf4e15eb2aa5350"
vscode-languageserver-protocol "^3.10.0"
vscode-uri "^1.0.3"
vscode-nls@^3.2.4:
version "3.2.4"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-3.2.4.tgz#2166b4183c8aea884d20727f5449e62be69fd398"
vscode-uri@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-1.0.1.tgz#11a86befeac3c4aa3ec08623651a3c81a6d0bbc8"
vscode-uri@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-1.0.3.tgz#631bdbf716dccab0e65291a8dc25c23232085a52"
vscode-uri@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-1.0.5.tgz#3b899a8ef71c37f3054d79bdbdda31c7bf36f20d"
wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"

View file

@ -38,29 +38,22 @@ vscode-jsonrpc@^3.6.2:
version "3.6.2"
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-3.6.2.tgz#3b5eef691159a15556ecc500e9a8a0dd143470c8"
vscode-languageclient@^4.1.4:
version "4.1.4"
resolved "https://registry.yarnpkg.com/vscode-languageclient/-/vscode-languageclient-4.1.4.tgz#fff1a6bca4714835dca7fce35bc4ce81442fdf2c"
vscode-languageclient@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/vscode-languageclient/-/vscode-languageclient-4.4.0.tgz#b05868f6477b6f0c9910b24daae4f3e8c4b65902"
dependencies:
vscode-languageserver-protocol "^3.7.2"
vscode-languageserver-protocol "^3.10.0"
vscode-languageserver-protocol-foldingprovider@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol-foldingprovider/-/vscode-languageserver-protocol-foldingprovider-2.0.1.tgz#051d0d9e58d1b79dc4681acd48f21797f5515bfd"
dependencies:
vscode-languageserver-protocol "^3.7.2"
vscode-languageserver-types "^3.7.2"
vscode-languageserver-protocol@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.7.2.tgz#df58621c032139010888b6a9ddc969423f9ba9d6"
vscode-languageserver-protocol@^3.10.0:
version "3.10.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.10.0.tgz#f8dcdf987687f64a26e7c32d498fc781a0e886dc"
dependencies:
vscode-jsonrpc "^3.6.2"
vscode-languageserver-types "^3.7.2"
vscode-languageserver-types "^3.10.0"
vscode-languageserver-types@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.7.2.tgz#aad8846f8e3e27962648554de5a8417e358f34eb"
vscode-languageserver-types@^3.10.0:
version "3.10.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.10.0.tgz#944e5308f3b36a3f372c766f1a344e903ec9c389"
vscode-nls@^3.2.4:
version "3.2.4"

View file

@ -4,7 +4,7 @@
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
"Once accepted there, we are happy to receive an update request."
],
"version": "https://github.com/atom/language-java/commit/b9f1a853a69184363b0fb15f52da07c9660bf730",
"version": "https://github.com/atom/language-java/commit/2f20bc5a5b07686ec0139e2969431210d81b6991",
"name": "Java",
"scopeName": "source.java",
"patterns": [
@ -1424,7 +1424,7 @@
},
"variables": {
"begin": "(?x)\n(?=\n (\n (void|boolean|byte|char|short|int|float|long|double)\n |\n (?>(\\w+\\.)*[A-Z]+\\w*) # e.g. `javax.ws.rs.Response`, or `String`\n )\n (\n <[\\w<>,\\.?\\s\\[\\]]*> # e.g. `HashMap<Integer, String>`, or `List<java.lang.String>`\n )?\n (\n (\\[\\])* # int[][]\n )?\n \\s+\n [A-Za-z_$][\\w$]* # At least one identifier after space\n ([\\w\\[\\],$][\\w\\[\\],\\s]*)? # possibly primitive array or additional identifiers\n \\s*(=|;)\n)",
"end": "(?=;)",
"end": "(?=\\=|;)",
"name": "meta.definition.variable.java",
"patterns": [
{
@ -1438,20 +1438,6 @@
{
"include": "#all-types"
},
{
"begin": "=",
"beginCaptures": {
"0": {
"name": "keyword.operator.assignment.java"
}
},
"end": "(?=;)",
"patterns": [
{
"include": "#code"
}
]
},
{
"include": "#code"
}
@ -1459,7 +1445,7 @@
},
"member-variables": {
"begin": "(?=private|protected|public|native|synchronized|abstract|threadsafe|transient|static|final)",
"end": "(?=;)",
"end": "(?=\\=|;)",
"patterns": [
{
"include": "#storage-modifiers"

View file

@ -727,7 +727,7 @@
},
{
"c": "=",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java keyword.operator.assignment.java",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java keyword.operator.assignment.java",
"r": {
"dark_plus": "keyword.operator: #D4D4D4",
"light_plus": "keyword.operator: #000000",
@ -738,7 +738,7 @@
},
{
"c": " ",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
@ -749,7 +749,7 @@
},
{
"c": "0.0",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java constant.numeric.decimal.java",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java constant.numeric.decimal.java",
"r": {
"dark_plus": "constant.numeric: #B5CEA8",
"light_plus": "constant.numeric: #09885A",
@ -826,7 +826,7 @@
},
{
"c": "=",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java keyword.operator.assignment.java",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java keyword.operator.assignment.java",
"r": {
"dark_plus": "keyword.operator: #D4D4D4",
"light_plus": "keyword.operator: #000000",
@ -837,7 +837,7 @@
},
{
"c": " ",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
@ -848,7 +848,7 @@
},
{
"c": "10e3",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java constant.numeric.decimal.java",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java constant.numeric.decimal.java",
"r": {
"dark_plus": "constant.numeric: #B5CEA8",
"light_plus": "constant.numeric: #09885A",
@ -925,7 +925,7 @@
},
{
"c": "=",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java keyword.operator.assignment.java",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java keyword.operator.assignment.java",
"r": {
"dark_plus": "keyword.operator: #D4D4D4",
"light_plus": "keyword.operator: #000000",
@ -936,7 +936,7 @@
},
{
"c": " ",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
@ -947,7 +947,7 @@
},
{
"c": "134l",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java constant.numeric.decimal.java",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java constant.numeric.decimal.java",
"r": {
"dark_plus": "constant.numeric: #B5CEA8",
"light_plus": "constant.numeric: #09885A",
@ -1398,7 +1398,7 @@
},
{
"c": "=",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java keyword.operator.assignment.java",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java keyword.operator.assignment.java",
"r": {
"dark_plus": "keyword.operator: #D4D4D4",
"light_plus": "keyword.operator: #000000",
@ -1409,7 +1409,7 @@
},
{
"c": " ",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
@ -1420,7 +1420,7 @@
},
{
"c": "0",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java constant.numeric.decimal.java",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java constant.numeric.decimal.java",
"r": {
"dark_plus": "constant.numeric: #B5CEA8",
"light_plus": "constant.numeric: #09885A",
@ -2047,7 +2047,7 @@
},
{
"c": "=",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java keyword.operator.assignment.java",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java keyword.operator.assignment.java",
"r": {
"dark_plus": "keyword.operator: #D4D4D4",
"light_plus": "keyword.operator: #000000",
@ -2058,7 +2058,7 @@
},
{
"c": " ",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
@ -2069,7 +2069,7 @@
},
{
"c": "0x5",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java constant.numeric.hex.java",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java constant.numeric.hex.java",
"r": {
"dark_plus": "constant.numeric: #B5CEA8",
"light_plus": "constant.numeric: #09885A",
@ -2179,7 +2179,7 @@
},
{
"c": "=",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java keyword.operator.assignment.java",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java keyword.operator.assignment.java",
"r": {
"dark_plus": "keyword.operator: #D4D4D4",
"light_plus": "keyword.operator: #000000",
@ -2190,7 +2190,7 @@
},
{
"c": " ",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
@ -2201,7 +2201,7 @@
},
{
"c": "new",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java keyword.control.new.java",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java keyword.control.new.java",
"r": {
"dark_plus": "keyword.control: #C586C0",
"light_plus": "keyword.control: #AF00DB",
@ -2212,7 +2212,7 @@
},
{
"c": " ",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
@ -2223,7 +2223,7 @@
},
{
"c": "Vector",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java meta.function-call.java entity.name.function.java",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.function-call.java entity.name.function.java",
"r": {
"dark_plus": "entity.name.function: #DCDCAA",
"light_plus": "entity.name.function: #795E26",
@ -2234,7 +2234,7 @@
},
{
"c": "(",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java meta.function-call.java punctuation.definition.parameters.begin.bracket.round.java",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.function-call.java punctuation.definition.parameters.begin.bracket.round.java",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
@ -2245,7 +2245,7 @@
},
{
"c": ")",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java meta.function-call.java punctuation.definition.parameters.end.bracket.round.java",
"t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.function-call.java punctuation.definition.parameters.end.bracket.round.java",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",

View file

@ -8,12 +8,10 @@ import * as path from 'path';
import * as nls from 'vscode-nls';
const localize = nls.loadMessageBundle();
import { workspace, languages, ExtensionContext, extensions, Uri, LanguageConfiguration, TextDocument, FoldingRangeKind, FoldingRange, Disposable, FoldingContext } from 'vscode';
import { LanguageClient, LanguageClientOptions, RequestType, ServerOptions, TransportKind, NotificationType, DidChangeConfigurationNotification, CancellationToken } from 'vscode-languageclient';
import { workspace, languages, ExtensionContext, extensions, Uri, LanguageConfiguration } from 'vscode';
import { LanguageClient, LanguageClientOptions, RequestType, ServerOptions, TransportKind, NotificationType, DidChangeConfigurationNotification } from 'vscode-languageclient';
import TelemetryReporter from 'vscode-extension-telemetry';
import { FoldingRangeRequest, FoldingRangeRequestParam, FoldingRangeClientCapabilities, FoldingRangeKind as LSFoldingRangeKind } from 'vscode-languageserver-protocol-foldingprovider';
import { hash } from './utils/hash';
namespace VSCodeContentRequest {
@ -97,21 +95,6 @@ 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.registerProposedFeatures();
client.registerFeature({
fillClientCapabilities(capabilities: FoldingRangeClientCapabilities): void {
let textDocumentCap = capabilities.textDocument;
if (!textDocumentCap) {
textDocumentCap = capabilities.textDocument = {};
}
textDocumentCap.foldingRange = {
dynamicRegistration: false,
rangeLimit: 5000,
lineFoldingOnly: true
};
},
initialize(capabilities, documentSelector): void {
}
});
let disposable = client.start();
toDispose.push(disposable);
@ -141,8 +124,6 @@ export function activate(context: ExtensionContext) {
toDispose.push(workspace.onDidCloseTextDocument(d => handleContentChange(d.uri)));
client.sendNotification(SchemaAssociationNotification.type, getSchemaAssociation(context));
toDispose.push(initFoldingProvider());
});
let languageConfiguration: LanguageConfiguration = {
@ -154,38 +135,6 @@ export function activate(context: ExtensionContext) {
};
languages.setLanguageConfiguration('json', languageConfiguration);
languages.setLanguageConfiguration('jsonc', languageConfiguration);
function initFoldingProvider(): Disposable {
function getKind(kind: string | undefined): FoldingRangeKind | undefined {
if (kind) {
switch (kind) {
case LSFoldingRangeKind.Comment:
return FoldingRangeKind.Comment;
case LSFoldingRangeKind.Imports:
return FoldingRangeKind.Imports;
case LSFoldingRangeKind.Region:
return FoldingRangeKind.Region;
}
}
return void 0;
}
return languages.registerFoldingRangeProvider(documentSelector, {
provideFoldingRanges(document: TextDocument, context: FoldingContext, token: CancellationToken) {
const param: FoldingRangeRequestParam = {
textDocument: client.code2ProtocolConverter.asTextDocumentIdentifier(document)
};
return client.sendRequest(FoldingRangeRequest.type, param, token).then(ranges => {
if (Array.isArray(ranges)) {
return ranges.map(r => new FoldingRange(r.startLine, r.endLine, getKind(r.kind)));
}
return null;
}, error => {
client.logFailedRequest(FoldingRangeRequest.type, error);
return null;
});
}
});
}
}
export function deactivate(): Promise<any> {

View file

@ -101,8 +101,7 @@
},
"dependencies": {
"vscode-extension-telemetry": "0.0.17",
"vscode-languageclient": "^4.1.4",
"vscode-languageserver-protocol-foldingprovider": "^2.0.1",
"vscode-languageclient": "^4.4.0",
"vscode-nls": "^3.2.4"
},
"devDependencies": {

View file

@ -11,13 +11,12 @@
"vscode-json-languageserver": "./bin/vscode-json-languageserver"
},
"dependencies": {
"jsonc-parser": "^2.0.0-next.1",
"request-light": "^0.2.2",
"vscode-json-languageservice": "^3.1.2",
"vscode-languageserver": "^4.1.3",
"vscode-languageserver-protocol-foldingprovider": "^2.0.1",
"jsonc-parser": "^2.0.1",
"request-light": "^0.2.3",
"vscode-json-languageservice": "^3.1.4",
"vscode-languageserver": "^4.4.0",
"vscode-nls": "^3.2.4",
"vscode-uri": "^1.0.3"
"vscode-uri": "^1.0.5"
},
"devDependencies": {
"@types/mocha": "2.2.33",

View file

@ -19,8 +19,6 @@ import { formatError, runSafe, runSafeAsync } from './utils/runner';
import { JSONDocument, JSONSchema, getLanguageService, DocumentLanguageSettings, SchemaConfiguration } from 'vscode-json-languageservice';
import { getLanguageModelCache } from './languageModelCache';
import { FoldingRangeRequest, FoldingRangeServerCapabilities } from 'vscode-languageserver-protocol-foldingprovider';
interface ISchemaAssociations {
[pattern: string]: string[];
}
@ -81,7 +79,7 @@ connection.onInitialize((params: InitializeParams): InitializeResult => {
clientSnippetSupport = getClientCapability('textDocument.completion.completionItem.snippetSupport', false);
clientDynamicRegisterSupport = getClientCapability('workspace.symbol.dynamicRegistration', false);
foldingRangeLimit = getClientCapability('textDocument.foldingRange.rangeLimit', Number.MAX_VALUE);
const capabilities: ServerCapabilities & FoldingRangeServerCapabilities = {
const capabilities: ServerCapabilities = {
// Tell the client that the server works in FULL text document sync mode
textDocumentSync: documents.syncKind,
completionProvider: clientSnippetSupport ? { resolveProvider: true, triggerCharacters: ['"', ':'] } : void 0,
@ -382,7 +380,7 @@ connection.onColorPresentation((params, token) => {
}, [], `Error while computing color presentations for ${params.textDocument.uri}`, token);
});
connection.onRequest(FoldingRangeRequest.type, (params, token) => {
connection.onFoldingRanges((params, token) => {
return runSafe(() => {
const document = documents.get(params.textDocument.uri);
if (document) {

View file

@ -16,13 +16,7 @@ agent-base@4, agent-base@^4.1.0:
dependencies:
es6-promisify "^5.0.0"
debug@2:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
dependencies:
ms "2.0.0"
debug@^3.1.0:
debug@3.1.0, debug@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
dependencies:
@ -38,24 +32,20 @@ es6-promisify@^5.0.0:
dependencies:
es6-promise "^4.0.3"
http-proxy-agent@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-2.0.0.tgz#46482a2f0523a4d6082551709f469cb3e4a85ff4"
http-proxy-agent@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-2.1.0.tgz#e4821beef5b2142a2026bd73926fe537631c5405"
dependencies:
agent-base "4"
debug "2"
debug "3.1.0"
https-proxy-agent@2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.1.1.tgz#a7ce4382a1ba8266ee848578778122d491260fd9"
https-proxy-agent@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz#51552970fa04d723e04c56d04178c3f92592bbc0"
dependencies:
agent-base "^4.1.0"
debug "^3.1.0"
jsonc-parser@^2.0.0-next.1:
version "2.0.0-next.1"
resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-2.0.0-next.1.tgz#445a824f765a96abfbb286d759a9b1d226b18088"
jsonc-parser@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-2.0.1.tgz#9d23cd2709714fff508a1a6679d82135bee1ae60"
@ -64,68 +54,53 @@ ms@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
request-light@^0.2.2:
version "0.2.2"
resolved "https://registry.yarnpkg.com/request-light/-/request-light-0.2.2.tgz#53e48af32ad1514e45221ea5ece5ce782720f712"
request-light@^0.2.3:
version "0.2.3"
resolved "https://registry.yarnpkg.com/request-light/-/request-light-0.2.3.tgz#a18635ec6dd92f8705c019c42ef645f684d94f7e"
dependencies:
http-proxy-agent "2.0.0"
https-proxy-agent "2.1.1"
vscode-nls "^2.0.2"
http-proxy-agent "^2.1.0"
https-proxy-agent "^2.2.1"
vscode-nls "^3.2.2"
vscode-json-languageservice@^3.1.2:
version "3.1.2"
resolved "https://registry.yarnpkg.com/vscode-json-languageservice/-/vscode-json-languageservice-3.1.2.tgz#5c70fc32ad389e6da48452e7b0187ea5e70f68bf"
vscode-json-languageservice@^3.1.4:
version "3.1.4"
resolved "https://registry.yarnpkg.com/vscode-json-languageservice/-/vscode-json-languageservice-3.1.4.tgz#72e84e2754ad117f9e8d36876c1a66fe16234235"
dependencies:
jsonc-parser "^2.0.1"
vscode-languageserver-types "^3.7.2"
vscode-nls "^3.2.2"
vscode-uri "^1.0.3"
vscode-languageserver-types "^3.10.0"
vscode-nls "^3.2.4"
vscode-uri "^1.0.5"
vscode-jsonrpc@^3.6.2:
version "3.6.2"
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-3.6.2.tgz#3b5eef691159a15556ecc500e9a8a0dd143470c8"
vscode-languageserver-protocol-foldingprovider@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol-foldingprovider/-/vscode-languageserver-protocol-foldingprovider-2.0.1.tgz#051d0d9e58d1b79dc4681acd48f21797f5515bfd"
dependencies:
vscode-languageserver-protocol "^3.7.2"
vscode-languageserver-types "^3.7.2"
vscode-languageserver-protocol@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.7.2.tgz#df58621c032139010888b6a9ddc969423f9ba9d6"
vscode-languageserver-protocol@^3.10.0:
version "3.10.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.10.0.tgz#f8dcdf987687f64a26e7c32d498fc781a0e886dc"
dependencies:
vscode-jsonrpc "^3.6.2"
vscode-languageserver-types "^3.7.2"
vscode-languageserver-types "^3.10.0"
vscode-languageserver-types@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.7.2.tgz#aad8846f8e3e27962648554de5a8417e358f34eb"
vscode-languageserver-types@^3.10.0:
version "3.10.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.10.0.tgz#944e5308f3b36a3f372c766f1a344e903ec9c389"
vscode-languageserver@^4.1.3:
version "4.1.3"
resolved "https://registry.yarnpkg.com/vscode-languageserver/-/vscode-languageserver-4.1.3.tgz#937d37c955b6b9c2409388413cd6f54d1eb9fe7d"
vscode-languageserver@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver/-/vscode-languageserver-4.4.0.tgz#b6e8b37a739ccb629d92f3635f0099d191c856fa"
dependencies:
vscode-languageserver-protocol "^3.7.2"
vscode-uri "^1.0.1"
vscode-languageserver-protocol "^3.10.0"
vscode-uri "^1.0.3"
vscode-nls@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-2.0.2.tgz#808522380844b8ad153499af5c3b03921aea02da"
vscode-nls@^3.2.2:
version "3.2.2"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-3.2.2.tgz#3817eca5b985c2393de325197cf4e15eb2aa5350"
vscode-nls@^3.2.4:
vscode-nls@^3.2.2, vscode-nls@^3.2.4:
version "3.2.4"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-3.2.4.tgz#2166b4183c8aea884d20727f5449e62be69fd398"
vscode-uri@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-1.0.1.tgz#11a86befeac3c4aa3ec08623651a3c81a6d0bbc8"
vscode-uri@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-1.0.3.tgz#631bdbf716dccab0e65291a8dc25c23232085a52"
vscode-uri@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-1.0.5.tgz#3b899a8ef71c37f3054d79bdbdda31c7bf36f20d"

View file

@ -38,29 +38,22 @@ vscode-jsonrpc@^3.6.2:
version "3.6.2"
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-3.6.2.tgz#3b5eef691159a15556ecc500e9a8a0dd143470c8"
vscode-languageclient@^4.1.4:
version "4.1.4"
resolved "https://registry.yarnpkg.com/vscode-languageclient/-/vscode-languageclient-4.1.4.tgz#fff1a6bca4714835dca7fce35bc4ce81442fdf2c"
vscode-languageclient@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/vscode-languageclient/-/vscode-languageclient-4.4.0.tgz#b05868f6477b6f0c9910b24daae4f3e8c4b65902"
dependencies:
vscode-languageserver-protocol "^3.7.2"
vscode-languageserver-protocol "^3.10.0"
vscode-languageserver-protocol-foldingprovider@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol-foldingprovider/-/vscode-languageserver-protocol-foldingprovider-2.0.1.tgz#051d0d9e58d1b79dc4681acd48f21797f5515bfd"
dependencies:
vscode-languageserver-protocol "^3.7.2"
vscode-languageserver-types "^3.7.2"
vscode-languageserver-protocol@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.7.2.tgz#df58621c032139010888b6a9ddc969423f9ba9d6"
vscode-languageserver-protocol@^3.10.0:
version "3.10.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.10.0.tgz#f8dcdf987687f64a26e7c32d498fc781a0e886dc"
dependencies:
vscode-jsonrpc "^3.6.2"
vscode-languageserver-types "^3.7.2"
vscode-languageserver-types "^3.10.0"
vscode-languageserver-types@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.7.2.tgz#aad8846f8e3e27962648554de5a8417e358f34eb"
vscode-languageserver-types@^3.10.0:
version "3.10.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.10.0.tgz#944e5308f3b36a3f372c766f1a344e903ec9c389"
vscode-nls@^3.2.4:
version "3.2.4"

View file

@ -1,4 +1,4 @@
{
"displayName": "Less Language Basics",
"description": "Provides syntax highlighting, bracket matching and folding Less files."
"description": "Provides syntax highlighting, bracket matching and folding in Less files."
}

View file

@ -4,23 +4,25 @@
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
"Once accepted there, we are happy to receive an update request."
],
"version": "https://github.com/textmate/lua.tmbundle/commit/42da2c6ff5d86c068f72520f856190f413911a80",
"version": "https://github.com/textmate/lua.tmbundle/commit/8ae5641365b28f697121ba1133890e8d81f5b00e",
"name": "Lua",
"scopeName": "source.lua",
"comment": "Lua Syntax: version 0.8",
"patterns": [
{
"begin": "\\b((local\\b)\\s+)?(function)\\s*(\\s+[a-zA-Z_][a-zA-Z0-9_]*(\\.[a-zA-Z_][a-zA-Z0-9_]*)*(:[a-zA-Z_][a-zA-Z0-9_]*)?\\s*)?(\\()",
"begin": "\\b(?:(local)\\s+)?(function)\\s*(?:\\s+([a-zA-Z_][a-zA-Z0-9_]*(?:([\\.:])[a-zA-Z_][a-zA-Z0-9_]*)?)\\s*)?(\\()",
"beginCaptures": {
"1": {
"name": "storage.modifier.local.lua"
},
"3": {
"2": {
"name": "keyword.control.lua"
},
"4": {
"3": {
"name": "entity.name.function.lua"
},
"4": {
"name": "punctuation.separator.parameter.lua"
},
"5": {
"name": "punctuation.definition.parameters.begin.lua"
}
@ -36,6 +38,10 @@
{
"match": "[a-zA-Z_][a-zA-Z0-9_]*",
"name": "variable.parameter.function.lua"
},
{
"match": ",",
"name": "punctuation.separator.arguments.lua"
}
]
},

View file

@ -55,7 +55,18 @@
}
},
{
"c": " fact ",
"c": " ",
"t": "source.lua meta.function.lua",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF"
}
},
{
"c": "fact",
"t": "source.lua meta.function.lua entity.name.function.lua",
"r": {
"dark_plus": "entity.name.function: #DCDCAA",
@ -66,7 +77,7 @@
}
},
{
"c": "(",
"c": " ",
"t": "source.lua meta.function.lua",
"r": {
"dark_plus": "default: #D4D4D4",
@ -76,6 +87,17 @@
"hc_black": "default: #FFFFFF"
}
},
{
"c": "(",
"t": "source.lua meta.function.lua punctuation.definition.parameters.begin.lua",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF"
}
},
{
"c": "n",
"t": "source.lua meta.function.lua variable.parameter.function.lua",

View file

@ -36,7 +36,9 @@
"surroundingPairs": [
["(", ")"],
["[", "]"],
["`", "`"]
["`", "`"],
["_", "_"],
["*", "*"]
],
"folding": {
"offSide": true,

View file

@ -24,7 +24,7 @@ export function activate(context: vscode.ExtensionContext) {
const telemetryReporter = loadDefaultTelemetryReporter();
context.subscriptions.push(telemetryReporter);
const contributions = getMarkdownExtensionContributions();
const contributions = getMarkdownExtensionContributions(context);
const cspArbiter = new ExtensionContentSecurityPolicyArbiter(context.globalState, context.workspaceState);
const engine = new MarkdownEngine(contributions, githubSlugifier);

View file

@ -271,6 +271,14 @@ export class MarkdownPreview {
this.editor.title = MarkdownPreview.getPreviewTitle(this._resource, this._locked);
}
private get iconPath() {
const root = path.join(this._contributions.extensionPath, 'media');
return {
light: vscode.Uri.file(path.join(root, 'Preview.svg')),
dark: vscode.Uri.file(path.join(root, 'Preview_inverse.svg'))
};
}
private isPreviewOf(resource: vscode.Uri): boolean {
return this._resource.fsPath === resource.fsPath;
}
@ -327,6 +335,7 @@ export class MarkdownPreview {
const content = await this._contentProvider.provideTextDocumentContent(document, this._previewConfigurations, this.line, this.state);
if (this._resource === resource) {
this.editor.title = MarkdownPreview.getPreviewTitle(this._resource, this._locked);
this.editor.iconPath = this.iconPath;
this.editor.webview.options = MarkdownPreview.getWebviewOptions(resource, this._contributions);
this.editor.webview.html = content;
}

View file

@ -26,6 +26,7 @@ const resolveExtensionResources = (extension: vscode.Extension<any>, resourcePat
};
export interface MarkdownContributions {
readonly extensionPath: string;
readonly previewScripts: vscode.Uri[];
readonly previewStyles: vscode.Uri[];
readonly markdownItPlugins: Thenable<(md: any) => any>[];
@ -40,6 +41,10 @@ class MarkdownExtensionContributions implements MarkdownContributions {
private _loaded = false;
public constructor(
public readonly extensionPath: string,
) { }
public get previewScripts(): vscode.Uri[] {
this.ensureLoaded();
return this._scripts;
@ -111,6 +116,6 @@ class MarkdownExtensionContributions implements MarkdownContributions {
}
}
export function getMarkdownExtensionContributions(): MarkdownContributions {
return new MarkdownExtensionContributions();
export function getMarkdownExtensionContributions(context: vscode.ExtensionContext): MarkdownContributions {
return new MarkdownExtensionContributions(context.extensionPath);
}

View file

@ -9,6 +9,7 @@ import { MarkdownContributions } from '../markdownExtensions';
import { githubSlugifier } from '../slugify';
const emptyContributions = new class implements MarkdownContributions {
readonly extensionPath = '';
readonly previewScripts: vscode.Uri[] = [];
readonly previewStyles: vscode.Uri[] = [];
readonly previewResourceRoots: vscode.Uri[] = [];

View file

@ -1,8 +1,10 @@
{
"version": "0.1.0",
"version": "2.0.0",
"command": "npm",
"isShellCommand": true,
"showOutput": "silent",
"type": "shell",
"presentation": {
"reveal": "silent",
},
"args": ["run", "compile"],
"isBackground": true,
"problemMatcher": "$tsc-watch"

View file

@ -29,5 +29,5 @@ The extension provides code lense actions to run or debug a script from the edit
- `npm.exclude` - Glob patterns for folders that should be excluded from automatic script detection. The pattern is matched against the **absolute path** of the package.json. For example, to exclude all test folders use '&ast;&ast;/test/&ast;&ast;'.
- `npm.enableScriptExplorer` - Enable an explorer view for npm scripts.
- `npm.scriptExplorerAction` - The default click action: `open` or `run`, the default is `open`.
- `npm.scriptCodeLens.enable` - Enable/disable the code lenses to run a script.
- `npm.scriptCodeLens.enable` - Enable/disable the code lenses to run a script, the default is `false`.

View file

@ -178,12 +178,6 @@
"scope": "resource",
"description": "%config.npm.runSilent%"
},
"npm.scriptCodeLens.enable": {
"type": "boolean",
"default": true,
"scope": "resource",
"description": "%config.scriptCodeLens.enable%"
},
"npm.packageManager": {
"scope": "resource",
"type": "string",

View file

@ -7,7 +7,6 @@
"config.npm.exclude": "Configure glob patterns for folders that should be excluded from automatic script detection.",
"config.npm.enableScriptExplorer": "Enable an explorer view for npm scripts.",
"config.npm.scriptExplorerAction": "The default click action used in the scripts explorer: 'open' or 'run', the default is 'open'.",
"config.scriptCodeLens.enable": "Enable the code lens to 'Run' or 'Debug' an npm script.",
"npm.parseError": "Npm task detection: failed to parse the file {0}",
"taskdef.script": "The npm script to customize.",
"taskdef.path": "The path to the folder of the package.json file that provides the script. Can be omitted.",

View file

@ -1,86 +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';
import {
ExtensionContext, CodeLensProvider, TextDocument, commands, ProviderResult, CodeLens, CancellationToken,
workspace, tasks, Range, Command, Event, EventEmitter
} from 'vscode';
import {
createTask, startDebugging, findAllScriptRanges, extractDebugArgFromScript
} from './tasks';
import * as nls from 'vscode-nls';
const localize = nls.loadMessageBundle();
export class NpmLensProvider implements CodeLensProvider {
private extensionContext: ExtensionContext;
private _onDidChangeCodeLenses: EventEmitter<void> = new EventEmitter<void>();
readonly onDidChangeCodeLenses: Event<void> = this._onDidChangeCodeLenses.event;
constructor(context: ExtensionContext) {
this.extensionContext = context;
context.subscriptions.push(commands.registerCommand('npm.runScriptFromLens', this.runScriptFromLens, this));
context.subscriptions.push(commands.registerCommand('npm.debugScriptFromLens', this.debugScriptFromLens, this));
}
public provideCodeLenses(document: TextDocument, _token: CancellationToken): ProviderResult<CodeLens[]> {
let result = findAllScriptRanges(document.getText());
let folder = workspace.getWorkspaceFolder(document.uri);
let lenses: CodeLens[] = [];
if (folder && !workspace.getConfiguration('npm', folder.uri).get<string>('scriptCodeLens.enable', 'true')) {
return lenses;
}
result.forEach((value, key) => {
let start = document.positionAt(value[0]);
let end = document.positionAt(value[0] + value[1]);
let range = new Range(start, end);
let command: Command = {
command: 'npm.runScriptFromLens',
title: localize('run', "Run"),
arguments: [document, key]
};
let lens: CodeLens = new CodeLens(range, command);
lenses.push(lens);
let debugArgs = extractDebugArgFromScript(value[2]);
if (debugArgs) {
command = {
command: 'npm.debugScriptFromLens',
title: localize('debug', "Debug"),
arguments: [document, key, debugArgs[0], debugArgs[1]]
};
lens = new CodeLens(range, command);
lenses.push(lens);
}
});
return lenses;
}
public refresh() {
this._onDidChangeCodeLenses.fire();
}
public runScriptFromLens(document: TextDocument, script: string) {
let uri = document.uri;
let folder = workspace.getWorkspaceFolder(uri);
if (folder) {
let task = createTask(script, `run ${script}`, folder, uri);
tasks.executeTask(task);
}
}
public debugScriptFromLens(document: TextDocument, script: string, protocol: string, port: number) {
let uri = document.uri;
let folder = workspace.getWorkspaceFolder(uri);
if (folder) {
startDebugging(script, protocol, port, folder);
}
}
}

View file

@ -6,22 +6,21 @@
import * as httpRequest from 'request-light';
import * as vscode from 'vscode';
import { addJSONProviders } from './features/jsonContributions';
import { NpmScriptsTreeDataProvider } from './npmView';
import { invalidateScriptsCache, NpmTaskProvider } from './tasks';
import { NpmLensProvider } from './lenses';
import { invalidateTasksCache, NpmTaskProvider } from './tasks';
import { invalidateHoverScriptsCache, NpmScriptHoverProvider } from './scriptHover';
export async function activate(context: vscode.ExtensionContext): Promise<void> {
const taskProvider = registerTaskProvider(context);
const treeDataProvider = registerExplorer(context);
const lensProvider = registerLensProvider(context);
const hoverProvider = registerHoverProvider(context);
configureHttpRequest();
vscode.workspace.onDidChangeConfiguration((e) => {
let d = vscode.workspace.onDidChangeConfiguration((e) => {
configureHttpRequest();
if (e.affectsConfiguration('npm.exclude')) {
invalidateScriptsCache();
invalidateTasksCache();
if (treeDataProvider) {
treeDataProvider.refresh();
}
@ -31,21 +30,29 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
treeDataProvider.refresh();
}
}
if (e.affectsConfiguration('npm.scriptCodeLens.enable')) {
if (lensProvider) {
lensProvider.refresh();
}
}
});
context.subscriptions.push(d);
d = vscode.workspace.onDidChangeTextDocument((e) => {
invalidateHoverScriptsCache(e.document);
});
context.subscriptions.push(d);
context.subscriptions.push(addJSONProviders(httpRequest.xhr));
}
function registerTaskProvider(context: vscode.ExtensionContext): vscode.Disposable | undefined {
function invalidateScriptCaches() {
invalidateHoverScriptsCache();
invalidateTasksCache();
}
if (vscode.workspace.workspaceFolders) {
let watcher = vscode.workspace.createFileSystemWatcher('**/package.json');
watcher.onDidChange((_e) => invalidateScriptsCache());
watcher.onDidDelete((_e) => invalidateScriptsCache());
watcher.onDidCreate((_e) => invalidateScriptsCache());
watcher.onDidChange((_e) => invalidateScriptCaches());
watcher.onDidDelete((_e) => invalidateScriptCaches());
watcher.onDidCreate((_e) => invalidateScriptCaches());
context.subscriptions.push(watcher);
let provider: vscode.TaskProvider = new NpmTaskProvider(context);
@ -66,15 +73,15 @@ function registerExplorer(context: vscode.ExtensionContext): NpmScriptsTreeDataP
return undefined;
}
function registerLensProvider(context: vscode.ExtensionContext): NpmLensProvider | undefined {
function registerHoverProvider(context: vscode.ExtensionContext): NpmScriptHoverProvider | undefined {
if (vscode.workspace.workspaceFolders) {
let npmSelector: vscode.DocumentSelector = {
language: 'json',
scheme: 'file',
pattern: '**/package.json'
};
let provider = new NpmLensProvider(context);
context.subscriptions.push(vscode.languages.registerCodeLensProvider(npmSelector, provider));
let provider = new NpmScriptHoverProvider(context);
context.subscriptions.push(vscode.languages.registerHoverProvider(npmSelector, provider));
return provider;
}
return undefined;

View file

@ -0,0 +1,126 @@
/*---------------------------------------------------------------------------------------------
* 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 {
ExtensionContext, TextDocument, commands, ProviderResult, CancellationToken,
workspace, tasks, Range, HoverProvider, Hover, Position, MarkdownString, Uri
} from 'vscode';
import {
createTask, startDebugging, findAllScriptRanges, extractDebugArgFromScript
} from './tasks';
import * as nls from 'vscode-nls';
const localize = nls.loadMessageBundle();
let cachedDocument: Uri | undefined = undefined;
let cachedScriptsMap: Map<string, [number, number, string]> | undefined = undefined;
export function invalidateHoverScriptsCache(document?: TextDocument) {
if (!document) {
cachedDocument = undefined;
return;
}
if (document.uri === cachedDocument) {
cachedDocument = undefined;
}
}
export class NpmScriptHoverProvider implements HoverProvider {
private extensionContext: ExtensionContext;
constructor(context: ExtensionContext) {
this.extensionContext = context;
context.subscriptions.push(commands.registerCommand('npm.runScriptFromHover', this.runScriptFromHover, this));
context.subscriptions.push(commands.registerCommand('npm.debugScriptFromHover', this.debugScriptFromHover, this));
}
public provideHover(document: TextDocument, position: Position, _token: CancellationToken): ProviderResult<Hover> {
let hover: Hover | undefined = undefined;
if (!cachedDocument || cachedDocument.fsPath !== document.uri.fsPath) {
cachedScriptsMap = findAllScriptRanges(document.getText());
cachedDocument = document.uri;
}
cachedScriptsMap!.forEach((value, key) => {
let start = document.positionAt(value[0]);
let end = document.positionAt(value[0] + value[1]);
let range = new Range(start, end);
if (range.contains(position)) {
let contents: MarkdownString = new MarkdownString();
contents.isTrusted = true;
contents.appendMarkdown(this.createRunScriptMarkdown(key, document.uri));
let debugArgs = extractDebugArgFromScript(value[2]);
if (debugArgs) {
contents.appendMarkdown(this.createDebugScriptMarkdown(key, document.uri, debugArgs[0], debugArgs[1]));
}
hover = new Hover(contents);
}
});
return hover;
}
private createRunScriptMarkdown(script: string, documentUri: Uri): string {
let args = {
documentUri: documentUri,
script: script,
};
return this.createMarkdownLink(
localize('runScript', 'Run Script'),
'npm.runScriptFromHover',
args,
localize('runScript.tooltip', 'Run the script as a task')
);
}
private createDebugScriptMarkdown(script: string, documentUri: Uri, protocol: string, port: number): string {
let args = {
documentUri: documentUri,
script: script,
protocol: protocol,
port: port
};
return this.createMarkdownLink(
localize('debugScript', 'Debug Script'),
'npm.debugScriptFromHover',
args,
localize('debugScript.tooltip', 'Runs the script under the debugger'),
'|'
);
}
private createMarkdownLink(label: string, cmd: string, args: any, tooltip: string, separator?: string): string {
let encodedArgs = encodeURIComponent(JSON.stringify(args));
let prefix = '';
if (separator) {
prefix = ` ${separator} `;
}
return `${prefix}[${label}](command:${cmd}?${encodedArgs} "${tooltip}")`;
}
public runScriptFromHover(args: any) {
let script = args.script;
let documentUri = args.documentUri;
let folder = workspace.getWorkspaceFolder(documentUri);
if (folder) {
let task = createTask(script, `run ${script}`, folder, documentUri);
tasks.executeTask(task);
}
}
public debugScriptFromHover(args: any) {
let script = args.script;
let documentUri = args.documentUri;
let protocol = args.protocol;
let port = args.port;
let folder = workspace.getWorkspaceFolder(documentUri);
if (folder) {
startDebugging(script, protocol, port, folder);
}
}
}

View file

@ -41,7 +41,7 @@ export class NpmTaskProvider implements TaskProvider {
}
}
export function invalidateScriptsCache() {
export function invalidateTasksCache() {
cachedTasks = undefined;
}
@ -371,6 +371,9 @@ async function findAllScripts(buffer: string): Promise<StringMap> {
export function findAllScriptRanges(buffer: string): Map<string, [number, number, string]> {
var scripts: Map<string, [number, number, string]> = new Map();
let script: string | undefined = undefined;
let offset: number;
let length: number;
let inScripts = false;
let visitor: JSONVisitor = {
@ -381,18 +384,20 @@ export function findAllScriptRanges(buffer: string): Map<string, [number, number
inScripts = false;
}
},
onLiteralValue(value: any, offset: number, length: number) {
onLiteralValue(value: any, _offset: number, _length: number) {
if (script) {
scripts.set(script, [offset, length, value]);
script = undefined;
}
},
onObjectProperty(property: string, offset: number, length: number) {
onObjectProperty(property: string, off: number, len: number) {
if (property === 'scripts') {
inScripts = true;
}
else if (inScripts) {
script = property;
offset = off;
length = len;
}
}
};

View file

@ -3,7 +3,7 @@
"version": "0.0.1",
"description": "Dependencies shared by all extensions",
"dependencies": {
"typescript": "3.0.1-insiders.20180713"
"typescript": "3.0.1-insiders.20180723"
},
"scripts": {
"postinstall": "node ./postinstall"

View file

@ -4,7 +4,7 @@
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
"Once accepted there, we are happy to receive an update request."
],
"version": "https://github.com/MagicStack/MagicPython/commit/b453f26ed856c9b16a053517c41207e3a72cc7d5",
"version": "https://github.com/MagicStack/MagicPython/commit/fb56c6a98d684e30bed1b0f9647e85741a48f914",
"name": "MagicPython",
"scopeName": "source.python",
"patterns": [
@ -97,7 +97,8 @@
},
"docstring-statement": {
"begin": "^(?=\\s*[rR]?(\\'\\'\\'|\\\"\\\"\\\"|\\'|\\\"))",
"end": "(?<=\\'\\'\\'|\\\"\\\"\\\"|\\'|\\\")",
"comment": "the string either terminates correctly or by the beginning of a new line (this is for single line docstrings that aren't terminated) AND it's not followed by another docstring",
"end": "((?<=\\1)|^)(?!\\s*[rR]?(\\'\\'\\'|\\\"\\\"\\\"|\\'|\\\"))",
"patterns": [
{
"include": "#docstring"
@ -164,7 +165,7 @@
{
"name": "string.quoted.docstring.single.python",
"begin": "(\\'|\\\")",
"end": "(\\1)|((?<!\\\\)\\n)",
"end": "(\\1)|(\\n)",
"beginCaptures": {
"1": {
"name": "punctuation.definition.string.begin.python"
@ -190,7 +191,7 @@
{
"name": "string.quoted.docstring.raw.single.python",
"begin": "([rR])(\\'|\\\")",
"end": "(\\2)|((?<!\\\\)\\n)",
"end": "(\\2)|(\\n)",
"beginCaptures": {
"1": {
"name": "storage.type.string.python"
@ -847,40 +848,45 @@
"match": "\\\\$"
},
"string-formatting": {
"name": "constant.character.format.placeholder.other.python",
"match": "(?x)\n % (\\([\\w\\s]*\\))?\n [-+#0 ]*\n (\\d+|\\*)? (\\.(\\d+|\\*))?\n ([hlL])?\n [diouxXeEfFgGcrsa%]\n"
"name": "meta.format.percent.python",
"match": "(?x)\n (\n % (\\([\\w\\s]*\\))?\n [-+#0 ]*\n (\\d+|\\*)? (\\.(\\d+|\\*))?\n ([hlL])?\n [diouxXeEfFgGcrsa%]\n )\n",
"captures": {
"1": {
"name": "constant.character.format.placeholder.other.python"
}
}
},
"string-brace-formatting": {
"patterns": [
{
"name": "constant.character.format.placeholder.other.python",
"match": "(?x)\n (?:\n {{ | }}\n | (?:\n {\n \\w*? (\\.[[:alpha:]_]\\w*? | \\[[^\\]'\"]+\\])*?\n (![rsa])?\n ( : \\w? [<>=^]? [-+ ]? \\#?\n \\d* ,? (\\.\\d+)? [bcdeEfFgGnosxX%]? )?\n })\n )\n",
"name": "meta.format.brace.python",
"match": "(?x)\n (\n {{ | }}\n | (?:\n {\n \\w*? (\\.[[:alpha:]_]\\w*? | \\[[^\\]'\"]+\\])*?\n (![rsa])?\n ( : \\w? [<>=^]? [-+ ]? \\#?\n \\d* ,? (\\.\\d+)? [bcdeEfFgGnosxX%]? )?\n })\n )\n",
"captures": {
"2": {
"name": "storage.type.format.python"
"1": {
"name": "constant.character.format.placeholder.other.python"
},
"3": {
"name": "storage.type.format.python"
},
"4": {
"name": "storage.type.format.python"
}
}
},
{
"name": "constant.character.format.placeholder.other.python",
"begin": "(?x)\n \\{\n \\w*? (\\.[[:alpha:]_]\\w*? | \\[[^\\]'\"]+\\])*?\n (![rsa])?\n (:)\n (?=[^'\"}\\n]*\\})\n",
"end": "\\}",
"beginCaptures": {
"2": {
"name": "storage.type.format.python"
"name": "meta.format.brace.python",
"match": "(?x)\n (\n {\n \\w*? (\\.[[:alpha:]_]\\w*? | \\[[^\\]'\"]+\\])*?\n (![rsa])?\n (:)\n (\n [^'\"{}\\n]+?\n |\n \\{ [^'\"}\\n]*? \\}\n )*\n }\n )\n",
"captures": {
"1": {
"name": "constant.character.format.placeholder.other.python"
},
"3": {
"name": "storage.type.format.python"
},
"4": {
"name": "storage.type.format.python"
}
},
"patterns": [
{
"match": "(?x) \\{ [^'\"}\\n]*? \\} (?=.*?\\})\n"
}
]
}
}
]
},
@ -4537,7 +4543,7 @@
},
"string-quoted-single-line": {
"name": "string.quoted.single.python",
"begin": "(\\b[rR](?=[uU]))?([uU])?((['\"]))",
"begin": "(?:\\b([rR])(?=[uU]))?([uU])?((['\"]))",
"end": "(\\3)|((?<!\\\\)\\n)",
"beginCaptures": {
"1": {
@ -4711,7 +4717,7 @@
},
"string-quoted-multi-line": {
"name": "string.quoted.multi.python",
"begin": "(\\b[rR](?=[uU]))?([uU])?('''|\"\"\")",
"begin": "(?:\\b([rR])(?=[uU]))?([uU])?('''|\"\"\")",
"end": "(\\3)",
"beginCaptures": {
"1": {

View file

@ -73,7 +73,8 @@
"type": "boolean",
"default": false,
"description": "%typescript.disableAutomaticTypeAcquisition%",
"scope": "window"
"scope": "window",
"tags": ["backgroundOnlineFeature"]
},
"typescript.npm": {
"type": [
@ -384,6 +385,12 @@
"build",
"watch"
],
"enumDescriptions": [
"%typescript.tsc.autoDetect.on%",
"%typescript.tsc.autoDetect.off%",
"%typescript.tsc.autoDetect.build%",
"%typescript.tsc.autoDetect.watch%"
],
"description": "%typescript.tsc.autoDetect%",
"scope": "window"
},
@ -462,6 +469,11 @@
"relative",
"non-relative"
],
"enumDescriptions": [
"%typescript.preferences.importModuleSpecifier.auto%",
"%typescript.preferences.importModuleSpecifier.relative%",
"%typescript.preferences.importModuleSpecifier.nonRelative%"
],
"default": "auto",
"description": "%typescript.preferences.importModuleSpecifier%",
"scope": "resource"
@ -477,18 +489,6 @@
"description": "%typescript.preferences.importModuleSpecifier%",
"scope": "resource"
},
"javascript.showUnused": {
"type": "boolean",
"default": true,
"description": "%typescript.showUnused%",
"scope": "resource"
},
"typescript.showUnused": {
"type": "boolean",
"default": true,
"description": "%typescript.showUnused%",
"scope": "resource"
},
"typescript.updateImportsOnFileMove.enabled": {
"type": "string",
"enum": [

View file

@ -15,7 +15,7 @@
"javascript.format.enable": "Enable/disable default JavaScript formatter.",
"format.insertSpaceAfterCommaDelimiter": "Defines space handling after a comma delimiter.",
"format.insertSpaceAfterConstructor": "Defines space handling after the constructor keyword. Requires using TypeScript 2.3.0 or newer in the workspace.",
"format.insertSpaceAfterSemicolonInForStatements": " Defines space handling after a semicolon in a for statement.",
"format.insertSpaceAfterSemicolonInForStatements": "Defines space handling after a semicolon in a for statement.",
"format.insertSpaceBeforeAndAfterBinaryOperators": "Defines space handling after a binary operator.",
"format.insertSpaceAfterKeywordsInControlFlowStatements": "Defines space handling after keywords in a control flow statement.",
"format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": "Defines space handling after function keyword for anonymous functions.",
@ -42,19 +42,25 @@
"typescript.npm": "Specifies the path to the NPM executable used for Automatic Type Acquisition. Requires using TypeScript 2.3.4 or newer in the workspace.",
"typescript.check.npmIsInstalled": "Check if NPM is installed for Automatic Type Acquisition.",
"javascript.nameSuggestions": "Enable/disable including unique names from the file in JavaScript suggestion lists.",
"typescript.tsc.autoDetect": "Controls auto detection of tsc tasks. 'off' disables this feature. 'build' only creates single run compile tasks. 'watch' only creates compile and watch tasks. 'on' creates both build and watch tasks. Default is 'on'.",
"typescript.tsc.autoDetect": "Controls auto detection of tsc tasks.",
"typescript.tsc.autoDetect.off": "Disable this feature.",
"typescript.tsc.autoDetect.on": "Create both build and watch tasks.",
"typescript.tsc.autoDetect.build": "Only create single run compile tasks.",
"typescript.tsc.autoDetect.watch": "Only create compile and watch tasks.",
"typescript.problemMatchers.tsc.label": "TypeScript problems",
"typescript.problemMatchers.tscWatch.label": "TypeScript problems (watch mode)",
"typescript.quickSuggestionsForPaths": "Enable/disable quick suggestions when typing out an import path.",
"typescript.locale": "Sets the locale used to report JavaScript and TypeScript errors. Requires using TypeScript 2.6.0 or newer in the workspace. Default of 'null' uses VS Code's locale.",
"javascript.implicitProjectConfig.experimentalDecorators": "Enable/disable 'experimentalDecorators' for JavaScript files that are not part of a project. Existing jsconfig.json or tsconfig.json files override this setting. Requires using TypeScript 2.3.1 or newer in the workspace.",
"javascript.implicitProjectConfig.experimentalDecorators": "Enable/disable `experimentalDecorators` for JavaScript files that are not part of a project. Existing jsconfig.json or tsconfig.json files override this setting. Requires using TypeScript 2.3.1 or newer in the workspace.",
"typescript.autoImportSuggestions.enabled": "Enable/disable auto import suggestions. Requires using TypeScript 2.6.1 or newer in the workspace.",
"taskDefinition.tsconfig.description": "The tsconfig file that defines the TS build.",
"javascript.suggestionActions.enabled": "Enable/disable suggestion diagnostics for JavaScript files in the editor. Requires using TypeScript 2.8 or newer in the workspace.",
"typescript.suggestionActions.enabled": "Enable/disable suggestion diagnostics for TypeScript files in the editor. Requires using TypeScript 2.8 or newer in the workspace.",
"typescript.preferences.quoteStyle": "Preferred quote style to use for quick fixes: 'single' quotes, 'double' quotes, or 'auto' infer quote type from existing imports. Requires using TypeScript 2.9 or newer in the workspace.",
"typescript.preferences.importModuleSpecifier": "Preferred path style for auto imports:\n- \"relative\" to the file location.\n- \"non-relative\" based on the 'baseUrl' configured in your 'jsconfig.json' / 'tsconfig.json'.\n- \"auto\" infer the shortest path type.\nRequires using TypeScript 2.9 or newer in the workspace.",
"typescript.showUnused": "Enable/disable highlighting of unused variables in code. Requires using TypeScript 2.9 or newer in the workspace.",
"typescript.preferences.importModuleSpecifier": "Preferred path style for auto imports.",
"typescript.preferences.importModuleSpecifier.auto": "Infer the shortest path type.",
"typescript.preferences.importModuleSpecifier.relative": "Relative to the file location.",
"typescript.preferences.importModuleSpecifier.nonRelative": "Based on the `baseUrl` configured in your `jsconfig.json` / `tsconfig.json`.",
"typescript.updateImportsOnFileMove.enabled": "Enable/disable automatic updating of import paths when you rename or move a file in VS Code. Possible values are: 'prompt' on each rename, 'always' update paths automatically, and 'never' rename paths and don't prompt me. Requires using TypeScript 2.9 or newer in the workspace.",
"typescript.autoClosingTags": "Enable/disable automatic closing of JSX tags. Requires using TypeScript 3.0 or newer in the workspace."
}
}

View file

@ -3,18 +3,18 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { CancellationToken, CodeLens, CodeLensProvider, Event, EventEmitter, Position, Range, TextDocument, Uri } from 'vscode';
import * as vscode from 'vscode';
import * as Proto from '../protocol';
import { ITypeScriptServiceClient } from '../typescriptService';
import { escapeRegExp } from '../utils/regexp';
import * as typeConverters from '../utils/typeConverters';
export class ReferencesCodeLens extends CodeLens {
export class ReferencesCodeLens extends vscode.CodeLens {
constructor(
public document: Uri,
public document: vscode.Uri,
public file: string,
range: Range
range: vscode.Range
) {
super(range);
}
@ -26,7 +26,7 @@ export class CachedNavTreeResponse {
private document: string = '';
public execute(
document: TextDocument,
document: vscode.TextDocument,
f: () => Promise<Proto.NavTreeResponse>
) {
if (this.matches(document)) {
@ -36,12 +36,12 @@ export class CachedNavTreeResponse {
return this.update(document, f());
}
private matches(document: TextDocument): boolean {
private matches(document: vscode.TextDocument): boolean {
return this.version === document.version && this.document === document.uri.toString();
}
private update(
document: TextDocument,
document: vscode.TextDocument,
response: Promise<Proto.NavTreeResponse>
): Promise<Proto.NavTreeResponse> {
this.response = response;
@ -51,19 +51,19 @@ export class CachedNavTreeResponse {
}
}
export abstract class TypeScriptBaseCodeLensProvider implements CodeLensProvider {
private onDidChangeCodeLensesEmitter = new EventEmitter<void>();
export abstract class TypeScriptBaseCodeLensProvider implements vscode.CodeLensProvider {
private onDidChangeCodeLensesEmitter = new vscode.EventEmitter<void>();
public constructor(
protected client: ITypeScriptServiceClient,
private cachedResponse: CachedNavTreeResponse
) { }
public get onDidChangeCodeLenses(): Event<void> {
public get onDidChangeCodeLenses(): vscode.Event<void> {
return this.onDidChangeCodeLensesEmitter.event;
}
async provideCodeLenses(document: TextDocument, token: CancellationToken): Promise<CodeLens[]> {
async provideCodeLenses(document: vscode.TextDocument, token: vscode.CancellationToken): Promise<vscode.CodeLens[]> {
const filepath = this.client.toPath(document.uri);
if (!filepath) {
return [];
@ -76,7 +76,7 @@ export abstract class TypeScriptBaseCodeLensProvider implements CodeLensProvider
}
const tree = response.body;
const referenceableSpans: Range[] = [];
const referenceableSpans: vscode.Range[] = [];
if (tree && tree.childItems) {
tree.childItems.forEach(item => this.walkNavTree(document, item, null, referenceableSpans));
}
@ -87,16 +87,16 @@ export abstract class TypeScriptBaseCodeLensProvider implements CodeLensProvider
}
protected abstract extractSymbol(
document: TextDocument,
document: vscode.TextDocument,
item: Proto.NavigationTree,
parent: Proto.NavigationTree | null
): Range | null;
): vscode.Range | null;
private walkNavTree(
document: TextDocument,
document: vscode.TextDocument,
item: Proto.NavigationTree,
parent: Proto.NavigationTree | null,
results: Range[]
results: vscode.Range[]
): void {
if (!item) {
return;
@ -109,7 +109,7 @@ export abstract class TypeScriptBaseCodeLensProvider implements CodeLensProvider
(item.childItems || []).forEach(child => this.walkNavTree(document, child, item, results));
}
protected getSymbolRange(document: TextDocument, item: Proto.NavigationTree): Range | null {
protected getSymbolRange(document: vscode.TextDocument, item: Proto.NavigationTree): vscode.Range | null {
if (!item) {
return null;
}
@ -131,8 +131,8 @@ export abstract class TypeScriptBaseCodeLensProvider implements CodeLensProvider
const identifierMatch = new RegExp(`^(.*?(\\b|\\W))${escapeRegExp(item.text || '')}(\\b|\\W)`, 'gm');
const match = identifierMatch.exec(text);
const prefixLength = match ? match.index + match[1].length : 0;
const startOffset = document.offsetAt(new Position(range.start.line, range.start.character)) + prefixLength;
return new Range(
const startOffset = document.offsetAt(new vscode.Position(range.start.line, range.start.character)) + prefixLength;
return new vscode.Range(
document.positionAt(startOffset),
document.positionAt(startOffset + item.text.length));
}

View file

@ -4,12 +4,12 @@
*--------------------------------------------------------------------------------------------*/
import * as fs from 'fs';
import { CancellationTokenSource, Disposable, EventEmitter, TextDocument, TextDocumentChangeEvent, TextDocumentContentChangeEvent, Uri, workspace } from 'vscode';
import * as vscode from 'vscode';
import * as Proto from '../protocol';
import { ITypeScriptServiceClient } from '../typescriptService';
import API from '../utils/api';
import { Delayer } from '../utils/async';
import { disposeAll } from '../utils/dispose';
import { Disposable } from '../utils/dispose';
import * as languageModeIds from '../utils/languageModeIds';
import { ResourceMap } from '../utils/resourceMap';
import * as typeConverters from '../utils/typeConverters';
@ -32,7 +32,7 @@ function mode2ScriptKind(mode: string): 'TS' | 'TSX' | 'JS' | 'JSX' | undefined
class SyncedBuffer {
constructor(
private readonly document: TextDocument,
private readonly document: vscode.TextDocument,
public readonly filepath: string,
private readonly client: ITypeScriptServiceClient
) { }
@ -66,7 +66,7 @@ class SyncedBuffer {
this.client.execute('open', args, false);
}
public get resource(): Uri {
public get resource(): vscode.Uri {
return this.document.uri;
}
@ -94,7 +94,7 @@ class SyncedBuffer {
this.client.execute('close', args, false);
}
public onContentChanged(events: TextDocumentContentChangeEvent[]): void {
public onContentChanged(events: vscode.TextDocumentContentChangeEvent[]): void {
for (const { range, text } of events) {
const args: Proto.ChangeRequestArgs = {
insertString: text,
@ -108,7 +108,7 @@ class SyncedBuffer {
class SyncedBufferMap extends ResourceMap<SyncedBuffer> {
public getForPath(filePath: string): SyncedBuffer | undefined {
return this.get(Uri.file(filePath));
return this.get(vscode.Uri.file(filePath));
}
public get allBuffers(): Iterable<SyncedBuffer> {
@ -131,7 +131,7 @@ class GetErrRequest {
files: string[],
onDone: () => void
) {
const token = new CancellationTokenSource();
const token = new vscode.CancellationTokenSource();
return new GetErrRequest(client, files, token, onDone);
}
@ -140,7 +140,7 @@ class GetErrRequest {
private constructor(
client: ITypeScriptServiceClient,
public readonly files: string[],
private readonly _token: CancellationTokenSource,
private readonly _token: vscode.CancellationTokenSource,
onDone: () => void
) {
const args: Proto.GeterrRequestArgs = {
@ -168,14 +168,13 @@ class GetErrRequest {
}
}
export default class BufferSyncSupport {
export default class BufferSyncSupport extends Disposable {
private readonly client: ITypeScriptServiceClient;
private _validateJavaScript: boolean = true;
private _validateTypeScript: boolean = true;
private readonly modeIds: Set<string>;
private readonly disposables: Disposable[] = [];
private readonly syncedBuffers: SyncedBufferMap;
private readonly pendingDiagnostics: PendingDiagnostics;
private readonly diagnosticDelayer: Delayer<any>;
@ -186,20 +185,21 @@ export default class BufferSyncSupport {
client: ITypeScriptServiceClient,
modeIds: string[]
) {
super();
this.client = client;
this.modeIds = new Set<string>(modeIds);
this.diagnosticDelayer = new Delayer<any>(300);
const pathNormalizer = (path: Uri) => this.client.normalizedPath(path);
const pathNormalizer = (path: vscode.Uri) => this.client.normalizedPath(path);
this.syncedBuffers = new SyncedBufferMap(pathNormalizer);
this.pendingDiagnostics = new PendingDiagnostics(pathNormalizer);
this.updateConfiguration();
workspace.onDidChangeConfiguration(this.updateConfiguration, this, this.disposables);
vscode.workspace.onDidChangeConfiguration(this.updateConfiguration, this, this._disposables);
}
private readonly _onDelete = new EventEmitter<Uri>();
private readonly _onDelete = this._register(new vscode.EventEmitter<vscode.Uri>());
public readonly onDelete = this._onDelete.event;
public listen(): void {
@ -207,22 +207,22 @@ export default class BufferSyncSupport {
return;
}
this.listening = true;
workspace.onDidOpenTextDocument(this.openTextDocument, this, this.disposables);
workspace.onDidCloseTextDocument(this.onDidCloseTextDocument, this, this.disposables);
workspace.onDidChangeTextDocument(this.onDidChangeTextDocument, this, this.disposables);
workspace.textDocuments.forEach(this.openTextDocument, this);
vscode.workspace.onDidOpenTextDocument(this.openTextDocument, this, this._disposables);
vscode.workspace.onDidCloseTextDocument(this.onDidCloseTextDocument, this, this._disposables);
vscode.workspace.onDidChangeTextDocument(this.onDidChangeTextDocument, this, this._disposables);
vscode.workspace.textDocuments.forEach(this.openTextDocument, this);
}
public handles(resource: Uri): boolean {
public handles(resource: vscode.Uri): boolean {
return this.syncedBuffers.has(resource);
}
public toResource(filePath: string): Uri {
public toResource(filePath: string): vscode.Uri {
const buffer = this.syncedBuffers.getForPath(filePath);
if (buffer) {
return buffer.resource;
}
return Uri.file(filePath);
return vscode.Uri.file(filePath);
}
public reOpenDocuments(): void {
@ -231,12 +231,7 @@ export default class BufferSyncSupport {
}
}
public dispose(): void {
disposeAll(this.disposables);
this._onDelete.dispose();
}
public openTextDocument(document: TextDocument): void {
public openTextDocument(document: vscode.TextDocument): void {
if (!this.modeIds.has(document.languageId)) {
return;
}
@ -256,7 +251,7 @@ export default class BufferSyncSupport {
this.requestDiagnostic(syncedBuffer);
}
public closeResource(resource: Uri): void {
public closeResource(resource: vscode.Uri): void {
const syncedBuffer = this.syncedBuffers.get(resource);
if (!syncedBuffer) {
return;
@ -269,11 +264,11 @@ export default class BufferSyncSupport {
}
}
private onDidCloseTextDocument(document: TextDocument): void {
private onDidCloseTextDocument(document: vscode.TextDocument): void {
this.closeResource(document.uri);
}
private onDidChangeTextDocument(e: TextDocumentChangeEvent): void {
private onDidChangeTextDocument(e: vscode.TextDocumentChangeEvent): void {
const syncedBuffer = this.syncedBuffers.get(e.document.uri);
if (!syncedBuffer) {
return;
@ -299,7 +294,7 @@ export default class BufferSyncSupport {
this.triggerDiagnostics();
}
public getErr(resources: Uri[]): any {
public getErr(resources: vscode.Uri[]): any {
const handledResources = resources.filter(resource => this.handles(resource));
if (!handledResources.length) {
return;
@ -330,7 +325,7 @@ export default class BufferSyncSupport {
return true;
}
public hasPendingDiagnostics(resource: Uri): boolean {
public hasPendingDiagnostics(resource: vscode.Uri): boolean {
return this.pendingDiagnostics.has(resource);
}
@ -366,8 +361,8 @@ export default class BufferSyncSupport {
}
private updateConfiguration() {
const jsConfig = workspace.getConfiguration('javascript', null);
const tsConfig = workspace.getConfiguration('typescript', null);
const jsConfig = vscode.workspace.getConfiguration('javascript', null);
const tsConfig = vscode.workspace.getConfiguration('typescript', null);
this._validateJavaScript = jsConfig.get<boolean>('validate.enable', true);
this._validateTypeScript = tsConfig.get<boolean>('validate.enable', true);

View file

@ -366,8 +366,8 @@ class TypeScriptCompletionItemProvider implements vscode.CompletionItemProvider
let details: Proto.CompletionEntryDetails[] | undefined;
try {
const response = await this.client.execute('completionEntryDetails', args, token);
details = response.body;
const { body } = await this.client.execute('completionEntryDetails', args, token);
details = body;
} catch {
return item;
}
@ -529,9 +529,8 @@ class TypeScriptCompletionItemProvider implements vscode.CompletionItemProvider
// Workaround for https://github.com/Microsoft/TypeScript/issues/12677
// Don't complete function calls inside of destructive assigments or imports
try {
const infoResponse = await this.client.execute('quickinfo', typeConverters.Position.toFileLocationRequestArgs(filepath, position));
const info = infoResponse.body;
switch (info && info.kind) {
const { body } = await this.client.execute('quickinfo', typeConverters.Position.toFileLocationRequestArgs(filepath, position));
switch (body && body.kind) {
case 'var':
case 'let':
case 'const':

View file

@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { CancellationToken, Location, Position, TextDocument } from 'vscode';
import * as vscode from 'vscode';
import * as Proto from '../protocol';
import { ITypeScriptServiceClient } from '../typescriptService';
import * as typeConverters from '../utils/typeConverters';
@ -16,10 +16,10 @@ export default class TypeScriptDefinitionProviderBase {
protected async getSymbolLocations(
definitionType: 'definition' | 'implementation' | 'typeDefinition',
document: TextDocument,
position: Position,
token: CancellationToken | boolean
): Promise<Location[] | undefined> {
document: vscode.TextDocument,
position: vscode.Position,
token: vscode.CancellationToken | boolean
): Promise<vscode.Location[] | undefined> {
const filepath = this.client.toPath(document.uri);
if (!filepath) {
return undefined;
@ -32,7 +32,7 @@ export default class TypeScriptDefinitionProviderBase {
return locations.map(location =>
typeConverters.Location.fromTextSpan(this.client.toResource(location.file), location));
} catch {
return [];
return undefined;
}
}
}

View file

@ -12,8 +12,8 @@ import { VersionDependentRegistration } from '../utils/dependentRegistration';
const localize = nls.loadMessageBundle();
interface Directive {
value: string;
description: string;
readonly value: string;
readonly description: string;
}
const directives: Directive[] = [
@ -21,17 +21,17 @@ const directives: Directive[] = [
value: '@ts-check',
description: localize(
'ts-check',
'Enables semantic checking in a JavaScript file. Must be at the top of a file.')
"Enables semantic checking in a JavaScript file. Must be at the top of a file.")
}, {
value: '@ts-nocheck',
description: localize(
'ts-nocheck',
'Disables semantic checking in a JavaScript file. Must be at the top of a file.')
"Disables semantic checking in a JavaScript file. Must be at the top of a file.")
}, {
value: '@ts-ignore',
description: localize(
'ts-ignore',
'Suppresses @ts-check errors on the next line of a file.')
"Suppresses @ts-check errors on the next line of a file.")
}
];
@ -63,13 +63,6 @@ class DirectiveCommentCompletionProvider implements vscode.CompletionItemProvide
}
return [];
}
public resolveCompletionItem(
item: vscode.CompletionItem,
_token: vscode.CancellationToken
) {
return item;
}
}
export function register(

View file

@ -26,15 +26,14 @@ class TypeScriptDocumentHighlightProvider implements vscode.DocumentHighlightPro
}
const args = typeConverters.Position.toFileLocationRequestArgs(file, position);
let items: Proto.OccurrencesResponseItem[] | undefined;
let items: Proto.OccurrencesResponseItem[];
try {
const response = await this.client.execute('occurrences', args, token);
items = response.body;
const { body } = await this.client.execute('occurrences', args, token);
if (!body) {
return [];
}
items = body;
} catch {
// noop
}
if (!items) {
return [];
}

View file

@ -41,11 +41,14 @@ class TypeScriptDocumentSymbolProvider implements vscode.DocumentSymbolProvider
}
let tree: Proto.NavigationTree | undefined;
let tree: Proto.NavigationTree;
try {
const args: Proto.FileRequestArgs = { file };
const response = await this.client.execute('navtree', args, token);
tree = response.body;
const { body } = await this.client.execute('navtree', args, token);
if (!body) {
return undefined;
}
tree = body;
} catch {
return undefined;
}

View file

@ -3,11 +3,12 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { CancellationToken, Disposable, FormattingOptions, TextDocument, window, workspace as Workspace, workspace, WorkspaceConfiguration } from 'vscode';
import * as vscode from 'vscode';
import * as Proto from '../protocol';
import { ITypeScriptServiceClient } from '../typescriptService';
import API from '../utils/api';
import { isTypeScriptDocument } from '../utils/languageModeIds';
import { ResourceMap } from '../utils/resourceMap';
function objsAreEqual<T>(a: T, b: T): boolean {
@ -22,8 +23,8 @@ function objsAreEqual<T>(a: T, b: T): boolean {
}
interface FileConfiguration {
formatOptions: Proto.FormatCodeSettings;
preferences: Proto.UserPreferences;
readonly formatOptions: Proto.FormatCodeSettings;
readonly preferences: Proto.UserPreferences;
}
function areFileConfigurationsEqual(a: FileConfiguration, b: FileConfiguration): boolean {
@ -34,19 +35,18 @@ function areFileConfigurationsEqual(a: FileConfiguration, b: FileConfiguration):
}
export default class FileConfigurationManager {
private onDidCloseTextDocumentSub: Disposable | undefined;
private formatOptions: { [key: string]: FileConfiguration | undefined } = Object.create(null);
private onDidCloseTextDocumentSub: vscode.Disposable | undefined;
private formatOptions = new ResourceMap<FileConfiguration>();
public constructor(
private readonly client: ITypeScriptServiceClient
) {
this.onDidCloseTextDocumentSub = Workspace.onDidCloseTextDocument((textDocument) => {
const key = textDocument.uri.toString();
this.onDidCloseTextDocumentSub = vscode.workspace.onDidCloseTextDocument((textDocument) => {
// When a document gets closed delete the cached formatting options.
// This is necessary since the tsserver now closed a project when its
// last file in it closes which drops the stored formatting options
// as well.
delete this.formatOptions[key];
this.formatOptions.delete(textDocument.uri);
});
}
@ -58,38 +58,36 @@ export default class FileConfigurationManager {
}
public async ensureConfigurationForDocument(
document: TextDocument,
token: CancellationToken | undefined
document: vscode.TextDocument,
token: vscode.CancellationToken | undefined
): Promise<void> {
const editor = window.visibleTextEditors.find(editor => editor.document.fileName === document.fileName);
const editor = vscode.window.visibleTextEditors.find(editor => editor.document.fileName === document.fileName);
if (editor) {
const formattingOptions = {
tabSize: editor.options.tabSize,
insertSpaces: editor.options.insertSpaces
} as FormattingOptions;
} as vscode.FormattingOptions;
return this.ensureConfigurationOptions(document, formattingOptions, token);
}
}
public async ensureConfigurationOptions(
document: TextDocument,
options: FormattingOptions,
token: CancellationToken | undefined
document: vscode.TextDocument,
options: vscode.FormattingOptions,
token: vscode.CancellationToken | undefined
): Promise<void> {
const file = this.client.toPath(document.uri);
if (!file) {
return;
}
const key = document.uri.toString();
const cachedOptions = this.formatOptions[key];
const cachedOptions = this.formatOptions.get(document.uri);
const currentOptions = this.getFileOptions(document, options);
if (cachedOptions && areFileConfigurationsEqual(cachedOptions, currentOptions)) {
return;
}
this.formatOptions[key] = currentOptions;
this.formatOptions.set(document.uri, currentOptions);
const args: Proto.ConfigureRequestArguments = {
file,
...currentOptions,
@ -98,13 +96,12 @@ export default class FileConfigurationManager {
}
public reset() {
this.formatOptions = Object.create(null);
this.formatOptions.clear();
}
private getFileOptions(
document: TextDocument,
options: FormattingOptions
document: vscode.TextDocument,
options: vscode.FormattingOptions
): FileConfiguration {
return {
formatOptions: this.getFormatOptions(document, options),
@ -113,10 +110,10 @@ export default class FileConfigurationManager {
}
private getFormatOptions(
document: TextDocument,
options: FormattingOptions
document: vscode.TextDocument,
options: vscode.FormattingOptions
): Proto.FormatCodeSettings {
const config = workspace.getConfiguration(
const config = vscode.workspace.getConfiguration(
isTypeScriptDocument(document) ? 'typescript.format' : 'javascript.format',
document.uri);
@ -144,12 +141,12 @@ export default class FileConfigurationManager {
};
}
private getPreferences(document: TextDocument): Proto.UserPreferences {
private getPreferences(document: vscode.TextDocument): Proto.UserPreferences {
if (!this.client.apiVersion.gte(API.v290)) {
return {};
}
const preferences = workspace.getConfiguration(
const preferences = vscode.workspace.getConfiguration(
isTypeScriptDocument(document) ? 'typescript.preferences' : 'javascript.preferences',
document.uri);
@ -161,7 +158,7 @@ export default class FileConfigurationManager {
}
}
function getQuoteStylePreference(config: WorkspaceConfiguration) {
function getQuoteStylePreference(config: vscode.WorkspaceConfiguration) {
switch (config.get<string>('quoteStyle')) {
case 'single': return 'single';
case 'double': return 'double';
@ -169,7 +166,7 @@ function getQuoteStylePreference(config: WorkspaceConfiguration) {
}
}
function getImportModuleSpecifierPreference(config: WorkspaceConfiguration) {
function getImportModuleSpecifierPreference(config: vscode.WorkspaceConfiguration) {
switch (config.get<string>('importModuleSpecifier')) {
case 'relative': return 'relative';
case 'non-relative': return 'non-relative';

View file

@ -26,12 +26,12 @@ class TypeScriptFoldingProvider implements vscode.FoldingRangeProvider {
}
const args: Proto.FileRequestArgs = { file };
const response: Proto.OutliningSpansResponse = await this.client.execute('getOutliningSpans', args, token);
if (!response || !response.body) {
const { body } = await this.client.execute('getOutliningSpans', args, token);
if (!body) {
return;
}
return response.body
return body
.map(span => this.convertOutliningSpan(span, document))
.filter(foldingRange => !!foldingRange) as vscode.FoldingRange[];
}

View file

@ -29,16 +29,19 @@ class TypeScriptFormattingProvider implements vscode.DocumentRangeFormattingEdit
await this.formattingOptionsManager.ensureConfigurationOptions(document, options, token);
let edits: Proto.CodeEdit[] | undefined;
let edits: Proto.CodeEdit[];
try {
const args = typeConverters.Range.toFormattingRequestArgs(file, range);
const response = await this.client.execute('format', args, token);
edits = response.body;
const { body } = await this.client.execute('format', args, token);
if (!body) {
return undefined;
}
edits = body;
} catch {
// noop
return undefined;
}
return (edits || []).map(typeConverters.TextEdit.fromCodeEdit);
return edits.map(typeConverters.TextEdit.fromCodeEdit);
}
public async provideOnTypeFormattingEdits(
@ -60,8 +63,8 @@ class TypeScriptFormattingProvider implements vscode.DocumentRangeFormattingEdit
key: ch
};
try {
const response = await this.client.execute('formatonkey', args, token);
const edits = response.body;
const { body } = await this.client.execute('formatonkey', args, token);
const edits = body;
const result: vscode.TextEdit[] = [];
if (!edits) {
return result;

View file

@ -27,12 +27,11 @@ class TypeScriptHoverProvider implements vscode.HoverProvider {
}
const args = typeConverters.Position.toFileLocationRequestArgs(filepath, position);
try {
const response = await this.client.execute('quickinfo', args, token);
if (response && response.body) {
const data = response.body;
const { body } = await this.client.execute('quickinfo', args, token);
if (body) {
return new vscode.Hover(
TypeScriptHoverProvider.getContents(data),
typeConverters.Range.fromTextSpan(data));
TypeScriptHoverProvider.getContents(body),
typeConverters.Range.fromTextSpan(body));
}
} catch (e) {
// noop

View file

@ -23,9 +23,9 @@ export default class TypeScriptImplementationsCodeLensProvider extends TypeScrip
const codeLens = inputCodeLens as ReferencesCodeLens;
const args = typeConverters.Position.toFileLocationRequestArgs(codeLens.file, codeLens.range.start);
try {
const response = await this.client.execute('implementation', args, token);
if (response && response.body) {
const locations = response.body
const { body } = await this.client.execute('implementation', args, token);
if (body) {
const locations = body
.map(reference =>
// Only take first line on implementation: https://github.com/Microsoft/vscode/issues/23924
new vscode.Location(this.client.toResource(reference.file),

View file

@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { CancellationToken, CompletionItem, CompletionItemKind, CompletionItemProvider, Disposable, DocumentSelector, languages, Position, Range, SnippetString, TextDocument, TextEditor, Uri, window } from 'vscode';
import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
import * as Proto from '../protocol';
import { ITypeScriptServiceClient } from '../typescriptService';
@ -14,12 +14,12 @@ import * as typeConverters from '../utils/typeConverters';
const localize = nls.loadMessageBundle();
class JsDocCompletionItem extends CompletionItem {
class JsDocCompletionItem extends vscode.CompletionItem {
constructor(
document: TextDocument,
position: Position
document: vscode.TextDocument,
position: vscode.Position
) {
super('/** */', CompletionItemKind.Snippet);
super('/** */', vscode.CompletionItemKind.Snippet);
this.detail = localize('typescript.jsDocCompletionItem.documentation', 'JSDoc comment');
this.insertText = '';
this.sortText = '\0';
@ -28,7 +28,7 @@ class JsDocCompletionItem extends CompletionItem {
const prefix = line.slice(0, position.character).match(/\/\**\s*$/);
const suffix = line.slice(position.character).match(/^\s*\**\//);
const start = position.translate(0, prefix ? -prefix[0].length : 0);
this.range = new Range(
this.range = new vscode.Range(
start,
position.translate(0, suffix ? suffix[0].length : 0));
@ -40,7 +40,7 @@ class JsDocCompletionItem extends CompletionItem {
}
}
class JsDocCompletionProvider implements CompletionItemProvider {
class JsDocCompletionProvider implements vscode.CompletionItemProvider {
constructor(
private readonly client: ITypeScriptServiceClient,
@ -50,10 +50,10 @@ class JsDocCompletionProvider implements CompletionItemProvider {
}
public async provideCompletionItems(
document: TextDocument,
position: Position,
token: CancellationToken
): Promise<CompletionItem[]> {
document: vscode.TextDocument,
position: vscode.Position,
token: vscode.CancellationToken
): Promise<vscode.CompletionItem[]> {
const file = this.client.toPath(document.uri);
if (!file) {
return [];
@ -72,8 +72,8 @@ class JsDocCompletionProvider implements CompletionItemProvider {
private async isCommentableLocation(
file: string,
position: Position,
token: CancellationToken
position: vscode.Position,
token: vscode.CancellationToken
): Promise<boolean> {
const args: Proto.FileRequestArgs = {
file
@ -104,7 +104,7 @@ class JsDocCompletionProvider implements CompletionItemProvider {
return matchesPosition(body);
}
private isValidCursorPosition(document: TextDocument, position: Position): boolean {
private isValidCursorPosition(document: vscode.TextDocument, position: vscode.Position): boolean {
// Only show the JSdoc completion when the everything before the cursor is whitespace
// or could be the opening of a comment
const line = document.lineAt(position.line).text;
@ -112,7 +112,7 @@ class JsDocCompletionProvider implements CompletionItemProvider {
return prefix.match(/^\s*$|\/\*\*\s*$|^\s*\/\*\*+\s*$/) !== null;
}
public resolveCompletionItem(item: CompletionItem, _token: CancellationToken) {
public resolveCompletionItem(item: vscode.CompletionItem, _token: vscode.CancellationToken) {
return item;
}
}
@ -129,13 +129,13 @@ class TryCompleteJsDocCommand implements Command {
* Try to insert a jsdoc comment, using a template provide by typescript
* if possible, otherwise falling back to a default comment format.
*/
public async execute(resource: Uri, start: Position): Promise<boolean> {
public async execute(resource: vscode.Uri, start: vscode.Position): Promise<boolean> {
const file = this.client.toPath(resource);
if (!file) {
return false;
}
const editor = window.activeTextEditor;
const editor = vscode.window.activeTextEditor;
if (!editor || editor.document.uri.fsPath !== resource.fsPath) {
return false;
}
@ -148,7 +148,7 @@ class TryCompleteJsDocCommand implements Command {
return this.tryInsertDefaultDoc(editor, start);
}
private async tryInsertJsDocFromTemplate(editor: TextEditor, file: string, position: Position): Promise<boolean> {
private async tryInsertJsDocFromTemplate(editor: vscode.TextEditor, file: string, position: vscode.Position): Promise<boolean> {
const snippet = await TryCompleteJsDocCommand.getSnippetTemplate(this.client, file, position);
if (!snippet) {
return false;
@ -159,7 +159,7 @@ class TryCompleteJsDocCommand implements Command {
{ undoStopBefore: false, undoStopAfter: true });
}
public static getSnippetTemplate(client: ITypeScriptServiceClient, file: string, position: Position): Promise<SnippetString | undefined> {
public static getSnippetTemplate(client: ITypeScriptServiceClient, file: string, position: vscode.Position): Promise<vscode.SnippetString | undefined> {
const args = typeConverters.Position.toFileLocationRequestArgs(file, position);
return Promise.race([
client.execute('docCommentTemplate', args),
@ -181,14 +181,14 @@ class TryCompleteJsDocCommand implements Command {
/**
* Insert the default JSDoc
*/
private tryInsertDefaultDoc(editor: TextEditor, position: Position): Thenable<boolean> {
const snippet = new SnippetString(`/**\n * $0\n */`);
private tryInsertDefaultDoc(editor: vscode.TextEditor, position: vscode.Position): Thenable<boolean> {
const snippet = new vscode.SnippetString(`/**\n * $0\n */`);
return editor.insertSnippet(snippet, position, { undoStopBefore: false, undoStopAfter: true });
}
}
export function templateToSnippet(template: string): SnippetString {
export function templateToSnippet(template: string): vscode.SnippetString {
// TODO: use append placeholder
let snippetIndex = 1;
template = template.replace(/\$/g, '\\$');
@ -204,16 +204,16 @@ export function templateToSnippet(template: string): SnippetString {
out += post + ` \${${snippetIndex++}}`;
return out;
});
return new SnippetString(template);
return new vscode.SnippetString(template);
}
export function register(
selector: DocumentSelector,
selector: vscode.DocumentSelector,
client: ITypeScriptServiceClient,
commandManager: CommandManager
): Disposable {
): vscode.Disposable {
return new ConfigurationDependentRegistration('jsDocCompletion', 'enabled', () => {
return languages.registerCompletionItemProvider(selector,
return vscode.languages.registerCompletionItemProvider(selector,
new JsDocCompletionProvider(client, commandManager),
'*');
});

View file

@ -9,7 +9,7 @@
* ------------------------------------------------------------------------------------------ */
import * as vscode from 'vscode';
import { disposeAll } from '../utils/dispose';
import { Disposable } from '../utils/dispose';
import * as languageModeIds from '../utils/languageModeIds';
const jsTsLanguageConfiguration: vscode.LanguageConfiguration = {
@ -64,10 +64,10 @@ const jsxTagsLanguageConfiguration: vscode.LanguageConfiguration = {
],
};
export class LanguageConfigurationManager {
private readonly _registrations: vscode.Disposable[] = [];
export class LanguageConfigurationManager extends Disposable {
constructor() {
super();
const standardLanguages = [
languageModeIds.javascript,
languageModeIds.javascriptreact,
@ -82,10 +82,6 @@ export class LanguageConfigurationManager {
}
private registerConfiguration(language: string, config: vscode.LanguageConfiguration) {
this._registrations.push(vscode.languages.setLanguageConfiguration(language, config));
}
dispose() {
disposeAll(this._registrations);
this._register(vscode.languages.setLanguageConfiguration(language, config));
}
}

View file

@ -45,12 +45,8 @@ class OrganizeImportsCommand implements Command {
}
}
};
const response = await this.client.execute('organizeImports', args);
if (!response || !response.success) {
return false;
}
const edits = typeconverts.WorkspaceEdit.fromFileCodeEdits(this.client, response.body);
const { body } = await this.client.execute('organizeImports', args);
const edits = typeconverts.WorkspaceEdit.fromFileCodeEdits(this.client, body);
return vscode.workspace.applyEdit(edits);
}
}

View file

@ -10,6 +10,7 @@ import { ITypeScriptServiceClient } from '../typescriptService';
import API from '../utils/api';
import { applyCodeActionCommands, getEditForCodeAction } from '../utils/codeAction';
import { Command, CommandManager } from '../utils/commandManager';
import { VersionDependentRegistration } from '../utils/dependentRegistration';
import TelemetryReporter from '../utils/telemetry';
import * as typeConverters from '../utils/typeConverters';
import { DiagnosticsManager } from './diagnostics';
@ -29,20 +30,19 @@ class ApplyCodeActionCommand implements Command {
public async execute(
action: Proto.CodeFixAction
): Promise<boolean> {
if (action.fixName) {
/* __GDPR__
"quickFix.execute" : {
"fixName" : { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" },
"${include}": [
"${TypeScriptCommonProperties}"
]
}
*/
this.telemetryReporter.logTelemetry('quickFix.execute', {
fixName: action.fixName
});
}
return applyCodeActionCommands(this.client, action);
/* __GDPR__
"quickFix.execute" : {
"fixName" : { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" },
"${include}": [
"${TypeScriptCommonProperties}"
]
}
*/
this.telemetryReporter.logTelemetry('quickFix.execute', {
fixName: action.fixName
});
return applyCodeActionCommands(this.client, action.commands);
}
}
@ -64,19 +64,17 @@ class ApplyFixAllCodeAction implements Command {
return;
}
if (tsAction.fixName) {
/* __GDPR__
"quickFixAll.execute" : {
"fixName" : { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" },
"${include}": [
"${TypeScriptCommonProperties}"
]
}
*/
this.telemetryReporter.logTelemetry('quickFixAll.execute', {
fixName: tsAction.fixName
});
}
/* __GDPR__
"quickFixAll.execute" : {
"fixName" : { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" },
"${include}": [
"${TypeScriptCommonProperties}"
]
}
*/
this.telemetryReporter.logTelemetry('quickFixAll.execute', {
fixName: tsAction.fixName
});
const args: Proto.GetCombinedCodeFixRequestArgs = {
scope: {
@ -87,17 +85,14 @@ class ApplyFixAllCodeAction implements Command {
};
try {
const combinedCodeFixesResponse = await this.client.execute('getCombinedCodeFix', args);
if (!combinedCodeFixesResponse.body) {
const { body } = await this.client.execute('getCombinedCodeFix', args);
if (!body) {
return;
}
const edit = typeConverters.WorkspaceEdit.fromFileCodeEdits(this.client, combinedCodeFixesResponse.body.changes);
const edit = typeConverters.WorkspaceEdit.fromFileCodeEdits(this.client, body.changes);
await vscode.workspace.applyEdit(edit);
if (combinedCodeFixesResponse.command) {
await vscode.commands.executeCommand(ApplyCodeActionCommand.ID, combinedCodeFixesResponse.command);
}
await applyCodeActionCommands(this.client, body.commands);
} catch {
// noop
}
@ -128,6 +123,34 @@ class DiagnosticsSet {
public get values(): Iterable<vscode.Diagnostic> {
return this._values.values();
}
public get size() {
return this._values.size;
}
}
class CodeActionSet {
private _actions: vscode.CodeAction[] = [];
private _fixAllActions = new Set<{}>();
public get values() {
return this._actions;
}
public addAction(action: vscode.CodeAction) {
this._actions.push(action);
}
public addFixAllAction(fixId: {}, action: vscode.CodeAction) {
if (!this.hasFixAllAction(fixId)) {
this.addAction(action);
this._fixAllActions.add(fixId);
}
}
public hasFixAllAction(fixId: {}) {
return this._fixAllActions.has(fixId);
}
}
class SupportedCodeActionProvider {
@ -137,10 +160,9 @@ class SupportedCodeActionProvider {
private readonly client: ITypeScriptServiceClient
) { }
public async getFixableDiagnosticsForContext(context: vscode.CodeActionContext): Promise<vscode.Diagnostic[]> {
public async getFixableDiagnosticsForContext(context: vscode.CodeActionContext): Promise<DiagnosticsSet> {
const supportedActions = await this.supportedCodeActions;
const fixableDiagnostics = DiagnosticsSet.from(context.diagnostics.filter(diagnostic => supportedActions.has(+(diagnostic.code!))));
return Array.from(fixableDiagnostics.values);
return DiagnosticsSet.from(context.diagnostics.filter(diagnostic => supportedActions.has(+(diagnostic.code!))));
}
private get supportedCodeActions(): Thenable<Set<number>> {
@ -177,17 +199,13 @@ class TypeScriptQuickFixProvider implements vscode.CodeActionProvider {
context: vscode.CodeActionContext,
token: vscode.CancellationToken
): Promise<vscode.CodeAction[]> {
if (!this.client.apiVersion.gte(API.v213)) {
return [];
}
const file = this.client.toPath(document.uri);
if (!file) {
return [];
}
const fixableDiagnostics = await this.supportedCodeActionProvider.getFixableDiagnosticsForContext(context);
if (!fixableDiagnostics.length) {
if (!fixableDiagnostics.size) {
return [];
}
@ -198,7 +216,7 @@ class TypeScriptQuickFixProvider implements vscode.CodeActionProvider {
await this.formattingConfigurationManager.ensureConfigurationForDocument(document, token);
const results: vscode.CodeAction[] = [];
for (const diagnostic of fixableDiagnostics) {
for (const diagnostic of fixableDiagnostics.values) {
results.push(...await this.getFixesForDiagnostic(document, file, diagnostic, token));
}
return results;
@ -214,26 +232,28 @@ class TypeScriptQuickFixProvider implements vscode.CodeActionProvider {
...typeConverters.Range.toFileRangeRequestArgs(file, diagnostic.range),
errorCodes: [+(diagnostic.code!)]
};
const codeFixesResponse = await this.client.execute('getCodeFixes', args, token);
if (codeFixesResponse.body) {
const results: vscode.CodeAction[] = [];
for (const tsCodeFix of codeFixesResponse.body) {
results.push(...await this.getAllFixesForTsCodeAction(document, file, diagnostic, tsCodeFix));
}
return results;
const { body } = await this.client.execute('getCodeFixes', args, token);
if (!body) {
return [];
}
return [];
const results = new CodeActionSet();
for (const tsCodeFix of body) {
this.addAllFixesForTsCodeAction(results, document, file, diagnostic, tsCodeFix);
}
return results.values;
}
private async getAllFixesForTsCodeAction(
private addAllFixesForTsCodeAction(
results: CodeActionSet,
document: vscode.TextDocument,
file: string,
diagnostic: vscode.Diagnostic,
tsAction: Proto.CodeAction
): Promise<Iterable<vscode.CodeAction>> {
const singleFix = this.getSingleFixForTsCodeAction(diagnostic, tsAction);
const fixAll = await this.getFixAllForTsCodeAction(document, file, diagnostic, tsAction as Proto.CodeFixAction);
return fixAll ? [singleFix, fixAll] : [singleFix];
): CodeActionSet {
results.addAction(this.getSingleFixForTsCodeAction(diagnostic, tsAction));
this.addFixAllForTsCodeAction(results, document, file, diagnostic, tsAction as Proto.CodeFixAction);
return results;
}
private getSingleFixForTsCodeAction(
@ -243,42 +263,41 @@ class TypeScriptQuickFixProvider implements vscode.CodeActionProvider {
const codeAction = new vscode.CodeAction(tsAction.description, vscode.CodeActionKind.QuickFix);
codeAction.edit = getEditForCodeAction(this.client, tsAction);
codeAction.diagnostics = [diagnostic];
if (tsAction.commands) {
codeAction.command = {
command: ApplyCodeActionCommand.ID,
arguments: [tsAction],
title: tsAction.description
};
}
codeAction.command = {
command: ApplyCodeActionCommand.ID,
arguments: [tsAction],
title: ''
};
return codeAction;
}
private async getFixAllForTsCodeAction(
private addFixAllForTsCodeAction(
results: CodeActionSet,
document: vscode.TextDocument,
file: string,
diagnostic: vscode.Diagnostic,
tsAction: Proto.CodeFixAction,
): Promise<vscode.CodeAction | undefined> {
if (!tsAction.fixId || !this.client.apiVersion.gte(API.v270)) {
return undefined;
): CodeActionSet {
if (!tsAction.fixId || !this.client.apiVersion.gte(API.v270) || results.hasFixAllAction(results)) {
return results;
}
// Make sure there are multiple diagnostics of the same type in the file
if (!this.diagnosticsManager.getDiagnostics(document.uri).some(x => x.code === diagnostic.code && x !== diagnostic)) {
return;
return results;
}
const action = new vscode.CodeAction(
tsAction.fixAllDescription || localize('fixAllInFileLabel', '{0} (Fix all in file)', tsAction.description),
vscode.CodeActionKind.QuickFix);
action.diagnostics = [diagnostic];
action.command = {
command: ApplyFixAllCodeAction.ID,
arguments: [file, tsAction],
title: ''
};
return action;
results.addFixAllAction(tsAction.fixId, action);
return results;
}
}
@ -290,6 +309,7 @@ export function register(
diagnosticsManager: DiagnosticsManager,
telemetryReporter: TelemetryReporter
) {
return vscode.languages.registerCodeActionsProvider(selector,
new TypeScriptQuickFixProvider(client, fileConfigurationManager, commandManager, diagnosticsManager, telemetryReporter));
return new VersionDependentRegistration(client, API.v213, () =>
vscode.languages.registerCodeActionsProvider(selector,
new TypeScriptQuickFixProvider(client, fileConfigurationManager, commandManager, diagnosticsManager, telemetryReporter)));
}

View file

@ -47,8 +47,7 @@ class ApplyRefactoringCommand implements Command {
refactor,
action
};
const response = await this.client.execute('getEditsForRefactor', args);
const body = response && response.body;
const { body } = await this.client.execute('getEditsForRefactor', args);
if (!body || !body.edits.length) {
return false;
}
@ -142,11 +141,11 @@ class TypeScriptRefactorProvider implements vscode.CodeActionProvider {
const args: Proto.GetApplicableRefactorsRequestArgs = typeConverters.Range.toFileRangeRequestArgs(file, rangeOrSelection);
let refactorings: Proto.ApplicableRefactorInfo[];
try {
const response = await this.client.execute('getApplicableRefactors', args, token);
if (!response.body) {
const { body } = await this.client.execute('getApplicableRefactors', args, token);
if (!body) {
return undefined;
}
refactorings = response.body;
refactorings = body;
} catch {
return undefined;
}

View file

@ -26,13 +26,13 @@ class TypeScriptReferenceSupport implements vscode.ReferenceProvider {
const args = typeConverters.Position.toFileLocationRequestArgs(filepath, position);
try {
const msg = await this.client.execute('references', args, token);
if (!msg.body) {
const { body } = await this.client.execute('references', args, token);
if (!body) {
return [];
}
const result: vscode.Location[] = [];
const has203Features = this.client.apiVersion.gte(API.v203);
for (const ref of msg.body.refs) {
for (const ref of body.refs) {
if (!options.includeDeclaration && has203Features && ref.isDefinition) {
continue;
}

View file

@ -21,7 +21,7 @@ class TypeScriptReferencesCodeLensProvider extends TypeScriptBaseCodeLensProvide
const codeLens = inputCodeLens as ReferencesCodeLens;
const args = typeConverters.Position.toFileLocationRequestArgs(codeLens.file, codeLens.range.start);
return this.client.execute('references', args, token).then(response => {
if (!response || !response.body) {
if (!response.body) {
throw codeLens;
}

View file

@ -32,17 +32,17 @@ class TypeScriptRenameProvider implements vscode.RenameProvider {
};
try {
const response = await this.client.execute('rename', args, token);
if (!response.body) {
const { body } = await this.client.execute('rename', args, token);
if (!body) {
return null;
}
const renameInfo = response.body.info;
const renameInfo = body.info;
if (!renameInfo.canRename) {
return Promise.reject<vscode.WorkspaceEdit>(renameInfo.localizedErrorMessage);
}
return this.toWorkspaceEdit(response.body.locs, newName);
return this.toWorkspaceEdit(body.locs, newName);
} catch {
// noop
}

View file

@ -28,13 +28,13 @@ class TypeScriptSignatureHelpProvider implements vscode.SignatureHelpProvider {
}
const args: Proto.SignatureHelpRequestArgs = typeConverters.Position.toFileLocationRequestArgs(filepath, position);
let info: Proto.SignatureHelpItems | undefined = undefined;
let info: Proto.SignatureHelpItems;
try {
const response = await this.client.execute('signatureHelp', args, token);
info = response.body;
if (!info) {
const { body } = await this.client.execute('signatureHelp', args, token);
if (!body) {
return undefined;
}
info = body;
} catch {
return undefined;
}

View file

@ -8,19 +8,19 @@ import * as Proto from '../protocol';
import { ITypeScriptServiceClient } from '../typescriptService';
import API from '../utils/api';
import { ConditionalRegistration, ConfigurationDependentRegistration, VersionDependentRegistration } from '../utils/dependentRegistration';
import { disposeAll } from '../utils/dispose';
import { Disposable } from '../utils/dispose';
import * as typeConverters from '../utils/typeConverters';
class TagClosing {
class TagClosing extends Disposable {
private _disposed = false;
private _timeout: NodeJS.Timer | undefined = undefined;
private _cancel: vscode.CancellationTokenSource | undefined = undefined;
private readonly _disposables: vscode.Disposable[] = [];
constructor(
private readonly client: ITypeScriptServiceClient
) {
super();
vscode.workspace.onDidChangeTextDocument(
event => this.onDidChangeTextDocument(event.document, event.contentChanges),
null,
@ -28,10 +28,9 @@ class TagClosing {
}
public dispose() {
super.dispose();
this._disposed = true;
disposeAll(this._disposables);
if (this._timeout) {
clearTimeout(this._timeout);
this._timeout = undefined;
@ -89,16 +88,16 @@ class TagClosing {
}
let position = new vscode.Position(rangeStart.line, rangeStart.character + lastChange.text.length);
let body: Proto.TextInsertion | undefined = undefined;
let insertion: Proto.TextInsertion;
const args: Proto.JsxClosingTagRequestArgs = typeConverters.Position.toFileLocationRequestArgs(filepath, position);
this._cancel = new vscode.CancellationTokenSource();
try {
const response = await this.client.execute('jsxClosingTag', args, this._cancel.token);
body = response && response.body;
const { body } = await this.client.execute('jsxClosingTag', args, this._cancel.token);
if (!body) {
return;
}
insertion = body;
} catch {
return;
}
@ -115,7 +114,7 @@ class TagClosing {
const activeDocument = activeEditor.document;
if (document === activeDocument && activeDocument.version === version) {
activeEditor.insertSnippet(
this.getTagSnippet(body),
this.getTagSnippet(insertion),
this.getInsertionPositions(activeEditor, position));
}
}, 100);
@ -136,24 +135,19 @@ class TagClosing {
}
}
export class ActiveDocumentDependentRegistration {
export class ActiveDocumentDependentRegistration extends Disposable {
private readonly _registration: ConditionalRegistration;
private readonly _disposables: vscode.Disposable[] = [];
constructor(
private readonly selector: vscode.DocumentSelector,
register: () => vscode.Disposable,
) {
this._registration = new ConditionalRegistration(register);
super();
this._registration = this._register(new ConditionalRegistration(register));
vscode.window.onDidChangeActiveTextEditor(this.update, this, this._disposables);
this.update();
}
public dispose() {
disposeAll(this._disposables);
this._registration.dispose();
}
private update() {
const editor = vscode.window.activeTextEditor;
const enabled = !!(editor && vscode.languages.match(this.selector, editor.document));

View file

@ -15,6 +15,7 @@ import { isTypeScriptDocument } from '../utils/languageModeIds';
import { escapeRegExp } from '../utils/regexp';
import * as typeConverters from '../utils/typeConverters';
import FileConfigurationManager from './fileConfigurationManager';
import { VersionDependentRegistration } from '../utils/dependentRegistration';
const localize = nls.loadMessageBundle();
@ -26,7 +27,7 @@ enum UpdateImportsOnFileMoveSetting {
Never = 'never',
}
export class UpdateImportsOnFileRenameHandler {
class UpdateImportsOnFileRenameHandler {
private readonly _onDidRenameSub: vscode.Disposable;
public constructor(
@ -47,10 +48,6 @@ export class UpdateImportsOnFileRenameHandler {
oldResource: vscode.Uri,
newResource: vscode.Uri,
): Promise<void> {
if (!this.client.apiVersion.gte(API.v290)) {
return;
}
const targetResource = await this.getTargetResource(newResource);
if (!targetResource) {
return;
@ -87,11 +84,11 @@ export class UpdateImportsOnFileRenameHandler {
// Workaround for https://github.com/Microsoft/vscode/issues/52967
// Never attempt to update import paths if the file does not contain something the looks like an export
try {
const tree = await this.client.execute('navtree', { file: newFile });
const { body } = await this.client.execute('navtree', { file: newFile });
const hasExport = (node: Proto.NavigationTree): boolean => {
return !!node.kindModifiers.match(/\bexports?\b/g) || !!(node.childItems && node.childItems.some(hasExport));
};
if (!tree.body || !tree.body || !hasExport(tree.body)) {
if (!body || !hasExport(body)) {
return;
}
} catch {
@ -304,3 +301,11 @@ export class UpdateImportsOnFileRenameHandler {
}
}
export function register(
client: ITypeScriptServiceClient,
fileConfigurationManager: FileConfigurationManager,
handles: (uri: vscode.Uri) => Promise<boolean>,
) {
return new VersionDependentRegistration(client, API.v290, () =>
new UpdateImportsOnFileRenameHandler(client, fileConfigurationManager, handles));
}

View file

@ -44,13 +44,13 @@ class TypeScriptWorkspaceSymbolProvider implements vscode.WorkspaceSymbolProvide
file: filepath,
searchValue: search
};
const response = await this.client.execute('navto', args, token);
if (!response.body) {
const { body } = await this.client.execute('navto', args, token);
if (!body) {
return [];
}
const result: vscode.SymbolInformation[] = [];
for (const item of response.body) {
for (const item of body) {
if (!item.containerName && item.kind === 'alias') {
continue;
}

View file

@ -10,7 +10,7 @@ import { DiagnosticKind } from './features/diagnostics';
import FileConfigurationManager from './features/fileConfigurationManager';
import TypeScriptServiceClient from './typescriptServiceClient';
import { CommandManager } from './utils/commandManager';
import { disposeAll } from './utils/dispose';
import { Disposable } from './utils/dispose';
import * as fileSchemes from './utils/fileSchemes';
import { LanguageDescription } from './utils/languageDescription';
import { memoize } from './utils/memoize';
@ -21,8 +21,7 @@ import TypingsStatus from './utils/typingsStatus';
const validateSetting = 'validate.enable';
const suggestionSetting = 'suggestionActions.enabled';
export default class LanguageProvider {
private readonly disposables: vscode.Disposable[] = [];
export default class LanguageProvider extends Disposable {
constructor(
private readonly client: TypeScriptServiceClient,
@ -32,7 +31,8 @@ export default class LanguageProvider {
private readonly typingsStatus: TypingsStatus,
private readonly fileConfigurationManager: FileConfigurationManager
) {
vscode.workspace.onDidChangeConfiguration(this.configurationChanged, this, this.disposables);
super();
vscode.workspace.onDidChangeConfiguration(this.configurationChanged, this, this._disposables);
this.configurationChanged();
client.onReady(async () => {
@ -40,9 +40,6 @@ export default class LanguageProvider {
});
}
public dispose(): void {
disposeAll(this.disposables);
}
@memoize
private get documentSelector(): vscode.DocumentFilter[] {
@ -60,27 +57,27 @@ export default class LanguageProvider {
const cachedResponse = new CachedNavTreeResponse();
this.disposables.push((await import('./features/completions')).register(selector, this.client, this.typingsStatus, this.fileConfigurationManager, this.commandManager));
this.disposables.push((await import('./features/definitions')).register(selector, this.client));
this.disposables.push((await import('./features/directiveCommentCompletions')).register(selector, this.client));
this.disposables.push((await import('./features/documentHighlight')).register(selector, this.client));
this.disposables.push((await import('./features/documentSymbol')).register(selector, this.client));
this.disposables.push((await import('./features/folding')).register(selector, this.client));
this.disposables.push((await import('./features/formatting')).register(selector, this.description.id, this.client, this.fileConfigurationManager));
this.disposables.push((await import('./features/hover')).register(selector, this.client));
this.disposables.push((await import('./features/implementations')).register(selector, this.client));
this.disposables.push((await import('./features/implementationsCodeLens')).register(selector, this.description.id, this.client, cachedResponse));
this.disposables.push((await import('./features/jsDocCompletions')).register(selector, this.client, this.commandManager));
this.disposables.push((await import('./features/organizeImports')).register(selector, this.client, this.commandManager, this.fileConfigurationManager, this.telemetryReporter));
this.disposables.push((await import('./features/quickFix')).register(selector, this.client, this.fileConfigurationManager, this.commandManager, this.client.diagnosticsManager, this.telemetryReporter));
this.disposables.push((await import('./features/refactor')).register(selector, this.client, this.fileConfigurationManager, this.commandManager, this.telemetryReporter));
this.disposables.push((await import('./features/references')).register(selector, this.client));
this.disposables.push((await import('./features/referencesCodeLens')).register(selector, this.description.id, this.client, cachedResponse));
this.disposables.push((await import('./features/rename')).register(selector, this.client));
this.disposables.push((await import('./features/signatureHelp')).register(selector, this.client));
this.disposables.push((await import('./features/tagClosing')).register(selector, this.description.id, this.client));
this.disposables.push((await import('./features/typeDefinitions')).register(selector, this.client));
this.disposables.push((await import('./features/workspaceSymbols')).register(this.client, this.description.modeIds));
this._register((await import('./features/completions')).register(selector, this.client, this.typingsStatus, this.fileConfigurationManager, this.commandManager));
this._register((await import('./features/definitions')).register(selector, this.client));
this._register((await import('./features/directiveCommentCompletions')).register(selector, this.client));
this._register((await import('./features/documentHighlight')).register(selector, this.client));
this._register((await import('./features/documentSymbol')).register(selector, this.client));
this._register((await import('./features/folding')).register(selector, this.client));
this._register((await import('./features/formatting')).register(selector, this.description.id, this.client, this.fileConfigurationManager));
this._register((await import('./features/hover')).register(selector, this.client));
this._register((await import('./features/implementations')).register(selector, this.client));
this._register((await import('./features/implementationsCodeLens')).register(selector, this.description.id, this.client, cachedResponse));
this._register((await import('./features/jsDocCompletions')).register(selector, this.client, this.commandManager));
this._register((await import('./features/organizeImports')).register(selector, this.client, this.commandManager, this.fileConfigurationManager, this.telemetryReporter));
this._register((await import('./features/quickFix')).register(selector, this.client, this.fileConfigurationManager, this.commandManager, this.client.diagnosticsManager, this.telemetryReporter));
this._register((await import('./features/refactor')).register(selector, this.client, this.fileConfigurationManager, this.commandManager, this.telemetryReporter));
this._register((await import('./features/references')).register(selector, this.client));
this._register((await import('./features/referencesCodeLens')).register(selector, this.description.id, this.client, cachedResponse));
this._register((await import('./features/rename')).register(selector, this.client));
this._register((await import('./features/signatureHelp')).register(selector, this.client));
this._register((await import('./features/tagClosing')).register(selector, this.description.id, this.client));
this._register((await import('./features/typeDefinitions')).register(selector, this.client));
this._register((await import('./features/workspaceSymbols')).register(this.client, this.description.modeIds));
}
private configurationChanged(): void {

View file

@ -8,17 +8,17 @@
* https://github.com/Microsoft/TypeScript-Sublime-Plugin/blob/master/TypeScript%20Indent.tmPreferences
* ------------------------------------------------------------------------------------------ */
import { Diagnostic, DiagnosticRelatedInformation, DiagnosticSeverity, DiagnosticTag, Disposable, Memento, Range, Uri, workspace } from 'vscode';
import * as vscode from 'vscode';
import { DiagnosticKind } from './features/diagnostics';
import FileConfigurationManager from './features/fileConfigurationManager';
import { UpdateImportsOnFileRenameHandler } from './features/updatePathsOnRename';
import { register as registerUpdatePathsOnRename } from './features/updatePathsOnRename';
import LanguageProvider from './languageProvider';
import * as Proto from './protocol';
import * as PConst from './protocol.const';
import TypeScriptServiceClient from './typescriptServiceClient';
import API from './utils/api';
import { CommandManager } from './utils/commandManager';
import { disposeAll } from './utils/dispose';
import { Disposable } from './utils/dispose';
import { LanguageDescription, DiagnosticLanguage } from './utils/languageDescription';
import LogDirectoryProvider from './utils/logDirectoryProvider';
import { TypeScriptServerPlugin } from './utils/plugins';
@ -36,26 +36,24 @@ const styleCheckDiagnostics = [
7030 // not all code paths return a value
];
export default class TypeScriptServiceClientHost {
private readonly ataProgressReporter: AtaProgressReporter;
export default class TypeScriptServiceClientHost extends Disposable {
private readonly typingsStatus: TypingsStatus;
private readonly client: TypeScriptServiceClient;
private readonly languages: LanguageProvider[] = [];
private readonly languagePerId = new Map<string, LanguageProvider>();
private readonly disposables: Disposable[] = [];
private readonly versionStatus: VersionStatus;
private readonly fileConfigurationManager: FileConfigurationManager;
private readonly updateImportsOnFileRenameHandler: UpdateImportsOnFileRenameHandler;
private reportStyleCheckAsWarnings: boolean = true;
constructor(
descriptions: LanguageDescription[],
workspaceState: Memento,
workspaceState: vscode.Memento,
plugins: TypeScriptServerPlugin[],
private readonly commandManager: CommandManager,
logDirectoryProvider: LogDirectoryProvider
) {
super();
const handleProjectCreateOrDelete = () => {
this.client.execute('reloadProjects', null, false);
this.triggerAllDiagnostics();
@ -65,11 +63,11 @@ export default class TypeScriptServiceClientHost {
this.triggerAllDiagnostics();
}, 1500);
};
const configFileWatcher = workspace.createFileSystemWatcher('**/[tj]sconfig.json');
this.disposables.push(configFileWatcher);
configFileWatcher.onDidCreate(handleProjectCreateOrDelete, this, this.disposables);
configFileWatcher.onDidDelete(handleProjectCreateOrDelete, this, this.disposables);
configFileWatcher.onDidChange(handleProjectChange, this, this.disposables);
const configFileWatcher = vscode.workspace.createFileSystemWatcher('**/[tj]sconfig.json');
this._register(configFileWatcher);
configFileWatcher.onDidCreate(handleProjectCreateOrDelete, this, this._disposables);
configFileWatcher.onDidDelete(handleProjectCreateOrDelete, this, this._disposables);
configFileWatcher.onDidChange(handleProjectChange, this, this._disposables);
const allModeIds = this.getAllModeIds(descriptions);
this.client = new TypeScriptServiceClient(
@ -78,30 +76,30 @@ export default class TypeScriptServiceClientHost {
plugins,
logDirectoryProvider,
allModeIds);
this.disposables.push(this.client);
this._register(this.client);
this.client.onDiagnosticsReceived(({ kind, resource, diagnostics }) => {
this.diagnosticsReceived(kind, resource, diagnostics);
}, null, this.disposables);
}, null, this._disposables);
this.client.onConfigDiagnosticsReceived(diag => this.configFileDiagnosticsReceived(diag), null, this.disposables);
this.client.onResendModelsRequested(() => this.populateService(), null, this.disposables);
this.client.onConfigDiagnosticsReceived(diag => this.configFileDiagnosticsReceived(diag), null, this._disposables);
this.client.onResendModelsRequested(() => this.populateService(), null, this._disposables);
this.versionStatus = new VersionStatus(resource => this.client.toPath(resource));
this.disposables.push(this.versionStatus);
this._register(this.versionStatus);
this.typingsStatus = new TypingsStatus(this.client);
this.ataProgressReporter = new AtaProgressReporter(this.client);
this.fileConfigurationManager = new FileConfigurationManager(this.client);
this._register(new AtaProgressReporter(this.client));
this.typingsStatus = this._register(new TypingsStatus(this.client));
this.fileConfigurationManager = this._register(new FileConfigurationManager(this.client));
for (const description of descriptions) {
const manager = new LanguageProvider(this.client, description, this.commandManager, this.client.telemetryReporter, this.typingsStatus, this.fileConfigurationManager);
this.languages.push(manager);
this.disposables.push(manager);
this._register(manager);
this.languagePerId.set(description.id, manager);
}
this.updateImportsOnFileRenameHandler = new UpdateImportsOnFileRenameHandler(this.client, this.fileConfigurationManager, uri => this.handles(uri));
this._register(registerUpdatePathsOnRename(this.client, this.fileConfigurationManager, uri => this.handles(uri)));
this.client.ensureServiceStarted();
this.client.onReady(() => {
@ -126,7 +124,7 @@ export default class TypeScriptServiceClientHost {
};
const manager = new LanguageProvider(this.client, description, this.commandManager, this.client.telemetryReporter, this.typingsStatus, this.fileConfigurationManager);
this.languages.push(manager);
this.disposables.push(manager);
this._register(manager);
this.languagePerId.set(description.id, manager);
}
});
@ -135,7 +133,7 @@ export default class TypeScriptServiceClientHost {
this.triggerAllDiagnostics();
});
workspace.onDidChangeConfiguration(this.configurationChanged, this, this.disposables);
vscode.workspace.onDidChangeConfiguration(this.configurationChanged, this, this._disposables);
this.configurationChanged();
}
@ -147,14 +145,6 @@ export default class TypeScriptServiceClientHost {
return allModeIds;
}
public dispose(): void {
disposeAll(this.disposables);
this.typingsStatus.dispose();
this.ataProgressReporter.dispose();
this.fileConfigurationManager.dispose();
this.updateImportsOnFileRenameHandler.dispose();
}
public get serviceClient(): TypeScriptServiceClient {
return this.client;
}
@ -164,7 +154,7 @@ export default class TypeScriptServiceClientHost {
this.triggerAllDiagnostics();
}
public async handles(resource: Uri): Promise<boolean> {
public async handles(resource: vscode.Uri): Promise<boolean> {
const provider = await this.findLanguage(resource);
if (provider) {
return true;
@ -173,14 +163,14 @@ export default class TypeScriptServiceClientHost {
}
private configurationChanged(): void {
const typescriptConfig = workspace.getConfiguration('typescript');
const typescriptConfig = vscode.workspace.getConfiguration('typescript');
this.reportStyleCheckAsWarnings = typescriptConfig.get('reportStyleChecksAsWarnings', true);
}
private async findLanguage(resource: Uri): Promise<LanguageProvider | undefined> {
private async findLanguage(resource: vscode.Uri): Promise<LanguageProvider | undefined> {
try {
const doc = await workspace.openTextDocument(resource);
const doc = await vscode.workspace.openTextDocument(resource);
return this.languages.find(language => language.handles(resource, doc));
} catch {
return undefined;
@ -199,7 +189,7 @@ export default class TypeScriptServiceClientHost {
this.client.bufferSyncSupport.requestAllDiagnostics();
// See https://github.com/Microsoft/TypeScript/issues/5530
workspace.saveAll(false).then(() => {
vscode.workspace.saveAll(false).then(() => {
for (const language of this.languagePerId.values()) {
language.reInitialize();
}
@ -208,7 +198,7 @@ export default class TypeScriptServiceClientHost {
private async diagnosticsReceived(
kind: DiagnosticKind,
resource: Uri,
resource: vscode.Uri,
diagnostics: Proto.Diagnostic[]
): Promise<void> {
const language = await this.findLanguage(resource);
@ -234,10 +224,10 @@ export default class TypeScriptServiceClientHost {
if (body.diagnostics.length === 0) {
language.configFileDiagnosticsReceived(this.client.toResource(body.configFile), []);
} else if (body.diagnostics.length >= 1) {
workspace.openTextDocument(Uri.file(body.configFile)).then((document) => {
vscode.workspace.openTextDocument(vscode.Uri.file(body.configFile)).then((document) => {
let curly: [number, number, number] | undefined = undefined;
let nonCurly: [number, number, number] | undefined = undefined;
let diagnostic: Diagnostic;
let diagnostic: vscode.Diagnostic;
for (let index = 0; index < document.lineCount; index++) {
const line = document.lineAt(index);
const text = line.text;
@ -256,16 +246,16 @@ export default class TypeScriptServiceClientHost {
}
const match = curly || nonCurly;
if (match) {
diagnostic = new Diagnostic(new Range(match[0], match[1], match[0], match[2]), body.diagnostics[0].text);
diagnostic = new vscode.Diagnostic(new vscode.Range(match[0], match[1], match[0], match[2]), body.diagnostics[0].text);
} else {
diagnostic = new Diagnostic(new Range(0, 0, 0, 0), body.diagnostics[0].text);
diagnostic = new vscode.Diagnostic(new vscode.Range(0, 0, 0, 0), body.diagnostics[0].text);
}
if (diagnostic) {
diagnostic.source = language.diagnosticSource;
language.configFileDiagnosticsReceived(this.client.toResource(body.configFile), [diagnostic]);
}
}, _error => {
language.configFileDiagnosticsReceived(this.client.toResource(body.configFile), [new Diagnostic(new Range(0, 0, 0, 0), body.diagnostics[0].text)]);
language.configFileDiagnosticsReceived(this.client.toResource(body.configFile), [new vscode.Diagnostic(new vscode.Range(0, 0, 0, 0), body.diagnostics[0].text)]);
});
}
});
@ -274,14 +264,14 @@ export default class TypeScriptServiceClientHost {
private createMarkerDatas(
diagnostics: Proto.Diagnostic[],
source: string
): (Diagnostic & { reportUnnecessary: any })[] {
): (vscode.Diagnostic & { reportUnnecessary: any })[] {
return diagnostics.map(tsDiag => this.tsDiagnosticToVsDiagnostic(tsDiag, source));
}
private tsDiagnosticToVsDiagnostic(diagnostic: Proto.Diagnostic, source: string): Diagnostic & { reportUnnecessary: any } {
private tsDiagnosticToVsDiagnostic(diagnostic: Proto.Diagnostic, source: string): vscode.Diagnostic & { reportUnnecessary: any } {
const { start, end, text } = diagnostic;
const range = new Range(typeConverters.Position.fromLocation(start), typeConverters.Position.fromLocation(end));
const converted = new Diagnostic(range, text);
const range = new vscode.Range(typeConverters.Position.fromLocation(start), typeConverters.Position.fromLocation(end));
const converted = new vscode.Diagnostic(range, text);
converted.severity = this.getDiagnosticSeverity(diagnostic);
converted.source = diagnostic.source || source;
if (diagnostic.code) {
@ -294,36 +284,36 @@ export default class TypeScriptServiceClientHost {
if (!span) {
return undefined;
}
return new DiagnosticRelatedInformation(typeConverters.Location.fromTextSpan(this.client.toResource(span.file), span), info.message);
}).filter((x: any) => !!x) as DiagnosticRelatedInformation[];
return new vscode.DiagnosticRelatedInformation(typeConverters.Location.fromTextSpan(this.client.toResource(span.file), span), info.message);
}).filter((x: any) => !!x) as vscode.DiagnosticRelatedInformation[];
}
if (diagnostic.reportsUnnecessary) {
converted.tags = [DiagnosticTag.Unnecessary];
converted.tags = [vscode.DiagnosticTag.Unnecessary];
}
(converted as Diagnostic & { reportUnnecessary: any }).reportUnnecessary = diagnostic.reportsUnnecessary;
return converted as Diagnostic & { reportUnnecessary: any };
(converted as vscode.Diagnostic & { reportUnnecessary: any }).reportUnnecessary = diagnostic.reportsUnnecessary;
return converted as vscode.Diagnostic & { reportUnnecessary: any };
}
private getDiagnosticSeverity(diagnostic: Proto.Diagnostic): DiagnosticSeverity {
private getDiagnosticSeverity(diagnostic: Proto.Diagnostic): vscode.DiagnosticSeverity {
if (this.reportStyleCheckAsWarnings
&& this.isStyleCheckDiagnostic(diagnostic.code)
&& diagnostic.category === PConst.DiagnosticCategory.error
) {
return DiagnosticSeverity.Warning;
return vscode.DiagnosticSeverity.Warning;
}
switch (diagnostic.category) {
case PConst.DiagnosticCategory.error:
return DiagnosticSeverity.Error;
return vscode.DiagnosticSeverity.Error;
case PConst.DiagnosticCategory.warning:
return DiagnosticSeverity.Warning;
return vscode.DiagnosticSeverity.Warning;
case PConst.DiagnosticCategory.suggestion:
return DiagnosticSeverity.Hint;
return vscode.DiagnosticSeverity.Hint;
default:
return DiagnosticSeverity.Error;
return vscode.DiagnosticSeverity.Error;
}
}

View file

@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { CancellationToken, Event, Uri } from 'vscode';
import * as vscode from 'vscode';
import BufferSyncSupport from './features/bufferSyncSupport';
import * as Proto from './protocol';
import API from './utils/api';
@ -17,27 +17,27 @@ export interface ITypeScriptServiceClient {
*
* Does not try handling case insensitivity.
*/
normalizedPath(resource: Uri): string | null;
normalizedPath(resource: vscode.Uri): string | null;
/**
* Map a resource to a normalized path
*
* This will attempt to handle case insensitivity.
*/
toPath(resource: Uri): string | null;
toPath(resource: vscode.Uri): string | null;
/**
* Convert a path to a resource.
*/
toResource(filepath: string): Uri;
toResource(filepath: string): vscode.Uri;
getWorkspaceRootForResource(resource: Uri): string | undefined;
getWorkspaceRootForResource(resource: vscode.Uri): string | undefined;
readonly onTsServerStarted: Event<API>;
readonly onProjectLanguageServiceStateChanged: Event<Proto.ProjectLanguageServiceStateEventBody>;
readonly onDidBeginInstallTypings: Event<Proto.BeginInstallTypesEventBody>;
readonly onDidEndInstallTypings: Event<Proto.EndInstallTypesEventBody>;
readonly onTypesInstallerInitializationFailed: Event<Proto.TypesInstallerInitializationFailedEventBody>;
readonly onTsServerStarted: vscode.Event<API>;
readonly onProjectLanguageServiceStateChanged: vscode.Event<Proto.ProjectLanguageServiceStateEventBody>;
readonly onDidBeginInstallTypings: vscode.Event<Proto.BeginInstallTypesEventBody>;
readonly onDidEndInstallTypings: vscode.Event<Proto.EndInstallTypesEventBody>;
readonly onTypesInstallerInitializationFailed: vscode.Event<Proto.TypesInstallerInitializationFailedEventBody>;
readonly apiVersion: API;
readonly plugins: TypeScriptServerPlugin[];
@ -45,42 +45,42 @@ export interface ITypeScriptServiceClient {
readonly logger: Logger;
readonly bufferSyncSupport: BufferSyncSupport;
execute(command: 'configure', args: Proto.ConfigureRequestArguments, token?: CancellationToken): Promise<Proto.ConfigureResponse>;
execute(command: 'open', args: Proto.OpenRequestArgs, expectedResult: boolean, token?: CancellationToken): Promise<any>;
execute(command: 'close', args: Proto.FileRequestArgs, expectedResult: boolean, token?: CancellationToken): Promise<any>;
execute(command: 'change', args: Proto.ChangeRequestArgs, expectedResult: boolean, token?: CancellationToken): Promise<any>;
execute(command: 'quickinfo', args: Proto.FileLocationRequestArgs, token?: CancellationToken): Promise<Proto.QuickInfoResponse>;
execute(command: 'completions', args: Proto.CompletionsRequestArgs, token?: CancellationToken): Promise<Proto.CompletionsResponse>;
execute(command: 'completionInfo', args: Proto.CompletionsRequestArgs, token?: CancellationToken): Promise<Proto.CompletionInfoResponse>;
execute(command: 'completionEntryDetails', args: Proto.CompletionDetailsRequestArgs, token?: CancellationToken): Promise<Proto.CompletionDetailsResponse>;
execute(command: 'signatureHelp', args: Proto.SignatureHelpRequestArgs, token?: CancellationToken): Promise<Proto.SignatureHelpResponse>;
execute(command: 'definition', args: Proto.FileLocationRequestArgs, token?: CancellationToken): Promise<Proto.DefinitionResponse>;
execute(command: 'definitionAndBoundSpan', args: Proto.FileLocationRequestArgs, token?: CancellationToken): Promise<Proto.DefinitionInfoAndBoundSpanReponse>;
execute(command: 'implementation', args: Proto.FileLocationRequestArgs, token?: CancellationToken): Promise<Proto.ImplementationResponse>;
execute(command: 'typeDefinition', args: Proto.FileLocationRequestArgs, token?: CancellationToken): Promise<Proto.TypeDefinitionResponse>;
execute(command: 'references', args: Proto.FileLocationRequestArgs, token?: CancellationToken): Promise<Proto.ReferencesResponse>;
execute(command: 'navto', args: Proto.NavtoRequestArgs, token?: CancellationToken): Promise<Proto.NavtoResponse>;
execute(command: 'format', args: Proto.FormatRequestArgs, token?: CancellationToken): Promise<Proto.FormatResponse>;
execute(command: 'formatonkey', args: Proto.FormatOnKeyRequestArgs, token?: CancellationToken): Promise<Proto.FormatResponse>;
execute(command: 'rename', args: Proto.RenameRequestArgs, token?: CancellationToken): Promise<Proto.RenameResponse>;
execute(command: 'occurrences', args: Proto.FileLocationRequestArgs, token?: CancellationToken): Promise<Proto.OccurrencesResponse>;
execute(command: 'projectInfo', args: Proto.ProjectInfoRequestArgs, token?: CancellationToken): Promise<Proto.ProjectInfoResponse>;
execute(command: 'reloadProjects', args: any, expectedResult: boolean, token?: CancellationToken): Promise<any>;
execute(command: 'reload', args: Proto.ReloadRequestArgs, expectedResult: boolean, token?: CancellationToken): Promise<any>;
execute(command: 'compilerOptionsForInferredProjects', args: Proto.SetCompilerOptionsForInferredProjectsArgs, token?: CancellationToken): Promise<any>;
execute(command: 'navtree', args: Proto.FileRequestArgs, token?: CancellationToken): Promise<Proto.NavTreeResponse>;
execute(command: 'getCodeFixes', args: Proto.CodeFixRequestArgs, token?: CancellationToken): Promise<Proto.GetCodeFixesResponse>;
execute(command: 'getSupportedCodeFixes', args: null, token?: CancellationToken): Promise<Proto.GetSupportedCodeFixesResponse>;
execute(command: 'getCombinedCodeFix', args: Proto.GetCombinedCodeFixRequestArgs, token?: CancellationToken): Promise<Proto.GetCombinedCodeFixResponse>;
execute(command: 'docCommentTemplate', args: Proto.FileLocationRequestArgs, token?: CancellationToken): Promise<Proto.DocCommandTemplateResponse>;
execute(command: 'getApplicableRefactors', args: Proto.GetApplicableRefactorsRequestArgs, token?: CancellationToken): Promise<Proto.GetApplicableRefactorsResponse>;
execute(command: 'getEditsForRefactor', args: Proto.GetEditsForRefactorRequestArgs, token?: CancellationToken): Promise<Proto.GetEditsForRefactorResponse>;
execute(command: 'applyCodeActionCommand', args: Proto.ApplyCodeActionCommandRequestArgs, token?: CancellationToken): Promise<Proto.ApplyCodeActionCommandResponse>;
execute(command: 'organizeImports', args: Proto.OrganizeImportsRequestArgs, token?: CancellationToken): Promise<Proto.OrganizeImportsResponse>;
execute(command: 'getOutliningSpans', args: Proto.FileRequestArgs, token: CancellationToken): Promise<Proto.OutliningSpansResponse>;
execute(command: 'configure', args: Proto.ConfigureRequestArguments, token?: vscode.CancellationToken): Promise<Proto.ConfigureResponse>;
execute(command: 'open', args: Proto.OpenRequestArgs, expectedResult: boolean, token?: vscode.CancellationToken): Promise<any>;
execute(command: 'close', args: Proto.FileRequestArgs, expectedResult: boolean, token?: vscode.CancellationToken): Promise<any>;
execute(command: 'change', args: Proto.ChangeRequestArgs, expectedResult: boolean, token?: vscode.CancellationToken): Promise<any>;
execute(command: 'quickinfo', args: Proto.FileLocationRequestArgs, token?: vscode.CancellationToken): Promise<Proto.QuickInfoResponse>;
execute(command: 'completions', args: Proto.CompletionsRequestArgs, token?: vscode.CancellationToken): Promise<Proto.CompletionsResponse>;
execute(command: 'completionInfo', args: Proto.CompletionsRequestArgs, token?: vscode.CancellationToken): Promise<Proto.CompletionInfoResponse>;
execute(command: 'completionEntryDetails', args: Proto.CompletionDetailsRequestArgs, token?: vscode.CancellationToken): Promise<Proto.CompletionDetailsResponse>;
execute(command: 'signatureHelp', args: Proto.SignatureHelpRequestArgs, token?: vscode.CancellationToken): Promise<Proto.SignatureHelpResponse>;
execute(command: 'definition', args: Proto.FileLocationRequestArgs, token?: vscode.CancellationToken): Promise<Proto.DefinitionResponse>;
execute(command: 'definitionAndBoundSpan', args: Proto.FileLocationRequestArgs, token?: vscode.CancellationToken): Promise<Proto.DefinitionInfoAndBoundSpanReponse>;
execute(command: 'implementation', args: Proto.FileLocationRequestArgs, token?: vscode.CancellationToken): Promise<Proto.ImplementationResponse>;
execute(command: 'typeDefinition', args: Proto.FileLocationRequestArgs, token?: vscode.CancellationToken): Promise<Proto.TypeDefinitionResponse>;
execute(command: 'references', args: Proto.FileLocationRequestArgs, token?: vscode.CancellationToken): Promise<Proto.ReferencesResponse>;
execute(command: 'navto', args: Proto.NavtoRequestArgs, token?: vscode.CancellationToken): Promise<Proto.NavtoResponse>;
execute(command: 'format', args: Proto.FormatRequestArgs, token?: vscode.CancellationToken): Promise<Proto.FormatResponse>;
execute(command: 'formatonkey', args: Proto.FormatOnKeyRequestArgs, token?: vscode.CancellationToken): Promise<Proto.FormatResponse>;
execute(command: 'rename', args: Proto.RenameRequestArgs, token?: vscode.CancellationToken): Promise<Proto.RenameResponse>;
execute(command: 'occurrences', args: Proto.FileLocationRequestArgs, token?: vscode.CancellationToken): Promise<Proto.OccurrencesResponse>;
execute(command: 'projectInfo', args: Proto.ProjectInfoRequestArgs, token?: vscode.CancellationToken): Promise<Proto.ProjectInfoResponse>;
execute(command: 'reloadProjects', args: any, expectedResult: boolean, token?: vscode.CancellationToken): Promise<any>;
execute(command: 'reload', args: Proto.ReloadRequestArgs, expectedResult: boolean, token?: vscode.CancellationToken): Promise<any>;
execute(command: 'compilerOptionsForInferredProjects', args: Proto.SetCompilerOptionsForInferredProjectsArgs, token?: vscode.CancellationToken): Promise<any>;
execute(command: 'navtree', args: Proto.FileRequestArgs, token?: vscode.CancellationToken): Promise<Proto.NavTreeResponse>;
execute(command: 'getCodeFixes', args: Proto.CodeFixRequestArgs, token?: vscode.CancellationToken): Promise<Proto.GetCodeFixesResponse>;
execute(command: 'getSupportedCodeFixes', args: null, token?: vscode.CancellationToken): Promise<Proto.GetSupportedCodeFixesResponse>;
execute(command: 'getCombinedCodeFix', args: Proto.GetCombinedCodeFixRequestArgs, token?: vscode.CancellationToken): Promise<Proto.GetCombinedCodeFixResponse>;
execute(command: 'docCommentTemplate', args: Proto.FileLocationRequestArgs, token?: vscode.CancellationToken): Promise<Proto.DocCommandTemplateResponse>;
execute(command: 'getApplicableRefactors', args: Proto.GetApplicableRefactorsRequestArgs, token?: vscode.CancellationToken): Promise<Proto.GetApplicableRefactorsResponse>;
execute(command: 'getEditsForRefactor', args: Proto.GetEditsForRefactorRequestArgs, token?: vscode.CancellationToken): Promise<Proto.GetEditsForRefactorResponse>;
execute(command: 'applyCodeActionCommand', args: Proto.ApplyCodeActionCommandRequestArgs, token?: vscode.CancellationToken): Promise<Proto.ApplyCodeActionCommandResponse>;
execute(command: 'organizeImports', args: Proto.OrganizeImportsRequestArgs, token?: vscode.CancellationToken): Promise<Proto.OrganizeImportsResponse>;
execute(command: 'getOutliningSpans', args: Proto.FileRequestArgs, token: vscode.CancellationToken): Promise<Proto.OutliningSpansResponse>;
execute(command: 'getEditsForFileRename', args: Proto.GetEditsForFileRenameRequestArgs): Promise<Proto.GetEditsForFileRenameResponse>;
execute(command: 'jsxClosingTag', args: Proto.JsxClosingTagRequestArgs, token: CancellationToken): Promise<Proto.JsxClosingTagResponse>;
execute(command: string, args: any, expectedResult: boolean | CancellationToken, token?: CancellationToken): Promise<any>;
execute(command: 'jsxClosingTag', args: Proto.JsxClosingTagRequestArgs, token: vscode.CancellationToken): Promise<Proto.JsxClosingTagResponse>;
execute(command: string, args: any, expectedResult: boolean | vscode.CancellationToken, token?: vscode.CancellationToken): Promise<any>;
executeAsync(command: 'geterr', args: Proto.GeterrRequestArgs, token: CancellationToken): Promise<any>;
executeAsync(command: 'geterr', args: Proto.GeterrRequestArgs, token: vscode.CancellationToken): Promise<any>;
}

View file

@ -6,7 +6,7 @@
import * as cp from 'child_process';
import * as fs from 'fs';
import * as path from 'path';
import { CancellationToken, commands, Disposable, env, EventEmitter, Memento, MessageItem, Uri, window, workspace } from 'vscode';
import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
import BufferSyncSupport from './features/bufferSyncSupport';
import { DiagnosticKind, DiagnosticsManager } from './features/diagnostics';
@ -14,7 +14,7 @@ import * as Proto from './protocol';
import { ITypeScriptServiceClient } from './typescriptService';
import API from './utils/api';
import { TsServerLogLevel, TypeScriptServiceConfiguration } from './utils/configuration';
import { disposeAll } from './utils/dispose';
import { Disposable } from './utils/dispose';
import * as electron from './utils/electron';
import * as fileSchemes from './utils/fileSchemes';
import * as is from './utils/is';
@ -30,9 +30,6 @@ import { TypeScriptVersion, TypeScriptVersionProvider } from './utils/versionPro
import { ICallback, Reader } from './utils/wireProtocol';
const localize = nls.loadMessageBundle();
interface CallbackItem {
@ -155,11 +152,11 @@ class ForkedTsServerProcess {
export interface TsDiagnostics {
readonly kind: DiagnosticKind;
readonly resource: Uri;
readonly resource: vscode.Uri;
readonly diagnostics: Proto.Diagnostic[];
}
export default class TypeScriptServiceClient implements ITypeScriptServiceClient {
export default class TypeScriptServiceClient extends Disposable implements ITypeScriptServiceClient {
private static readonly WALK_THROUGH_SNIPPET_SCHEME_COLON = `${fileSchemes.walkThroughSnippet}:`;
private pathSeparator: string;
@ -194,18 +191,17 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
*/
private _tsserverVersion: string | undefined;
private readonly disposables: Disposable[] = [];
public readonly bufferSyncSupport: BufferSyncSupport;
public readonly diagnosticsManager: DiagnosticsManager;
constructor(
private readonly workspaceState: Memento,
private readonly workspaceState: vscode.Memento,
private readonly onDidChangeTypeScriptVersion: (version: TypeScriptVersion) => void,
public readonly plugins: TypeScriptServerPlugin[],
private readonly logDirectoryProvider: LogDirectoryProvider,
allModeIds: string[]
) {
super();
this.pathSeparator = path.sep;
this.lastStart = Date.now();
@ -235,9 +231,9 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
this.diagnosticsManager = new DiagnosticsManager('typescript');
this.bufferSyncSupport.onDelete(resource => {
this.diagnosticsManager.delete(resource);
}, null, this.disposables);
}, null, this._disposables);
workspace.onDidChangeConfiguration(() => {
vscode.workspace.onDidChangeConfiguration(() => {
const oldConfiguration = this._configuration;
this._configuration = TypeScriptServiceConfiguration.loadFromWorkspace();
@ -256,9 +252,9 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
this.restartTsServer();
}
}
}, this, this.disposables);
}, this, this._disposables);
this.telemetryReporter = new TelemetryReporter(() => this._tsserverVersion || this._apiVersion.versionString);
this.disposables.push(this.telemetryReporter);
this._register(this.telemetryReporter);
}
public get configuration() {
@ -266,22 +262,15 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
}
public dispose() {
super.dispose();
this.bufferSyncSupport.dispose();
this._onTsServerStarted.dispose();
this._onDidBeginInstallTypings.dispose();
this._onDidEndInstallTypings.dispose();
this._onTypesInstallerInitializationFailed.dispose();
if (this.servicePromise) {
this.servicePromise.then(childProcess => {
childProcess.kill();
}).then(undefined, () => void 0);
}
disposeAll(this.disposables);
this._onDiagnosticsReceived.dispose();
this._onConfigDiagnosticsReceived.dispose();
this._onResendModelsRequested.dispose();
}
public restartTsServer(): void {
@ -302,28 +291,28 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
}
}
private readonly _onTsServerStarted = new EventEmitter<API>();
private readonly _onTsServerStarted = this._register(new vscode.EventEmitter<API>());
public readonly onTsServerStarted = this._onTsServerStarted.event;
private readonly _onDiagnosticsReceived = new EventEmitter<TsDiagnostics>();
private readonly _onDiagnosticsReceived = this._register(new vscode.EventEmitter<TsDiagnostics>());
public readonly onDiagnosticsReceived = this._onDiagnosticsReceived.event;
private readonly _onConfigDiagnosticsReceived = new EventEmitter<Proto.ConfigFileDiagnosticEvent>();
private readonly _onConfigDiagnosticsReceived = this._register(new vscode.EventEmitter<Proto.ConfigFileDiagnosticEvent>());
public readonly onConfigDiagnosticsReceived = this._onConfigDiagnosticsReceived.event;
private readonly _onResendModelsRequested = new EventEmitter<void>();
private readonly _onResendModelsRequested = this._register(new vscode.EventEmitter<void>());
public readonly onResendModelsRequested = this._onResendModelsRequested.event;
private readonly _onProjectLanguageServiceStateChanged = new EventEmitter<Proto.ProjectLanguageServiceStateEventBody>();
private readonly _onProjectLanguageServiceStateChanged = this._register(new vscode.EventEmitter<Proto.ProjectLanguageServiceStateEventBody>());
public readonly onProjectLanguageServiceStateChanged = this._onProjectLanguageServiceStateChanged.event;
private readonly _onDidBeginInstallTypings = new EventEmitter<Proto.BeginInstallTypesEventBody>();
private readonly _onDidBeginInstallTypings = this._register(new vscode.EventEmitter<Proto.BeginInstallTypesEventBody>());
public readonly onDidBeginInstallTypings = this._onDidBeginInstallTypings.event;
private readonly _onDidEndInstallTypings = new EventEmitter<Proto.EndInstallTypesEventBody>();
private readonly _onDidEndInstallTypings = this._register(new vscode.EventEmitter<Proto.EndInstallTypesEventBody>());
public readonly onDidEndInstallTypings = this._onDidEndInstallTypings.event;
private readonly _onTypesInstallerInitializationFailed = new EventEmitter<Proto.TypesInstallerInitializationFailedEventBody>();
private readonly _onTypesInstallerInitializationFailed = this._register(new vscode.EventEmitter<Proto.TypesInstallerInitializationFailedEventBody>());
public readonly onTypesInstallerInitializationFailed = this._onTypesInstallerInitializationFailed.event;
public get apiVersion(): API {
@ -371,7 +360,7 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
this.info(`Using tsserver from: ${currentVersion.path}`);
if (!fs.existsSync(currentVersion.tsServerPath)) {
window.showWarningMessage(localize('noServerFound', 'The path {0} doesn\'t point to a valid tsserver install. Falling back to bundled TypeScript version.', currentVersion.path));
vscode.window.showWarningMessage(localize('noServerFound', 'The path {0} doesn\'t point to a valid tsserver install. Falling back to bundled TypeScript version.', currentVersion.path));
this.versionPicker.useBundledVersion();
currentVersion = this.versionPicker.currentVersion;
@ -395,7 +384,7 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
if (err || !childProcess) {
this.lastError = err;
this.error('Starting TSServer failed with error.', err);
window.showErrorMessage(localize('serverCouldNotBeStarted', 'TypeScript language server couldn\'t be started. Error message is: {0}', err.message || err));
vscode.window.showErrorMessage(localize('serverCouldNotBeStarted', 'TypeScript language server couldn\'t be started. Error message is: {0}', err.message || err));
/* __GDPR__
"error" : {
"${include}": [
@ -482,7 +471,7 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
public async openTsServerLogFile(): Promise<boolean> {
if (!this.apiVersion.gte(API.v222)) {
window.showErrorMessage(
vscode.window.showErrorMessage(
localize(
'typescript.openTsServerLog.notSupported',
'TS Server logging requires TS 2.2.2+'));
@ -490,7 +479,7 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
}
if (this._configuration.tsServerLogLevel === TsServerLogLevel.Off) {
window.showErrorMessage<MessageItem>(
vscode.window.showErrorMessage<vscode.MessageItem>(
localize(
'typescript.openTsServerLog.loggingNotEnabled',
'TS Server logging is off. Please set `typescript.tsserver.log` and restart the TS server to enable logging'),
@ -501,7 +490,7 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
})
.then(selection => {
if (selection) {
return workspace.getConfiguration().update('typescript.tsserver.log', 'verbose', true).then(() => {
return vscode.workspace.getConfiguration().update('typescript.tsserver.log', 'verbose', true).then(() => {
this.restartTsServer();
});
}
@ -511,17 +500,17 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
}
if (!this.tsServerLogFile) {
window.showWarningMessage(localize(
vscode.window.showWarningMessage(localize(
'typescript.openTsServerLog.noLogFile',
'TS Server has not started logging.'));
return false;
}
try {
await commands.executeCommand('revealFileInOS', Uri.parse(this.tsServerLogFile));
await vscode.commands.executeCommand('revealFileInOS', vscode.Uri.parse(this.tsServerLogFile));
return true;
} catch {
window.showWarningMessage(localize(
vscode.window.showWarningMessage(localize(
'openTsServerLog.openFileFailedFailed',
'Could not open TS Server log file'));
return false;
@ -564,7 +553,7 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
reportIssue
}
interface MyMessageItem extends MessageItem {
interface MyMessageItem extends vscode.MessageItem {
id: MessageAction;
}
@ -585,7 +574,7 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
if (diff < 10 * 1000 /* 10 seconds */) {
this.lastStart = Date.now();
startService = false;
prompt = window.showErrorMessage<MyMessageItem>(
prompt = vscode.window.showErrorMessage<MyMessageItem>(
localize('serverDiedAfterStart', 'The TypeScript language service died 5 times right after it got started. The service will not be restarted.'),
{
title: localize('serverDiedReportIssue', 'Report Issue'),
@ -602,7 +591,7 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
this.resetClientVersion();
} else if (diff < 60 * 1000 /* 1 Minutes */) {
this.lastStart = Date.now();
prompt = window.showWarningMessage<MyMessageItem>(
prompt = vscode.window.showWarningMessage<MyMessageItem>(
localize('serverDied', 'The TypeScript language service died unexpectedly 5 times in the last 5 Minutes.'),
{
title: localize('serverDiedReportIssue', 'Report Issue'),
@ -612,7 +601,7 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
if (prompt) {
prompt.then(item => {
if (item && item.id === MessageAction.reportIssue) {
return commands.executeCommand('workbench.action.reportIssues');
return vscode.commands.executeCommand('workbench.action.reportIssues');
}
return undefined;
});
@ -624,7 +613,7 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
}
}
public normalizedPath(resource: Uri): string | null {
public normalizedPath(resource: vscode.Uri): string | null {
if (this._apiVersion.gte(API.v213)) {
if (resource.scheme === fileSchemes.walkThroughSnippet || resource.scheme === fileSchemes.untitled) {
const dirName = path.dirname(resource.path);
@ -646,7 +635,7 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
return result.replace(new RegExp('\\' + this.pathSeparator, 'g'), '/');
}
public toPath(resource: Uri): string | null {
public toPath(resource: vscode.Uri): string | null {
return this.normalizedPath(resource);
}
@ -654,11 +643,11 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
return this._apiVersion.gte(API.v270) ? '^' : '';
}
public toResource(filepath: string): Uri {
public toResource(filepath: string): vscode.Uri {
if (this._apiVersion.gte(API.v213)) {
if (filepath.startsWith(TypeScriptServiceClient.WALK_THROUGH_SNIPPET_SCHEME_COLON) || (filepath.startsWith(fileSchemes.untitled + ':'))
) {
let resource = Uri.parse(filepath);
let resource = vscode.Uri.parse(filepath);
if (this.inMemoryResourcePrefix) {
const dirName = path.dirname(resource.path);
const fileName = path.basename(resource.path);
@ -672,8 +661,8 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
return this.bufferSyncSupport.toResource(filepath);
}
public getWorkspaceRootForResource(resource: Uri): string | undefined {
const roots = workspace.workspaceFolders;
public getWorkspaceRootForResource(resource: vscode.Uri): string | undefined {
const roots = vscode.workspace.workspaceFolders;
if (!roots || !roots.length) {
return undefined;
}
@ -690,12 +679,12 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
return undefined;
}
public executeAsync(command: string, args: Proto.GeterrRequestArgs, token: CancellationToken): Promise<any> {
public executeAsync(command: string, args: Proto.GeterrRequestArgs, token: vscode.CancellationToken): Promise<any> {
return this.executeImpl(command, args, { isAsync: true, token, expectsResult: true });
}
public execute(command: string, args: any, expectsResultOrToken?: boolean | CancellationToken): Promise<any> {
let token: CancellationToken | undefined = undefined;
public execute(command: string, args: any, expectsResultOrToken?: boolean | vscode.CancellationToken): Promise<any> {
let token: vscode.CancellationToken | undefined = undefined;
let expectsResult = true;
if (typeof expectsResultOrToken === 'boolean') {
expectsResult = expectsResultOrToken;
@ -705,7 +694,7 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
return this.executeImpl(command, args, { isAsync: false, token, expectsResult });
}
private executeImpl(command: string, args: any, executeInfo: { isAsync: boolean, token?: CancellationToken, expectsResult: boolean }): Promise<any> {
private executeImpl(command: string, args: any, executeInfo: { isAsync: boolean, token?: vscode.CancellationToken, expectsResult: boolean }): Promise<any> {
const request = this.requestQueue.createRequest(command, args);
const requestInfo: RequestItem = {
request: request,
@ -885,7 +874,7 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
case 'projectsUpdatedInBackground':
if (event.body) {
const body = (event as Proto.ProjectsUpdatedInBackgroundEvent).body;
const resources = body.openFiles.map(Uri.file);
const resources = body.openFiles.map(vscode.Uri.file);
this.bufferSyncSupport.getErr(resources);
}
break;
@ -1059,7 +1048,7 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
const getTsLocale = (configuration: TypeScriptServiceConfiguration): string | undefined =>
(configuration.locale
? configuration.locale
: env.language);
: vscode.env.language);
function getDignosticsKind(event: Proto.Event) {
switch (event.event) {

View file

@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { workspace, WorkspaceEdit } from 'vscode';
import * as vscode from 'vscode';
import * as Proto from '../protocol';
import { ITypeScriptServiceClient } from '../typescriptService';
import * as typeConverters from './typeConverters';
@ -11,7 +11,7 @@ import * as typeConverters from './typeConverters';
export function getEditForCodeAction(
client: ITypeScriptServiceClient,
action: Proto.CodeAction
): WorkspaceEdit | undefined {
): vscode.WorkspaceEdit | undefined {
return action.changes && action.changes.length
? typeConverters.WorkspaceEdit.fromFileCodeEdits(client, action.changes)
: undefined;
@ -23,23 +23,20 @@ export async function applyCodeAction(
): Promise<boolean> {
const workspaceEdit = getEditForCodeAction(client, action);
if (workspaceEdit) {
if (!(await workspace.applyEdit(workspaceEdit))) {
if (!(await vscode.workspace.applyEdit(workspaceEdit))) {
return false;
}
}
return applyCodeActionCommands(client, action);
return applyCodeActionCommands(client, action.commands);
}
export async function applyCodeActionCommands(
client: ITypeScriptServiceClient,
action: Proto.CodeAction
commands: ReadonlyArray<{}> | undefined
): Promise<boolean> {
if (action.commands && action.commands.length) {
for (const command of action.commands) {
const response = await client.execute('applyCodeActionCommand', { command });
if (!response || !response.body) {
return false;
}
if (commands && commands.length) {
for (const command of commands) {
await client.execute('applyCodeActionCommand', { command });
}
}
return true;

View file

@ -2,7 +2,7 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { workspace, WorkspaceConfiguration } from 'vscode';
import * as vscode from 'vscode';
import * as arrays from './arrays';
export enum TsServerLogLevel {
@ -58,7 +58,7 @@ export class TypeScriptServiceConfiguration {
}
private constructor() {
const configuration = workspace.getConfiguration();
const configuration = vscode.workspace.getConfiguration();
this.locale = TypeScriptServiceConfiguration.extractLocale(configuration);
this.globalTsdk = TypeScriptServiceConfiguration.extractGlobalTsdk(configuration);
@ -83,7 +83,7 @@ export class TypeScriptServiceConfiguration {
&& arrays.equals(this.tsServerPluginPaths, other.tsServerPluginPaths);
}
private static extractGlobalTsdk(configuration: WorkspaceConfiguration): string | null {
private static extractGlobalTsdk(configuration: vscode.WorkspaceConfiguration): string | null {
const inspect = configuration.inspect('typescript.tsdk');
if (inspect && inspect.globalValue && 'string' === typeof inspect.globalValue) {
return inspect.globalValue;
@ -91,7 +91,7 @@ export class TypeScriptServiceConfiguration {
return null;
}
private static extractLocalTsdk(configuration: WorkspaceConfiguration): string | null {
private static extractLocalTsdk(configuration: vscode.WorkspaceConfiguration): string | null {
const inspect = configuration.inspect('typescript.tsdk');
if (inspect && inspect.workspaceValue && 'string' === typeof inspect.workspaceValue) {
return inspect.workspaceValue;
@ -99,32 +99,32 @@ export class TypeScriptServiceConfiguration {
return null;
}
private static readTsServerLogLevel(configuration: WorkspaceConfiguration): TsServerLogLevel {
private static readTsServerLogLevel(configuration: vscode.WorkspaceConfiguration): TsServerLogLevel {
const setting = configuration.get<string>('typescript.tsserver.log', 'off');
return TsServerLogLevel.fromString(setting);
}
private static readTsServerPluginPaths(configuration: WorkspaceConfiguration): string[] {
private static readTsServerPluginPaths(configuration: vscode.WorkspaceConfiguration): string[] {
return configuration.get<string[]>('typescript.tsserver.pluginPaths', []);
}
private static readCheckJs(configuration: WorkspaceConfiguration): boolean {
private static readCheckJs(configuration: vscode.WorkspaceConfiguration): boolean {
return configuration.get<boolean>('javascript.implicitProjectConfig.checkJs', false);
}
private static readExperimentalDecorators(configuration: WorkspaceConfiguration): boolean {
private static readExperimentalDecorators(configuration: vscode.WorkspaceConfiguration): boolean {
return configuration.get<boolean>('javascript.implicitProjectConfig.experimentalDecorators', false);
}
private static readNpmLocation(configuration: WorkspaceConfiguration): string | null {
private static readNpmLocation(configuration: vscode.WorkspaceConfiguration): string | null {
return configuration.get<string | null>('typescript.npm', null);
}
private static readDisableAutomaticTypeAcquisition(configuration: WorkspaceConfiguration): boolean {
private static readDisableAutomaticTypeAcquisition(configuration: vscode.WorkspaceConfiguration): boolean {
return configuration.get<boolean>('typescript.disableAutomaticTypeAcquisition', false);
}
private static extractLocale(configuration: WorkspaceConfiguration): string | null {
private static extractLocale(configuration: vscode.WorkspaceConfiguration): string | null {
return configuration.get<string | null>('typescript.locale', null);
}
}

View file

@ -6,7 +6,7 @@
import * as vscode from 'vscode';
import { ITypeScriptServiceClient } from '../typescriptService';
import API from './api';
import { disposeAll } from './dispose';
import { Disposable } from './dispose';
export class ConditionalRegistration {
private registration: vscode.Disposable | undefined = undefined;
@ -36,15 +36,15 @@ export class ConditionalRegistration {
}
}
export class VersionDependentRegistration {
export class VersionDependentRegistration extends Disposable {
private readonly _registration: ConditionalRegistration;
private readonly _disposables: vscode.Disposable[] = [];
constructor(
private readonly client: ITypeScriptServiceClient,
private readonly minVersion: API,
register: () => vscode.Disposable,
) {
super();
this._registration = new ConditionalRegistration(register);
this.update(client.apiVersion);
@ -55,7 +55,7 @@ export class VersionDependentRegistration {
}
public dispose() {
disposeAll(this._disposables);
super.dispose();
this._registration.dispose();
}
@ -65,22 +65,22 @@ export class VersionDependentRegistration {
}
export class ConfigurationDependentRegistration {
export class ConfigurationDependentRegistration extends Disposable {
private readonly _registration: ConditionalRegistration;
private readonly _disposables: vscode.Disposable[] = [];
constructor(
private readonly language: string,
private readonly configValue: string,
register: () => vscode.Disposable,
) {
super();
this._registration = new ConditionalRegistration(register);
this.update();
vscode.workspace.onDidChangeConfiguration(this.update, this, this._disposables);
}
public dispose() {
disposeAll(this._disposables);
super.dispose();
this._registration.dispose();
}

View file

@ -5,7 +5,7 @@
import * as vscode from 'vscode';
export function disposeAll(disposables: vscode.Disposable[]) {
function disposeAll(disposables: vscode.Disposable[]) {
while (disposables.length) {
const item = disposables.pop();
if (item) {
@ -13,3 +13,26 @@ export function disposeAll(disposables: vscode.Disposable[]) {
}
}
}
export abstract class Disposable {
private _isDisposed = false;
protected _disposables: vscode.Disposable[] = [];
public dispose(): any {
if (this._isDisposed) {
return;
}
this._isDisposed = true;
disposeAll(this._disposables);
}
protected _register<T extends vscode.Disposable>(value: T): T {
if (this._isDisposed) {
value.dispose();
} else {
this._disposables.push(value);
}
return value;
}
}

View file

@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { OutputChannel, window } from 'vscode';
import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
import * as is from './is';
import { memoize } from './memoize';
@ -13,8 +13,8 @@ const localize = nls.loadMessageBundle();
export default class Logger {
@memoize
private get output(): OutputChannel {
return window.createOutputChannel(localize('channelName', 'TypeScript'));
private get output(): vscode.OutputChannel {
return vscode.window.createOutputChannel(localize('channelName', 'TypeScript'));
}
private data2String(data: any): string {

View file

@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as path from 'path';
import { workspace } from 'vscode';
import * as vscode from 'vscode';
import { TypeScriptServiceConfiguration } from './configuration';
import { RelativeWorkspacePathResolver } from './relativePathResolver';
@ -37,7 +37,7 @@ export class TypeScriptPluginPathsProvider {
return [workspacePath];
}
return (workspace.workspaceFolders || [])
return (vscode.workspace.workspaceFolders || [])
.map(workspaceFolder => path.join(workspaceFolder.uri.fsPath, pluginPath));
}
}

View file

@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { extensions } from 'vscode';
import * as vscode from 'vscode';
export interface TypeScriptServerPlugin {
readonly path: string;
@ -13,7 +13,7 @@ export interface TypeScriptServerPlugin {
export function getContributedTypeScriptServerPlugins(): TypeScriptServerPlugin[] {
const plugins: TypeScriptServerPlugin[] = [];
for (const extension of extensions.all) {
for (const extension of vscode.extensions.all) {
const pack = extension.packageJSON;
if (pack.contributes && pack.contributes.typescriptServerPlugins && Array.isArray(pack.contributes.typescriptServerPlugins)) {
for (const plugin of pack.contributes.typescriptServerPlugins) {

View file

@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { MarkdownString } from 'vscode';
import * as vscode from 'vscode';
import * as Proto from '../protocol';
function getTagBodyText(tag: Proto.JSDocTagInfo): string | undefined {
@ -64,17 +64,17 @@ export function tagsMarkdownPreview(tags: Proto.JSDocTagInfo[]): string {
export function markdownDocumentation(
documentation: Proto.SymbolDisplayPart[],
tags: Proto.JSDocTagInfo[]
): MarkdownString {
const out = new MarkdownString();
): vscode.MarkdownString {
const out = new vscode.MarkdownString();
addMarkdownDocumentation(out, documentation, tags);
return out;
}
export function addMarkdownDocumentation(
out: MarkdownString,
out: vscode.MarkdownString,
documentation: Proto.SymbolDisplayPart[] | undefined,
tags: Proto.JSDocTagInfo[] | undefined
): MarkdownString {
): vscode.MarkdownString {
if (documentation) {
out.appendMarkdown(plain(documentation));
}

View file

@ -3,11 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as path from 'path';
import { workspace } from 'vscode';
import * as vscode from 'vscode';
export class RelativeWorkspacePathResolver {
public asAbsoluteWorkspacePath(relativePath: string): string | undefined {
for (const root of workspace.workspaceFolders || []) {
for (const root of vscode.workspace.workspaceFolders || []) {
const rootPrefixes = [`./${root.name}/`, `${root.name}/`, `.\\${root.name}\\`, `${root.name}\\`];
for (const rootPrefix of rootPrefixes) {
if (relativePath.startsWith(rootPrefix)) {

View file

@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as fs from 'fs';
import { Uri } from 'vscode';
import * as vscode from 'vscode';
import { memoize } from './memoize';
import { getTempFile } from './temp';
@ -18,27 +18,27 @@ export class ResourceMap<T> {
private readonly _map = new Map<string, T>();
constructor(
private readonly _normalizePath?: (resource: Uri) => string | null
private readonly _normalizePath?: (resource: vscode.Uri) => string | null
) { }
public has(resource: Uri): boolean {
public has(resource: vscode.Uri): boolean {
const file = this.toKey(resource);
return !!file && this._map.has(file);
}
public get(resource: Uri): T | undefined {
public get(resource: vscode.Uri): T | undefined {
const file = this.toKey(resource);
return file ? this._map.get(file) : undefined;
}
public set(resource: Uri, value: T) {
public set(resource: vscode.Uri, value: T) {
const file = this.toKey(resource);
if (file) {
this._map.set(file, value);
}
}
public delete(resource: Uri): void {
public delete(resource: vscode.Uri): void {
const file = this.toKey(resource);
if (file) {
this._map.delete(file);
@ -57,7 +57,7 @@ export class ResourceMap<T> {
return this._map.entries();
}
private toKey(resource: Uri): string | null {
private toKey(resource: vscode.Uri): string | null {
const key = this._normalizePath ? this._normalizePath(resource) : resource.fsPath;
if (!key) {
return key;

View file

@ -3,12 +3,10 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { workspace } from 'vscode';
import * as vscode from 'vscode';
import * as Proto from '../protocol';
import Logger from './logger';
enum Trace {
Off,
Messages,
@ -45,7 +43,7 @@ export default class Tracer {
}
private static readTrace(): Trace {
let result: Trace = Trace.fromString(workspace.getConfiguration().get<string>('typescript.tsserver.trace', 'off'));
let result: Trace = Trace.fromString(vscode.workspace.getConfiguration().get<string>('typescript.tsserver.trace', 'off'));
if (result === Trace.Off && !!process.env.TSS_TRACE) {
result = Trace.Messages;
}

View file

@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Disposable, MessageItem, ProgressLocation, window, workspace } from 'vscode';
import * as vscode from 'vscode';
import { loadMessageBundle } from 'vscode-nls';
import { ITypeScriptServiceClient } from '../typescriptService';
@ -11,10 +11,10 @@ const localize = loadMessageBundle();
const typingsInstallTimeout = 30 * 1000;
export default class TypingsStatus extends Disposable {
export default class TypingsStatus extends vscode.Disposable {
private _acquiringTypings: { [eventId: string]: NodeJS.Timer } = Object.create({});
private _client: ITypeScriptServiceClient;
private _subscriptions: Disposable[] = [];
private _subscriptions: vscode.Disposable[] = [];
constructor(client: ITypeScriptServiceClient) {
super(() => this.dispose());
@ -60,10 +60,10 @@ export default class TypingsStatus extends Disposable {
export class AtaProgressReporter {
private _promises = new Map<number, Function>();
private _disposable: Disposable;
private _disposable: vscode.Disposable;
constructor(client: ITypeScriptServiceClient) {
this._disposable = Disposable.from(
this._disposable = vscode.Disposable.from(
client.onDidBeginInstallTypings(e => this._onBegin(e.eventId)),
client.onDidEndInstallTypings(e => this._onEndOrTimeout(e.eventId)),
client.onTypesInstallerInitializationFailed(_ => this.onTypesInstallerInitializationFailed()));
@ -83,8 +83,8 @@ export class AtaProgressReporter {
});
});
window.withProgress({
location: ProgressLocation.Window,
vscode.window.withProgress({
location: vscode.ProgressLocation.Window,
title: localize('installingPackages', "Fetching data for better TypeScript IntelliSense")
}, () => promise);
}
@ -98,12 +98,12 @@ export class AtaProgressReporter {
}
private onTypesInstallerInitializationFailed() {
interface MyMessageItem extends MessageItem {
interface MyMessageItem extends vscode.MessageItem {
id: number;
}
if (workspace.getConfiguration('typescript').get<boolean>('check.npmIsInstalled', true)) {
window.showWarningMessage<MyMessageItem>(
if (vscode.workspace.getConfiguration('typescript').get<boolean>('check.npmIsInstalled', true)) {
vscode.window.showWarningMessage<MyMessageItem>(
localize(
'typesInstallerInitializationFailed.title',
"Could not install typings files for JavaScript language features. Please ensure that NPM is installed or configure 'typescript.npm' in your user settings. Click [here]({0}) to learn more.",
@ -118,7 +118,7 @@ export class AtaProgressReporter {
}
switch (selected.id) {
case 1:
const tsConfig = workspace.getConfiguration('typescript');
const tsConfig = vscode.workspace.getConfiguration('typescript');
tsConfig.update('check.npmIsInstalled', false, true);
break;
}

View file

@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { commands, Memento, QuickPickItem, Uri, window, workspace } from 'vscode';
import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
import { TypeScriptVersion, TypeScriptVersionProvider } from './versionProvider';
@ -11,7 +11,7 @@ const localize = nls.loadMessageBundle();
const useWorkspaceTsdkStorageKey = 'typescript.useWorkspaceTsdk';
interface MyQuickPickItem extends QuickPickItem {
interface MyQuickPickItem extends vscode.QuickPickItem {
id: MessageAction;
version?: TypeScriptVersion;
}
@ -27,7 +27,7 @@ export class TypeScriptVersionPicker {
public constructor(
private readonly versionProvider: TypeScriptVersionProvider,
private readonly workspaceState: Memento
private readonly workspaceState: vscode.Memento
) {
this._currentVersion = this.versionProvider.defaultVersion;
@ -82,7 +82,7 @@ export class TypeScriptVersionPicker {
id: MessageAction.learnMore
});
const selected = await window.showQuickPick<MyQuickPickItem>(pickOptions, {
const selected = await vscode.window.showQuickPick<MyQuickPickItem>(pickOptions, {
placeHolder: localize(
'selectTsVersion',
'Select the TypeScript version used for JavaScript and TypeScript language features'),
@ -97,7 +97,7 @@ export class TypeScriptVersionPicker {
case MessageAction.useLocal:
await this.workspaceState.update(useWorkspaceTsdkStorageKey, true);
if (selected.version) {
const tsConfig = workspace.getConfiguration('typescript');
const tsConfig = vscode.workspace.getConfiguration('typescript');
await tsConfig.update('tsdk', selected.version.pathLabel, false);
const previousVersion = this.currentVersion;
@ -114,7 +114,7 @@ export class TypeScriptVersionPicker {
case MessageAction.learnMore:
commands.executeCommand('vscode.open', Uri.parse('https://go.microsoft.com/fwlink/?linkid=839919'));
vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://go.microsoft.com/fwlink/?linkid=839919'));
return { oldVersion: this.currentVersion };
default:

View file

@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as fs from 'fs';
import * as path from 'path';
import { window, workspace } from 'vscode';
import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
import API from './api';
import { TypeScriptServiceConfiguration } from './configuration';
@ -12,9 +12,6 @@ import { RelativeWorkspacePathResolver } from './relativePathResolver';
const localize = nls.loadMessageBundle();
export class TypeScriptVersion {
constructor(
public readonly path: string,
@ -40,7 +37,7 @@ export class TypeScriptVersion {
}
// Allow TS developers to provide custom version
const tsdkVersion = workspace.getConfiguration().get<string | undefined>('typescript.tsdk_version', undefined);
const tsdkVersion = vscode.workspace.getConfiguration().get<string | undefined>('typescript.tsdk_version', undefined);
if (tsdkVersion) {
return API.fromVersionString(tsdkVersion);
}
@ -152,7 +149,7 @@ export class TypeScriptVersionProvider {
} catch (e) {
// noop
}
window.showErrorMessage(localize(
vscode.window.showErrorMessage(localize(
'noBundledServerFound',
'VS Code\'s tsserver was deleted by another application such as a misbehaving virus detection tool. Please reinstall VS Code.'));
throw new Error('Could not find bundled tsserver.js');
@ -182,14 +179,14 @@ export class TypeScriptVersionProvider {
}
private loadTypeScriptVersionsFromPath(relativePath: string): TypeScriptVersion[] {
if (!workspace.workspaceFolders) {
if (!vscode.workspace.workspaceFolders) {
return [];
}
const versions: TypeScriptVersion[] = [];
for (const root of workspace.workspaceFolders) {
for (const root of vscode.workspace.workspaceFolders) {
let label: string = relativePath;
if (workspace.workspaceFolders && workspace.workspaceFolders.length > 1) {
if (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 1) {
label = path.join(root.name, relativePath);
}

View file

@ -4,7 +4,7 @@
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
"Once accepted there, we are happy to receive an update request."
],
"version": "https://github.com/atom/language-xml/commit/27352842917b911383122bdcf98ed0d69d55c179",
"version": "https://github.com/atom/language-xml/commit/bd810deb404a12bea8ec5799fda2909349ba2654",
"name": "XML",
"scopeName": "text.xml",
"patterns": [
@ -350,14 +350,38 @@
]
},
"comments": {
"begin": "<[!%]--",
"captures": {
"0": {
"name": "punctuation.definition.comment.xml"
"patterns": [
{
"begin": "<%--",
"captures": {
"0": {
"name": "punctuation.definition.comment.xml"
},
"end": "--%>",
"name": "comment.block.xml"
}
},
{
"begin": "<!--",
"captures": {
"0": {
"name": "punctuation.definition.comment.xml"
}
},
"end": "-->",
"name": "comment.block.xml",
"patterns": [
{
"begin": "--(?!>)",
"captures": {
"0": {
"name": "invalid.illegal.bad-comments-or-CDATA.xml"
}
}
}
]
}
},
"end": "--%?>",
"name": "comment.block.xml"
]
}
}
}

View file

@ -2,6 +2,6 @@
# yarn lockfile v1
typescript@3.0.1-insiders.20180713:
version "3.0.1-insiders.20180713"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.0.1-insiders.20180713.tgz#02775b5197ab02b79ed5b84e7483c18ed164e55e"
typescript@3.0.1-insiders.20180723:
version "3.0.1-insiders.20180723"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.0.1-insiders.20180723.tgz#266fbafb349a6429777ab3525cda3bb0a2adc661"

View file

@ -1,7 +1,7 @@
{
"name": "code-oss-dev",
"version": "1.26.0",
"distro": "ba277984505f7010dbff765d57412a25891b4dea",
"distro": "4b5c6aa6ea6f222d62d08ca5653049b200be93a5",
"author": {
"name": "Microsoft Corporation"
},
@ -50,7 +50,7 @@
"vscode-nsfw": "1.0.17",
"vscode-ripgrep": "^1.0.1",
"vscode-textmate": "^4.0.1",
"vscode-xterm": "3.6.0-beta3",
"vscode-xterm": "3.6.0-beta5",
"yauzl": "^2.9.1"
},
"devDependencies": {
@ -138,4 +138,4 @@
"windows-mutex": "^0.2.0",
"windows-process-tree": "0.2.2"
}
}
}

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