mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-31 17:20:28 -04:00
Vscode merge (#4582)
* Merge from vscode 37cb23d3dd4f9433d56d4ba5ea3203580719a0bd * fix issues with merges * bump node version in azpipe * replace license headers * remove duplicate launch task * fix build errors * fix build errors * fix tslint issues * working through package and linux build issues * more work * wip * fix packaged builds * working through linux build errors * wip * wip * wip * fix mac and linux file limits * iterate linux pipeline * disable editor typing * revert series to parallel * remove optimize vscode from linux * fix linting issues * revert testing change * add work round for new node * readd packaging for extensions * fix issue with angular not resolving decorator dependencies
This commit is contained in:
124
src/vs/workbench/contrib/scm/common/scm.ts
Normal file
124
src/vs/workbench/contrib/scm/common/scm.ts
Normal file
@@ -0,0 +1,124 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IViewContainersRegistry, ViewContainer, Extensions as ViewContainerExtensions } from 'vs/workbench/common/views';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Command } from 'vs/editor/common/modes';
|
||||
import { ColorIdentifier } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { ISequence } from 'vs/base/common/sequence';
|
||||
|
||||
export const VIEWLET_ID = 'workbench.view.scm';
|
||||
export const VIEW_CONTAINER: ViewContainer = Registry.as<IViewContainersRegistry>(ViewContainerExtensions.ViewContainersRegistry).registerViewContainer(VIEWLET_ID);
|
||||
|
||||
export interface IBaselineResourceProvider {
|
||||
getBaselineResource(resource: URI): Promise<URI>;
|
||||
}
|
||||
|
||||
export const ISCMService = createDecorator<ISCMService>('scm');
|
||||
|
||||
export interface ISCMResourceDecorations {
|
||||
icon?: URI;
|
||||
iconDark?: URI;
|
||||
tooltip?: string;
|
||||
strikeThrough?: boolean;
|
||||
faded?: boolean;
|
||||
|
||||
source?: string;
|
||||
letter?: string;
|
||||
color?: ColorIdentifier;
|
||||
}
|
||||
|
||||
export interface ISCMResource {
|
||||
readonly resourceGroup: ISCMResourceGroup;
|
||||
readonly sourceUri: URI;
|
||||
readonly decorations: ISCMResourceDecorations;
|
||||
open(): Promise<void>;
|
||||
}
|
||||
|
||||
export interface ISCMResourceGroup extends ISequence<ISCMResource> {
|
||||
readonly provider: ISCMProvider;
|
||||
readonly label: string;
|
||||
readonly id: string;
|
||||
readonly hideWhenEmpty: boolean;
|
||||
readonly onDidChange: Event<void>;
|
||||
}
|
||||
|
||||
export interface ISCMProvider extends IDisposable {
|
||||
readonly label: string;
|
||||
readonly id: string;
|
||||
readonly contextValue: string;
|
||||
|
||||
readonly groups: ISequence<ISCMResourceGroup>;
|
||||
|
||||
// TODO@Joao: remove
|
||||
readonly onDidChangeResources: Event<void>;
|
||||
|
||||
readonly rootUri?: URI;
|
||||
readonly count?: number;
|
||||
readonly commitTemplate?: string;
|
||||
readonly onDidChangeCommitTemplate?: Event<string>;
|
||||
readonly onDidChangeStatusBarCommands?: Event<Command[]>;
|
||||
readonly acceptInputCommand?: Command;
|
||||
readonly statusBarCommands?: Command[];
|
||||
readonly onDidChange: Event<void>;
|
||||
|
||||
getOriginalResource(uri: URI): Promise<URI | null>;
|
||||
}
|
||||
|
||||
export const enum InputValidationType {
|
||||
Error = 0,
|
||||
Warning = 1,
|
||||
Information = 2
|
||||
}
|
||||
|
||||
export interface IInputValidation {
|
||||
message: string;
|
||||
type: InputValidationType;
|
||||
}
|
||||
|
||||
export interface IInputValidator {
|
||||
(value: string, cursorPosition: number): Promise<IInputValidation | undefined>;
|
||||
}
|
||||
|
||||
export interface ISCMInput {
|
||||
value: string;
|
||||
readonly onDidChange: Event<string>;
|
||||
|
||||
placeholder: string;
|
||||
readonly onDidChangePlaceholder: Event<string>;
|
||||
|
||||
validateInput: IInputValidator;
|
||||
readonly onDidChangeValidateInput: Event<void>;
|
||||
|
||||
visible: boolean;
|
||||
readonly onDidChangeVisibility: Event<boolean>;
|
||||
}
|
||||
|
||||
export interface ISCMRepository extends IDisposable {
|
||||
readonly onDidFocus: Event<void>;
|
||||
readonly selected: boolean;
|
||||
readonly onDidChangeSelection: Event<boolean>;
|
||||
readonly provider: ISCMProvider;
|
||||
readonly input: ISCMInput;
|
||||
focus(): void;
|
||||
setSelected(selected: boolean): void;
|
||||
}
|
||||
|
||||
export interface ISCMService {
|
||||
|
||||
readonly _serviceBrand: any;
|
||||
readonly onDidAddRepository: Event<ISCMRepository>;
|
||||
readonly onDidRemoveRepository: Event<ISCMRepository>;
|
||||
|
||||
readonly repositories: ISCMRepository[];
|
||||
readonly selectedRepositories: ISCMRepository[];
|
||||
readonly onDidChangeSelectedRepositories: Event<ISCMRepository[]>;
|
||||
|
||||
registerSCMProvider(provider: ISCMProvider): ISCMRepository;
|
||||
}
|
||||
175
src/vs/workbench/contrib/scm/common/scmService.ts
Normal file
175
src/vs/workbench/contrib/scm/common/scmService.ts
Normal file
@@ -0,0 +1,175 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { ISCMService, ISCMProvider, ISCMInput, ISCMRepository, IInputValidator } from './scm';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { equals } from 'vs/base/common/arrays';
|
||||
|
||||
class SCMInput implements ISCMInput {
|
||||
|
||||
private _value = '';
|
||||
|
||||
get value(): string {
|
||||
return this._value;
|
||||
}
|
||||
|
||||
set value(value: string) {
|
||||
this._value = value;
|
||||
this._onDidChange.fire(value);
|
||||
}
|
||||
|
||||
private _onDidChange = new Emitter<string>();
|
||||
get onDidChange(): Event<string> { return this._onDidChange.event; }
|
||||
|
||||
private _placeholder = '';
|
||||
|
||||
get placeholder(): string {
|
||||
return this._placeholder;
|
||||
}
|
||||
|
||||
set placeholder(placeholder: string) {
|
||||
this._placeholder = placeholder;
|
||||
this._onDidChangePlaceholder.fire(placeholder);
|
||||
}
|
||||
|
||||
private _onDidChangePlaceholder = new Emitter<string>();
|
||||
get onDidChangePlaceholder(): Event<string> { return this._onDidChangePlaceholder.event; }
|
||||
|
||||
private _visible = true;
|
||||
|
||||
get visible(): boolean {
|
||||
return this._visible;
|
||||
}
|
||||
|
||||
set visible(visible: boolean) {
|
||||
this._visible = visible;
|
||||
this._onDidChangeVisibility.fire(visible);
|
||||
}
|
||||
|
||||
private _onDidChangeVisibility = new Emitter<boolean>();
|
||||
get onDidChangeVisibility(): Event<boolean> { return this._onDidChangeVisibility.event; }
|
||||
|
||||
private _validateInput: IInputValidator = () => Promise.resolve(undefined);
|
||||
|
||||
get validateInput(): IInputValidator {
|
||||
return this._validateInput;
|
||||
}
|
||||
|
||||
set validateInput(validateInput: IInputValidator) {
|
||||
this._validateInput = validateInput;
|
||||
this._onDidChangeValidateInput.fire();
|
||||
}
|
||||
|
||||
private _onDidChangeValidateInput = new Emitter<void>();
|
||||
get onDidChangeValidateInput(): Event<void> { return this._onDidChangeValidateInput.event; }
|
||||
}
|
||||
|
||||
class SCMRepository implements ISCMRepository {
|
||||
|
||||
private _onDidFocus = new Emitter<void>();
|
||||
readonly onDidFocus: Event<void> = this._onDidFocus.event;
|
||||
|
||||
private _selected = false;
|
||||
get selected(): boolean {
|
||||
return this._selected;
|
||||
}
|
||||
|
||||
private _onDidChangeSelection = new Emitter<boolean>();
|
||||
readonly onDidChangeSelection: Event<boolean> = this._onDidChangeSelection.event;
|
||||
|
||||
readonly input: ISCMInput = new SCMInput();
|
||||
|
||||
constructor(
|
||||
public readonly provider: ISCMProvider,
|
||||
private disposable: IDisposable
|
||||
) { }
|
||||
|
||||
focus(): void {
|
||||
this._onDidFocus.fire();
|
||||
}
|
||||
|
||||
setSelected(selected: boolean): void {
|
||||
this._selected = selected;
|
||||
this._onDidChangeSelection.fire(selected);
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.disposable.dispose();
|
||||
this.provider.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
export class SCMService implements ISCMService {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
private _providerIds = new Set<string>();
|
||||
private _repositories: ISCMRepository[] = [];
|
||||
get repositories(): ISCMRepository[] { return [...this._repositories]; }
|
||||
|
||||
private _selectedRepositories: ISCMRepository[] = [];
|
||||
get selectedRepositories(): ISCMRepository[] { return [...this._selectedRepositories]; }
|
||||
|
||||
private _onDidChangeSelectedRepositories = new Emitter<ISCMRepository[]>();
|
||||
readonly onDidChangeSelectedRepositories: Event<ISCMRepository[]> = this._onDidChangeSelectedRepositories.event;
|
||||
|
||||
private _onDidAddProvider = new Emitter<ISCMRepository>();
|
||||
get onDidAddRepository(): Event<ISCMRepository> { return this._onDidAddProvider.event; }
|
||||
|
||||
private _onDidRemoveProvider = new Emitter<ISCMRepository>();
|
||||
get onDidRemoveRepository(): Event<ISCMRepository> { return this._onDidRemoveProvider.event; }
|
||||
|
||||
constructor(@ILogService private readonly logService: ILogService) { }
|
||||
|
||||
registerSCMProvider(provider: ISCMProvider): ISCMRepository {
|
||||
this.logService.trace('SCMService#registerSCMProvider');
|
||||
|
||||
if (this._providerIds.has(provider.id)) {
|
||||
throw new Error(`SCM Provider ${provider.id} already exists.`);
|
||||
}
|
||||
|
||||
this._providerIds.add(provider.id);
|
||||
|
||||
const disposable = toDisposable(() => {
|
||||
const index = this._repositories.indexOf(repository);
|
||||
|
||||
if (index < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
selectedDisposable.dispose();
|
||||
this._providerIds.delete(provider.id);
|
||||
this._repositories.splice(index, 1);
|
||||
this._onDidRemoveProvider.fire(repository);
|
||||
this.onDidChangeSelection();
|
||||
});
|
||||
|
||||
const repository = new SCMRepository(provider, disposable);
|
||||
const selectedDisposable = repository.onDidChangeSelection(this.onDidChangeSelection, this);
|
||||
|
||||
this._repositories.push(repository);
|
||||
this._onDidAddProvider.fire(repository);
|
||||
|
||||
// automatically select the first repository
|
||||
if (this._repositories.length === 1) {
|
||||
repository.setSelected(true);
|
||||
}
|
||||
|
||||
return repository;
|
||||
}
|
||||
|
||||
private onDidChangeSelection(): void {
|
||||
const selectedRepositories = this._repositories.filter(r => r.selected);
|
||||
|
||||
if (equals(this._selectedRepositories, selectedRepositories)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._selectedRepositories = this._repositories.filter(r => r.selected);
|
||||
this._onDidChangeSelectedRepositories.fire(this.selectedRepositories);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user