-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
api-samples: add new command to output api version
The following commit adds a new command to the `api-samples` to output the supported vscode api version for development purposes. The api version is changeable by specifying a cli argument such as: `yarn start --vscode-api-version={version}` Signed-off-by: vince-fugnitto <vincent.fugnitto@ericsson.com>
- Loading branch information
1 parent
36bc609
commit 1b521ea
Showing
4 changed files
with
55 additions
and
1 deletion.
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
48 changes: 48 additions & 0 deletions
48
examples/api-samples/src/browser/vsx/sample-vsx-command-contribution.ts
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,48 @@ | ||
/******************************************************************************** | ||
* Copyright (C) 2020 Ericsson 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 { inject, injectable, interfaces } from 'inversify'; | ||
import { VSXEnvironment } from '@theia/vsx-registry/lib/common/vsx-environment'; | ||
import { Command, CommandContribution, CommandRegistry, MessageService } from '@theia/core/lib/common'; | ||
|
||
@injectable() | ||
export class VSXCommandContribution implements CommandContribution { | ||
|
||
@inject(MessageService) | ||
protected readonly messageService: MessageService; | ||
|
||
@inject(VSXEnvironment) | ||
protected readonly environment: VSXEnvironment; | ||
|
||
protected readonly command: Command = { | ||
id: 'vsx.echo-api-version', | ||
label: 'VS Code API Version' | ||
}; | ||
|
||
registerCommands(commands: CommandRegistry): void { | ||
commands.registerCommand(this.command, { | ||
execute: async () => { | ||
const version = await this.environment.getVscodeApiVersion(); | ||
this.messageService.info(`Supported VS Code API Version: ${version}`); | ||
} | ||
}); | ||
} | ||
|
||
} | ||
|
||
export const bindVSXCommand = (bind: interfaces.Bind) => { | ||
bind(CommandContribution).to(VSXCommandContribution).inSingletonScope(); | ||
}; |