Skip to content

Commit

Permalink
launch preferences support
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
  • Loading branch information
akosyakov committed Apr 23, 2019
1 parent 90937c3 commit 60ec59d
Show file tree
Hide file tree
Showing 45 changed files with 1,757 additions and 1,313 deletions.
14 changes: 0 additions & 14 deletions .theia/settings.json

This file was deleted.

263 changes: 132 additions & 131 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,133 +1,134 @@
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach by Process ID",
"processId": "${command:PickProcess}"
},
{
"type": "node",
"request": "launch",
"name": "Launch with Node.js",
"program": "${file}"
},
{
"type": "node",
"request": "launch",
"name": "Launch Electron Backend",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
"windows": {
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
},
"program": "${workspaceRoot}/examples/electron/src-gen/frontend/electron-main.js",
"protocol": "inspector",
"args": [
"--log-level=debug",
"--hostname=localhost",
"--no-cluster",
"--app-project-path=${workspaceRoot}/examples/electron",
"--no-app-auto-install"
],
"env": {
"NODE_ENV": "development"
},
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/examples/electron/src-gen/frontend/electron-main.js",
"${workspaceRoot}/examples/electron/src-gen/backend/main.js",
"${workspaceRoot}/examples/electron/lib/**/*.js",
"${workspaceRoot}/packages/*/lib/**/*.js",
"${workspaceRoot}/dev-packages/*/lib/**/*.js"
],
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
},
{
"type": "node",
"request": "launch",
"name": "Launch Backend",
"program": "${workspaceRoot}/examples/browser/src-gen/backend/main.js",
"args": [
"--hostname=0.0.0.0",
"--port=3000",
"--no-cluster",
"--app-project-path=${workspaceRoot}/examples/browser",
"--no-app-auto-install",
"--plugins=local-dir:plugins"
],
"env": {
"NODE_ENV": "development"
},
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/examples/browser/src-gen/backend/*.js",
"${workspaceRoot}/examples/browser/lib/**/*.js",
"${workspaceRoot}/packages/*/lib/**/*.js",
"${workspaceRoot}/dev-packages/*/lib/**/*.js"
],
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
},
{
"type": "node",
"request": "launch",
"name": "Launch Backend (eclipse.jdt.ls)",
"program": "${workspaceRoot}/examples/browser/src-gen/backend/main.js",
"args": [
"--log-level=debug",
"--root-dir=${workspaceRoot}/../eclipse.jdt.ls/org.eclipse.jdt.ls.core",
"--port=3000",
"--no-cluster",
"--no-app-auto-install"
],
"env": {
"NODE_ENV": "development"
},
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/examples/browser/src-gen/backend/*.js",
"${workspaceRoot}/examples/browser/lib/**/*.js",
"${workspaceRoot}/packages/*/lib/**/*.js",
"${workspaceRoot}/dev-packages/*/lib/**/*.js"
],
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
},
{
"type": "node",
"request": "launch",
"protocol": "inspector",
"name": "Run Mocha Test",
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
"args": [
"--no-timeouts",
"--colors",
"--opts",
"${workspaceRoot}/configs/mocha.opts",
"**/${fileBasenameNoExtension}.js"
],
"env": {
"TS_NODE_PROJECT": "${workspaceRoot}/tsconfig.json"
},
"sourceMaps": true,
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
},
{
"name": "Launch Frontend",
"type": "chrome",
"request": "launch",
"url": "http://localhost:3000/",
"webRoot": "${workspaceRoot}"
}
]
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach by Process ID",
"processId": "${command:PickProcess}"
},
{
"type": "node",
"request": "launch",
"name": "Launch with Node.js",
"program": "${file}"
},
{
"type": "node",
"request": "launch",
"name": "Launch Electron Backend",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
"windows": {
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
},
"program": "${workspaceRoot}/examples/electron/src-gen/frontend/electron-main.js",
"protocol": "inspector",
"args": [
"--log-level=debug",
"--hostname=localhost",
"--no-cluster",
"--app-project-path=${workspaceRoot}/examples/electron",
"--no-app-auto-install"
],
"env": {
"NODE_ENV": "development"
},
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/examples/electron/src-gen/frontend/electron-main.js",
"${workspaceRoot}/examples/electron/src-gen/backend/main.js",
"${workspaceRoot}/examples/electron/lib/**/*.js",
"${workspaceRoot}/packages/*/lib/**/*.js",
"${workspaceRoot}/dev-packages/*/lib/**/*.js"
],
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
},
{
"type": "node",
"request": "launch",
"name": "Launch Backend",
"program": "${workspaceRoot}/examples/browser/src-gen/backend/main.js",
"args": [
"--hostname=0.0.0.0",
"--port=3000",
"--no-cluster",
"--app-project-path=${workspaceRoot}/examples/browser",
"--no-app-auto-install",
"--plugins=local-dir:plugins"
],
"env": {
"NODE_ENV": "development"
},
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/examples/browser/src-gen/backend/*.js",
"${workspaceRoot}/examples/browser/lib/**/*.js",
"${workspaceRoot}/packages/*/lib/**/*.js",
"${workspaceRoot}/dev-packages/*/lib/**/*.js"
],
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
},
{
"type": "node",
"request": "launch",
"name": "Launch Backend (eclipse.jdt.ls)",
"program": "${workspaceRoot}/examples/browser/src-gen/backend/main.js",
"args": [
"--log-level=debug",
"--root-dir=${workspaceRoot}/../eclipse.jdt.ls/org.eclipse.jdt.ls.core",
"--port=3000",
"--no-cluster",
"--no-app-auto-install"
],
"env": {
"NODE_ENV": "development"
},
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/examples/browser/src-gen/backend/*.js",
"${workspaceRoot}/examples/browser/lib/**/*.js",
"${workspaceRoot}/packages/*/lib/**/*.js",
"${workspaceRoot}/dev-packages/*/lib/**/*.js"
],
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
},
{
"type": "node",
"request": "launch",
"protocol": "inspector",
"name": "Run Mocha Test",
"runtimeVersion": "10.15.3",
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
"args": [
"--no-timeouts",
"--colors",
"--opts",
"${workspaceRoot}/configs/mocha.opts",
"**/${fileBasenameNoExtension}.js"
],
"env": {
"TS_NODE_PROJECT": "${workspaceRoot}/tsconfig.json"
},
"sourceMaps": true,
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
},
{
"name": "Launch Frontend",
"type": "chrome",
"request": "launch",
"url": "http://localhost:3000/",
"webRoot": "${workspaceRoot}"
}
]
}
52 changes: 31 additions & 21 deletions packages/core/src/browser/frontend-application-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import '../../src/browser/style/index.css';
import 'font-awesome/css/font-awesome.min.css';
import 'file-icons-js/css/style.css';

