Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debt - use product service in more places #135651

Merged
merged 1 commit into from Oct 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -19,7 +19,7 @@ import {
import { areSameExtensions, ExtensionIdentifierWithVersion, getGalleryExtensionTelemetryData, getLocalExtensionTelemetryData, getMaliciousExtensionsSet } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { ExtensionType, IExtensionManifest } from 'vs/platform/extensions/common/extensions';
import { ILogService } from 'vs/platform/log/common/log';
import product from 'vs/platform/product/common/product';
import { IProductService } from 'vs/platform/product/common/productService';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';

export const INSTALL_ERROR_VALIDATING = 'validating';
Expand Down Expand Up @@ -71,6 +71,7 @@ export abstract class AbstractExtensionManagementService extends Disposable impl
@IExtensionGalleryService protected readonly galleryService: IExtensionGalleryService,
@ITelemetryService protected readonly telemetryService: ITelemetryService,
@ILogService protected readonly logService: ILogService,
@IProductService protected readonly productService: IProductService
) {
super();
this._register(toDisposable(() => {
Expand All @@ -93,7 +94,7 @@ export abstract class AbstractExtensionManagementService extends Disposable impl

if (!await this.canInstall(extension)) {
const targetPlatform = await this.getTargetPlatform();
const error = new ExtensionManagementError(nls.localize('incompatible platform', "The '{0}' extension is not available in {1} for {2}.", extension.identifier.id, product.nameLong, TargetPlatformToString(targetPlatform)), INSTALL_ERROR_VALIDATING);
const error = new ExtensionManagementError(nls.localize('incompatible platform', "The '{0}' extension is not available in {1} for {2}.", extension.identifier.id, this.productService.nameLong, TargetPlatformToString(targetPlatform)), INSTALL_ERROR_VALIDATING);
this.logService.error(`Cannot install extension.`, extension.identifier.id, error.message);
reportTelemetry(this.telemetryService, 'extensionGallery:install', getGalleryExtensionTelemetryData(extension), undefined, error);
throw error;
Expand Down Expand Up @@ -389,7 +390,7 @@ export abstract class AbstractExtensionManagementService extends Disposable impl

const compatibleExtension = await this.getCompatibleVersion(extension, fetchCompatibleVersion);
if (!compatibleExtension) {
throw new ExtensionManagementError(nls.localize('notFoundCompatibleDependency', "Can't install '{0}' extension because it is not compatible with the current version of VS Code (version {1}).", extension.identifier.id, product.version), INSTALL_ERROR_INCOMPATIBLE);
throw new ExtensionManagementError(nls.localize('notFoundCompatibleDependency', "Can't install '{0}' extension because it is not compatible with the current version of VS Code (version {1}).", extension.identifier.id, this.productService.version), INSTALL_ERROR_INCOMPATIBLE);
}

return compatibleExtension;
Expand Down
Expand Up @@ -36,7 +36,7 @@ import { isEngineValid } from 'vs/platform/extensions/common/extensionValidator'
import { IFileService } from 'vs/platform/files/common/files';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ILogService } from 'vs/platform/log/common/log';
import product from 'vs/platform/product/common/product';
import { IProductService } from 'vs/platform/product/common/productService';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';

const INSTALL_ERROR_UNSET_UNINSTALLED = 'unsetUninstalled';
Expand All @@ -62,8 +62,9 @@ export class ExtensionManagementService extends AbstractExtensionManagementServi
@IDownloadService private downloadService: IDownloadService,
@IInstantiationService instantiationService: IInstantiationService,
@IFileService private readonly fileService: IFileService,
@IProductService productService: IProductService
) {
super(galleryService, telemetryService, logService);
super(galleryService, telemetryService, logService, productService);
const extensionLifecycle = this._register(instantiationService.createInstance(ExtensionsLifecycle));
this.extensionsScanner = this._register(instantiationService.createInstance(ExtensionsScanner, extension => extensionLifecycle.postUninstall(extension)));
this.manifestCache = this._register(new ExtensionsManifestCache(environmentService, this));
Expand Down Expand Up @@ -139,8 +140,8 @@ export class ExtensionManagementService extends AbstractExtensionManagementServi

const downloadLocation = await this.downloadVsix(vsix);
const manifest = await getManifest(path.resolve(downloadLocation.fsPath));
if (manifest.engines && manifest.engines.vscode && !isEngineValid(manifest.engines.vscode, product.version, product.date)) {
throw new Error(nls.localize('incompatible', "Unable to install extension '{0}' as it is not compatible with VS Code '{1}'.", getGalleryExtensionId(manifest.publisher, manifest.name), product.version));
if (manifest.engines && manifest.engines.vscode && !isEngineValid(manifest.engines.vscode, this.productService.version, this.productService.date)) {
throw new Error(nls.localize('incompatible', "Unable to install extension '{0}' as it is not compatible with VS Code '{1}'.", getGalleryExtensionId(manifest.publisher, manifest.name), this.productService.version));
}

return this.installExtension(manifest, downloadLocation, options);
Expand Down
3 changes: 1 addition & 2 deletions src/vs/platform/files/common/io.ts
Expand Up @@ -10,7 +10,6 @@ import { IDataTransformer, IErrorTransformer, WriteableStream } from 'vs/base/co
import { URI } from 'vs/base/common/uri';
import { localize } from 'vs/nls';
import { createFileSystemProviderError, ensureFileSystemProviderError, FileReadStreamOptions, FileSystemProviderErrorCode, IFileSystemProviderWithOpenReadWriteCloseCapability } from 'vs/platform/files/common/files';
import product from 'vs/platform/product/common/product';

export interface ICreateReadStreamOptions extends FileReadStreamOptions {

Expand Down Expand Up @@ -128,7 +127,7 @@ function throwIfTooLarge(totalBytesRead: number, options: ICreateReadStreamOptio
// Return early if file is too large to load and we have configured limits
if (options?.limits) {
if (typeof options.limits.memory === 'number' && totalBytesRead > options.limits.memory) {
throw createFileSystemProviderError(localize('fileTooLargeForHeapError', "To open a file of this size, you need to restart and allow {0} to use more memory", product.nameShort), FileSystemProviderErrorCode.FileExceedsMemoryLimit);
throw createFileSystemProviderError(localize('fileTooLargeForHeapError', "To open a file of this size, you need to restart and allow to use more memory"), FileSystemProviderErrorCode.FileExceedsMemoryLimit);
}

if (typeof options.limits.size === 'number' && totalBytesRead > options.limits.size) {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/platform/product/common/product.ts
Expand Up @@ -57,7 +57,7 @@ else {
// Running out of sources
if (Object.keys(product).length === 0) {
Object.assign(product, {
version: '1.61.0-dev',
version: '1.62.0-dev',
nameShort: 'Code - OSS Dev',
nameLong: 'Code - OSS Dev',
applicationName: 'code-oss',
Expand Down
31 changes: 16 additions & 15 deletions src/vs/server/remoteAgentEnvironmentImpl.ts
Expand Up @@ -12,7 +12,6 @@ import { IRemoteAgentEnvironmentDTO, IGetEnvironmentDataArguments, IScanExtensio
import * as nls from 'vs/nls';
import { FileAccess, Schemas } from 'vs/base/common/network';
import { IServerEnvironmentService } from 'vs/server/serverEnvironmentService';
import product from 'vs/platform/product/common/product';
import { ExtensionScanner, ExtensionScannerInput, IExtensionResolver, IExtensionReference } from 'vs/workbench/services/extensions/node/extensionPoints';
import { IServerChannel } from 'vs/base/parts/ipc/common/ipc';
import { ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensions/common/extensions';
Expand All @@ -32,6 +31,7 @@ import { IExtensionManagementCLIService } from 'vs/platform/extensionManagement/
import { cwd } from 'vs/base/common/process';
import { IRemoteTelemetryService } from 'vs/server/remoteTelemetryService';
import { Promises } from 'vs/base/node/pfs';
import { IProductService } from 'vs/platform/product/common/productService';

let _SystemExtensionsRoot: string | null = null;
function getSystemExtensionsRoot(): string {
Expand Down Expand Up @@ -61,7 +61,8 @@ export class RemoteAgentEnvironmentChannel implements IServerChannel {
extensionManagementCLIService: IExtensionManagementCLIService,
private readonly logService: ILogService,
private readonly telemetryService: IRemoteTelemetryService,
private readonly telemetryAppender: ITelemetryAppender | null
private readonly telemetryAppender: ITelemetryAppender | null,
private readonly productService: IProductService
) {
this._logger = new class implements ILog {
public error(source: string, message: string): void {
Expand Down Expand Up @@ -414,9 +415,9 @@ export class RemoteAgentEnvironmentChannel implements IServerChannel {
const extDescsP = extensionDevelopmentPaths.map(extDevPath => {
return ExtensionScanner.scanOneOrMultipleExtensions(
new ExtensionScannerInput(
product.version,
product.date,
product.commit,
this.productService.version,
this.productService.date,
this.productService.commit,
language,
true, // dev mode
extDevPath,
Expand All @@ -439,9 +440,9 @@ export class RemoteAgentEnvironmentChannel implements IServerChannel {
}

private _scanBuiltinExtensions(language: string, translations: Translations): Promise<IExtensionDescription[]> {
const version = product.version;
const commit = product.commit;
const date = product.date;
const version = this.productService.version;
const commit = this.productService.commit;
const date = this.productService.date;
const devMode = !!process.env['VSCODE_DEV'];

const input = new ExtensionScannerInput(version, date, commit, language, devMode, getSystemExtensionsRoot(), true, false, translations);
Expand All @@ -459,7 +460,7 @@ export class RemoteAgentEnvironmentChannel implements IServerChannel {
}
}

const builtInExtensions = Promise.resolve(product.builtInExtensions || []);
const builtInExtensions = Promise.resolve(this.productService.builtInExtensions || []);

const input = new ExtensionScannerInput(version, date, commit, language, devMode, getExtraDevSystemExtensionsRoot(), true, false, {});
const extraBuiltinExtensions = builtInExtensions
Expand All @@ -475,9 +476,9 @@ export class RemoteAgentEnvironmentChannel implements IServerChannel {
private _scanInstalledExtensions(language: string, translations: Translations): Promise<IExtensionDescription[]> {
const devMode = !!process.env['VSCODE_DEV'];
const input = new ExtensionScannerInput(
product.version,
product.date,
product.commit,
this.productService.version,
this.productService.date,
this.productService.commit,
language,
devMode,
this.environmentService.extensionsPath!,
Expand All @@ -492,9 +493,9 @@ export class RemoteAgentEnvironmentChannel implements IServerChannel {
private _scanSingleExtension(extensionPath: string, isBuiltin: boolean, language: string, translations: Translations): Promise<IExtensionDescription | null> {
const devMode = !!process.env['VSCODE_DEV'];
const input = new ExtensionScannerInput(
product.version,
product.date,
product.commit,
this.productService.version,
this.productService.date,
this.productService.commit,
language,
devMode,
extensionPath,
Expand Down
20 changes: 10 additions & 10 deletions src/vs/server/remoteExtensionHostAgentServer.ts
Expand Up @@ -229,7 +229,7 @@ export class RemoteExtensionHostAgentServer extends Disposable {
const logService = getOrCreateSpdLogService(this._environmentService);
logService.trace(`Remote configuration data at ${REMOTE_DATA_FOLDER}`);
logService.trace('process arguments:', this._environmentService.args);
const serverGreeting = product.serverGreeting.join('\n');
const serverGreeting = _productService.serverGreeting.join('\n');
if (serverGreeting) {
logService.info(`\n\n${serverGreeting}\n\n`);
}
Expand All @@ -242,7 +242,7 @@ export class RemoteExtensionHostAgentServer extends Disposable {
this._allReconnectionTokens = new Set<string>();

if (hasWebClient) {
this._webClientServer = new WebClientServer(this._connectionToken, this._environmentService, this._logService);
this._webClientServer = new WebClientServer(this._connectionToken, this._environmentService, this._logService, this._productService);
} else {
this._webClientServer = null;
}
Expand Down Expand Up @@ -281,16 +281,16 @@ export class RemoteExtensionHostAgentServer extends Disposable {
services.set(IRequestService, new SyncDescriptor(RequestService));

let appInsightsAppender: ITelemetryAppender = NullAppender;
if (!this._environmentService.args['disable-telemetry'] && product.enableTelemetry) {
if (product.aiConfig && product.aiConfig.asimovKey) {
appInsightsAppender = new AppInsightsAppender(eventPrefix, null, product.aiConfig.asimovKey);
if (!this._environmentService.args['disable-telemetry'] && this._productService.enableTelemetry) {
if (this._productService.aiConfig && this._productService.aiConfig.asimovKey) {
appInsightsAppender = new AppInsightsAppender(eventPrefix, null, this._productService.aiConfig.asimovKey);
this._register(toDisposable(() => appInsightsAppender!.flush())); // Ensure the AI appender is disposed so that it flushes remaining data
}

const machineId = await getMachineId();
const config: ITelemetryServiceConfig = {
appenders: [appInsightsAppender],
commonProperties: resolveCommonProperties(fileService, release(), hostname(), process.arch, product.commit, product.version + '-remote', machineId, product.msftInternalDomains, this._environmentService.installSourcePath, 'remoteAgent'),
commonProperties: resolveCommonProperties(fileService, release(), hostname(), process.arch, this._productService.commit, this._productService.version + '-remote', machineId, this._productService.msftInternalDomains, this._environmentService.installSourcePath, 'remoteAgent'),
piiPaths: [this._environmentService.appRoot]
};

Expand Down Expand Up @@ -323,10 +323,10 @@ export class RemoteExtensionHostAgentServer extends Disposable {
services.set(IPtyService, ptyService);

return instantiationService.invokeFunction(accessor => {
const remoteExtensionEnvironmentChannel = new RemoteAgentEnvironmentChannel(this._connectionToken, this._environmentService, extensionManagementCLIService, this._logService, accessor.get(IRemoteTelemetryService), appInsightsAppender);
const remoteExtensionEnvironmentChannel = new RemoteAgentEnvironmentChannel(this._connectionToken, this._environmentService, extensionManagementCLIService, this._logService, accessor.get(IRemoteTelemetryService), appInsightsAppender, this._productService);
this._socketServer.registerChannel('remoteextensionsenvironment', remoteExtensionEnvironmentChannel);

this._socketServer.registerChannel(REMOTE_TERMINAL_CHANNEL_NAME, new RemoteTerminalChannel(this._environmentService, this._logService, ptyService));
this._socketServer.registerChannel(REMOTE_TERMINAL_CHANNEL_NAME, new RemoteTerminalChannel(this._environmentService, this._logService, ptyService, this._productService));

const remoteFileSystemChannel = new RemoteAgentFileSystemProviderChannel(this._logService, this._environmentService);
this._socketServer.registerChannel(REMOTE_FILE_SYSTEM_CHANNEL_NAME, remoteFileSystemChannel);
Expand Down Expand Up @@ -375,7 +375,7 @@ export class RemoteExtensionHostAgentServer extends Disposable {
// Version
if (pathname === '/version') {
res.writeHead(200, { 'Content-Type': 'text/plain' });
return res.end(product.commit || '');
return res.end(this._productService.commit || '');
}

// Delay shutdown
Expand Down Expand Up @@ -628,7 +628,7 @@ export class RemoteExtensionHostAgentServer extends Disposable {
}

const rendererCommit = msg2.commit;
const myCommit = product.commit;
const myCommit = this._productService.commit;
if (rendererCommit && myCommit) {
// Running in the built version where commits are defined
if (rendererCommit !== myCommit) {
Expand Down
7 changes: 4 additions & 3 deletions src/vs/server/remoteTerminalChannel.ts
Expand Up @@ -14,7 +14,6 @@ import { IURITransformer } from 'vs/base/common/uriIpc';
import { IServerChannel } from 'vs/base/parts/ipc/common/ipc';
import { createRandomIPCHandle } from 'vs/base/parts/ipc/node/ipc.net';
import { ILogService } from 'vs/platform/log/common/log';
import product from 'vs/platform/product/common/product';
import { RemoteAgentConnectionContext } from 'vs/platform/remote/common/remoteAgentEnvironment';
import { IPtyService, IShellLaunchConfig, ITerminalProfile, ITerminalsLayoutInfo } from 'vs/platform/terminal/common/terminal';
import { IGetTerminalLayoutInfoArgs, ISetTerminalLayoutInfoArgs } from 'vs/platform/terminal/common/terminalProcess';
Expand All @@ -29,6 +28,7 @@ import * as terminalEnvironment from 'vs/workbench/contrib/terminal/common/termi
import { AbstractVariableResolverService } from 'vs/workbench/services/configurationResolver/common/variableResolver';
import { buildUserEnvironment } from 'vs/server/extensionHostConnection';
import { IServerEnvironmentService } from 'vs/server/serverEnvironmentService';
import { IProductService } from 'vs/platform/product/common/productService';

class CustomVariableResolver extends AbstractVariableResolverService {
constructor(
Expand Down Expand Up @@ -88,7 +88,8 @@ export class RemoteTerminalChannel extends Disposable implements IServerChannel<
constructor(
private readonly _environmentService: IServerEnvironmentService,
private readonly _logService: ILogService,
private readonly _ptyService: IPtyService
private readonly _ptyService: IPtyService,
private readonly _productService: IProductService
) {
super();
}
Expand Down Expand Up @@ -216,7 +217,7 @@ export class RemoteTerminalChannel extends Disposable implements IServerChannel<
shellLaunchConfig,
envFromConfig,
variableResolver,
product.version,
this._productService.version,
args.configuration['terminal.integrated.detectLocale'],
baseEnv
);
Expand Down