#56137 Remove wireCancellationToken from Extension editor
This commit is contained in:
parent
934593d7fd
commit
bdaedb0238
|
@ -13,6 +13,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'
|
|||
import { ILocalization } from 'vs/platform/localizations/common/localizations';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IWorkspaceFolder, IWorkspace } from 'vs/platform/workspace/common/workspace';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
|
||||
export const EXTENSION_IDENTIFIER_PATTERN = '^([a-z0-9A-Z][a-z0-9\-A-Z]*)\\.([a-z0-9A-Z][a-z0-9\-A-Z]*)$';
|
||||
export const EXTENSION_IDENTIFIER_REGEX = new RegExp(EXTENSION_IDENTIFIER_PATTERN);
|
||||
|
@ -271,12 +272,12 @@ export interface IExtensionGalleryService {
|
|||
query(options?: IQueryOptions): TPromise<IPager<IGalleryExtension>>;
|
||||
download(extension: IGalleryExtension, operation: InstallOperation): TPromise<string>;
|
||||
reportStatistic(publisher: string, name: string, version: string, type: StatisticType): TPromise<void>;
|
||||
getReadme(extension: IGalleryExtension): TPromise<string>;
|
||||
getManifest(extension: IGalleryExtension): TPromise<IExtensionManifest>;
|
||||
getChangelog(extension: IGalleryExtension): TPromise<string>;
|
||||
getReadme(extension: IGalleryExtension, token: CancellationToken): TPromise<string>;
|
||||
getManifest(extension: IGalleryExtension, token: CancellationToken): TPromise<IExtensionManifest>;
|
||||
getChangelog(extension: IGalleryExtension, token: CancellationToken): TPromise<string>;
|
||||
getCoreTranslation(extension: IGalleryExtension, languageId: string): TPromise<ITranslation>;
|
||||
loadCompatibleVersion(extension: IGalleryExtension): TPromise<IGalleryExtension>;
|
||||
loadAllDependencies(dependencies: IExtensionIdentifier[]): TPromise<IGalleryExtension[]>;
|
||||
loadAllDependencies(dependencies: IExtensionIdentifier[], token: CancellationToken): TPromise<IGalleryExtension[]>;
|
||||
getExtensionsReport(): TPromise<IReportedExtension[]>;
|
||||
getExtension(id: IExtensionIdentifier, version?: string): TPromise<IGalleryExtension>;
|
||||
}
|
||||
|
|
|
@ -538,13 +538,13 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
|
|||
.then(() => zipPath);
|
||||
}
|
||||
|
||||
getReadme(extension: IGalleryExtension): TPromise<string> {
|
||||
return this.getAsset(extension.assets.readme)
|
||||
getReadme(extension: IGalleryExtension, token: CancellationToken): TPromise<string> {
|
||||
return this.getAsset(extension.assets.readme, {}, token)
|
||||
.then(asText);
|
||||
}
|
||||
|
||||
getManifest(extension: IGalleryExtension): TPromise<IExtensionManifest> {
|
||||
return this.getAsset(extension.assets.manifest)
|
||||
getManifest(extension: IGalleryExtension, token: CancellationToken): TPromise<IExtensionManifest> {
|
||||
return this.getAsset(extension.assets.manifest, {}, token)
|
||||
.then(asText)
|
||||
.then(JSON.parse);
|
||||
}
|
||||
|
@ -559,13 +559,13 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
|
|||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
getChangelog(extension: IGalleryExtension): TPromise<string> {
|
||||
return this.getAsset(extension.assets.changelog)
|
||||
getChangelog(extension: IGalleryExtension, token: CancellationToken): TPromise<string> {
|
||||
return this.getAsset(extension.assets.changelog, {}, token)
|
||||
.then(asText);
|
||||
}
|
||||
|
||||
loadAllDependencies(extensions: IExtensionIdentifier[]): TPromise<IGalleryExtension[]> {
|
||||
return this.getDependenciesReccursively(extensions.map(e => e.id), []);
|
||||
loadAllDependencies(extensions: IExtensionIdentifier[], token: CancellationToken): TPromise<IGalleryExtension[]> {
|
||||
return this.getDependenciesReccursively(extensions.map(e => e.id), [], token);
|
||||
}
|
||||
|
||||
loadCompatibleVersion(extension: IGalleryExtension): TPromise<IGalleryExtension> {
|
||||
|
@ -603,7 +603,7 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
|
|||
});
|
||||
}
|
||||
|
||||
private loadDependencies(extensionNames: string[]): TPromise<IGalleryExtension[]> {
|
||||
private loadDependencies(extensionNames: string[], token: CancellationToken): TPromise<IGalleryExtension[]> {
|
||||
if (!extensionNames || extensionNames.length === 0) {
|
||||
return TPromise.as([]);
|
||||
}
|
||||
|
@ -616,7 +616,7 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
|
|||
.withAssetTypes(AssetType.Icon, AssetType.License, AssetType.Details, AssetType.Manifest, AssetType.VSIX)
|
||||
.withFilter(FilterType.ExtensionName, ...extensionNames);
|
||||
|
||||
return this.queryGallery(query, CancellationToken.None).then(result => {
|
||||
return this.queryGallery(query, token).then(result => {
|
||||
const dependencies = [];
|
||||
const ids = [];
|
||||
|
||||
|
@ -631,7 +631,7 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
|
|||
});
|
||||
}
|
||||
|
||||
private getDependenciesReccursively(toGet: string[], result: IGalleryExtension[]): TPromise<IGalleryExtension[]> {
|
||||
private getDependenciesReccursively(toGet: string[], result: IGalleryExtension[], token: CancellationToken): TPromise<IGalleryExtension[]> {
|
||||
if (!toGet || !toGet.length) {
|
||||
return TPromise.wrap(result);
|
||||
}
|
||||
|
@ -640,7 +640,7 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
|
|||
return TPromise.wrap(result);
|
||||
}
|
||||
|
||||
return this.loadDependencies(toGet)
|
||||
return this.loadDependencies(toGet, token)
|
||||
.then(loadedDependencies => {
|
||||
const dependenciesSet = new Set<string>();
|
||||
for (const dep of loadedDependencies) {
|
||||
|
@ -651,7 +651,7 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
|
|||
result = distinct(result.concat(loadedDependencies), d => d.identifier.uuid);
|
||||
const dependencies: string[] = [];
|
||||
dependenciesSet.forEach(d => !ExtensionGalleryService.hasExtensionByName(result, d) && dependencies.push(d));
|
||||
return this.getDependenciesReccursively(dependencies, result);
|
||||
return this.getDependenciesReccursively(dependencies, result, token);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import { Action } from 'vs/base/common/actions';
|
|||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
|
||||
export class MulitExtensionManagementService extends Disposable implements IExtensionManagementService {
|
||||
|
||||
|
@ -99,7 +100,7 @@ export class MulitExtensionManagementService extends Disposable implements IExte
|
|||
if (this.otherServers.length === 0) {
|
||||
return this.localServer.extensionManagementService.installFromGallery(gallery);
|
||||
}
|
||||
return this.extensionGalleryService.getManifest(gallery)
|
||||
return this.extensionGalleryService.getManifest(gallery, CancellationToken.None)
|
||||
.then(manifest => {
|
||||
const servers = isWorkspaceExtension(manifest, this.configurationService) ? this.servers : [this.localServer];
|
||||
return TPromise.join(servers.map(server => server.extensionManagementService.installFromGallery(gallery)))
|
||||
|
|
|
@ -11,6 +11,7 @@ import { IPager } from 'vs/base/common/paging';
|
|||
import { IQueryOptions, IExtensionManifest, LocalExtensionType, EnablementState, ILocalExtension, IGalleryExtension } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IViewContainersRegistry, ViewContainer, Extensions as ViewContainerExtensions } from 'vs/workbench/common/views';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
|
||||
export const VIEWLET_ID = 'workbench.view.extensions';
|
||||
export const VIEW_CONTAINER: ViewContainer = Registry.as<IViewContainersRegistry>(ViewContainerExtensions.ViewContainersRegistry).registerViewContainer(VIEWLET_ID);
|
||||
|
@ -52,10 +53,10 @@ export interface IExtension {
|
|||
extensionPack: string[];
|
||||
telemetryData: any;
|
||||
preview: boolean;
|
||||
getManifest(): TPromise<IExtensionManifest | undefined>;
|
||||
getReadme(): TPromise<string>;
|
||||
getManifest(token: CancellationToken): TPromise<IExtensionManifest | undefined>;
|
||||
getReadme(token: CancellationToken): TPromise<string>;
|
||||
hasReadme(): boolean;
|
||||
getChangelog(): TPromise<string>;
|
||||
getChangelog(token: CancellationToken): TPromise<string>;
|
||||
hasChangelog(): boolean;
|
||||
local?: ILocalExtension;
|
||||
locals?: ILocalExtension[];
|
||||
|
@ -87,7 +88,7 @@ export interface IExtensionsWorkbenchService {
|
|||
uninstall(extension: IExtension): TPromise<void>;
|
||||
reinstall(extension: IExtension): TPromise<void>;
|
||||
setEnablement(extensions: IExtension | IExtension[], enablementState: EnablementState): TPromise<void>;
|
||||
loadDependencies(extension: IExtension): TPromise<IExtensionDependencies>;
|
||||
loadDependencies(extension: IExtension, token: CancellationToken): TPromise<IExtensionDependencies>;
|
||||
open(extension: IExtension, sideByside?: boolean): TPromise<any>;
|
||||
checkForUpdates(): TPromise<void>;
|
||||
allowedBadgeProviders: string[];
|
||||
|
|
|
@ -9,7 +9,7 @@ import 'vs/css!./media/extensionEditor';
|
|||
import { localize } from 'vs/nls';
|
||||
import { TPromise, Promise } from 'vs/base/common/winjs.base';
|
||||
import { marked } from 'vs/base/common/marked/marked';
|
||||
import { createCancelablePromise, wireCancellationToken } from 'vs/base/common/async';
|
||||
import { createCancelablePromise } from 'vs/base/common/async';
|
||||
import * as arrays from 'vs/base/common/arrays';
|
||||
import { OS } from 'vs/base/common/platform';
|
||||
import { Event, Emitter, once, chain } from 'vs/base/common/event';
|
||||
|
@ -283,10 +283,10 @@ export class ExtensionEditor extends BaseEditor {
|
|||
|
||||
this.transientDisposables = dispose(this.transientDisposables);
|
||||
|
||||
this.extensionReadme = new Cache(() => createCancelablePromise(token => wireCancellationToken(token, extension.getReadme())));
|
||||
this.extensionChangelog = new Cache(() => createCancelablePromise(token => wireCancellationToken(token, extension.getChangelog())));
|
||||
this.extensionManifest = new Cache(() => createCancelablePromise(token => wireCancellationToken(token, extension.getManifest())));
|
||||
this.extensionDependencies = new Cache(() => createCancelablePromise(token => wireCancellationToken(token, this.extensionsWorkbenchService.loadDependencies(extension))));
|
||||
this.extensionReadme = new Cache(() => createCancelablePromise(token => extension.getReadme(token)));
|
||||
this.extensionChangelog = new Cache(() => createCancelablePromise(token => extension.getChangelog(token)));
|
||||
this.extensionManifest = new Cache(() => createCancelablePromise(token => extension.getManifest(token)));
|
||||
this.extensionDependencies = new Cache(() => createCancelablePromise(token => this.extensionsWorkbenchService.loadDependencies(extension, token)));
|
||||
|
||||
const onError = once(domEvent(this.icon, 'error'));
|
||||
onError(() => this.icon.src = extension.iconUrlFallback, null, this.transientDisposables);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import { localize } from 'vs/nls';
|
||||
import { append, $, addClass, removeClass, toggleClass } from 'vs/base/browser/dom';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { IDisposable, dispose, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
@ -23,6 +23,7 @@ import { IExtensionService } from 'vs/workbench/services/extensions/common/exten
|
|||
import { IExtensionTipsService, IExtensionManagementServerService } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { createCancelablePromise } from 'vs/base/common/async';
|
||||
|
||||
export interface ITemplateData {
|
||||
root: HTMLElement;
|
||||
|
@ -180,12 +181,13 @@ export class Renderer implements IPagedRenderer<IExtension, ITemplateData> {
|
|||
data.ratings.style.display = '';
|
||||
data.extension = extension;
|
||||
|
||||
extension.getManifest().then(manifest => {
|
||||
const manifestPromise = createCancelablePromise(token => extension.getManifest(token).then(manifest => {
|
||||
if (manifest) {
|
||||
const name = manifest && manifest.contributes && manifest.contributes.localizations && manifest.contributes.localizations.length > 0 && manifest.contributes.localizations[0].localizedLanguageName;
|
||||
if (name) { data.description.textContent = name[0].toLocaleUpperCase() + name.slice(1); }
|
||||
}
|
||||
});
|
||||
}));
|
||||
data.disposables.push(toDisposable(() => manifestPromise.cancel()));
|
||||
}
|
||||
|
||||
disposeElement(): void {
|
||||
|
|
|
@ -38,6 +38,7 @@ import { IExtensionService } from 'vs/workbench/services/extensions/common/exten
|
|||
import { groupBy } from 'vs/base/common/collections';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import * as resources from 'vs/base/common/resources';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
|
||||
interface IExtensionStateProvider<T> {
|
||||
(extension: Extension): T;
|
||||
|
@ -205,10 +206,10 @@ class Extension implements IExtension {
|
|||
return this.local && this.gallery && semver.gt(this.local.manifest.version, this.gallery.version);
|
||||
}
|
||||
|
||||
getManifest(): TPromise<IExtensionManifest> {
|
||||
getManifest(token: CancellationToken): TPromise<IExtensionManifest> {
|
||||
if (this.gallery && !this.isGalleryOutdated()) {
|
||||
if (this.gallery.assets.manifest) {
|
||||
return this.galleryService.getManifest(this.gallery);
|
||||
return this.galleryService.getManifest(this.gallery, token);
|
||||
}
|
||||
this.logService.error(nls.localize('Manifest is not found', "Manifest is not found"), this.id);
|
||||
return TPromise.as(undefined);
|
||||
|
@ -229,10 +230,10 @@ class Extension implements IExtension {
|
|||
return this.type === LocalExtensionType.System;
|
||||
}
|
||||
|
||||
getReadme(): TPromise<string> {
|
||||
getReadme(token: CancellationToken): TPromise<string> {
|
||||
if (this.gallery && !this.isGalleryOutdated()) {
|
||||
if (this.gallery.assets.readme) {
|
||||
return this.galleryService.getReadme(this.gallery);
|
||||
return this.galleryService.getReadme(this.gallery, token);
|
||||
}
|
||||
this.telemetryService.publicLog('extensions:NotFoundReadMe', this.telemetryData);
|
||||
}
|
||||
|
@ -266,9 +267,9 @@ ${this.description}
|
|||
return this.type === LocalExtensionType.System;
|
||||
}
|
||||
|
||||
getChangelog(): TPromise<string> {
|
||||
getChangelog(token: CancellationToken): TPromise<string> {
|
||||
if (this.gallery && this.gallery.assets.changelog && !this.isGalleryOutdated()) {
|
||||
return this.galleryService.getChangelog(this.gallery);
|
||||
return this.galleryService.getChangelog(this.gallery, token);
|
||||
}
|
||||
|
||||
const changelogUrl = this.local && this.local.changelogUrl;
|
||||
|
@ -468,7 +469,7 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService,
|
|||
});
|
||||
}
|
||||
|
||||
loadDependencies(extension: IExtension): TPromise<IExtensionDependencies> {
|
||||
loadDependencies(extension: IExtension, token: CancellationToken): TPromise<IExtensionDependencies> {
|
||||
if (!extension.dependencies.length) {
|
||||
return TPromise.wrap<IExtensionDependencies>(null);
|
||||
}
|
||||
|
@ -477,7 +478,7 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService,
|
|||
.then(report => {
|
||||
const maliciousSet = getMaliciousExtensionsSet(report);
|
||||
|
||||
return this.galleryService.loadAllDependencies((<Extension>extension).dependencies.map(id => ({ id })))
|
||||
return this.galleryService.loadAllDependencies((<Extension>extension).dependencies.map(id => ({ id })), token)
|
||||
.then(galleryExtensions => galleryExtensions.map(galleryExtension => this.fromGallery(galleryExtension, maliciousSet)))
|
||||
.then(extensions => [...this.local, ...extensions])
|
||||
.then(extensions => {
|
||||
|
|
|
@ -38,6 +38,7 @@ import { ProgressService2 } from 'vs/workbench/services/progress/browser/progres
|
|||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { URLService } from 'vs/platform/url/common/urlService';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
|
||||
suite('ExtensionsWorkbenchServiceTest', () => {
|
||||
|
||||
|
@ -474,7 +475,7 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
|||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(aGalleryExtension('a')));
|
||||
|
||||
return testObject.queryGallery().then(page => {
|
||||
return testObject.loadDependencies(page.firstPage[0]).then(dependencies => {
|
||||
return testObject.loadDependencies(page.firstPage[0], CancellationToken.None).then(dependencies => {
|
||||
assert.equal(null, dependencies);
|
||||
});
|
||||
});
|
||||
|
@ -487,7 +488,7 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
|||
|
||||
return testObject.queryGallery().then(page => {
|
||||
const extension = page.firstPage[0];
|
||||
return testObject.loadDependencies(extension).then(actual => {
|
||||
return testObject.loadDependencies(extension, CancellationToken.None).then(actual => {
|
||||
assert.ok(actual.hasDependencies);
|
||||
assert.equal(extension, actual.extension);
|
||||
assert.equal(null, actual.dependent);
|
||||
|
@ -526,7 +527,7 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
|||
|
||||
return testObject.queryGallery().then(page => {
|
||||
const extension = page.firstPage[0];
|
||||
return testObject.loadDependencies(extension).then(actual => {
|
||||
return testObject.loadDependencies(extension, CancellationToken.None).then(actual => {
|
||||
assert.ok(actual.hasDependencies);
|
||||
assert.equal(extension, actual.extension);
|
||||
assert.equal(null, actual.dependent);
|
||||
|
@ -558,7 +559,7 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
|||
|
||||
return testObject.queryGallery().then(page => {
|
||||
const extension = page.firstPage[0];
|
||||
return testObject.loadDependencies(extension).then(actual => {
|
||||
return testObject.loadDependencies(extension, CancellationToken.None).then(actual => {
|
||||
assert.ok(actual.hasDependencies);
|
||||
assert.equal(extension, actual.extension);
|
||||
assert.equal(null, actual.dependent);
|
||||
|
@ -592,7 +593,7 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
|||
|
||||
return testObject.queryGallery().then(page => {
|
||||
const extension = page.firstPage[0];
|
||||
return testObject.loadDependencies(extension).then(actual => {
|
||||
return testObject.loadDependencies(extension, CancellationToken.None).then(actual => {
|
||||
assert.ok(actual.hasDependencies);
|
||||
assert.equal(extension, actual.extension);
|
||||
assert.equal(null, actual.dependent);
|
||||
|
@ -630,7 +631,7 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
|||
|
||||
return testObject.queryGallery().then(page => {
|
||||
const extension = page.firstPage[0];
|
||||
return testObject.loadDependencies(extension).then(a => {
|
||||
return testObject.loadDependencies(extension, CancellationToken.None).then(a => {
|
||||
assert.ok(a.hasDependencies);
|
||||
assert.equal(extension, a.extension);
|
||||
assert.equal(null, a.dependent);
|
||||
|
|
|
@ -29,6 +29,7 @@ import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
|
|||
import { VIEWLET_ID as EXTENSIONS_VIEWLET_ID, IExtensionsViewlet } from 'vs/workbench/parts/extensions/common/extensions';
|
||||
import { minimumTranslatedStrings } from 'vs/platform/node/minimalTranslations';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
|
||||
// Register action to configure locale and related settings
|
||||
const registry = Registry.as<IWorkbenchActionRegistry>(Extensions.WorkbenchActions);
|
||||
|
@ -131,7 +132,7 @@ export class LocalizationWorkbenchContribution extends Disposable implements IWo
|
|||
return;
|
||||
}
|
||||
|
||||
TPromise.join([this.galleryService.getManifest(extensionToFetchTranslationsFrom), this.galleryService.getCoreTranslation(extensionToFetchTranslationsFrom, locale)])
|
||||
TPromise.join([this.galleryService.getManifest(extensionToFetchTranslationsFrom, CancellationToken.None), this.galleryService.getCoreTranslation(extensionToFetchTranslationsFrom, locale)])
|
||||
.then(([manifest, translation]) => {
|
||||
const loc = manifest && manifest.contributes && manifest.contributes.localizations && manifest.contributes.localizations.filter(x => x.languageId.toLowerCase() === locale)[0];
|
||||
const languageName = loc ? (loc.languageName || locale) : locale;
|
||||
|
|
Loading…
Reference in a new issue