Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Expose actions registry in IDE API #701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/ide-api/api.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// tslint:disable no-any

import { ITerminalService } from "vs/workbench/contrib/terminal/common/terminal";
import { IWorkbenchActionRegistry } from 'vs/workbench/common/actions';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Importing from here won't work right?

It will within the project, but importing inside another would leave these unresolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those files aren't included in the ide-api package so anything that imports it won't be able to resolve those types (only applies if you're using TypeScript of course). We'll want to fully encapsulate the API within the typings file before publishing a new version of the API.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just use the vscode typings? Why are we wrapping?

Copy link
Member

@code-asher code-asher May 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd have to include VS Code's code with the ide-api package. Since the files we import may import other files, it'd probably be easiest to just import all of VS Code, but it feels odd (to me) to include the entirety of VS Code just for the types.

The way VS Code does it is to have an entirely separate typings file like we're doing here and redefine all the types. Actually maybe we can just import their typings file and re-export some things from it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@code-asher code-asher May 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually that wouldn't work because that doesn't include types for their internal methods, just what they expose to extensions.

import { Action } from 'vs/base/common/actions';
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';

export interface EvalHelper { }
interface ActiveEvalEmitter {
Expand Down Expand Up @@ -146,7 +149,10 @@ declare namespace ide {
export const client: {};

export const workbench: {
readonly action: Action,
readonly syncActionDescriptor: SyncActionDescriptor,
readonly statusbarService: IStatusbarService;
readonly actionsRegistry: IWorkbenchActionRegistry;
readonly notificationService: INotificationService;
readonly storageService: IStorageService;
readonly menuRegistry: IMenuRegistry;
Expand Down
15 changes: 10 additions & 5 deletions packages/vscode/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ import { IStatusbarService, StatusbarAlignment } from "vs/platform/statusbar/com
import * as paths from "./fill/paths";
import product from "./fill/product";
import "./vscode.scss";
import { MenuId, MenuRegistry } from "vs/platform/actions/common/actions";
import { Action } from 'vs/base/common/actions';
import { SyncActionDescriptor, MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
import { Registry } from 'vs/platform/registry/common/platform';
import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actions';
import { CommandsRegistry } from "vs/platform/commands/common/commands";
import { IFileService, FileOperation } from "vs/platform/files/common/files";
import { ITextFileService } from "vs/workbench/services/textfile/common/textfiles";
import { IModelService } from "vs/editor/common/services/modelService";
import { ITerminalService } from "vs/workbench/contrib/terminal/common/terminal";
import { IStorageService } from "vs/platform/storage/common/storage";

// NOTE: shouldn't import anything from VS Code here or anything that will
// depend on a synchronous fill like `os`.

Expand All @@ -33,11 +37,12 @@ class VSClient extends IdeClient {
window.ide = {
client: ideClientInstance,
workbench: {
action: Action,
syncActionDescriptor: SyncActionDescriptor,
commandRegistry: CommandsRegistry,
// tslint:disable-next-line:no-any
menuRegistry: MenuRegistry as any,
// tslint:disable-next-line:no-any
statusbarService: getService<IStatusbarService>(IStatusbarService) as any,
actionsRegistry: Registry.as<IWorkbenchActionRegistry>(Extensions.WorkbenchActions),
menuRegistry: MenuRegistry,
statusbarService: getService<IStatusbarService>(IStatusbarService),
notificationService: getService<INotificationService>(INotificationService),
terminalService: getService<ITerminalService>(ITerminalService),
storageService: {
Expand Down