Skip to content

Commit

Permalink
api-samples: add new command to output api version
Browse files Browse the repository at this point in the history
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
vince-fugnitto committed Jan 6, 2021
1 parent 36bc609 commit 1b521ea
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1 deletion.
3 changes: 3 additions & 0 deletions examples/api-samples/compile.tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
},
{
"path": "../../packages/output/compile.tsconfig.json"
},
{
"path": "../../packages/vsx-registry/compile.tsconfig.json"
}
]
}
3 changes: 2 additions & 1 deletion examples/api-samples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"description": "Theia - Example code to demonstrate Theia API",
"dependencies": {
"@theia/core": "^1.9.0",
"@theia/output": "^1.9.0"
"@theia/output": "^1.9.0",
"@theia/vsx-registry": "^1.9.0"
},
"theiaExtensions": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { bindSampleUnclosableView } from './view/sample-unclosable-view-contribu
import { bindSampleOutputChannelWithSeverity } from './output/sample-output-channel-with-severity';
import { bindSampleMenu } from './menu/sample-menu-contribution';
import { bindSampleFileWatching } from './file-watching/sample-file-watching-contribution';
import { bindVSXCommand } from './vsx/sample-vsx-command-contribution';

import '../../src/browser/style/branding.css';

Expand All @@ -29,4 +30,5 @@ export default new ContainerModule(bind => {
bindSampleOutputChannelWithSeverity(bind);
bindSampleMenu(bind);
bindSampleFileWatching(bind);
bindVSXCommand(bind);
});
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();
};

0 comments on commit 1b521ea

Please sign in to comment.