monaco-languageclient
Advanced tools
Comparing version 0.3.0 to 0.4.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var MonacoCommands = (function () { | ||
var MonacoCommands = /** @class */ (function () { | ||
function MonacoCommands(editor) { | ||
@@ -5,0 +5,0 @@ this.editor = editor; |
@@ -8,3 +8,3 @@ "use strict"; | ||
var protocol_1 = require("vscode-base-languageclient/lib/protocol"); | ||
var ConsoleWindow = (function () { | ||
var ConsoleWindow = /** @class */ (function () { | ||
function ConsoleWindow() { | ||
@@ -11,0 +11,0 @@ this.channels = new Map(); |
@@ -1,2 +0,3 @@ | ||
import { CodeActionParams, CodeLensParams, DocumentFormattingParams, DocumentOnTypeFormattingParams, DocumentRangeFormattingParams, ReferenceParams, RenameParams, TextDocumentPositionParams, Position, TextDocumentIdentifier, CompletionItem, CompletionList, Range, Diagnostic, Hover, SignatureHelp, SignatureInformation, ParameterInformation, Definition, Location, DocumentHighlight, SymbolInformation, DocumentSymbolParams, CodeActionContext, DiagnosticSeverity, Command, CodeLens, FormattingOptions, TextEdit, WorkspaceEdit } from 'vscode-base-languageclient/lib/base'; | ||
/// <reference types="monaco-editor-core/monaco" /> | ||
import { CodeActionParams, CodeLensParams, DocumentFormattingParams, DocumentOnTypeFormattingParams, DocumentRangeFormattingParams, ReferenceParams, RenameParams, TextDocumentPositionParams, Position, TextDocumentIdentifier, CompletionItem, CompletionList, Range, Diagnostic, Hover, SignatureHelp, SignatureInformation, ParameterInformation, Definition, Location, DocumentHighlight, SymbolInformation, DocumentSymbolParams, CodeActionContext, DiagnosticSeverity, Command, CodeLens, FormattingOptions, TextEdit, WorkspaceEdit, DocumentLinkParams, DocumentLink } from 'vscode-base-languageclient/lib/base'; | ||
import IReadOnlyModel = monaco.editor.IReadOnlyModel; | ||
@@ -54,2 +55,4 @@ export declare type RecursivePartial<T> = { | ||
asRenameParams(model: IReadOnlyModel, position: monaco.IPosition, newName: string): RenameParams; | ||
asDocumentLinkParams(model: IReadOnlyModel): DocumentLinkParams; | ||
asDocumentLink(link: monaco.languages.ILink): DocumentLink; | ||
} | ||
@@ -110,2 +113,4 @@ export declare class ProtocolToMonacoConverter { | ||
} | undefined; | ||
asILinks(documentLinks: DocumentLink[]): monaco.languages.ILink[]; | ||
asILink(documentLink: DocumentLink): monaco.languages.ILink; | ||
asRange(range: null): null; | ||
@@ -112,0 +117,0 @@ asRange(range: undefined): undefined; |
@@ -31,3 +31,3 @@ "use strict"; | ||
})(ProtocolCompletionItem = exports.ProtocolCompletionItem || (exports.ProtocolCompletionItem = {})); | ||
var MonacoToProtocolConverter = (function () { | ||
var MonacoToProtocolConverter = /** @class */ (function () { | ||
function MonacoToProtocolConverter() { | ||
@@ -225,6 +225,17 @@ } | ||
}; | ||
MonacoToProtocolConverter.prototype.asDocumentLinkParams = function (model) { | ||
return { | ||
textDocument: this.asTextDocumentIdentifier(model) | ||
}; | ||
}; | ||
MonacoToProtocolConverter.prototype.asDocumentLink = function (link) { | ||
return { | ||
range: this.asRange(link.range), | ||
target: link.url | ||
}; | ||
}; | ||
return MonacoToProtocolConverter; | ||
}()); | ||
exports.MonacoToProtocolConverter = MonacoToProtocolConverter; | ||
var ProtocolToMonacoConverter = (function () { | ||
var ProtocolToMonacoConverter = /** @class */ (function () { | ||
function ProtocolToMonacoConverter() { | ||
@@ -525,2 +536,18 @@ } | ||
}; | ||
ProtocolToMonacoConverter.prototype.asILinks = function (documentLinks) { | ||
var links = []; | ||
for (var _i = 0, documentLinks_1 = documentLinks; _i < documentLinks_1.length; _i++) { | ||
var documentLink = documentLinks_1[_i]; | ||
links.push(this.asILink(documentLink)); | ||
} | ||
return links; | ||
}; | ||
ProtocolToMonacoConverter.prototype.asILink = function (documentLink) { | ||
// a DocumentLink's target is optional but ILink's url is not | ||
// so we cast to any to get around the compiler's error | ||
return { | ||
range: this.asRange(documentLink.range), | ||
url: documentLink.target | ||
}; | ||
}; | ||
ProtocolToMonacoConverter.prototype.asRange = function (range) { | ||
@@ -527,0 +554,0 @@ if (range === undefined) { |
@@ -0,1 +1,2 @@ | ||
/// <reference types="monaco-editor-core/monaco" /> | ||
import { DiagnosticCollection, Diagnostic } from 'vscode-base-languageclient/lib/services'; | ||
@@ -2,0 +3,0 @@ import { DisposableCollection, Disposable } from './disposable'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var disposable_1 = require("./disposable"); | ||
var MonacoDiagnosticCollection = (function () { | ||
var MonacoDiagnosticCollection = /** @class */ (function () { | ||
function MonacoDiagnosticCollection(name, p2m) { | ||
@@ -36,3 +36,3 @@ this.name = name; | ||
exports.MonacoDiagnosticCollection = MonacoDiagnosticCollection; | ||
var MonacoModelDiagnostics = (function () { | ||
var MonacoModelDiagnostics = /** @class */ (function () { | ||
function MonacoModelDiagnostics(uri, diagnostics, owner, p2m) { | ||
@@ -39,0 +39,0 @@ var _this = this; |
@@ -9,3 +9,3 @@ "use strict"; | ||
exports.Disposable = services_1.Disposable; | ||
var DisposableCollection = (function () { | ||
var DisposableCollection = /** @class */ (function () { | ||
function DisposableCollection() { | ||
@@ -12,0 +12,0 @@ this.disposables = []; |
@@ -1,2 +0,3 @@ | ||
import { Languages, DiagnosticCollection, CompletionItemProvider, DocumentIdentifier, HoverProvider, SignatureHelpProvider, DefinitionProvider, ReferenceProvider, DocumentHighlightProvider, DocumentSymbolProvider, CodeActionProvider, CodeLensProvider, DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider, OnTypeFormattingEditProvider, RenameProvider, CompletionClientCapabilities, DocumentFilter, DocumentSelector } from "vscode-base-languageclient/lib/services"; | ||
/// <reference types="monaco-editor-core/monaco" /> | ||
import { Languages, DiagnosticCollection, CompletionItemProvider, DocumentIdentifier, HoverProvider, SignatureHelpProvider, DefinitionProvider, ReferenceProvider, DocumentHighlightProvider, DocumentSymbolProvider, CodeActionProvider, CodeLensProvider, DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider, OnTypeFormattingEditProvider, RenameProvider, CompletionClientCapabilities, DocumentFilter, DocumentSelector, DocumentLinkProvider } from "vscode-base-languageclient/lib/services"; | ||
import { ProtocolToMonacoConverter, MonacoToProtocolConverter } from './converter'; | ||
@@ -47,3 +48,5 @@ import { Disposable } from './disposable'; | ||
protected createRenameProvider(selector: DocumentSelector, provider: RenameProvider): monaco.languages.RenameProvider; | ||
registerDocumentLinkProvider(selector: DocumentSelector, provider: DocumentLinkProvider): Disposable; | ||
protected createDocumentLinkProvider(selector: DocumentSelector, provider: DocumentLinkProvider): monaco.languages.LinkProvider; | ||
protected matchModel(selector: string | DocumentFilter | DocumentSelector, model: MonacoModelIdentifier): boolean; | ||
} |
@@ -47,3 +47,3 @@ "use strict"; | ||
exports.getLanguages = getLanguages; | ||
var MonacoLanguages = (function () { | ||
var MonacoLanguages = /** @class */ (function () { | ||
function MonacoLanguages(p2m, m2p) { | ||
@@ -378,2 +378,32 @@ this.p2m = p2m; | ||
}; | ||
MonacoLanguages.prototype.registerDocumentLinkProvider = function (selector, provider) { | ||
var linkProvider = this.createDocumentLinkProvider(selector, provider); | ||
var providers = new disposable_1.DisposableCollection(); | ||
for (var _i = 0, _a = getLanguages(); _i < _a.length; _i++) { | ||
var language = _a[_i]; | ||
providers.push(monaco.languages.registerLinkProvider(language, linkProvider)); | ||
} | ||
return providers; | ||
}; | ||
MonacoLanguages.prototype.createDocumentLinkProvider = function (selector, provider) { | ||
var _this = this; | ||
return { | ||
provideLinks: function (model, token) { | ||
if (!_this.matchModel(selector, MonacoModelIdentifier.fromModel(model))) { | ||
return undefined; | ||
} | ||
var params = _this.m2p.asDocumentLinkParams(model); | ||
return provider.provideDocumentLinks(params, token).then(function (result) { return _this.p2m.asILinks(result); }); | ||
}, | ||
resolveLink: function (link, token) { | ||
// resolve the link if the provider supports it | ||
// and the link doesn't have a url set | ||
if (provider.resolveDocumentLink && (link.url === null || link.url === undefined)) { | ||
var documentLink = _this.m2p.asDocumentLink(link); | ||
return provider.resolveDocumentLink(documentLink, token).then(function (result) { return _this.p2m.asILink(result); }); | ||
} | ||
return link; | ||
} | ||
}; | ||
}; | ||
MonacoLanguages.prototype.matchModel = function (selector, model) { | ||
@@ -380,0 +410,0 @@ var _this = this; |
@@ -0,3 +1,4 @@ | ||
/// <reference types="monaco-editor-core/monaco" /> | ||
import { MonacoToProtocolConverter, ProtocolToMonacoConverter } from './converter'; | ||
import { Workspace, TextDocumentDidChangeEvent, TextDocument, Event, Emitter } from 'vscode-base-languageclient/lib/services'; | ||
import { Workspace, TextDocumentDidChangeEvent, TextDocument, Event, Emitter, WorkspaceClientCapabilites } from 'vscode-base-languageclient/lib/services'; | ||
import { WorkspaceEdit } from 'vscode-base-languageclient/lib/base'; | ||
@@ -9,2 +10,3 @@ import IModel = monaco.editor.IModel; | ||
protected _rootUri: string | null; | ||
readonly capabilities: WorkspaceClientCapabilites; | ||
protected readonly documents: Map<string, TextDocument>; | ||
@@ -11,0 +13,0 @@ protected readonly onDidOpenTextDocumentEmitter: Emitter<TextDocument>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var services_1 = require("vscode-base-languageclient/lib/services"); | ||
var MonacoWorkspace = (function () { | ||
var MonacoWorkspace = /** @class */ (function () { | ||
function MonacoWorkspace(p2m, m2p, _rootUri) { | ||
@@ -11,2 +11,8 @@ if (_rootUri === void 0) { _rootUri = null; } | ||
this._rootUri = _rootUri; | ||
this.capabilities = { | ||
applyEdit: true, | ||
workspaceEdit: { | ||
documentChanges: true | ||
} | ||
}; | ||
this.documents = new Map(); | ||
@@ -13,0 +19,0 @@ this.onDidOpenTextDocumentEmitter = new services_1.Emitter(); |
{ | ||
"name": "monaco-languageclient", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "Monaco Language client implementation", | ||
@@ -23,3 +23,3 @@ "author": "TypeFox GmbH (http://www.typefox.io)", | ||
"glob-to-regexp": "^0.3.0", | ||
"monaco-editor": "^0.10.0", | ||
"monaco-editor-core": "^0.10.1", | ||
"vscode-base-languageclient": "^0.0.1-alpha.2" | ||
@@ -26,0 +26,0 @@ }, |
@@ -16,3 +16,3 @@ /* -------------------------------------------------------------------------------------------- | ||
SymbolInformation, DocumentSymbolParams, CodeActionContext, DiagnosticSeverity, | ||
Command, CodeLens, FormattingOptions, TextEdit, WorkspaceEdit | ||
Command, CodeLens, FormattingOptions, TextEdit, WorkspaceEdit, DocumentLinkParams, DocumentLink | ||
} from 'vscode-base-languageclient/lib/base'; | ||
@@ -258,2 +258,15 @@ import IReadOnlyModel = monaco.editor.IReadOnlyModel; | ||
} | ||
asDocumentLinkParams(model: IReadOnlyModel): DocumentLinkParams { | ||
return { | ||
textDocument: this.asTextDocumentIdentifier(model) | ||
} | ||
} | ||
asDocumentLink(link: monaco.languages.ILink): DocumentLink { | ||
return { | ||
range: this.asRange(link.range), | ||
target: link.url | ||
} | ||
} | ||
} | ||
@@ -573,2 +586,19 @@ | ||
asILinks(documentLinks: DocumentLink[]): monaco.languages.ILink[] { | ||
let links = []; | ||
for (let documentLink of documentLinks) { | ||
links.push(this.asILink(documentLink)); | ||
} | ||
return links; | ||
} | ||
asILink(documentLink: DocumentLink): monaco.languages.ILink { | ||
// a DocumentLink's target is optional but ILink's url is not | ||
// so we cast to any to get around the compiler's error | ||
return { | ||
range: this.asRange(documentLink.range), | ||
url: documentLink.target | ||
} as any; | ||
} | ||
asRange(range: null): null; | ||
@@ -575,0 +605,0 @@ asRange(range: undefined): undefined; |
@@ -10,3 +10,3 @@ /* -------------------------------------------------------------------------------------------- | ||
DocumentSymbolProvider, CodeActionProvider, CodeLensProvider, DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider, OnTypeFormattingEditProvider, RenameProvider, | ||
CompletionClientCapabilities, DocumentFilter, DocumentSelector | ||
CompletionClientCapabilities, DocumentFilter, DocumentSelector, DocumentLinkProvider | ||
} from "vscode-base-languageclient/lib/services"; | ||
@@ -365,2 +365,33 @@ import { MonacoDiagnosticCollection } from './diagnostic-collection'; | ||
registerDocumentLinkProvider(selector: DocumentSelector, provider: DocumentLinkProvider): Disposable { | ||
const linkProvider = this.createDocumentLinkProvider(selector, provider); | ||
const providers = new DisposableCollection(); | ||
for (const language of getLanguages()) { | ||
providers.push(monaco.languages.registerLinkProvider(language, linkProvider)); | ||
} | ||
return providers; | ||
} | ||
protected createDocumentLinkProvider(selector: DocumentSelector, provider: DocumentLinkProvider): monaco.languages.LinkProvider { | ||
return { | ||
provideLinks: (model, token) => { | ||
if (!this.matchModel(selector, MonacoModelIdentifier.fromModel(model))) { | ||
return undefined!; | ||
} | ||
const params = this.m2p.asDocumentLinkParams(model); | ||
return provider.provideDocumentLinks(params, token).then(result => this.p2m.asILinks(result)); | ||
}, | ||
resolveLink: (link: monaco.languages.ILink, token) => { | ||
// resolve the link if the provider supports it | ||
// and the link doesn't have a url set | ||
if (provider.resolveDocumentLink && (link.url === null || link.url === undefined)) { | ||
const documentLink = this.m2p.asDocumentLink(link); | ||
return provider.resolveDocumentLink(documentLink, token).then(result => this.p2m.asILink(result)); | ||
} | ||
return link; | ||
} | ||
} | ||
} | ||
protected matchModel(selector: string | DocumentFilter | DocumentSelector, model: MonacoModelIdentifier): boolean { | ||
@@ -367,0 +398,0 @@ if (Array.isArray(selector)) { |
@@ -6,3 +6,3 @@ /* -------------------------------------------------------------------------------------------- | ||
import { MonacoToProtocolConverter, ProtocolToMonacoConverter } from './converter'; | ||
import { Workspace, TextDocumentDidChangeEvent, TextDocument, Event, Emitter } from 'vscode-base-languageclient/lib/services'; | ||
import { Workspace, TextDocumentDidChangeEvent, TextDocument, Event, Emitter, WorkspaceClientCapabilites } from 'vscode-base-languageclient/lib/services'; | ||
import { WorkspaceEdit } from 'vscode-base-languageclient/lib/base'; | ||
@@ -14,2 +14,8 @@ import IModel = monaco.editor.IModel; | ||
public readonly capabilities: WorkspaceClientCapabilites = { | ||
applyEdit: true, | ||
workspaceEdit: { | ||
documentChanges: true | ||
} | ||
}; | ||
protected readonly documents = new Map<string, TextDocument>(); | ||
@@ -16,0 +22,0 @@ protected readonly onDidOpenTextDocumentEmitter = new Emitter<TextDocument>(); |
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
196616
2972
+ Addedmonaco-editor-core@^0.10.1
+ Addedmonaco-editor-core@0.10.1(transitive)
- Removedmonaco-editor@^0.10.0
- Removedmonaco-editor@0.10.1(transitive)