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 Oct 6, 2020
1 parent 55a1109 commit 3ee4e3a
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.6.0",
"@theia/output": "^1.6.0"
"@theia/output": "^1.6.0",
"@theia/vsx-registry": "^1.6.0"
},
"theiaExtensions": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { bindDynamicLabelProvider } from './label/sample-dynamic-label-provider-
import { bindSampleUnclosableView } from './view/sample-unclosable-view-contribution';
import { bindSampleOutputChannelWithSeverity } from './output/sample-output-channel-with-severity';
import { bindSampleMenu } from './menu/sample-menu-contribution';
import { bindVSXCommand } from './vsx/sample-vsx-command-contribution';

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

Expand All @@ -27,4 +28,5 @@ export default new ContainerModule(bind => {
bindSampleUnclosableView(bind);
bindSampleOutputChannelWithSeverity(bind);
bindSampleMenu(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 3ee4e3a

Please sign in to comment.