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

Update the SCM Plugin API from the latest vscode #9045

Merged
merged 1 commit into from
Mar 15, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/git/src/browser/git-commit-message-validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import { injectable } from 'inversify';
import { MaybePromise } from '@theia/core/lib/common/types';
import { ScmInputIssueType } from '@theia/scm/lib/browser/scm-input';

@injectable()
export class GitCommitMessageValidator {
Expand All @@ -42,14 +43,14 @@ export class GitCommitMessageValidator {
protected isLineValid(line: string, index: number): GitCommitMessageValidator.Result | undefined {
if (index === 1 && line.length !== 0) {
return {
status: 'warning',
status: ScmInputIssueType.Warning,
message: 'The second line should be empty to separate the commit message from the body'
};
}
const diff = line.length - this.maxCharsPerLine();
if (diff > 0) {
return {
status: 'warning',
status: ScmInputIssueType.Warning,
message: `${diff} characters over ${this.maxCharsPerLine()} in current line`
};
}
Expand All @@ -67,7 +68,7 @@ export namespace GitCommitMessageValidator {
/**
* Type for the validation result with a status and a corresponding message.
*/
export type Result = Readonly<{ message: string, status: 'info' | 'success' | 'warning' | 'error' }>;
export type Result = Readonly<{ message: string, status: ScmInputIssueType }>;

export namespace Result {

Expand Down
28 changes: 21 additions & 7 deletions packages/git/src/browser/git-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,22 @@
********************************************************************************/
import { inject, injectable } from 'inversify';
import URI from '@theia/core/lib/common/uri';
import { Command, CommandContribution, CommandRegistry, DisposableCollection, MenuContribution, MenuModelRegistry, Mutable, MenuAction } from '@theia/core';
import {
Command,
CommandContribution,
CommandRegistry,
DisposableCollection,
MenuAction,
MenuContribution,
MenuModelRegistry,
Mutable
} from '@theia/core';
import { DiffUris, Widget } from '@theia/core/lib/browser';
import { TabBarToolbarContribution, TabBarToolbarRegistry, TabBarToolbarItem } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
import {
TabBarToolbarContribution,
TabBarToolbarItem,
TabBarToolbarRegistry
} from '@theia/core/lib/browser/shell/tab-bar-toolbar';
import { EditorContextMenu, EditorManager, EditorOpenerOptions, EditorWidget } from '@theia/editor/lib/browser';
import { Git, GitFileChange, GitFileStatus } from '../common';
import { GitRepositoryTracker } from './git-repository-tracker';
Expand All @@ -28,11 +41,12 @@ import { GitRepositoryProvider } from './git-repository-provider';
import { GitErrorHandler } from '../browser/git-error-handler';
import { ScmWidget } from '@theia/scm/lib/browser/scm-widget';
import { ScmTreeWidget } from '@theia/scm/lib/browser/scm-tree-widget';
import { ScmResource, ScmCommand } from '@theia/scm/lib/browser/scm-provider';
import { ScmCommand, ScmResource } from '@theia/scm/lib/browser/scm-provider';
import { ProgressService } from '@theia/core/lib/common/progress-service';
import { GitPreferences } from './git-preferences';
import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution';
import { ColorRegistry } from '@theia/core/lib/browser/color-registry';
import { ScmInputIssueType } from '@theia/scm/lib/browser/scm-input';

export namespace GIT_COMMANDS {
export const CLONE = {
Expand Down Expand Up @@ -487,7 +501,7 @@ export class GitContribution implements CommandContribution, MenuContribution, T
const lastCommit = await scmRepository.provider.amendSupport.getLastCommit();
if (lastCommit === undefined) {
scmRepository.input.issue = {
type: 'error',
type: ScmInputIssueType.Error,
message: 'No previous commit to amend'
};
scmRepository.input.focus();
Expand Down Expand Up @@ -727,15 +741,15 @@ export class GitContribution implements CommandContribution, MenuContribution, T
const message = options.message || scmRepository.input.value;
if (!message.trim()) {
scmRepository.input.issue = {
type: 'error',
type: ScmInputIssueType.Error,
message: 'Please provide a commit message'
};
scmRepository.input.focus();
return;
}
if (!scmRepository.provider.stagedChanges.length) {
scmRepository.input.issue = {
type: 'error',
type: ScmInputIssueType.Error,
message: 'No changes added to commit'
};
scmRepository.input.focus();
Expand Down Expand Up @@ -776,7 +790,7 @@ export class GitContribution implements CommandContribution, MenuContribution, T
scmRepository.input.focus();
} catch (e) {
scmRepository.input.issue = {
type: 'warning',
type: ScmInputIssueType.Warning,
message: 'Make sure you configure your \'user.name\' and \'user.email\' in git.'
};
}
Expand Down
6 changes: 6 additions & 0 deletions packages/plugin-ext/src/common/arrays.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,9 @@ export function isNonEmptyArray<T>(obj: T[] | readonly T[] | undefined | null):
export function flatten<T>(arr: T[][]): T[] {
return (<T[]>[]).concat(...arr);
}

export interface Splice<T> {
readonly start: number;
readonly deleteCount: number;
readonly toInsert: T[];
}
53 changes: 42 additions & 11 deletions packages/plugin-ext/src/common/plugin-api-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -690,10 +690,11 @@ export namespace ScmCommandArg {
export interface ScmExt {
createSourceControl(plugin: Plugin, id: string, label: string, rootUri?: theia.Uri): theia.SourceControl;
getLastInputBox(plugin: Plugin): theia.SourceControlInputBox | undefined;
$updateInputBox(sourceControlHandle: number, message: string): Promise<void>;
$onInputBoxValueChange(sourceControlHandle: number, message: string): Promise<void>;
$executeResourceCommand(sourceControlHandle: number, groupHandle: number, resourceHandle: number): Promise<void>;
$provideOriginalResource(sourceControlHandle: number, uri: string, token: CancellationToken): Promise<UriComponents | undefined>;
$setSourceControlSelection(sourceControlHandle: number, selected: boolean): Promise<void>;
$validateInput(sourceControlHandle: number, value: string, cursorPosition: number): Promise<[string, number] | undefined>;
$setSelectedSourceControl(selectedSourceControlHandle: number | undefined): Promise<void>;
$provideOriginalResource(sourceControlHandle: number, uri: string, token: theia.CancellationToken): Promise<UriComponents | undefined>;
}

export namespace TimelineCommandArg {
Expand Down Expand Up @@ -762,18 +763,19 @@ export interface DecorationData {
}

export interface ScmMain {
$registerSourceControl(sourceControlHandle: number, id: string, label: string, rootUri?: string): Promise<void>
$registerSourceControl(sourceControlHandle: number, id: string, label: string, rootUri?: UriComponents): Promise<void>;
$updateSourceControl(sourceControlHandle: number, features: SourceControlProviderFeatures): Promise<void>;
$unregisterSourceControl(sourceControlHandle: number): Promise<void>;

$registerGroup(sourceControlHandle: number, groupHandle: number, id: string, label: string): Promise<void>;
$updateGroup(sourceControlHandle: number, groupHandle: number, features: SourceControlGroupFeatures): Promise<void>;
$updateGroupLabel(sourceControlHandle: number, groupHandle: number, label: string): Promise<void>;
$updateResourceState(sourceControlHandle: number, groupHandle: number, resources: SourceControlResourceState[]): Promise<void>;
$unregisterGroup(sourceControlHandle: number, groupHandle: number): Promise<void>;
$registerGroups(sourceControlHandle: number, groups: ScmRawResourceGroup[], splices: ScmRawResourceSplices[]): void;
$updateGroup(sourceControlHandle: number, groupHandle: number, features: SourceControlGroupFeatures): void;
$updateGroupLabel(sourceControlHandle: number, groupHandle: number, label: string): void;
$unregisterGroup(sourceControlHandle: number, groupHandle: number): void;

$setInputBoxValue(sourceControlHandle: number, value: string): Promise<void>;
$setInputBoxPlaceholder(sourceControlHandle: number, placeholder: string): Promise<void>;
$spliceResourceStates(sourceControlHandle: number, splices: ScmRawResourceSplices[]): void;

$setInputBoxValue(sourceControlHandle: number, value: string): void;
$setInputBoxPlaceholder(sourceControlHandle: number, placeholder: string): void;
}

export interface SourceControlProviderFeatures {
Expand All @@ -788,6 +790,35 @@ export interface SourceControlGroupFeatures {
hideWhenEmpty: boolean | undefined;
}

export interface ScmRawResource {
handle: number,
sourceUri: UriComponents,
icons: UriComponents[],
tooltip: string,
strikeThrough: boolean,
faded: boolean,
contextValue: string,
command: Command | undefined
}

export interface ScmRawResourceGroup {
handle: number,
id: string,
label: string,
features: SourceControlGroupFeatures
}

export interface ScmRawResourceSplice {
start: number,
deleteCount: number,
rawResources: ScmRawResource[]
}

export interface ScmRawResourceSplices {
handle: number,
splices: ScmRawResourceSplice[]
}

export interface SourceControlResourceState {
readonly handle: number
/**
Expand Down
Loading