import { ContainerModule } from 'inversify';
import { ContainerModule, interfaces } from 'inversify';
import {
bindContributionProvider,
SelectionService,
Expand Down Expand Up @@ -123,11 +123,7 @@ export const frontendApplicationModule = new ContainerModule((bind, unbind, isBo
bind(ShellLayoutRestorer).toSelf().inSingletonScope();
bind(CommandContribution).toService(ShellLayoutRestorer);

bind(DefaultResourceProvider).toSelf().inSingletonScope();
bind(ResourceProvider).toProvider(context =>
uri => context.container.get(DefaultResourceProvider).get(uri)
);
bindContributionProvider(bind, ResourceResolver);
bindResourceProvider(bind);
bind(InMemoryResources).toSelf().inSingletonScope();
bind(ResourceResolver).toService(InMemoryResources);

Expand All @@ -150,8 +146,7 @@ export const frontendApplicationModule = new ContainerModule((bind, unbind, isBo
bindContributionProvider(bind, KeybindingContext);
bindContributionProvider(bind, KeybindingContribution);

bind(MessageClient).toSelf().inSingletonScope();
bind(MessageService).toSelf().inSingletonScope().onActivation(({ container }, messages) => {
bindMessageService(bind).onActivation(({ container }, messages) => {
const client = container.get(MessageClient);
WebSocketConnectionProvider.createProxy(container, messageServicePath, client);
return messages;
Expand Down Expand Up @@ -197,19 +192,8 @@ export const frontendApplicationModule = new ContainerModule((bind, unbind, isBo
bind(LabelProviderContribution).to(DefaultUriLabelProviderContribution).inSingletonScope();
bind(LabelProviderContribution).to(DiffUriLabelProviderContribution).inSingletonScope();

bind(PreferenceProvider).toSelf().inSingletonScope().whenTargetNamed(PreferenceScope.User);
bind(PreferenceProvider).toSelf().inSingletonScope().whenTargetNamed(PreferenceScope.Workspace);
bind(PreferenceProvider).toSelf().inSingletonScope().whenTargetNamed(PreferenceScope.Folder);
bind(PreferenceProviderProvider).toFactory(ctx => (scope: PreferenceScope) => {
if (scope === PreferenceScope.Default) {
return ctx.container.get(PreferenceSchemaProvider);
}
return ctx.container.getNamed(PreferenceProvider, scope);
});
bind(PreferenceServiceImpl).toSelf().inSingletonScope();
bind(PreferenceService).toService(PreferenceServiceImpl);
bind(FrontendApplicationContribution).toService(PreferenceServiceImpl);
bindPreferenceSchemaProvider(bind);
bindPreferenceService(bind);
bind(FrontendApplicationContribution).toService(PreferenceService);

bind(JsonSchemaStore).toSelf().inSingletonScope();

Expand Down Expand Up @@ -250,3 +234,29 @@ export const frontendApplicationModule = new ContainerModule((bind, unbind, isBo

bindCorePreferences(bind);
});

export function bindMessageService(bind: interfaces.Bind): interfaces.BindingWhenOnSyntax<MessageService> {
bind(MessageClient).toSelf().inSingletonScope();
return bind(MessageService).toSelf().inSingletonScope();
}

export function bindPreferenceService(bind: interfaces.Bind): void {
bind(PreferenceProvider).toSelf().inSingletonScope().whenTargetNamed(PreferenceScope.User);
bind(PreferenceProvider).toSelf().inSingletonScope().whenTargetNamed(PreferenceScope.Workspace);
bind(PreferenceProvider).toSelf().inSingletonScope().whenTargetNamed(PreferenceScope.Folder);
bind(PreferenceProviderProvider).toFactory(ctx => (scope: PreferenceScope) => {
if (scope === PreferenceScope.Default) {
return ctx.container.get(PreferenceSchemaProvider);
}
return ctx.container.getNamed(PreferenceProvider, scope);
});
bind(PreferenceServiceImpl).toSelf().inSingletonScope();
bind(PreferenceService).toService(PreferenceServiceImpl);
bindPreferenceSchemaProvider(bind);
}

export function bindResourceProvider(bind: interfaces.Bind) {
bind(DefaultResourceProvider).toSelf().inSingletonScope();
bind(ResourceProvider).toProvider(context => uri => context.container.get(DefaultResourceProvider).get(uri));
bindContributionProvider(bind, ResourceResolver);
}
Loading

0 comments on commit 60ec59d

Please sign in to comment.