Merge commit 'be3e8236086165e5e45a5a10783823874b3f3ebd' as 'lib/vscode'

This commit is contained in:
Joe Previte
2020-12-15 15:52:33 -07:00
4649 changed files with 1311795 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
import { Registry } from 'vs/platform/registry/common/platform';
import { Extensions as WorkbenchExtensions, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
import { ViewsWelcomeContribution } from 'vs/workbench/contrib/welcome/common/viewsWelcomeContribution';
import { ViewsWelcomeExtensionPoint, viewsWelcomeExtensionPointDescriptor } from 'vs/workbench/contrib/welcome/common/viewsWelcomeExtensionPoint';
import { ExtensionsRegistry } from 'vs/workbench/services/extensions/common/extensionsRegistry';
const extensionPoint = ExtensionsRegistry.registerExtensionPoint<ViewsWelcomeExtensionPoint>(viewsWelcomeExtensionPointDescriptor);
class WorkbenchConfigurationContribution {
constructor(
@IInstantiationService instantiationService: IInstantiationService,
) {
instantiationService.createInstance(ViewsWelcomeContribution, extensionPoint);
}
}
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
.registerWorkbenchContribution(WorkbenchConfigurationContribution, LifecyclePhase.Eventually);

View File

@@ -0,0 +1,72 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as nls from 'vs/nls';
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { IExtensionPoint, IExtensionPointUser } from 'vs/workbench/services/extensions/common/extensionsRegistry';
import { ViewsWelcomeExtensionPoint, ViewWelcome, ViewIdentifierMap } from './viewsWelcomeExtensionPoint';
import { Registry } from 'vs/platform/registry/common/platform';
import { Extensions as ViewContainerExtensions, IViewsRegistry } from 'vs/workbench/common/views';
const viewsRegistry = Registry.as<IViewsRegistry>(ViewContainerExtensions.ViewsRegistry);
export class ViewsWelcomeContribution extends Disposable implements IWorkbenchContribution {
private viewWelcomeContents = new Map<ViewWelcome, IDisposable>();
constructor(extensionPoint: IExtensionPoint<ViewsWelcomeExtensionPoint>) {
super();
extensionPoint.setHandler((_, { added, removed }) => {
for (const contribution of removed) {
for (const welcome of contribution.value) {
const disposable = this.viewWelcomeContents.get(welcome);
if (disposable) {
disposable.dispose();
}
}
}
for (const contribution of added) {
for (const welcome of contribution.value) {
const id = ViewIdentifierMap[welcome.view] ?? welcome.view;
const { group, order } = parseGroupAndOrder(welcome, contribution);
const disposable = viewsRegistry.registerViewWelcomeContent(id, {
content: welcome.contents,
when: ContextKeyExpr.deserialize(welcome.when),
group,
order
});
this.viewWelcomeContents.set(welcome, disposable);
}
}
});
}
}
function parseGroupAndOrder(welcome: ViewWelcome, contribution: IExtensionPointUser<ViewsWelcomeExtensionPoint>): { group: string | undefined, order: number | undefined } {
let group: string | undefined;
let order: number | undefined;
if (welcome.group) {
if (!contribution.description.enableProposedApi) {
contribution.collector.warn(nls.localize('ViewsWelcomeExtensionPoint.proposedAPI', "The viewsWelcome contribution in '{0}' requires 'enableProposedApi' to be enabled.", contribution.description.identifier.value));
return { group, order };
}
const idx = welcome.group.lastIndexOf('@');
if (idx > 0) {
group = welcome.group.substr(0, idx);
order = Number(welcome.group.substr(idx + 1)) || undefined;
} else {
group = welcome.group;
}
}
return { group, order };
}

View File

@@ -0,0 +1,74 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as nls from 'vs/nls';
import { IConfigurationPropertySchema } from 'vs/platform/configuration/common/configurationRegistry';
export enum ViewsWelcomeExtensionPointFields {
view = 'view',
contents = 'contents',
when = 'when',
group = 'group',
}
export interface ViewWelcome {
readonly [ViewsWelcomeExtensionPointFields.view]: string;
readonly [ViewsWelcomeExtensionPointFields.contents]: string;
readonly [ViewsWelcomeExtensionPointFields.when]: string;
readonly [ViewsWelcomeExtensionPointFields.group]: string;
}
export type ViewsWelcomeExtensionPoint = ViewWelcome[];
export const ViewIdentifierMap: { [key: string]: string } = {
'explorer': 'workbench.explorer.emptyView',
'debug': 'workbench.debug.welcome',
'scm': 'workbench.scm',
};
const viewsWelcomeExtensionPointSchema = Object.freeze<IConfigurationPropertySchema>({
type: 'array',
description: nls.localize('contributes.viewsWelcome', "Contributed views welcome content. Welcome content will be rendered in tree based views whenever they have no meaningful content to display, ie. the File Explorer when no folder is open. Such content is useful as in-product documentation to drive users to use certain features before they are available. A good example would be a `Clone Repository` button in the File Explorer welcome view."),
items: {
type: 'object',
description: nls.localize('contributes.viewsWelcome.view', "Contributed welcome content for a specific view."),
required: [
ViewsWelcomeExtensionPointFields.view,
ViewsWelcomeExtensionPointFields.contents
],
properties: {
[ViewsWelcomeExtensionPointFields.view]: {
anyOf: [
{
type: 'string',
description: nls.localize('contributes.viewsWelcome.view.view', "Target view identifier for this welcome content. Only tree based views are supported.")
},
{
type: 'string',
description: nls.localize('contributes.viewsWelcome.view.view', "Target view identifier for this welcome content. Only tree based views are supported."),
enum: Object.keys(ViewIdentifierMap)
}
]
},
[ViewsWelcomeExtensionPointFields.contents]: {
type: 'string',
description: nls.localize('contributes.viewsWelcome.view.contents', "Welcome content to be displayed. The format of the contents is a subset of Markdown, with support for links only."),
},
[ViewsWelcomeExtensionPointFields.when]: {
type: 'string',
description: nls.localize('contributes.viewsWelcome.view.when', "Condition when the welcome content should be displayed."),
},
[ViewsWelcomeExtensionPointFields.group]: {
type: 'string',
description: nls.localize('contributes.viewsWelcome.view.group', "Group to which this welcome content belongs."),
},
}
}
});
export const viewsWelcomeExtensionPointDescriptor = {
extensionPoint: 'viewsWelcome',
jsonSchema: viewsWelcomeExtensionPointSchema
};