-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add OpenRPC method for evaluating a
when
clause
- Loading branch information
1 parent
9d85804
commit 8947e98
Showing
9 changed files
with
135 additions
and
2 deletions.
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
31 changes: 31 additions & 0 deletions
31
src/vs/workbench/api/browser/positron/mainThreadContextKeyService.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,31 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (C) 2024 Posit Software, PBC. All rights reserved. | ||
* Licensed under the Elastic License 2.0. See LICENSE.txt for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { extHostNamedCustomer, IExtHostContext } from 'vs/workbench/services/extensions/common/extHostCustomers'; | ||
import { MainPositronContext, MainThreadContextKeyServiceShape } from '../../common/positron/extHost.positron.protocol'; | ||
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; | ||
import { DisposableStore } from 'vs/base/common/lifecycle'; | ||
|
||
@extHostNamedCustomer(MainPositronContext.MainThreadContextKeyService) | ||
export class MainThreadContextKeyService implements MainThreadContextKeyServiceShape { | ||
|
||
private readonly _disposables = new DisposableStore(); | ||
|
||
constructor( | ||
extHostContext: IExtHostContext, | ||
@IContextKeyService private readonly contextKeyService: IContextKeyService | ||
) { | ||
} | ||
|
||
$evaluateWhenClause(whenClause: string): Promise<boolean> { | ||
const precondition = ContextKeyExpr.deserialize(whenClause); | ||
return Promise.resolve(this.contextKeyService.contextMatchesRules(precondition)); | ||
} | ||
|
||
public dispose(): void { | ||
this._disposables.dispose(); | ||
} | ||
|
||
} |
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
29 changes: 29 additions & 0 deletions
29
src/vs/workbench/api/common/positron/extHostContextKeyService.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,29 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (C) 2024 Posit Software, PBC. All rights reserved. | ||
* Licensed under the Elastic License 2.0. See LICENSE.txt for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import * as extHostProtocol from './extHost.positron.protocol'; | ||
|
||
export class ExtHostContextKeyService implements extHostProtocol.ExtHostContextKeyServiceShape { | ||
|
||
private readonly _proxy: extHostProtocol.MainThreadContextKeyServiceShape; | ||
|
||
constructor( | ||
mainContext: extHostProtocol.IMainPositronContext, | ||
) { | ||
// Trigger creation of the proxy | ||
this._proxy = mainContext.getProxy(extHostProtocol.MainPositronContext.MainThreadContextKeyService); | ||
} | ||
|
||
/** | ||
* Queries the main thread with a `when` clause. | ||
* | ||
* @returns If the `when` clause evaluates to true or false. | ||
*/ | ||
public evaluateWhenClause(whenClause: string): Promise<boolean> { | ||
return this._proxy.$evaluateWhenClause(whenClause); | ||
} | ||
|
||
} | ||
|
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