ソースを参照

Refactors command & quickpick imports

main
Eric Amodio 7年前
コミット
dfd0f8c365
19個のファイルの変更135行の追加120行の削除
  1. +16
    -70
      src/commands.ts
  2. +71
    -0
      src/commands/commands.ts
  3. +2
    -2
      src/commands/copyMessageToClipboard.ts
  4. +2
    -2
      src/commands/copyShaToClipboard.ts
  5. +2
    -2
      src/commands/diffLineWithPrevious.ts
  6. +2
    -2
      src/commands/diffLineWithWorking.ts
  7. +2
    -2
      src/commands/diffWithPrevious.ts
  8. +2
    -2
      src/commands/diffWithWorking.ts
  9. +2
    -2
      src/commands/showBlame.ts
  10. +2
    -2
      src/commands/showBlameHistory.ts
  11. +2
    -2
      src/commands/showFileHistory.ts
  12. +4
    -4
      src/commands/showQuickCommitDetails.ts
  13. +3
    -3
      src/commands/showQuickFileHistory.ts
  14. +3
    -3
      src/commands/showQuickRepoHistory.ts
  15. +3
    -3
      src/commands/showQuickRepoStatus.ts
  16. +2
    -2
      src/commands/toggleBlame.ts
  17. +2
    -2
      src/commands/toggleCodeLens.ts
  18. +6
    -15
      src/extension.ts
  19. +7
    -0
      src/quickPicks.ts

+ 16
- 70
src/commands.ts ファイルの表示

@ -1,71 +1,17 @@
'use strict';
import { commands, Disposable, TextEditor, TextEditorEdit, window } from 'vscode';
export type Commands = 'gitlens.copyMessageToClipboard' | 'gitlens.copyShaToClipboard' | 'gitlens.diffWithPrevious' | 'gitlens.diffLineWithPrevious' | 'gitlens.diffWithWorking' | 'gitlens.diffLineWithWorking' | 'gitlens.showBlame' | 'gitlens.showBlameHistory' | 'gitlens.showFileHistory' | 'gitlens.showQuickCommitDetails' | 'gitlens.showQuickFileHistory' | 'gitlens.showQuickRepoHistory' | 'gitlens.showQuickRepoStatus' | 'gitlens.toggleBlame' | 'gitlens.toggleCodeLens';
export const Commands = {
CopyMessageToClipboard: 'gitlens.copyMessageToClipboard' as Commands,
CopyShaToClipboard: 'gitlens.copyShaToClipboard' as Commands,
DiffWithPrevious: 'gitlens.diffWithPrevious' as Commands,
DiffLineWithPrevious: 'gitlens.diffLineWithPrevious' as Commands,
DiffWithWorking: 'gitlens.diffWithWorking' as Commands,
DiffLineWithWorking: 'gitlens.diffLineWithWorking' as Commands,
ShowBlame: 'gitlens.showBlame' as Commands,
ShowBlameHistory: 'gitlens.showBlameHistory' as Commands,
ShowFileHistory: 'gitlens.showFileHistory' as Commands,
ShowQuickCommitDetails: 'gitlens.showQuickCommitDetails' as Commands,
ShowQuickFileHistory: 'gitlens.showQuickFileHistory' as Commands,
ShowQuickRepoHistory: 'gitlens.showQuickRepoHistory' as Commands,
ShowQuickRepoStatus: 'gitlens.showQuickRepoStatus' as Commands,
ToggleBlame: 'gitlens.toggleBlame' as Commands,
ToggleCodeLens: 'gitlens.toggleCodeLens' as Commands
};
export abstract class Command extends Disposable {
private _disposable: Disposable;
constructor(command: Commands) {
super(() => this.dispose());
this._disposable = commands.registerCommand(command, this.execute, this);
}
dispose() {
this._disposable && this._disposable.dispose();
}
abstract execute(...args: any[]): any;
}
export abstract class EditorCommand extends Disposable {
private _disposable: Disposable;
constructor(command: Commands) {
super(() => this.dispose());
this._disposable = commands.registerTextEditorCommand(command, this.execute, this);
}
dispose() {
this._disposable && this._disposable.dispose();
}
abstract execute(editor: TextEditor, edit: TextEditorEdit, ...args: any[]): any;
}
export abstract class ActiveEditorCommand extends Disposable {
private _disposable: Disposable;
constructor(command: Commands) {
super(() => this.dispose());
this._disposable = commands.registerCommand(command, this._execute, this);
}
dispose() {
this._disposable && this._disposable.dispose();
}
_execute(...args: any[]): any {
return this.execute(window.activeTextEditor, ...args);
}
abstract execute(editor: TextEditor, ...args: any[]): any;
}
export { ActiveEditorCommand, Command, Commands, EditorCommand } from './commands/commands';
export { CopyMessageToClipboardCommand } from './commands/copyMessageToClipboard';
export { CopyShaToClipboardCommand } from './commands/copyShaToClipboard';
export { DiffLineWithPreviousCommand } from './commands/diffLineWithPrevious';
export { DiffLineWithWorkingCommand } from './commands/diffLineWithWorking';
export { DiffWithPreviousCommand } from './commands/diffWithPrevious';
export { DiffWithWorkingCommand } from './commands/diffWithWorking';
export { ShowBlameCommand } from './commands/showBlame';
export { ShowBlameHistoryCommand } from './commands/showBlameHistory';
export { ShowFileHistoryCommand } from './commands/showFileHistory';
export { ShowQuickCommitDetailsCommand } from './commands/showQuickCommitDetails';
export { ShowQuickFileHistoryCommand } from './commands/showQuickFileHistory';
export { ShowQuickRepoHistoryCommand } from './commands/showQuickRepoHistory';
export { ShowQuickRepoStatusCommand } from './commands/showQuickRepoStatus';
export { ToggleBlameCommand } from './commands/toggleBlame';
export { ToggleCodeLensCommand } from './commands/toggleCodeLens';

