sprotty-vscode
Advanced tools
Comparing version 0.1.3 to 0.2.0
@@ -16,3 +16,3 @@ /******************************************************************************** | ||
********************************************************************************/ | ||
import { Action } from 'sprotty-vscode-protocol'; | ||
import { Action } from 'sprotty-protocol'; | ||
/** | ||
@@ -19,0 +19,0 @@ * Used to locally intercept and handle actions in the VS Code extension. |
"use strict"; | ||
/******************************************************************************** | ||
* Copyright (c) 2020 TypeFox and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=action-handler.js.map |
@@ -16,5 +16,5 @@ /******************************************************************************** | ||
********************************************************************************/ | ||
import { Action } from 'sprotty-vscode-protocol'; | ||
import { Action } from 'sprotty-protocol'; | ||
import { LspLabelEditAction } from 'sprotty-vscode-protocol/lib/lsp/editing'; | ||
import { CompletionItem, LanguageClient } from 'vscode-languageclient'; | ||
import { CompletionItem, CommonLanguageClient } from 'vscode-languageclient'; | ||
import { ActionHandler } from '../../action-handler'; | ||
@@ -27,3 +27,3 @@ import { SprottyWebview } from '../../sprotty-webview'; | ||
handleAction(action: Action): Promise<boolean>; | ||
protected get languageClient(): LanguageClient; | ||
protected get languageClient(): CommonLanguageClient; | ||
chooseCrossReference(action: LspLabelEditAction): Promise<boolean>; | ||
@@ -30,0 +30,0 @@ protected filterCompletionItems(items: CompletionItem[]): CompletionItem[]; |
"use strict"; | ||
/******************************************************************************** | ||
* Copyright (c) 2020 TypeFox and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -49,3 +64,3 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
if (!(webview.extension instanceof sprotty_lsp_vscode_extension_1.SprottyLspVscodeExtension)) | ||
throw new Error('LspLabelEditActionHandler must be initialized wit a SprottyLspWebview'); | ||
throw new Error('LspLabelEditActionHandler must be initialized with a SprottyLspWebview'); | ||
} | ||
@@ -52,0 +67,0 @@ LspLabelEditActionHandler.prototype.handleAction = function (action) { |
@@ -26,4 +26,4 @@ "use strict"; | ||
for (var uri in changes) { | ||
if (changes.hasOwnProperty(uri)) { | ||
var textEdits = changes[uri]; | ||
var textEdits = changes[uri]; | ||
if (Array.isArray(textEdits)) { | ||
result.set(convertUri(uri), textEdits.map(convertTextEdit)); | ||
@@ -30,0 +30,0 @@ } |
@@ -16,3 +16,3 @@ /******************************************************************************** | ||
********************************************************************************/ | ||
import { Action } from 'sprotty-vscode-protocol'; | ||
import { Action } from 'sprotty-protocol'; | ||
import { ActionHandler } from '../../action-handler'; | ||
@@ -19,0 +19,0 @@ export declare class WorkspaceEditActionHandler implements ActionHandler { |
"use strict"; | ||
/******************************************************************************** | ||
* Copyright (c) 2020 TypeFox and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -3,0 +18,0 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } |
@@ -17,6 +17,6 @@ /******************************************************************************** | ||
import { NotificationType, Location } from 'vscode-languageclient'; | ||
import { ActionMessage } from 'sprotty-vscode-protocol'; | ||
export declare const acceptMessageType: NotificationType<ActionMessage, void>; | ||
export declare const didCloseMessageType: NotificationType<string, void>; | ||
export declare const openInTextEditorMessageType: NotificationType<OpenInTextEditorMessage, void>; | ||
import { ActionMessage } from 'sprotty-protocol'; | ||
export declare const acceptMessageType: NotificationType<ActionMessage>; | ||
export declare const didCloseMessageType: NotificationType<string>; | ||
export declare const openInTextEditorMessageType: NotificationType<OpenInTextEditorMessage>; | ||
export interface OpenInTextEditorMessage { | ||
@@ -23,0 +23,0 @@ location: Location; |
@@ -19,3 +19,3 @@ "use strict"; | ||
var vscode_languageclient_1 = require("vscode-languageclient"); | ||
///////////////////////////////////// | ||
// ---------------------------------- | ||
// Sprotty LSP extensions | ||
@@ -22,0 +22,0 @@ exports.acceptMessageType = new vscode_languageclient_1.NotificationType('diagram/accept'); |
@@ -17,8 +17,9 @@ /******************************************************************************** | ||
import * as vscode from 'vscode'; | ||
import { Emitter, LanguageClient } from 'vscode-languageclient'; | ||
import { Emitter, CommonLanguageClient } from 'vscode-languageclient'; | ||
import { OpenInTextEditorMessage } from './protocol'; | ||
import { ActionMessage, SprottyDiagramIdentifier } from 'sprotty-vscode-protocol'; | ||
import { ActionMessage } from 'sprotty-protocol'; | ||
import { SprottyDiagramIdentifier } from 'sprotty-vscode-protocol'; | ||
import { SprottyVscodeExtension } from '../sprotty-vscode-extension'; | ||
export declare abstract class SprottyLspVscodeExtension extends SprottyVscodeExtension { | ||
readonly languageClient: LanguageClient; | ||
readonly languageClient: CommonLanguageClient; | ||
protected acceptFromLanguageServerEmitter: Emitter<ActionMessage>; | ||
@@ -28,3 +29,3 @@ constructor(extensionPrefix: string, context: vscode.ExtensionContext); | ||
didCloseWebview(identifier: SprottyDiagramIdentifier): void; | ||
protected abstract activateLanguageClient(context: vscode.ExtensionContext): LanguageClient; | ||
protected abstract activateLanguageClient(context: vscode.ExtensionContext): CommonLanguageClient; | ||
deactivateLanguageClient(): Thenable<void>; | ||
@@ -31,0 +32,0 @@ protected openInTextEditor(message: OpenInTextEditorMessage): void; |
@@ -1,2 +0,17 @@ | ||
import { LanguageClient } from 'vscode-languageclient'; | ||
/******************************************************************************** | ||
* Copyright (c) 2020 TypeFox and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
import { CommonLanguageClient } from 'vscode-languageclient'; | ||
import { SprottyLspVscodeExtension } from './sprotty-lsp-vscode-extension'; | ||
@@ -10,3 +25,3 @@ import { SprottyWebview, SprottyWebviewOptions } from '../sprotty-webview'; | ||
protected ready(): Promise<void>; | ||
protected get languageClient(): LanguageClient; | ||
protected get languageClient(): CommonLanguageClient; | ||
protected connect(): Promise<void>; | ||
@@ -13,0 +28,0 @@ protected receiveFromWebview(message: any): Promise<boolean>; |
"use strict"; | ||
/******************************************************************************** | ||
* Copyright (c) 2020 TypeFox and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
var __extends = (this && this.__extends) || (function () { | ||
@@ -52,19 +67,4 @@ var extendStatics = function (d, b) { | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/******************************************************************************** | ||
* Copyright (c) 2020 TypeFox and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
var sprotty_vscode_protocol_1 = require("sprotty-vscode-protocol"); | ||
var messages_1 = require("vscode-jsonrpc/lib/messages"); | ||
var sprotty_protocol_1 = require("sprotty-protocol"); | ||
var messages_1 = require("vscode-jsonrpc/lib/common/messages"); | ||
var protocol_1 = require("./protocol"); | ||
@@ -113,3 +113,3 @@ var sprotty_lsp_vscode_extension_1 = require("./sprotty-lsp-vscode-extension"); | ||
if (!shouldPropagate) return [3 /*break*/, 8]; | ||
if (!sprotty_vscode_protocol_1.isActionMessage(message)) return [3 /*break*/, 2]; | ||
if (!sprotty_protocol_1.isActionMessage(message)) return [3 /*break*/, 2]; | ||
this.languageClient.sendNotification(protocol_1.acceptMessageType, message); | ||
@@ -116,0 +116,0 @@ return [3 /*break*/, 8]; |
@@ -104,10 +104,11 @@ "use strict"; | ||
var identifier, key, webView; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
var _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, this.createDiagramIdentifier(commandArgs)]; | ||
case 1: | ||
identifier = _a.sent(); | ||
identifier = _b.sent(); | ||
if (identifier) { | ||
key = this.getKey(identifier); | ||
webView = this.singleton || this.webviewMap.get(key); | ||
webView = (_a = this.singleton) !== null && _a !== void 0 ? _a : this.webviewMap.get(key); | ||
if (webView) { | ||
@@ -119,6 +120,8 @@ webView.reloadContent(identifier); | ||
webView = this.createWebView(identifier); | ||
this.webviewMap.set(key, webView); | ||
if (webView.singleton) { | ||
this.singleton = webView; | ||
} | ||
else { | ||
this.webviewMap.set(key, webView); | ||
} | ||
} | ||
@@ -159,7 +162,11 @@ } | ||
var e_1, _a; | ||
if (this.singleton && this.singleton.diagramPanel.active) { | ||
return this.singleton; | ||
} | ||
try { | ||
for (var _b = __values(this.webviewMap.values()), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var webview = _c.value; | ||
if (webview.diagramPanel.active) | ||
if (webview.diagramPanel.active) { | ||
return webview; | ||
} | ||
} | ||
@@ -166,0 +173,0 @@ } |
@@ -16,7 +16,8 @@ /******************************************************************************** | ||
********************************************************************************/ | ||
import { Action, ActionMessage, SprottyDiagramIdentifier } from 'sprotty-vscode-protocol'; | ||
import { Action, ActionMessage } from 'sprotty-protocol'; | ||
import { SprottyDiagramIdentifier } from 'sprotty-vscode-protocol'; | ||
import * as vscode from 'vscode'; | ||
import { ActionHandler } from './action-handler'; | ||
import { SprottyVscodeExtension } from './sprotty-vscode-extension'; | ||
import { ResponseMessage } from 'vscode-jsonrpc/lib/messages'; | ||
import { ResponseMessage } from 'vscode-jsonrpc/lib/common/messages'; | ||
export interface SprottyWebviewOptions { | ||
@@ -23,0 +24,0 @@ extension: SprottyVscodeExtension; |
"use strict"; | ||
/******************************************************************************** | ||
* Copyright (c) 2020 TypeFox and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -39,21 +54,7 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/******************************************************************************** | ||
* Copyright (c) 2020 TypeFox and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
var sprotty_protocol_1 = require("sprotty-protocol"); | ||
var sprotty_vscode_protocol_1 = require("sprotty-vscode-protocol"); | ||
var vscode = require("vscode"); | ||
var sprotty_vscode_extension_1 = require("./sprotty-vscode-extension"); | ||
var messages_1 = require("vscode-jsonrpc/lib/messages"); | ||
var messages_1 = require("vscode-jsonrpc/lib/common/messages"); | ||
var SprottyWebview = /** @class */ (function () { | ||
@@ -188,3 +189,3 @@ function SprottyWebview(options) { | ||
SprottyWebview.prototype.receiveFromWebview = function (message) { | ||
if (sprotty_vscode_protocol_1.isActionMessage(message)) | ||
if (sprotty_protocol_1.isActionMessage(message)) | ||
return this.accept(message.action); | ||
@@ -199,5 +200,5 @@ else if (sprotty_vscode_protocol_1.isWebviewReadyMessage(message)) { | ||
SprottyWebview.prototype.sendToWebview = function (message) { | ||
if (sprotty_vscode_protocol_1.isActionMessage(message) || sprotty_vscode_protocol_1.isDiagramIdentifier(message) || messages_1.isResponseMessage(message)) { | ||
if (sprotty_protocol_1.isActionMessage(message) || sprotty_vscode_protocol_1.isDiagramIdentifier(message) || messages_1.isResponseMessage(message)) { | ||
if (this.diagramPanel.visible) { | ||
if (sprotty_vscode_protocol_1.isActionMessage(message)) { | ||
if (sprotty_protocol_1.isActionMessage(message)) { | ||
var actionHandler = this.actionHandlers.get(message.action.kind); | ||
@@ -204,0 +205,0 @@ if (actionHandler && !actionHandler.handleAction(message.action)) |
{ | ||
"name": "sprotty-vscode", | ||
"version": "0.1.3", | ||
"version": "0.2.0", | ||
"displayName": "Sprotty VSCode Integration", | ||
@@ -46,12 +46,16 @@ "description": "Glue code to integrate Sprotty diagrams in VSCode extensions (extension part)", | ||
"path": "^0.12.7", | ||
"sprotty-vscode-protocol": "^0.0.5", | ||
"vscode-languageclient": "^5.2.1", | ||
"vscode-languageserver": "^5.2.1" | ||
"sprotty-vscode-protocol": "~0.2.0", | ||
"vscode-languageclient": "^7.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^8.0.0", | ||
"@types/node": "^12.12.6", | ||
"@types/vscode": "1.46.0", | ||
"@typescript-eslint/eslint-plugin": "^5.3.0", | ||
"@typescript-eslint/parser": "^5.3.0", | ||
"eslint": "^8.1.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-header": "^3.1.1", | ||
"eslint-plugin-no-null": "^1.0.2", | ||
"rimraf": "latest", | ||
"tslint": "^5.11.0", | ||
"typescript": "^3.1.3" | ||
"typescript": "~3.8.3" | ||
}, | ||
@@ -63,5 +67,4 @@ "scripts": { | ||
"watch": "tsc -w", | ||
"lint": "tslint -c ./tslint.json --project ./tsconfig.json" | ||
}, | ||
"gitHead": "6f3693049585202f9f68d719529b45b7db67c997" | ||
"lint": "eslint -c ../configs/.eslintrc.js \"src/**/!(*.spec.ts*)\"" | ||
} | ||
} |
@@ -16,4 +16,5 @@ /******************************************************************************** | ||
********************************************************************************/ | ||
import { Action } from 'sprotty-vscode-protocol'; | ||
import { Action } from 'sprotty-protocol'; | ||
/** | ||
@@ -20,0 +21,0 @@ * Used to locally intercept and handle actions in the VS Code extension. |
@@ -16,17 +16,10 @@ /******************************************************************************** | ||
********************************************************************************/ | ||
import { Action } from 'sprotty-vscode-protocol'; | ||
import { Action } from 'sprotty-protocol'; | ||
import { LspLabelEditAction } from 'sprotty-vscode-protocol/lib/lsp/editing'; | ||
import { QuickPickItem, window, workspace, WorkspaceEdit, TextEdit } from 'vscode'; | ||
import { | ||
CompletionItem, | ||
CompletionItemKind, | ||
CompletionList, | ||
CompletionRequest, | ||
LanguageClient, | ||
PrepareRenameRequest, | ||
RenameParams, | ||
RenameRequest, | ||
TextDocumentPositionParams, | ||
CompletionItem, CompletionItemKind, CompletionList, CompletionRequest, CommonLanguageClient, | ||
PrepareRenameRequest, RenameParams, RenameRequest, TextDocumentPositionParams | ||
} from 'vscode-languageclient'; | ||
import { ActionHandler } from '../../action-handler'; | ||
@@ -43,3 +36,3 @@ import { SprottyLspVscodeExtension } from '../sprotty-lsp-vscode-extension'; | ||
if (!(webview.extension instanceof SprottyLspVscodeExtension)) | ||
throw new Error('LspLabelEditActionHandler must be initialized wit a SprottyLspWebview'); | ||
throw new Error('LspLabelEditActionHandler must be initialized with a SprottyLspWebview'); | ||
} | ||
@@ -57,3 +50,3 @@ | ||
protected get languageClient(): LanguageClient { | ||
protected get languageClient(): CommonLanguageClient { | ||
return (this.webview.extension as SprottyLspVscodeExtension).languageClient; | ||
@@ -73,7 +66,8 @@ } | ||
const quickPickItems = this.filterCompletionItems(completionItems) | ||
.map(completionItem => { return <QuickPickItem> { | ||
label: completionItem.textEdit!.newText, | ||
value: completionItem | ||
}; | ||
}); | ||
.map(completionItem => { | ||
return <QuickPickItem> { | ||
label: completionItem.textEdit!.newText, | ||
value: completionItem | ||
}; | ||
}); | ||
const pick = await window.showQuickPick(quickPickItems); | ||
@@ -80,0 +74,0 @@ if (pick) { |
@@ -25,4 +25,4 @@ /******************************************************************************** | ||
for (const uri in changes) { | ||
if (changes.hasOwnProperty(uri)) { | ||
const textEdits = changes[uri]; | ||
const textEdits = changes[uri]; | ||
if (Array.isArray(textEdits)) { | ||
result.set(convertUri(uri), textEdits.map(convertTextEdit)); | ||
@@ -29,0 +29,0 @@ } |
@@ -19,3 +19,2 @@ /******************************************************************************** | ||
import { SprottyLspVscodeExtension } from '../sprotty-lsp-vscode-extension'; | ||
import { Action } from 'sprotty-vscode-protocol'; | ||
import { DeleteWithWorkspaceEditAction } from 'sprotty-vscode-protocol/lib/lsp/editing'; | ||
@@ -32,5 +31,5 @@ | ||
kind: DeleteWithWorkspaceEditAction.KIND | ||
} as Action); | ||
}); | ||
})); | ||
} | ||
} |
@@ -16,3 +16,4 @@ /******************************************************************************** | ||
********************************************************************************/ | ||
import { Action } from 'sprotty-vscode-protocol'; | ||
import { Action } from 'sprotty-protocol'; | ||
import { WorkspaceEditAction } from 'sprotty-vscode-protocol/lib/lsp/editing'; | ||
@@ -19,0 +20,0 @@ import { workspace } from 'vscode'; |
@@ -18,10 +18,10 @@ /******************************************************************************** | ||
import { NotificationType, Location } from 'vscode-languageclient'; | ||
import { ActionMessage } from 'sprotty-vscode-protocol'; | ||
import { ActionMessage } from 'sprotty-protocol'; | ||
///////////////////////////////////// | ||
// ---------------------------------- | ||
// Sprotty LSP extensions | ||
export const acceptMessageType = new NotificationType<ActionMessage, void>('diagram/accept'); | ||
export const didCloseMessageType = new NotificationType<string, void>('diagram/didClose'); | ||
export const openInTextEditorMessageType = new NotificationType<OpenInTextEditorMessage, void>('diagram/openInTextEditor'); | ||
export const acceptMessageType = new NotificationType<ActionMessage>('diagram/accept'); | ||
export const didCloseMessageType = new NotificationType<string>('diagram/didClose'); | ||
export const openInTextEditorMessageType = new NotificationType<OpenInTextEditorMessage>('diagram/openInTextEditor'); | ||
@@ -28,0 +28,0 @@ export interface OpenInTextEditorMessage { |
@@ -18,18 +18,19 @@ /******************************************************************************** | ||
import * as vscode from 'vscode'; | ||
import { Emitter, LanguageClient } from 'vscode-languageclient'; | ||
import { Emitter, CommonLanguageClient } from 'vscode-languageclient'; | ||
import { acceptMessageType, didCloseMessageType, OpenInTextEditorMessage, openInTextEditorMessageType } from './protocol'; | ||
import { ActionMessage, SprottyDiagramIdentifier } from 'sprotty-vscode-protocol'; | ||
import { ActionMessage } from 'sprotty-protocol'; | ||
import { SprottyDiagramIdentifier } from 'sprotty-vscode-protocol'; | ||
import { SprottyVscodeExtension } from '../sprotty-vscode-extension'; | ||
export abstract class SprottyLspVscodeExtension extends SprottyVscodeExtension { | ||
readonly languageClient: LanguageClient; | ||
readonly languageClient: CommonLanguageClient; | ||
protected acceptFromLanguageServerEmitter = new Emitter<ActionMessage>(); | ||
constructor(extensionPrefix: string, context: vscode.ExtensionContext) { | ||
constructor(extensionPrefix: string, context: vscode.ExtensionContext) { | ||
super(extensionPrefix, context); | ||
this.languageClient = this.activateLanguageClient(context); | ||
this.languageClient.onReady().then(() => { | ||
this.languageClient.onNotification(acceptMessageType, message => this.acceptFromLanguageServerEmitter.fire(message)); | ||
this.languageClient.onNotification(openInTextEditorMessageType, message => this.openInTextEditor(message)); | ||
this.languageClient.onNotification(acceptMessageType, (message: ActionMessage) => this.acceptFromLanguageServerEmitter.fire(message)); | ||
this.languageClient.onNotification(openInTextEditorMessageType, (message: OpenInTextEditorMessage) => this.openInTextEditor(message)); | ||
}); | ||
@@ -51,3 +52,3 @@ } | ||
protected abstract activateLanguageClient(context: vscode.ExtensionContext): LanguageClient; | ||
protected abstract activateLanguageClient(context: vscode.ExtensionContext): CommonLanguageClient; | ||
@@ -54,0 +55,0 @@ deactivateLanguageClient(): Thenable<void> { |
@@ -16,6 +16,7 @@ /******************************************************************************** | ||
********************************************************************************/ | ||
import { isActionMessage } from 'sprotty-vscode-protocol'; | ||
import { isNotificationMessage, isRequestMessage, ResponseMessage } from 'vscode-jsonrpc/lib/messages'; | ||
import { LanguageClient } from 'vscode-languageclient'; | ||
import { isActionMessage } from 'sprotty-protocol'; | ||
import { isNotificationMessage, isRequestMessage, ResponseMessage } from 'vscode-jsonrpc/lib/common/messages'; | ||
import { CommonLanguageClient } from 'vscode-languageclient'; | ||
import { acceptMessageType } from './protocol'; | ||
@@ -42,3 +43,3 @@ import { SprottyLspVscodeExtension } from './sprotty-lsp-vscode-extension'; | ||
protected get languageClient(): LanguageClient { | ||
protected get languageClient(): CommonLanguageClient { | ||
return this.extension.languageClient; | ||
@@ -45,0 +46,0 @@ } |
@@ -19,3 +19,4 @@ /******************************************************************************** | ||
import * as vscode from 'vscode'; | ||
import { Action, SprottyDiagramIdentifier } from 'sprotty-vscode-protocol'; | ||
import { Action } from 'sprotty-protocol'; | ||
import { SprottyDiagramIdentifier } from 'sprotty-vscode-protocol'; | ||
import { SprottyWebview } from './sprotty-webview'; | ||
@@ -28,3 +29,3 @@ | ||
constructor(readonly extensionPrefix: string, readonly context: vscode.ExtensionContext) { | ||
constructor(readonly extensionPrefix: string, readonly context: vscode.ExtensionContext) { | ||
this.registerCommands(); | ||
@@ -39,3 +40,3 @@ } | ||
const key = this.getKey(identifier); | ||
let webView = this.singleton || this.webviewMap.get(key); | ||
let webView = this.singleton ?? this.webviewMap.get(key); | ||
if (webView) { | ||
@@ -46,5 +47,6 @@ webView.reloadContent(identifier); | ||
webView = this.createWebView(identifier); | ||
this.webviewMap.set(key, webView); | ||
if (webView.singleton) { | ||
this.singleton = webView; | ||
} else { | ||
this.webviewMap.set(key, webView); | ||
} | ||
@@ -84,6 +86,10 @@ } | ||
protected findActiveWebview(): SprottyWebview | undefined { | ||
for (const webview of this.webviewMap.values()) { | ||
if (webview.diagramPanel.active) | ||
protected findActiveWebview(): SprottyWebview | undefined { | ||
if (this.singleton && this.singleton.diagramPanel.active) { | ||
return this.singleton; | ||
} | ||
for (const webview of this.webviewMap.values()) { | ||
if (webview.diagramPanel.active) { | ||
return webview; | ||
} | ||
} | ||
@@ -112,3 +118,3 @@ return undefined; | ||
const diagramType = await this.getDiagramType(commandArgs); | ||
if (!uri || !diagramType) | ||
if (!uri || !diagramType) | ||
return undefined; | ||
@@ -123,5 +129,5 @@ const clientId = diagramType + '_' + SprottyWebview.viewCount++; | ||
protected abstract getDiagramType(commandArgs: any[]): Promise<string | undefined> | string | undefined; | ||
protected abstract getDiagramType(commandArgs: any[]): Promise<string | undefined> | string | undefined; | ||
getDiagramTypeForUri(uri: vscode.Uri): Promise<string | undefined> | string | undefined { | ||
getDiagramTypeForUri(uri: vscode.Uri): Promise<string | undefined> | string | undefined { | ||
return this.getDiagramType([uri]); | ||
@@ -128,0 +134,0 @@ } |
@@ -16,5 +16,5 @@ /******************************************************************************** | ||
********************************************************************************/ | ||
import { | ||
Action, ActionMessage, isActionMessage, isDiagramIdentifier, isWebviewReadyMessage, SprottyDiagramIdentifier | ||
} from 'sprotty-vscode-protocol'; | ||
import { Action, ActionMessage, isActionMessage } from 'sprotty-protocol'; | ||
import { isDiagramIdentifier, isWebviewReadyMessage, SprottyDiagramIdentifier } from 'sprotty-vscode-protocol'; | ||
import * as vscode from 'vscode'; | ||
@@ -24,3 +24,3 @@ | ||
import { SprottyVscodeExtension, serializeUri } from './sprotty-vscode-extension'; | ||
import { isResponseMessage, ResponseMessage } from 'vscode-jsonrpc/lib/messages'; | ||
import { isResponseMessage, ResponseMessage } from 'vscode-jsonrpc/lib/common/messages'; | ||
@@ -46,3 +46,3 @@ export interface SprottyWebviewOptions { | ||
protected messageQueue: (ActionMessage | SprottyDiagramIdentifier | ResponseMessage)[] = []; | ||
protected messageQueue: (ActionMessage | SprottyDiagramIdentifier | ResponseMessage)[] = []; | ||
protected disposables: vscode.Disposable[] = []; | ||
@@ -82,3 +82,3 @@ | ||
const diagramPanel = vscode.window.createWebviewPanel( | ||
this.diagramIdentifier.diagramType || 'diagram', | ||
this.diagramIdentifier.diagramType || 'diagram', | ||
title, | ||
@@ -179,3 +179,3 @@ vscode.ViewColumn.Beside, | ||
protected sendToWebview(message: any) { | ||
if (isActionMessage(message) || isDiagramIdentifier(message) || isResponseMessage(message)) { | ||
if (isActionMessage(message) || isDiagramIdentifier(message) || isResponseMessage(message)) { | ||
if (this.diagramPanel.visible) { | ||
@@ -194,3 +194,3 @@ if (isActionMessage(message)) { | ||
dispatch(action: Action) { | ||
dispatch(action: Action) { | ||
this.sendToWebview({ | ||
@@ -202,3 +202,3 @@ clientId: this.diagramIdentifier.clientId, | ||
accept(action: Action): Thenable<boolean> { | ||
accept(action: Action): Thenable<boolean> { | ||
const actionHandler = this.actionHandlers.get(action.kind); | ||
@@ -205,0 +205,0 @@ if (actionHandler) |
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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 2 instances in 1 package
170536
3
69
2329
10
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedsemver@7.6.3(transitive)
+ Addedsprotty-protocol@0.11.0(transitive)
+ Addedsprotty-vscode-protocol@0.2.0(transitive)
+ Addedvscode-jsonrpc@6.0.0(transitive)
+ Addedvscode-languageclient@7.0.0(transitive)
+ Addedvscode-languageserver-protocol@3.16.0(transitive)
+ Addedvscode-languageserver-types@3.16.0(transitive)
- Removedvscode-languageserver@^5.2.1
- Removedsemver@5.7.2(transitive)
- Removedsprotty-vscode-protocol@0.0.5(transitive)
- Removedvscode-jsonrpc@4.0.0(transitive)
- Removedvscode-languageclient@5.2.1(transitive)
- Removedvscode-languageserver@5.2.1(transitive)
- Removedvscode-languageserver-protocol@3.14.1(transitive)
- Removedvscode-languageserver-types@3.14.0(transitive)
- Removedvscode-uri@1.0.8(transitive)
Updatedvscode-languageclient@^7.0.0