Skip to content

Commit

Permalink
Fix vscode.env.appRoot path
Browse files Browse the repository at this point in the history
  • Loading branch information
msujew committed Jan 18, 2024
1 parent eb8148b commit 7034ea5
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 13 deletions.
1 change: 1 addition & 0 deletions packages/core/src/common/application-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ export interface ExtensionInfo {
export interface ApplicationInfo {
name: string;
version: string;
appRoot: string;
}
6 changes: 5 additions & 1 deletion packages/core/src/node/application-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ export class ApplicationServerImpl implements ApplicationServer {
const name = pck.name;
const version = pck.version;

return Promise.resolve({ name, version });
return Promise.resolve({
name,
version,
appRoot: this.applicationPackage.projectPath
});
}
return Promise.resolve(undefined);
}
Expand Down
3 changes: 2 additions & 1 deletion packages/plugin-ext/src/common/plugin-api-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,10 @@ export interface EnvInit {
queryParams: QueryParameters;
language: string;
shell: string;
uiKind: UIKind,
uiKind: UIKind;
appName: string;
appHost: string;
appRoot: string;
}

export interface PluginAPI {
Expand Down
12 changes: 10 additions & 2 deletions packages/plugin-ext/src/hosted/browser/hosted-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ import { Measurement, Stopwatch } from '@theia/core/lib/common';
import { Uint8ArrayReadBuffer, Uint8ArrayWriteBuffer } from '@theia/core/lib/common/message-rpc/uint8-array-message-buffer';
import { BasicChannel } from '@theia/core/lib/common/message-rpc/channel';
import { NotebookTypeRegistry, NotebookService, NotebookRendererMessagingService } from '@theia/notebook/lib/browser';
import { ApplicationServer } from '@theia/core/lib/common/application-protocol';

export type PluginHost = 'frontend' | string;
export type DebugActivationEvent = 'onDebugResolve' | 'onDebugInitialConfigurations' | 'onDebugAdapterProtocolTracker' | 'onDebugDynamicConfigurations';
Expand Down Expand Up @@ -199,6 +200,9 @@ export class HostedPluginSupport {
@inject(PluginCustomEditorRegistry)
protected readonly customEditorRegistry: PluginCustomEditorRegistry;

@inject(ApplicationServer)
protected readonly applicationServer: ApplicationServer;

@inject(Stopwatch)
protected readonly stopwatch: Stopwatch;

Expand Down Expand Up @@ -557,7 +561,10 @@ export class HostedPluginSupport {
const isElectron = environment.electron.is();

const supportedActivationEvents = [...HostedPluginSupport.BUILTIN_ACTIVATION_EVENTS];
const additionalActivationEvents = await this.envServer.getValue(HostedPluginSupport.ADDITIONAL_ACTIVATION_EVENTS_ENV);
const [additionalActivationEvents, appInfo] = await Promise.all([
this.envServer.getValue(HostedPluginSupport.ADDITIONAL_ACTIVATION_EVENTS_ENV),
this.applicationServer.getApplicationInfo()
]);
if (additionalActivationEvents && additionalActivationEvents.value) {
additionalActivationEvents.value.split(',').forEach(event => supportedActivationEvents.push(event));
}
Expand All @@ -572,7 +579,8 @@ export class HostedPluginSupport {
shell: defaultShell,
uiKind: isElectron ? UIKind.Desktop : UIKind.Web,
appName: FrontendApplicationConfigProvider.get().applicationName,
appHost: isElectron ? 'desktop' : 'web' // TODO: 'web' could be the embedder's name, e.g. 'github.dev'
appHost: isElectron ? 'desktop' : 'web', // TODO: 'web' could be the embedder's name, e.g. 'github.dev'
appRoot: appInfo?.appRoot ?? ''
},
extApi,
webview: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class WorkerEnvExtImpl extends EnvExtImpl {
/**
* Throw error for app-root as there is no filesystem in worker context
*/
get appRoot(): string {
override get appRoot(): string {
throw new Error('There is no app root in worker context');
}

Expand Down
9 changes: 8 additions & 1 deletion packages/plugin-ext/src/plugin/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export abstract class EnvExtImpl {
private envMachineId: string;
private envSessionId: string;
private host: string;
private applicationRoot: string;
private _remoteName: string | undefined;

constructor(rpc: RPCProtocol) {
Expand Down Expand Up @@ -75,6 +76,10 @@ export abstract class EnvExtImpl {
this.host = appHost;
}

setAppRoot(appRoot: string): void {
this.applicationRoot = appRoot;
}

getClientOperatingSystem(): Promise<theia.OperatingSystem> {
return this.proxy.$getClientOperatingSystem();
}
Expand All @@ -83,7 +88,9 @@ export abstract class EnvExtImpl {
return this.applicationName;
}

abstract get appRoot(): string;
get appRoot(): string {
return this.applicationRoot;
}

abstract get isNewAppInstall(): boolean;

Expand Down
7 changes: 0 additions & 7 deletions packages/plugin-ext/src/plugin/node/env-node-ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@ export class EnvNodeExtImpl extends EnvExtImpl {
return this.macMachineId;
}

/**
* Provides application root.
*/
get appRoot(): string {
return __dirname;
}

get isNewAppInstall(): boolean {
return this._isNewAppInstall;
}
Expand Down
1 change: 1 addition & 0 deletions packages/plugin-ext/src/plugin/plugin-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ export class PluginManagerExtImpl implements PluginManagerExt, PluginManager {
this.envExt.setUIKind(params.env.uiKind);
this.envExt.setApplicationName(params.env.appName);
this.envExt.setAppHost(params.env.appHost);
this.envExt.setAppRoot(params.env.appRoot);

this.preferencesManager.init(params.preferences);

Expand Down

0 comments on commit 7034ea5

Please sign in to comment.