monaco-languageclient
Advanced tools
Comparing version 0.8.0-next.0 to 0.8.0-next.1
/// <reference types="monaco-editor-core/monaco" /> | ||
import { CodeActionParams, CodeLensParams, DocumentFormattingParams, DocumentOnTypeFormattingParams, DocumentRangeFormattingParams, ReferenceParams, RenameParams, TextDocumentPositionParams, Position, TextDocumentIdentifier, CompletionItem, CompletionList, CompletionParams, CompletionContext, CompletionTriggerKind, Range, Diagnostic, Hover, SignatureHelp, SignatureInformation, ParameterInformation, Definition, Location, DocumentHighlight, SymbolInformation, DocumentSymbolParams, CodeActionContext, DiagnosticSeverity, Command, CodeLens, FormattingOptions, TextEdit, WorkspaceEdit, DocumentLinkParams, DocumentLink, MarkedString, MarkupContent, ColorInformation, ColorPresentation } from './services'; | ||
import { CodeActionParams, CodeLensParams, DocumentFormattingParams, DocumentOnTypeFormattingParams, DocumentRangeFormattingParams, ReferenceParams, RenameParams, TextDocumentPositionParams, Position, TextDocumentIdentifier, CompletionItem, CompletionList, CompletionParams, CompletionContext, CompletionTriggerKind, Range, Diagnostic, Hover, SignatureHelp, SignatureInformation, ParameterInformation, Definition, Location, DocumentHighlight, SymbolInformation, DocumentSymbolParams, CodeActionContext, DiagnosticSeverity, Command, CodeLens, FormattingOptions, TextEdit, WorkspaceEdit, DocumentLinkParams, DocumentLink, MarkedString, MarkupContent, ColorInformation, ColorPresentation, FoldingRange } from './services'; | ||
import IReadOnlyModel = monaco.editor.IReadOnlyModel; | ||
@@ -146,3 +146,6 @@ export declare type RecursivePartial<T> = { | ||
asColorPresentation(item: ColorPresentation): monaco.languages.IColorPresentation; | ||
asFoldingRanges(items: FoldingRange[]): monaco.languages.FoldingRange[]; | ||
asFoldingRange(item: FoldingRange): monaco.languages.FoldingRange; | ||
asFoldingRangeKind(kind?: string): monaco.languages.FoldingRangeKind | undefined; | ||
} | ||
//# sourceMappingURL=monaco-converter.d.ts.map |
@@ -686,2 +686,27 @@ var __assign = (this && this.__assign) || function () { | ||
}; | ||
ProtocolToMonacoConverter.prototype.asFoldingRanges = function (items) { | ||
var _this = this; | ||
return items.map(function (item) { return _this.asFoldingRange(item); }); | ||
}; | ||
ProtocolToMonacoConverter.prototype.asFoldingRange = function (item) { | ||
return { | ||
start: item.startLine + 1, | ||
end: item.endLine + 1, | ||
kind: this.asFoldingRangeKind(item.kind) | ||
}; | ||
}; | ||
ProtocolToMonacoConverter.prototype.asFoldingRangeKind = function (kind) { | ||
if (kind) { | ||
switch (kind) { | ||
case services_1.FoldingRangeKind.Comment: | ||
return monaco.languages.FoldingRangeKind.Comment; | ||
case services_1.FoldingRangeKind.Imports: | ||
return monaco.languages.FoldingRangeKind.Imports; | ||
case services_1.FoldingRangeKind.Region: | ||
return monaco.languages.FoldingRangeKind.Region; | ||
} | ||
; | ||
} | ||
return undefined; | ||
}; | ||
return ProtocolToMonacoConverter; | ||
@@ -688,0 +713,0 @@ }()); |
@@ -5,2 +5,3 @@ import { BaseLanguageClient, MessageTransports, LanguageClientOptions } from "vscode-base-languageclient/lib/client"; | ||
export declare class MonacoLanguageClient extends BaseLanguageClient { | ||
static bypassConversion: (result: any) => any; | ||
protected readonly connectionProvider: IConnectionProvider; | ||
@@ -7,0 +8,0 @@ constructor({ id, name, clientOptions, connectionProvider }: MonacoLanguageClient.Options); |
@@ -29,3 +29,2 @@ var __extends = (this && this.__extends) || (function () { | ||
// bypass LSP <=> VS Code conversion | ||
var bypassConversion = function (result) { return result || undefined; }; | ||
var self = _this; | ||
@@ -37,3 +36,3 @@ self._p2c = new Proxy(self._p2c, { | ||
} | ||
return bypassConversion; | ||
return MonacoLanguageClient.bypassConversion; | ||
} | ||
@@ -66,3 +65,3 @@ }); | ||
} | ||
return bypassConversion; | ||
return MonacoLanguageClient.bypassConversion; | ||
} | ||
@@ -86,4 +85,7 @@ }); | ||
this.registerFeature(new workspaceFolders_1.WorkspaceFoldersFeature(this)); | ||
this.registerFeature(new foldingRange_1.FoldingRangeFeature(this)); | ||
var foldingRangeFeature = new foldingRange_1.FoldingRangeFeature(this); | ||
foldingRangeFeature['asFoldingRanges'] = MonacoLanguageClient.bypassConversion; | ||
this.registerFeature(foldingRangeFeature); | ||
}; | ||
MonacoLanguageClient.bypassConversion = function (result) { return result || undefined; }; | ||
return MonacoLanguageClient; | ||
@@ -90,0 +92,0 @@ }(client_1.BaseLanguageClient)); |
/// <reference types="monaco-editor-core/monaco" /> | ||
import { Languages, DiagnosticCollection, CompletionItemProvider, DocumentIdentifier, HoverProvider, SignatureHelpProvider, DefinitionProvider, ReferenceProvider, DocumentHighlightProvider, DocumentSymbolProvider, CodeActionProvider, CodeLensProvider, DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider, OnTypeFormattingEditProvider, RenameProvider, DocumentFilter, DocumentSelector, DocumentLinkProvider, ImplementationProvider, TypeDefinitionProvider, DocumentColorProvider } from "./services"; | ||
import { Languages, DiagnosticCollection, CompletionItemProvider, DocumentIdentifier, HoverProvider, SignatureHelpProvider, DefinitionProvider, ReferenceProvider, DocumentHighlightProvider, DocumentSymbolProvider, CodeActionProvider, CodeLensProvider, DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider, OnTypeFormattingEditProvider, RenameProvider, DocumentFilter, DocumentSelector, DocumentLinkProvider, ImplementationProvider, TypeDefinitionProvider, DocumentColorProvider, FoldingRangeProvider } from "./services"; | ||
import { ProtocolToMonacoConverter, MonacoToProtocolConverter } from './monaco-converter'; | ||
@@ -55,4 +55,7 @@ import { Disposable } from './disposable'; | ||
protected createDocumentColorProvider(selector: DocumentSelector, provider: DocumentColorProvider): monaco.languages.DocumentColorProvider; | ||
registerFoldingRangeProvider(selector: DocumentSelector, provider: FoldingRangeProvider): Disposable; | ||
protected createFoldingRangeProvider(selector: DocumentSelector, provider: FoldingRangeProvider): monaco.languages.FoldingRangeProvider; | ||
protected matchModel(selector: string | DocumentFilter | DocumentSelector, model: MonacoModelIdentifier): boolean; | ||
protected matchLanguage(selector: string | DocumentFilter | DocumentSelector, languageId: string): boolean; | ||
} | ||
//# sourceMappingURL=monaco-languages.d.ts.map |
@@ -60,3 +60,5 @@ define(["require", "exports", "glob-to-regexp", "./services", "./monaco-diagnostic-collection", "./disposable"], function (require, exports, globToRegExp, services_1, monaco_diagnostic_collection_1, disposable_1) { | ||
var language = _b[_a]; | ||
providers.push(monaco.languages.registerCompletionItemProvider(language, completionProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerCompletionItemProvider(language, completionProvider)); | ||
} | ||
} | ||
@@ -96,3 +98,5 @@ ; | ||
var language = _a[_i]; | ||
providers.push(monaco.languages.registerHoverProvider(language, hoverProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerHoverProvider(language, hoverProvider)); | ||
} | ||
} | ||
@@ -122,3 +126,5 @@ return providers; | ||
var language = _b[_a]; | ||
providers.push(monaco.languages.registerSignatureHelpProvider(language, signatureHelpProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerSignatureHelpProvider(language, signatureHelpProvider)); | ||
} | ||
} | ||
@@ -150,3 +156,5 @@ return providers; | ||
var language = _a[_i]; | ||
providers.push(monaco.languages.registerDefinitionProvider(language, definitionProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerDefinitionProvider(language, definitionProvider)); | ||
} | ||
} | ||
@@ -172,3 +180,5 @@ return providers; | ||
var language = _a[_i]; | ||
providers.push(monaco.languages.registerReferenceProvider(language, referenceProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerReferenceProvider(language, referenceProvider)); | ||
} | ||
} | ||
@@ -194,3 +204,5 @@ return providers; | ||
var language = _a[_i]; | ||
providers.push(monaco.languages.registerDocumentHighlightProvider(language, documentHighlightProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerDocumentHighlightProvider(language, documentHighlightProvider)); | ||
} | ||
} | ||
@@ -216,3 +228,5 @@ return providers; | ||
var language = _a[_i]; | ||
providers.push(monaco.languages.registerDocumentSymbolProvider(language, documentSymbolProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerDocumentSymbolProvider(language, documentSymbolProvider)); | ||
} | ||
} | ||
@@ -238,3 +252,5 @@ return providers; | ||
var language = _a[_i]; | ||
providers.push(monaco.languages.registerCodeActionProvider(language, codeActionProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerCodeActionProvider(language, codeActionProvider)); | ||
} | ||
} | ||
@@ -260,3 +276,5 @@ return providers; | ||
var language = _a[_i]; | ||
providers.push(monaco.languages.registerCodeLensProvider(language, codeLensProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerCodeLensProvider(language, codeLensProvider)); | ||
} | ||
} | ||
@@ -293,3 +311,5 @@ return providers; | ||
var language = _a[_i]; | ||
providers.push(monaco.languages.registerDocumentFormattingEditProvider(language, documentFormattingEditProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerDocumentFormattingEditProvider(language, documentFormattingEditProvider)); | ||
} | ||
} | ||
@@ -315,3 +335,5 @@ return providers; | ||
var language = _a[_i]; | ||
providers.push(monaco.languages.registerDocumentRangeFormattingEditProvider(language, documentRangeFormattingEditProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerDocumentRangeFormattingEditProvider(language, documentRangeFormattingEditProvider)); | ||
} | ||
} | ||
@@ -341,3 +363,5 @@ return providers; | ||
var language = _b[_a]; | ||
providers.push(monaco.languages.registerOnTypeFormattingEditProvider(language, onTypeFormattingEditProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerOnTypeFormattingEditProvider(language, onTypeFormattingEditProvider)); | ||
} | ||
} | ||
@@ -369,3 +393,5 @@ return providers; | ||
var language = _a[_i]; | ||
providers.push(monaco.languages.registerRenameProvider(language, renameProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerRenameProvider(language, renameProvider)); | ||
} | ||
} | ||
@@ -391,3 +417,5 @@ return providers; | ||
var language = _a[_i]; | ||
providers.push(monaco.languages.registerLinkProvider(language, linkProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerLinkProvider(language, linkProvider)); | ||
} | ||
} | ||
@@ -426,3 +454,5 @@ return providers; | ||
var language = _a[_i]; | ||
providers.push(monaco.languages.registerImplementationProvider(language, implementationProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerImplementationProvider(language, implementationProvider)); | ||
} | ||
} | ||
@@ -448,3 +478,5 @@ return providers; | ||
var language = _a[_i]; | ||
providers.push(monaco.languages.registerTypeDefinitionProvider(language, typeDefinitionProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerTypeDefinitionProvider(language, typeDefinitionProvider)); | ||
} | ||
} | ||
@@ -470,3 +502,5 @@ return providers; | ||
var language = _a[_i]; | ||
providers.push(monaco.languages.registerColorProvider(language, documentColorProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerColorProvider(language, documentColorProvider)); | ||
} | ||
} | ||
@@ -499,6 +533,31 @@ return providers; | ||
}; | ||
MonacoLanguages.prototype.registerFoldingRangeProvider = function (selector, provider) { | ||
var foldingRangeProvider = this.createFoldingRangeProvider(selector, provider); | ||
var providers = new disposable_1.DisposableCollection(); | ||
for (var _i = 0, _a = getLanguages(); _i < _a.length; _i++) { | ||
var language = _a[_i]; | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerFoldingRangeProvider(language, foldingRangeProvider)); | ||
} | ||
} | ||
return providers; | ||
}; | ||
MonacoLanguages.prototype.createFoldingRangeProvider = function (selector, provider) { | ||
var _this = this; | ||
return { | ||
provideFoldingRanges: function (model, context, token) { | ||
if (!_this.matchModel(selector, MonacoModelIdentifier.fromModel(model))) { | ||
return []; | ||
} | ||
var textDocument = _this.m2p.asTextDocumentIdentifier(model); | ||
return provider.provideFoldingRanges({ | ||
textDocument: textDocument | ||
}, token).then(function (result) { return _this.p2m.asFoldingRanges(result); }); | ||
} | ||
}; | ||
}; | ||
MonacoLanguages.prototype.matchModel = function (selector, model) { | ||
var _this = this; | ||
if (Array.isArray(selector)) { | ||
return selector.findIndex(function (filter) { return _this.matchModel(filter, model); }) !== -1; | ||
return selector.some(function (filter) { return _this.matchModel(filter, model); }); | ||
} | ||
@@ -519,2 +578,12 @@ if (services_1.DocumentFilter.is(selector)) { | ||
}; | ||
MonacoLanguages.prototype.matchLanguage = function (selector, languageId) { | ||
var _this = this; | ||
if (Array.isArray(selector)) { | ||
return selector.some(function (filter) { return _this.matchLanguage(filter, languageId); }); | ||
} | ||
if (services_1.DocumentFilter.is(selector)) { | ||
return !selector.language || selector.language === languageId; | ||
} | ||
return selector === languageId; | ||
}; | ||
return MonacoLanguages; | ||
@@ -521,0 +590,0 @@ }()); |
/// <reference types="monaco-editor-core/monaco" /> | ||
import { CodeActionParams, CodeLensParams, DocumentFormattingParams, DocumentOnTypeFormattingParams, DocumentRangeFormattingParams, ReferenceParams, RenameParams, TextDocumentPositionParams, Position, TextDocumentIdentifier, CompletionItem, CompletionList, CompletionParams, CompletionContext, CompletionTriggerKind, Range, Diagnostic, Hover, SignatureHelp, SignatureInformation, ParameterInformation, Definition, Location, DocumentHighlight, SymbolInformation, DocumentSymbolParams, CodeActionContext, DiagnosticSeverity, Command, CodeLens, FormattingOptions, TextEdit, WorkspaceEdit, DocumentLinkParams, DocumentLink, MarkedString, MarkupContent, ColorInformation, ColorPresentation } from './services'; | ||
import { CodeActionParams, CodeLensParams, DocumentFormattingParams, DocumentOnTypeFormattingParams, DocumentRangeFormattingParams, ReferenceParams, RenameParams, TextDocumentPositionParams, Position, TextDocumentIdentifier, CompletionItem, CompletionList, CompletionParams, CompletionContext, CompletionTriggerKind, Range, Diagnostic, Hover, SignatureHelp, SignatureInformation, ParameterInformation, Definition, Location, DocumentHighlight, SymbolInformation, DocumentSymbolParams, CodeActionContext, DiagnosticSeverity, Command, CodeLens, FormattingOptions, TextEdit, WorkspaceEdit, DocumentLinkParams, DocumentLink, MarkedString, MarkupContent, ColorInformation, ColorPresentation, FoldingRange } from './services'; | ||
import IReadOnlyModel = monaco.editor.IReadOnlyModel; | ||
@@ -146,3 +146,6 @@ export declare type RecursivePartial<T> = { | ||
asColorPresentation(item: ColorPresentation): monaco.languages.IColorPresentation; | ||
asFoldingRanges(items: FoldingRange[]): monaco.languages.FoldingRange[]; | ||
asFoldingRange(item: FoldingRange): monaco.languages.FoldingRange; | ||
asFoldingRangeKind(kind?: string): monaco.languages.FoldingRangeKind | undefined; | ||
} | ||
//# sourceMappingURL=monaco-converter.d.ts.map |
@@ -691,2 +691,27 @@ "use strict"; | ||
}; | ||
ProtocolToMonacoConverter.prototype.asFoldingRanges = function (items) { | ||
var _this = this; | ||
return items.map(function (item) { return _this.asFoldingRange(item); }); | ||
}; | ||
ProtocolToMonacoConverter.prototype.asFoldingRange = function (item) { | ||
return { | ||
start: item.startLine + 1, | ||
end: item.endLine + 1, | ||
kind: this.asFoldingRangeKind(item.kind) | ||
}; | ||
}; | ||
ProtocolToMonacoConverter.prototype.asFoldingRangeKind = function (kind) { | ||
if (kind) { | ||
switch (kind) { | ||
case services_1.FoldingRangeKind.Comment: | ||
return monaco.languages.FoldingRangeKind.Comment; | ||
case services_1.FoldingRangeKind.Imports: | ||
return monaco.languages.FoldingRangeKind.Imports; | ||
case services_1.FoldingRangeKind.Region: | ||
return monaco.languages.FoldingRangeKind.Region; | ||
} | ||
; | ||
} | ||
return undefined; | ||
}; | ||
return ProtocolToMonacoConverter; | ||
@@ -693,0 +718,0 @@ }()); |
@@ -5,2 +5,3 @@ import { BaseLanguageClient, MessageTransports, LanguageClientOptions } from "vscode-base-languageclient/lib/client"; | ||
export declare class MonacoLanguageClient extends BaseLanguageClient { | ||
static bypassConversion: (result: any) => any; | ||
protected readonly connectionProvider: IConnectionProvider; | ||
@@ -7,0 +8,0 @@ constructor({ id, name, clientOptions, connectionProvider }: MonacoLanguageClient.Options); |
@@ -38,3 +38,2 @@ "use strict"; | ||
// bypass LSP <=> VS Code conversion | ||
var bypassConversion = function (result) { return result || undefined; }; | ||
var self = _this; | ||
@@ -46,3 +45,3 @@ self._p2c = new Proxy(self._p2c, { | ||
} | ||
return bypassConversion; | ||
return MonacoLanguageClient.bypassConversion; | ||
} | ||
@@ -75,3 +74,3 @@ }); | ||
} | ||
return bypassConversion; | ||
return MonacoLanguageClient.bypassConversion; | ||
} | ||
@@ -95,4 +94,7 @@ }); | ||
this.registerFeature(new workspaceFolders_1.WorkspaceFoldersFeature(this)); | ||
this.registerFeature(new foldingRange_1.FoldingRangeFeature(this)); | ||
var foldingRangeFeature = new foldingRange_1.FoldingRangeFeature(this); | ||
foldingRangeFeature['asFoldingRanges'] = MonacoLanguageClient.bypassConversion; | ||
this.registerFeature(foldingRangeFeature); | ||
}; | ||
MonacoLanguageClient.bypassConversion = function (result) { return result || undefined; }; | ||
return MonacoLanguageClient; | ||
@@ -99,0 +101,0 @@ }(client_1.BaseLanguageClient)); |
/// <reference types="monaco-editor-core/monaco" /> | ||
import { Languages, DiagnosticCollection, CompletionItemProvider, DocumentIdentifier, HoverProvider, SignatureHelpProvider, DefinitionProvider, ReferenceProvider, DocumentHighlightProvider, DocumentSymbolProvider, CodeActionProvider, CodeLensProvider, DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider, OnTypeFormattingEditProvider, RenameProvider, DocumentFilter, DocumentSelector, DocumentLinkProvider, ImplementationProvider, TypeDefinitionProvider, DocumentColorProvider } from "./services"; | ||
import { Languages, DiagnosticCollection, CompletionItemProvider, DocumentIdentifier, HoverProvider, SignatureHelpProvider, DefinitionProvider, ReferenceProvider, DocumentHighlightProvider, DocumentSymbolProvider, CodeActionProvider, CodeLensProvider, DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider, OnTypeFormattingEditProvider, RenameProvider, DocumentFilter, DocumentSelector, DocumentLinkProvider, ImplementationProvider, TypeDefinitionProvider, DocumentColorProvider, FoldingRangeProvider } from "./services"; | ||
import { ProtocolToMonacoConverter, MonacoToProtocolConverter } from './monaco-converter'; | ||
@@ -55,4 +55,7 @@ import { Disposable } from './disposable'; | ||
protected createDocumentColorProvider(selector: DocumentSelector, provider: DocumentColorProvider): monaco.languages.DocumentColorProvider; | ||
registerFoldingRangeProvider(selector: DocumentSelector, provider: FoldingRangeProvider): Disposable; | ||
protected createFoldingRangeProvider(selector: DocumentSelector, provider: FoldingRangeProvider): monaco.languages.FoldingRangeProvider; | ||
protected matchModel(selector: string | DocumentFilter | DocumentSelector, model: MonacoModelIdentifier): boolean; | ||
protected matchLanguage(selector: string | DocumentFilter | DocumentSelector, languageId: string): boolean; | ||
} | ||
//# sourceMappingURL=monaco-languages.d.ts.map |
@@ -67,3 +67,5 @@ "use strict"; | ||
var language = _b[_a]; | ||
providers.push(monaco.languages.registerCompletionItemProvider(language, completionProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerCompletionItemProvider(language, completionProvider)); | ||
} | ||
} | ||
@@ -103,3 +105,5 @@ ; | ||
var language = _a[_i]; | ||
providers.push(monaco.languages.registerHoverProvider(language, hoverProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerHoverProvider(language, hoverProvider)); | ||
} | ||
} | ||
@@ -129,3 +133,5 @@ return providers; | ||
var language = _b[_a]; | ||
providers.push(monaco.languages.registerSignatureHelpProvider(language, signatureHelpProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerSignatureHelpProvider(language, signatureHelpProvider)); | ||
} | ||
} | ||
@@ -157,3 +163,5 @@ return providers; | ||
var language = _a[_i]; | ||
providers.push(monaco.languages.registerDefinitionProvider(language, definitionProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerDefinitionProvider(language, definitionProvider)); | ||
} | ||
} | ||
@@ -179,3 +187,5 @@ return providers; | ||
var language = _a[_i]; | ||
providers.push(monaco.languages.registerReferenceProvider(language, referenceProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerReferenceProvider(language, referenceProvider)); | ||
} | ||
} | ||
@@ -201,3 +211,5 @@ return providers; | ||
var language = _a[_i]; | ||
providers.push(monaco.languages.registerDocumentHighlightProvider(language, documentHighlightProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerDocumentHighlightProvider(language, documentHighlightProvider)); | ||
} | ||
} | ||
@@ -223,3 +235,5 @@ return providers; | ||
var language = _a[_i]; | ||
providers.push(monaco.languages.registerDocumentSymbolProvider(language, documentSymbolProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerDocumentSymbolProvider(language, documentSymbolProvider)); | ||
} | ||
} | ||
@@ -245,3 +259,5 @@ return providers; | ||
var language = _a[_i]; | ||
providers.push(monaco.languages.registerCodeActionProvider(language, codeActionProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerCodeActionProvider(language, codeActionProvider)); | ||
} | ||
} | ||
@@ -267,3 +283,5 @@ return providers; | ||
var language = _a[_i]; | ||
providers.push(monaco.languages.registerCodeLensProvider(language, codeLensProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerCodeLensProvider(language, codeLensProvider)); | ||
} | ||
} | ||
@@ -300,3 +318,5 @@ return providers; | ||
var language = _a[_i]; | ||
providers.push(monaco.languages.registerDocumentFormattingEditProvider(language, documentFormattingEditProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerDocumentFormattingEditProvider(language, documentFormattingEditProvider)); | ||
} | ||
} | ||
@@ -322,3 +342,5 @@ return providers; | ||
var language = _a[_i]; | ||
providers.push(monaco.languages.registerDocumentRangeFormattingEditProvider(language, documentRangeFormattingEditProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerDocumentRangeFormattingEditProvider(language, documentRangeFormattingEditProvider)); | ||
} | ||
} | ||
@@ -348,3 +370,5 @@ return providers; | ||
var language = _b[_a]; | ||
providers.push(monaco.languages.registerOnTypeFormattingEditProvider(language, onTypeFormattingEditProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerOnTypeFormattingEditProvider(language, onTypeFormattingEditProvider)); | ||
} | ||
} | ||
@@ -376,3 +400,5 @@ return providers; | ||
var language = _a[_i]; | ||
providers.push(monaco.languages.registerRenameProvider(language, renameProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerRenameProvider(language, renameProvider)); | ||
} | ||
} | ||
@@ -398,3 +424,5 @@ return providers; | ||
var language = _a[_i]; | ||
providers.push(monaco.languages.registerLinkProvider(language, linkProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerLinkProvider(language, linkProvider)); | ||
} | ||
} | ||
@@ -433,3 +461,5 @@ return providers; | ||
var language = _a[_i]; | ||
providers.push(monaco.languages.registerImplementationProvider(language, implementationProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerImplementationProvider(language, implementationProvider)); | ||
} | ||
} | ||
@@ -455,3 +485,5 @@ return providers; | ||
var language = _a[_i]; | ||
providers.push(monaco.languages.registerTypeDefinitionProvider(language, typeDefinitionProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerTypeDefinitionProvider(language, typeDefinitionProvider)); | ||
} | ||
} | ||
@@ -477,3 +509,5 @@ return providers; | ||
var language = _a[_i]; | ||
providers.push(monaco.languages.registerColorProvider(language, documentColorProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerColorProvider(language, documentColorProvider)); | ||
} | ||
} | ||
@@ -506,6 +540,31 @@ return providers; | ||
}; | ||
MonacoLanguages.prototype.registerFoldingRangeProvider = function (selector, provider) { | ||
var foldingRangeProvider = this.createFoldingRangeProvider(selector, provider); | ||
var providers = new disposable_1.DisposableCollection(); | ||
for (var _i = 0, _a = getLanguages(); _i < _a.length; _i++) { | ||
var language = _a[_i]; | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerFoldingRangeProvider(language, foldingRangeProvider)); | ||
} | ||
} | ||
return providers; | ||
}; | ||
MonacoLanguages.prototype.createFoldingRangeProvider = function (selector, provider) { | ||
var _this = this; | ||
return { | ||
provideFoldingRanges: function (model, context, token) { | ||
if (!_this.matchModel(selector, MonacoModelIdentifier.fromModel(model))) { | ||
return []; | ||
} | ||
var textDocument = _this.m2p.asTextDocumentIdentifier(model); | ||
return provider.provideFoldingRanges({ | ||
textDocument: textDocument | ||
}, token).then(function (result) { return _this.p2m.asFoldingRanges(result); }); | ||
} | ||
}; | ||
}; | ||
MonacoLanguages.prototype.matchModel = function (selector, model) { | ||
var _this = this; | ||
if (Array.isArray(selector)) { | ||
return selector.findIndex(function (filter) { return _this.matchModel(filter, model); }) !== -1; | ||
return selector.some(function (filter) { return _this.matchModel(filter, model); }); | ||
} | ||
@@ -526,2 +585,12 @@ if (services_1.DocumentFilter.is(selector)) { | ||
}; | ||
MonacoLanguages.prototype.matchLanguage = function (selector, languageId) { | ||
var _this = this; | ||
if (Array.isArray(selector)) { | ||
return selector.some(function (filter) { return _this.matchLanguage(filter, languageId); }); | ||
} | ||
if (services_1.DocumentFilter.is(selector)) { | ||
return !selector.language || selector.language === languageId; | ||
} | ||
return selector === languageId; | ||
}; | ||
return MonacoLanguages; | ||
@@ -528,0 +597,0 @@ }()); |
{ | ||
"name": "monaco-languageclient", | ||
"version": "0.8.0-next.0", | ||
"version": "0.8.0-next.1", | ||
"description": "Monaco Language client implementation", | ||
@@ -5,0 +5,0 @@ "author": "TypeFox GmbH (http://www.typefox.io)", |
@@ -18,3 +18,3 @@ /* -------------------------------------------------------------------------------------------- | ||
Command, CodeLens, FormattingOptions, TextEdit, WorkspaceEdit, DocumentLinkParams, DocumentLink, | ||
MarkedString, MarkupContent, ColorInformation, ColorPresentation | ||
MarkedString, MarkupContent, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind | ||
} from './services'; | ||
@@ -767,2 +767,28 @@ import IReadOnlyModel = monaco.editor.IReadOnlyModel; | ||
asFoldingRanges(items: FoldingRange[]): monaco.languages.FoldingRange[] { | ||
return items.map(item => this.asFoldingRange(item)); | ||
} | ||
asFoldingRange(item: FoldingRange): monaco.languages.FoldingRange { | ||
return { | ||
start: item.startLine + 1, | ||
end: item.endLine + 1, | ||
kind: this.asFoldingRangeKind(item.kind) | ||
}; | ||
} | ||
asFoldingRangeKind(kind?: string): monaco.languages.FoldingRangeKind | undefined { | ||
if (kind) { | ||
switch (kind) { | ||
case FoldingRangeKind.Comment: | ||
return monaco.languages.FoldingRangeKind.Comment; | ||
case FoldingRangeKind.Imports: | ||
return monaco.languages.FoldingRangeKind.Imports; | ||
case FoldingRangeKind.Region: | ||
return monaco.languages.FoldingRangeKind.Region; | ||
}; | ||
} | ||
return undefined; | ||
} | ||
} |
@@ -21,2 +21,4 @@ /* -------------------------------------------------------------------------------------------- | ||
static bypassConversion = (result: any) => result || undefined; | ||
protected readonly connectionProvider: IConnectionProvider; | ||
@@ -30,3 +32,2 @@ | ||
// bypass LSP <=> VS Code conversion | ||
const bypassConversion = (result: any) => result || undefined; | ||
const self: { | ||
@@ -41,3 +42,3 @@ _p2c: p2c.Converter, | ||
} | ||
return bypassConversion; | ||
return MonacoLanguageClient.bypassConversion; | ||
} | ||
@@ -70,3 +71,3 @@ }); | ||
} | ||
return bypassConversion; | ||
return MonacoLanguageClient.bypassConversion; | ||
} | ||
@@ -86,11 +87,14 @@ }); | ||
protected registerBuiltinFeatures(): void { | ||
super.registerBuiltinFeatures(); | ||
this.registerFeature(new TypeDefinitionFeature(this)); | ||
this.registerFeature(new ImplementationFeature(this)); | ||
this.registerFeature(new ColorProviderFeature(this)); | ||
this.registerFeature(new WorkspaceFoldersFeature(this)); | ||
this.registerFeature(new FoldingRangeFeature(this)); | ||
} | ||
protected registerBuiltinFeatures(): void { | ||
super.registerBuiltinFeatures(); | ||
this.registerFeature(new TypeDefinitionFeature(this)); | ||
this.registerFeature(new ImplementationFeature(this)); | ||
this.registerFeature(new ColorProviderFeature(this)); | ||
this.registerFeature(new WorkspaceFoldersFeature(this)); | ||
const foldingRangeFeature = new FoldingRangeFeature(this); | ||
foldingRangeFeature['asFoldingRanges'] = MonacoLanguageClient.bypassConversion; | ||
this.registerFeature(foldingRangeFeature); | ||
} | ||
} | ||
@@ -97,0 +101,0 @@ export namespace MonacoLanguageClient { |
@@ -10,3 +10,4 @@ /* -------------------------------------------------------------------------------------------- | ||
DocumentSymbolProvider, CodeActionProvider, CodeLensProvider, DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider, OnTypeFormattingEditProvider, RenameProvider, | ||
DocumentFilter, DocumentSelector, DocumentLinkProvider, ImplementationProvider, TypeDefinitionProvider, DocumentColorProvider | ||
DocumentFilter, DocumentSelector, DocumentLinkProvider, ImplementationProvider, TypeDefinitionProvider, DocumentColorProvider, | ||
FoldingRangeProvider | ||
} from "./services"; | ||
@@ -74,3 +75,5 @@ import { MonacoDiagnosticCollection } from './monaco-diagnostic-collection'; | ||
for (const language of getLanguages()) { | ||
providers.push(monaco.languages.registerCompletionItemProvider(language, completionProvider)) | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerCompletionItemProvider(language, completionProvider)) | ||
} | ||
}; | ||
@@ -105,3 +108,5 @@ return providers; | ||
for (const language of getLanguages()) { | ||
providers.push(monaco.languages.registerHoverProvider(language, hoverProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerHoverProvider(language, hoverProvider)); | ||
} | ||
} | ||
@@ -127,3 +132,5 @@ return providers; | ||
for (const language of getLanguages()) { | ||
providers.push(monaco.languages.registerSignatureHelpProvider(language, signatureHelpProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerSignatureHelpProvider(language, signatureHelpProvider)); | ||
} | ||
} | ||
@@ -151,3 +158,5 @@ return providers; | ||
for (const language of getLanguages()) { | ||
providers.push(monaco.languages.registerDefinitionProvider(language, definitionProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerDefinitionProvider(language, definitionProvider)); | ||
} | ||
} | ||
@@ -173,3 +182,5 @@ return providers; | ||
for (const language of getLanguages()) { | ||
providers.push(monaco.languages.registerReferenceProvider(language, referenceProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerReferenceProvider(language, referenceProvider)); | ||
} | ||
} | ||
@@ -195,3 +206,5 @@ return providers; | ||
for (const language of getLanguages()) { | ||
providers.push(monaco.languages.registerDocumentHighlightProvider(language, documentHighlightProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerDocumentHighlightProvider(language, documentHighlightProvider)); | ||
} | ||
} | ||
@@ -217,3 +230,5 @@ return providers; | ||
for (const language of getLanguages()) { | ||
providers.push(monaco.languages.registerDocumentSymbolProvider(language, documentSymbolProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerDocumentSymbolProvider(language, documentSymbolProvider)); | ||
} | ||
} | ||
@@ -239,3 +254,5 @@ return providers; | ||
for (const language of getLanguages()) { | ||
providers.push(monaco.languages.registerCodeActionProvider(language, codeActionProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerCodeActionProvider(language, codeActionProvider)); | ||
} | ||
} | ||
@@ -261,3 +278,5 @@ return providers; | ||
for (const language of getLanguages()) { | ||
providers.push(monaco.languages.registerCodeLensProvider(language, codeLensProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerCodeLensProvider(language, codeLensProvider)); | ||
} | ||
} | ||
@@ -294,3 +313,5 @@ return providers; | ||
for (const language of getLanguages()) { | ||
providers.push(monaco.languages.registerDocumentFormattingEditProvider(language, documentFormattingEditProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerDocumentFormattingEditProvider(language, documentFormattingEditProvider)); | ||
} | ||
} | ||
@@ -316,3 +337,5 @@ return providers; | ||
for (const language of getLanguages()) { | ||
providers.push(monaco.languages.registerDocumentRangeFormattingEditProvider(language, documentRangeFormattingEditProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerDocumentRangeFormattingEditProvider(language, documentRangeFormattingEditProvider)); | ||
} | ||
} | ||
@@ -338,3 +361,5 @@ return providers; | ||
for (const language of getLanguages()) { | ||
providers.push(monaco.languages.registerOnTypeFormattingEditProvider(language, onTypeFormattingEditProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerOnTypeFormattingEditProvider(language, onTypeFormattingEditProvider)); | ||
} | ||
} | ||
@@ -362,3 +387,5 @@ return providers; | ||
for (const language of getLanguages()) { | ||
providers.push(monaco.languages.registerRenameProvider(language, renameProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerRenameProvider(language, renameProvider)); | ||
} | ||
} | ||
@@ -384,3 +411,5 @@ return providers; | ||
for (const language of getLanguages()) { | ||
providers.push(monaco.languages.registerLinkProvider(language, linkProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerLinkProvider(language, linkProvider)); | ||
} | ||
} | ||
@@ -420,3 +449,5 @@ return providers; | ||
for (const language of getLanguages()) { | ||
providers.push(monaco.languages.registerImplementationProvider(language, implementationProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerImplementationProvider(language, implementationProvider)); | ||
} | ||
} | ||
@@ -442,3 +473,5 @@ return providers; | ||
for (const language of getLanguages()) { | ||
providers.push(monaco.languages.registerTypeDefinitionProvider(language, typeDefinitionProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerTypeDefinitionProvider(language, typeDefinitionProvider)); | ||
} | ||
} | ||
@@ -464,3 +497,5 @@ return providers; | ||
for (const language of getLanguages()) { | ||
providers.push(monaco.languages.registerColorProvider(language, documentColorProvider)); | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerColorProvider(language, documentColorProvider)); | ||
} | ||
} | ||
@@ -494,5 +529,30 @@ return providers; | ||
registerFoldingRangeProvider(selector: DocumentSelector, provider: FoldingRangeProvider): Disposable { | ||
const foldingRangeProvider = this.createFoldingRangeProvider(selector, provider); | ||
const providers = new DisposableCollection(); | ||
for (const language of getLanguages()) { | ||
if (this.matchLanguage(selector, language)) { | ||
providers.push(monaco.languages.registerFoldingRangeProvider(language, foldingRangeProvider)); | ||
} | ||
} | ||
return providers; | ||
} | ||
protected createFoldingRangeProvider(selector: DocumentSelector, provider: FoldingRangeProvider): monaco.languages.FoldingRangeProvider { | ||
return { | ||
provideFoldingRanges: (model, context, token) => { | ||
if (!this.matchModel(selector, MonacoModelIdentifier.fromModel(model))) { | ||
return []; | ||
} | ||
const textDocument = this.m2p.asTextDocumentIdentifier(model); | ||
return provider.provideFoldingRanges({ | ||
textDocument | ||
}, token).then(result => this.p2m.asFoldingRanges(result)); | ||
} | ||
} | ||
} | ||
protected matchModel(selector: string | DocumentFilter | DocumentSelector, model: MonacoModelIdentifier): boolean { | ||
if (Array.isArray(selector)) { | ||
return selector.findIndex(filter => this.matchModel(filter, model)) !== -1; | ||
return selector.some(filter => this.matchModel(filter, model)); | ||
} | ||
@@ -514,2 +574,14 @@ if (DocumentFilter.is(selector)) { | ||
protected matchLanguage(selector: string | DocumentFilter | DocumentSelector, languageId: string): boolean { | ||
if (Array.isArray(selector)) { | ||
return selector.some(filter => this.matchLanguage(filter, languageId)); | ||
} | ||
if (DocumentFilter.is(selector)) { | ||
return !selector.language || selector.language === languageId; | ||
} | ||
return selector === languageId; | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
694143
8912