-
-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for CodeActions triggering commands provided by the langu…
…age server Signed-off-by: Nicholas Gates <ngates@palantir.com>
- Loading branch information
Showing
10 changed files
with
173 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2017 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
import { Commands, Disposable } from 'vscode-base-languageclient/lib/services'; | ||
|
||
export class MonacoCommands implements Commands { | ||
|
||
public constructor(protected readonly editor: monaco.editor.IStandaloneCodeEditor) { } | ||
|
||
public registerCommand(command: string, callback: (...args: any[]) => any, thisArg?: any): Disposable { | ||
return this.editor._commandService.addCommand(command, { | ||
handler: (_accessor, ...args: any[]) => callback(...args) | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/// <reference path='../../node_modules/monaco-editor-core/monaco.d.ts'/> | ||
|
||
declare module monaco.editor { | ||
export interface IStandaloneCodeEditor { | ||
readonly _commandService: monaco.services.StandaloneCommandService; | ||
} | ||
} | ||
|
||
declare module monaco.commands { | ||
|
||
export interface ICommandEvent { | ||
commandId: string; | ||
} | ||
|
||
export interface ICommandService { | ||
onWillExecuteCommand: monaco.IEvent<ICommandEvent>; | ||
executeCommand<T>(commandId: string, ...args: any[]): monaco.Promise<T>; | ||
executeCommand(commandId: string, ...args: any[]): monaco.Promise<any>; | ||
} | ||
|
||
export interface ICommandHandler { | ||
(accessor: monaco.instantiation.ServicesAccessor, ...args: any[]): void; | ||
} | ||
|
||
export interface ICommand { | ||
handler: ICommandHandler; | ||
} | ||
} | ||
|
||
declare module monaco.instantiation { | ||
export interface ServiceIdentifier<T> { | ||
(...args: any[]): void; | ||
type: T; | ||
} | ||
export interface ServicesAccessor { | ||
get<T>(id: ServiceIdentifier<T>, isOptional?: typeof optional): T; | ||
} | ||
export interface IInstantiationService { | ||
} | ||
export function optional<T>(serviceIdentifier: ServiceIdentifier<T>): (target: Function, key: string, index: number) => void; | ||
} | ||
|
||
declare module monaco.services { | ||
export class StandaloneCommandService implements monaco.commands.ICommandService { | ||
constructor(instantiationService: monaco.instantiation.IInstantiationService); | ||
addCommand(id: string, command: monaco.commands.ICommand): IDisposable; | ||
onWillExecuteCommand: monaco.IEvent<monaco.commands.ICommandEvent>; | ||
executeCommand<T>(commandId: string, ...args: any[]): monaco.Promise<T>; | ||
executeCommand(commandId: string, ...args: any[]): monaco.Promise<any>; | ||
} | ||
} |