This repository has been archived by the owner on Jun 20, 2018. It is now read-only.
forked from eclipse-theia/theia
-
Notifications
You must be signed in to change notification settings - Fork 0
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,17 @@ | ||
/* | ||
* Copyright (C) 2018 Red Hat, Inc. and others. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
|
||
/** | ||
* Returns `true` if the parameter has type "object" and not null, an array, a regexp, a date. | ||
*/ | ||
export function isObject(obj: any): boolean { | ||
return typeof obj === 'object' | ||
&& obj !== null | ||
&& !Array.isArray(obj) | ||
&& !(obj instanceof RegExp) | ||
&& !(obj instanceof Date); | ||
} |
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
61 changes: 61 additions & 0 deletions
61
packages/plugin-ext/src/main/browser/preference-registry-main.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,61 @@ | ||
/* | ||
* Copyright (C) 2018 Red Hat, Inc. and others. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
|
||
import { | ||
PreferenceService, | ||
PreferenceServiceImpl, | ||
PreferenceScope | ||
} from '@theia/core/lib/browser/preferences'; | ||
import { interfaces } from 'inversify'; | ||
import { | ||
MAIN_RPC_CONTEXT, | ||
PreferenceRegistryExt, | ||
PreferenceRegistryMain, | ||
} from '../../api/plugin-api'; | ||
import { RPCProtocol } from '../../api/rpc-protocol'; | ||
import { ConfigurationTarget } from '../../plugin/types-impl'; | ||
|
||
export class PreferenceRegistryMainImpl implements PreferenceRegistryMain { | ||
private proxy: PreferenceRegistryExt; | ||
private preferenceService: PreferenceService; | ||
|
||
constructor(prc: RPCProtocol, container: interfaces.Container) { | ||
this.proxy = prc.getProxy(MAIN_RPC_CONTEXT.PREFERENCE_REGISTRY_EXT); | ||
this.preferenceService = container.get(PreferenceService); | ||
const preferenceServiceImpl = container.get(PreferenceServiceImpl); | ||
|
||
preferenceServiceImpl.onPreferenceChanged(e => { | ||
this.proxy.$acceptConfigurationChanged(preferenceServiceImpl.getPreferences(), e); | ||
}); | ||
} | ||
|
||
$updateConfigurationOption(target: boolean | ConfigurationTarget | undefined, key: string, value: any): PromiseLike<void> { | ||
const scope = this.parseConfigurationTarget(target); | ||
return this.preferenceService.set(key, value, scope); | ||
} | ||
|
||
$removeConfigurationOption(target: boolean | ConfigurationTarget | undefined, key: string): PromiseLike<void> { | ||
const scope = this.parseConfigurationTarget(target); | ||
return this.preferenceService.set(key, undefined, scope); | ||
} | ||
|
||
private parseConfigurationTarget(arg?: boolean | ConfigurationTarget): PreferenceScope { | ||
if (arg === void 0 || arg === null) { | ||
return PreferenceScope.Workspace; | ||
} | ||
if (typeof arg === 'boolean') { | ||
return arg ? PreferenceScope.User : PreferenceScope.Workspace; | ||
} | ||
|
||
if (arg === ConfigurationTarget.User) { | ||
return PreferenceScope.User; | ||
} else { | ||
return PreferenceScope.Workspace; | ||
} | ||
} | ||
|
||
} |
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 |
---|---|---|
|
@@ -18,6 +18,7 @@ import { WindowStateExtImpl } from './window-state'; | |
import { EnvExtImpl } from './env'; | ||
import { QueryParameters } from '../common/env'; | ||
import { | ||
ConfigurationTarget, | ||
Disposable, | ||
Position, | ||
Range, | ||
|
@@ -39,6 +40,7 @@ import { TextEditorsExtImpl } from './text-editors'; | |
import { DocumentsExtImpl } from './documents'; | ||
import Uri from 'vscode-uri'; | ||
import { TextEditorCursorStyle } from '../common/editor-options'; | ||
import { PreferenceRegistryExtImpl } from './preference-registry'; | ||
|
||
export function createAPI(rpc: RPCProtocol): typeof theia { | ||
const commandRegistryExt = rpc.set(MAIN_RPC_CONTEXT.COMMAND_REGISTRY_EXT, new CommandRegistryImpl(rpc)); | ||
|
@@ -50,6 +52,7 @@ export function createAPI(rpc: RPCProtocol): typeof theia { | |
const documents = rpc.set(MAIN_RPC_CONTEXT.DOCUMENTS_EXT, new DocumentsExtImpl(rpc, editorsAndDocuments)); | ||
const statusBarMessageRegistryExt = new StatusBarMessageRegistryExt(rpc); | ||
const envExt = rpc.set(MAIN_RPC_CONTEXT.ENV_EXT, new EnvExtImpl(rpc)); | ||
const preferenceRegistryExt = rpc.set(MAIN_RPC_CONTEXT.PREFERENCE_REGISTRY_EXT, new PreferenceRegistryExtImpl(rpc)); | ||
|
||
const commands: typeof theia.commands = { | ||
// tslint:disable-next-line:no-any | ||
|
@@ -155,6 +158,12 @@ export function createAPI(rpc: RPCProtocol): typeof theia { | |
onDidOpenTextDocument(listener, thisArg?, disposables?) { | ||
return documents.onDidAddDocument(listener, thisArg, disposables); | ||
}, | ||
getConfiguration(section?, resource?): theia.WorkspaceConfiguration { | ||
return preferenceRegistryExt.getConfiguration(section, resource); | ||
}, | ||
onDidChangeConfiguration(listener, thisArgs?, disposables?): theia.Disposable { | ||
return preferenceRegistryExt.onDidChangeConfiguration(listener, thisArgs, disposables); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is update method? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok |
||
}; | ||
|
||
const env: typeof theia.env = { | ||
|
@@ -194,6 +203,7 @@ export function createAPI(rpc: RPCProtocol): typeof theia { | |
SnippetString, | ||
DecorationRangeBehavior, | ||
OverviewRulerLane, | ||
ConfigurationTarget, | ||
}; | ||
|
||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK it was me that added it with a wrong name :o