+ 71
- 0
src/commands/commands.ts ファイルの表示

@ -0,0 +1,71 @@
'use strict';
import { commands, Disposable, TextEditor, TextEditorEdit, window } from 'vscode';
export type Commands = 'gitlens.copyMessageToClipboard' | 'gitlens.copyShaToClipboard' | 'gitlens.diffWithPrevious' | 'gitlens.diffLineWithPrevious' | 'gitlens.diffWithWorking' | 'gitlens.diffLineWithWorking' | 'gitlens.showBlame' | 'gitlens.showBlameHistory' | 'gitlens.showFileHistory' | 'gitlens.showQuickCommitDetails' | 'gitlens.showQuickFileHistory' | 'gitlens.showQuickRepoHistory' | 'gitlens.showQuickRepoStatus' | 'gitlens.toggleBlame' | 'gitlens.toggleCodeLens';
export const Commands = {
CopyMessageToClipboard: 'gitlens.copyMessageToClipboard' as Commands,
CopyShaToClipboard: 'gitlens.copyShaToClipboard' as Commands,
DiffWithPrevious: 'gitlens.diffWithPrevious' as Commands,
DiffLineWithPrevious: 'gitlens.diffLineWithPrevious' as Commands,
DiffWithWorking: 'gitlens.diffWithWorking' as Commands,
DiffLineWithWorking: 'gitlens.diffLineWithWorking' as Commands,
ShowBlame: 'gitlens.showBlame' as Commands,
ShowBlameHistory: 'gitlens.showBlameHistory' as Commands,
ShowFileHistory: 'gitlens.showFileHistory' as Commands,
ShowQuickCommitDetails: 'gitlens.showQuickCommitDetails' as Commands,
ShowQuickFileHistory: 'gitlens.showQuickFileHistory' as Commands,
ShowQuickRepoHistory: 'gitlens.showQuickRepoHistory' as Commands,
ShowQuickRepoStatus: 'gitlens.showQuickRepoStatus' as Commands,
ToggleBlame: 'gitlens.toggleBlame' as Commands,
ToggleCodeLens: 'gitlens.toggleCodeLens' as Commands
};
export abstract class Command extends Disposable {
private _disposable: Disposable;
constructor(command: Commands) {
super(() => this.dispose());
this._disposable = commands.registerCommand(command, this.execute, this);
}
dispose() {
this._disposable && this._disposable.dispose();
}
abstract execute(...args: any[]): any;
}
export abstract class EditorCommand extends Disposable {
private _disposable: Disposable;
constructor(command: Commands) {
super(() => this.dispose());
this._disposable = commands.registerTextEditorCommand(command, this.execute, this);
}
dispose() {
this._disposable && this._disposable.dispose();
}
abstract execute(editor: TextEditor, edit: TextEditorEdit, ...args: any[]): any;
}
export abstract class ActiveEditorCommand extends Disposable {
private _disposable: Disposable;
constructor(command: Commands) {
super(() => this.dispose());
this._disposable = commands.registerCommand(command, this._execute, this);
}
dispose() {
this._disposable && this._disposable.dispose();
}
_execute(...args: any[]): any {
return this.execute(window.activeTextEditor, ...args);
}
abstract execute(editor: TextEditor, ...args: any[]): any;
}

