From ae02023454f561b8de6e5bb575015c2218787f34 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Mon, 15 Mar 2021 14:27:37 -0700 Subject: [PATCH] fix(lib/vscode): register LogLevelChannel --- lib/vscode/src/vs/base/node/languagePacks.js | 44 ------------------- lib/vscode/src/vs/server/node/channel.ts | 7 ++- lib/vscode/src/vs/server/node/server.ts | 16 ++++--- .../electron-sandbox/localizationsService.ts | 14 ++++-- 4 files changed, 28 insertions(+), 53 deletions(-) diff --git a/lib/vscode/src/vs/base/node/languagePacks.js b/lib/vscode/src/vs/base/node/languagePacks.js index 2cc50d965..0899cab4e 100644 --- a/lib/vscode/src/vs/base/node/languagePacks.js +++ b/lib/vscode/src/vs/base/node/languagePacks.js @@ -71,50 +71,6 @@ * @returns {object} */ function getLanguagePackConfigurations(userDataPath) { - const configFile = path.join(userDataPath, 'languagepacks.json'); - try { - return nodeRequire(configFile); - } catch (err) { - // Do nothing. If we can't read the file we have no - // language pack config. - } - } - - function readFile(file) { - return new Promise(function (resolve, reject) { - fs.readFile(file, 'utf8', function (err, data) { - if (err) { - reject(err); - return; - } - resolve(data); - }); - }); - } - - /** - * @param {string} file - * @param {string} content - * @returns {Promise} - */ - function writeFile(file, content) { - return new Promise(function (resolve, reject) { - fs.writeFile(file, content, 'utf8', function (err) { - if (err) { - reject(err); - return; - } - resolve(); - }); - }); - } - - - /** - * @param {string} userDataPath - * @returns {object} - */ - function getLanguagePackConfigurations(userDataPath) { const configFile = path.join(userDataPath, 'languagepacks.json'); try { // NOTE@coder: Swapped require with readFile since require is cached and diff --git a/lib/vscode/src/vs/server/node/channel.ts b/lib/vscode/src/vs/server/node/channel.ts index 3ba30dba6..639f077c4 100644 --- a/lib/vscode/src/vs/server/node/channel.ts +++ b/lib/vscode/src/vs/server/node/channel.ts @@ -330,6 +330,11 @@ export class ExtensionEnvironmentChannel implements IServerChannel { } } +/* + NOTE@coder: + Reference: - ../../workbench/api/common/extHostDebugService.ts + 3/16/21 jsjoeio +*/ class VariableResolverService extends AbstractVariableResolverService { constructor( remoteAuthority: string, @@ -355,7 +360,7 @@ class VariableResolverService extends AbstractVariableResolverService { NOTE@coder: not sure where we could get this from. This is new. @jsjoeio 3/11/21 */ - return undefined; + return (args.resolverEnv && args.resolverEnv['VSCODE_CWD']) || env['VSCODE_CWD'] || process.cwd(); }, getExecPath: (): string | undefined => { // Assuming that resolverEnv is just for use in the resolver and not for diff --git a/lib/vscode/src/vs/server/node/server.ts b/lib/vscode/src/vs/server/node/server.ts index de187b006..b1a278388 100644 --- a/lib/vscode/src/vs/server/node/server.ts +++ b/lib/vscode/src/vs/server/node/server.ts @@ -29,7 +29,7 @@ import { ServiceCollection } from 'vs/platform/instantiation/common/serviceColle import { ILocalizationsService } from 'vs/platform/localizations/common/localizations'; import { LocalizationsService } from 'vs/platform/localizations/node/localizations'; import { ConsoleLogger, getLogLevel, ILoggerService, ILogService, MultiplexLogService } from 'vs/platform/log/common/log'; -import { LoggerChannel } from 'vs/platform/log/common/logIpc'; +import { LogLevelChannel } from 'vs/platform/log/common/logIpc'; import { LoggerService } from 'vs/platform/log/node/loggerService'; import { SpdLogLogger } from 'vs/platform/log/node/spdlogLog'; import product from 'vs/platform/product/common/product'; @@ -214,7 +214,7 @@ export class Vscode { private async initializeServices(args: NativeParsedArgs): Promise { /* NOTE@coder: this initializeServices is loosely based off this file: - https://github.com/cdr/code-server/blob/main/lib/vscode/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts#L148 + Reference: - ../../electron-browser/sharedProcess/sharedProcessMain.ts#L148 If upstream changes cause conflicts, look there ^. 3/11/21 @jsjoeio @@ -224,7 +224,7 @@ export class Vscode { fs.mkdirSync(environmentService.globalStorageHome.fsPath, { recursive: true }); /* NOTE@coder: Made these updates on based on this file (and lines): - https://github.com/cdr/code-server/blob/main/lib/vscode/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts#L144-L149 + Reference: - ../../electron-browser/sharedProcess/sharedProcessMain.ts#L144-L149 More details (from @code-asher): I think the logLevel channel is only used in the electron version of vscode so we can probably skip it. @@ -234,7 +234,7 @@ export class Vscode { */ const logService = new MultiplexLogService([ new ConsoleLogger(getLogLevel(environmentService)), - new SpdLogLogger(RemoteExtensionLogFileName, path.join(environmentService.logsPath, 'server.log'), false, getLogLevel(environmentService)) + new SpdLogLogger(RemoteExtensionLogFileName, path.join(environmentService.logsPath, `${RemoteExtensionLogFileName}.log`), false, getLogLevel(environmentService)) ]); const fileService = new FileService(logService); fileService.registerProvider(Schemas.file, new DiskFileSystemProvider(logService)); @@ -250,7 +250,13 @@ export class Vscode { ...environmentService.extraBuiltinExtensionPaths, ]; - this.ipc.registerChannel('logger', new LoggerChannel(loggerService)); + /* + NOTE@coder: we changed this channel registration from LogLevel to LogLevelChannel + because it changed upstream. + + 3/15/21 jsjoeio + */ + this.ipc.registerChannel('logger', new LogLevelChannel(logService)); this.ipc.registerChannel(ExtensionHostDebugBroadcastChannel.ChannelName, new ExtensionHostDebugBroadcastChannel()); this.services.set(ILogService, logService); diff --git a/lib/vscode/src/vs/workbench/services/localizations/electron-sandbox/localizationsService.ts b/lib/vscode/src/vs/workbench/services/localizations/electron-sandbox/localizationsService.ts index 7c59c49ee..38c8ebcf8 100644 --- a/lib/vscode/src/vs/workbench/services/localizations/electron-sandbox/localizationsService.ts +++ b/lib/vscode/src/vs/workbench/services/localizations/electron-sandbox/localizationsService.ts @@ -5,8 +5,8 @@ import { ProxyChannel } from 'vs/base/parts/ipc/common/ipc'; import { ILocalizationsService } from 'vs/platform/localizations/common/localizations'; -import { ISharedProcessService } from 'vs/platform/ipc/electron-sandbox/services'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; +import { IRemoteAgentService } from '../../remote/common/remoteAgentService'; // @ts-ignore: interface is implemented via proxy export class LocalizationsService implements ILocalizationsService { @@ -14,9 +14,17 @@ export class LocalizationsService implements ILocalizationsService { declare readonly _serviceBrand: undefined; constructor( - @ISharedProcessService sharedProcessService: ISharedProcessService, + @IRemoteAgentService remoteAgentService: IRemoteAgentService, ) { - return ProxyChannel.toService(sharedProcessService.getChannel('localizations')); + /* + NOTE@coder: + Upstream, they use the ISharedProcessService. + + We run this on the browser where there is no shared process so it needs to connect + to the localization channel through the remote agent. + 3/16/21 jsjoeio code-asher + */ + return ProxyChannel.toService(remoteAgentService.getConnection()!.getChannel('localizations')); } }