+ 2
- 2
src/commands/copyMessageToClipboard.ts ファイルの表示

@ -1,12 +1,12 @@
'use strict';
import { Iterables } from '../system';
import { TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands } from '../commands';
import { ActiveEditorCommand, Commands } from './commands';
import GitProvider, { GitUri } from '../gitProvider';
import { Logger } from '../logger';
import { copy } from 'copy-paste';
export default class CopyMessageToClipboardCommand extends ActiveEditorCommand {
export class CopyMessageToClipboardCommand extends ActiveEditorCommand {
constructor(private git: GitProvider, public repoPath: string) {
super(Commands.CopyMessageToClipboard);

+ 2
- 2
src/commands/copyShaToClipboard.ts ファイルの表示

@ -1,12 +1,12 @@
'use strict';
import { Iterables } from '../system';
import { TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands } from '../commands';
import { ActiveEditorCommand, Commands } from './commands';
import GitProvider, { GitUri } from '../gitProvider';
import { Logger } from '../logger';
import { copy } from 'copy-paste';
export default class CopyShaToClipboardCommand extends ActiveEditorCommand {
export class CopyShaToClipboardCommand extends ActiveEditorCommand {
constructor(private git: GitProvider, public repoPath: string) {
super(Commands.CopyShaToClipboard);

+ 2
- 2
src/commands/diffLineWithPrevious.ts ファイルの表示

@ -1,12 +1,12 @@
'use strict';
import { commands, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import { Commands, EditorCommand } from '../commands';
import { Commands, EditorCommand } from './commands';
import { BuiltInCommands } from '../constants';
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
import { Logger } from '../logger';
import * as path from 'path';
export default class DiffLineWithPreviousCommand extends EditorCommand {
export class DiffLineWithPreviousCommand extends EditorCommand {
constructor(private git: GitProvider) {
super(Commands.DiffLineWithPrevious);

+ 2
- 2
src/commands/diffLineWithWorking.ts ファイルの表示

@ -1,10 +1,10 @@
'use strict';
import { commands, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import { Commands, EditorCommand } from '../commands';
import { Commands, EditorCommand } from './commands';
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
import { Logger } from '../logger';
export default class DiffLineWithWorkingCommand extends EditorCommand {
export class DiffLineWithWorkingCommand extends EditorCommand {
constructor(private git: GitProvider) {
super(Commands.DiffLineWithWorking);

+ 2
- 2
src/commands/diffWithPrevious.ts ファイルの表示

@ -1,14 +1,14 @@
'use strict';
import { Iterables } from '../system';
import { commands, Range, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import { Commands, EditorCommand } from '../commands';
import { Commands, EditorCommand } from './commands';
import { BuiltInCommands } from '../constants';
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
import { Logger } from '../logger';
import * as moment from 'moment';
import * as path from 'path';
export default class DiffWithPreviousCommand extends EditorCommand {
export class DiffWithPreviousCommand extends EditorCommand {
constructor(private git: GitProvider) {
super(Commands.DiffWithPrevious);

+ 2
- 2
src/commands/diffWithWorking.ts ファイルの表示

@ -1,13 +1,13 @@
'use strict';
import { Iterables } from '../system';
import { commands, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import { Commands, EditorCommand } from '../commands';
import { Commands, EditorCommand } from './commands';
import { BuiltInCommands } from '../constants';
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
import { Logger } from '../logger';
import * as path from 'path';
export default class DiffWithWorkingCommand extends EditorCommand {
export class DiffWithWorkingCommand extends EditorCommand {
constructor(private git: GitProvider) {
super(Commands.DiffWithWorking);

+ 2
- 2
src/commands/showBlame.ts ファイルの表示

@ -1,10 +1,10 @@
'use strict';
import { TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import BlameAnnotationController from '../blameAnnotationController';
import { Commands, EditorCommand } from '../commands';
import { Commands, EditorCommand } from './commands';
import { Logger } from '../logger';
export default class ShowBlameCommand extends EditorCommand {
export class ShowBlameCommand extends EditorCommand {
constructor(private annotationController: BlameAnnotationController) {
super(Commands.ShowBlame);

+ 2
- 2
src/commands/showBlameHistory.ts ファイルの表示

@ -1,11 +1,11 @@
'use strict';
import { commands, Position, Range, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import { Commands, EditorCommand } from '../commands';
import { Commands, EditorCommand } from './commands';
import { BuiltInCommands } from '../constants';
import GitProvider, { GitUri } from '../gitProvider';
import { Logger } from '../logger';
export default class ShowBlameHistoryCommand extends EditorCommand {
export class ShowBlameHistoryCommand extends EditorCommand {
constructor(private git: GitProvider) {
super(Commands.ShowBlameHistory);

+ 2
- 2
src/commands/showFileHistory.ts ファイルの表示

@ -1,11 +1,11 @@
'use strict';
import { commands, Position, Range, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import { Commands, EditorCommand } from '../commands';
import { Commands, EditorCommand } from './commands';
import { BuiltInCommands } from '../constants';
import GitProvider, { GitUri } from '../gitProvider';
import { Logger } from '../logger';
export default class ShowFileHistoryCommand extends EditorCommand {
export class ShowFileHistoryCommand extends EditorCommand {
constructor(private git: GitProvider) {
super(Commands.ShowFileHistory);

+ 4
- 4
src/commands/showQuickCommitDetails.ts ファイルの表示

@ -1,12 +1,12 @@
'use strict';
import { Iterables } from '../system';
import { commands, TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands } from '../commands';
import { ActiveEditorCommand, Commands } from './commands';
import GitProvider, { GitCommit, GitLogCommit, GitUri } from '../gitProvider';
import { Logger } from '../logger';
import { CommandQuickPickItem, CommitFileDetailsQuickPick, CommitDetailsQuickPick, CommitWithFileStatusQuickPickItem } from '../quickPicks/commitDetails';
import { CommandQuickPickItem, CommitFileDetailsQuickPick, CommitDetailsQuickPick, CommitWithFileStatusQuickPickItem } from '../quickPicks';
export default class ShowQuickCommitDetailsCommand extends ActiveEditorCommand {
export class ShowQuickCommitDetailsCommand extends ActiveEditorCommand {
constructor(private git: GitProvider) {
super(Commands.ShowQuickCommitDetails);
@ -56,7 +56,7 @@ export default class ShowQuickCommitDetailsCommand extends ActiveEditorCommand {
pick = await CommitDetailsQuickPick.show(commit as GitLogCommit, uri, goBackCommand);
if (!pick) return undefined;
if (pick instanceof CommandQuickPickItem) {
if (!(pick instanceof CommitWithFileStatusQuickPickItem)) {
return pick.execute();
}

+ 3
- 3
src/commands/showQuickFileHistory.ts ファイルの表示

@ -1,11 +1,11 @@
'use strict';
import { commands, TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands } from '../commands';
import { ActiveEditorCommand, Commands } from './commands';
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
import { Logger } from '../logger';
import { CommandQuickPickItem, FileHistoryQuickPick } from '../quickPicks/fileHistory';
import { CommandQuickPickItem, FileHistoryQuickPick } from '../quickPicks';
export default class ShowQuickFileHistoryCommand extends ActiveEditorCommand {
export class ShowQuickFileHistoryCommand extends ActiveEditorCommand {
constructor(private git: GitProvider) {
super(Commands.ShowQuickFileHistory);

+ 3
- 3
src/commands/showQuickRepoHistory.ts ファイルの表示

@ -1,11 +1,11 @@
'use strict';
import { commands, TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands } from '../commands';
import { ActiveEditorCommand, Commands } from './commands';
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
import { Logger } from '../logger';
import { CommandQuickPickItem, RepoHistoryQuickPick } from '../quickPicks/repoHistory';
import { CommandQuickPickItem, RepoHistoryQuickPick } from '../quickPicks';
export default class ShowQuickRepoHistoryCommand extends ActiveEditorCommand {
export class ShowQuickRepoHistoryCommand extends ActiveEditorCommand {
constructor(private git: GitProvider, public repoPath: string) {
super(Commands.ShowQuickRepoHistory);

+ 3
- 3
src/commands/showQuickRepoStatus.ts ファイルの表示

@ -1,11 +1,11 @@
'use strict';
import { TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands } from '../commands';
import { ActiveEditorCommand, Commands } from './commands';
import GitProvider, { GitUri } from '../gitProvider';
import { Logger } from '../logger';
import { CommandQuickPickItem, RepoStatusQuickPick } from '../quickPicks/repoStatus';
import { CommandQuickPickItem, RepoStatusQuickPick } from '../quickPicks';
export default class ShowQuickRepoStatusCommand extends ActiveEditorCommand {
export class ShowQuickRepoStatusCommand extends ActiveEditorCommand {
constructor(private git: GitProvider, public repoPath: string) {
super(Commands.ShowQuickRepoStatus);

+ 2
- 2
src/commands/toggleBlame.ts ファイルの表示

@ -1,10 +1,10 @@
'use strict';
import { TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import BlameAnnotationController from '../blameAnnotationController';
import { Commands, EditorCommand } from '../commands';
import { Commands, EditorCommand } from './commands';
import { Logger } from '../logger';
export default class ToggleBlameCommand extends EditorCommand {
export class ToggleBlameCommand extends EditorCommand {
constructor(private annotationController: BlameAnnotationController) {
super(Commands.ToggleBlame);

+ 2
- 2
src/commands/toggleCodeLens.ts ファイルの表示

@ -1,9 +1,9 @@
'use strict';
import { TextEditor, TextEditorEdit } from 'vscode';
import { Commands, EditorCommand } from '../commands';
import { Commands, EditorCommand } from './commands';
import GitProvider from '../gitProvider';
export default class ToggleCodeLensCommand extends EditorCommand {
export class ToggleCodeLensCommand extends EditorCommand {
constructor(private git: GitProvider) {
super(Commands.ToggleCodeLens);

+ 6
- 15
src/extension.ts ファイルの表示

@ -3,21 +3,12 @@ import { commands, ExtensionContext, languages, window, workspace } from 'vscode
import BlameActiveLineController from './blameActiveLineController';
import BlameAnnotationController from './blameAnnotationController';
import { configureCssCharacters } from './blameAnnotationFormatter';
import CopyMessageToClipboardCommand from './commands/copyMessageToClipboard';
import CopyShaToClipboardCommand from './commands/copyShaToClipboard';
import DiffLineWithPreviousCommand from './commands/diffLineWithPrevious';
import DiffLineWithWorkingCommand from './commands/diffLineWithWorking';
import DiffWithPreviousCommand from './commands/diffWithPrevious';
import DiffWithWorkingCommand from './commands/diffWithWorking';
import ShowBlameCommand from './commands/showBlame';
import ShowBlameHistoryCommand from './commands/showBlameHistory';
import ShowFileHistoryCommand from './commands/showFileHistory';
import ShowQuickCommitDetailsCommand from './commands/showQuickCommitDetails';
import ShowQuickFileHistoryCommand from './commands/showQuickFileHistory';
import ShowQuickRepoHistoryCommand from './commands/showQuickRepoHistory';
import ShowQuickRepoStatusCommand from './commands/showQuickRepoStatus';
import ToggleBlameCommand from './commands/toggleBlame';
import ToggleCodeLensCommand from './commands/toggleCodeLens';
import { CopyMessageToClipboardCommand, CopyShaToClipboardCommand } from './commands';
import { DiffLineWithPreviousCommand, DiffLineWithWorkingCommand, DiffWithPreviousCommand, DiffWithWorkingCommand} from './commands';
import { ShowBlameCommand, ToggleBlameCommand } from './commands';
import { ShowBlameHistoryCommand, ShowFileHistoryCommand } from './commands';
import { ShowQuickCommitDetailsCommand, ShowQuickFileHistoryCommand, ShowQuickRepoHistoryCommand, ShowQuickRepoStatusCommand} from './commands';
import { ToggleCodeLensCommand } from './commands';
import { IAdvancedConfig, IBlameConfig } from './configuration';
import { BuiltInCommands, WorkspaceState } from './constants';
import GitContentProvider from './gitContentProvider';

+ 7
- 0
src/quickPicks.ts ファイルの表示

@ -0,0 +1,7 @@
'use strict';
export { CommandQuickPickItem, OpenFileCommandQuickPickItem, OpenFilesCommandQuickPickItem } from './quickPicks/quickPicks';
export { CommitQuickPickItem, CommitWithFileStatusQuickPickItem } from './quickPicks/gitQuickPicks';
export { OpenCommitFileCommandQuickPickItem, OpenCommitFilesCommandQuickPickItem, CommitDetailsQuickPick, CommitFileDetailsQuickPick } from './quickPicks/commitDetails';
export { FileHistoryQuickPick } from './quickPicks/fileHistory';
export { RepoHistoryQuickPick } from './quickPicks/repoHistory';
export { OpenStatusFileCommandQuickPickItem, OpenStatusFilesCommandQuickPickItem, RepoStatusQuickPick } from './quickPicks/repoStatus';

読み込み中…
キャンセル
保存