Browse Source

Moves Commands into commands file

main
Eric Amodio 7 years ago
parent
commit
a2f4c4c953
20 changed files with 95 additions and 102 deletions
  1. +71
    -0
      src/commands.ts
  2. +0
    -53
      src/commands/commands.ts
  3. +1
    -2
      src/commands/copyMessageToClipboard.ts
  4. +1
    -2
      src/commands/copyShaToClipboard.ts
  5. +2
    -2
      src/commands/diffLineWithPrevious.ts
  6. +1
    -2
      src/commands/diffLineWithWorking.ts
  7. +2
    -2
      src/commands/diffWithPrevious.ts
  8. +2
    -2
      src/commands/diffWithWorking.ts
  9. +1
    -2
      src/commands/showBlame.ts
  10. +2
    -2
      src/commands/showBlameHistory.ts
  11. +2
    -2
      src/commands/showFileHistory.ts
  12. +1
    -2
      src/commands/showQuickCommitDetails.ts
  13. +1
    -2
      src/commands/showQuickFileHistory.ts
  14. +1
    -2
      src/commands/showQuickRepoHistory.ts
  15. +1
    -2
      src/commands/toggleBlame.ts
  16. +1
    -2
      src/commands/toggleCodeLens.ts
  17. +1
    -1
      src/configuration.ts
  18. +0
    -18
      src/constants.ts
  19. +2
    -1
      src/gitCodeLensProvider.ts
  20. +2
    -1
      src/gitRevisionCodeLensProvider.ts

+ 71
- 0
src/commands.ts View File

@ -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;
}

+ 0
- 53
src/commands/commands.ts View File

@ -1,53 +0,0 @@
'use strict';
import { commands, Disposable, TextEditor, TextEditorEdit, window } from 'vscode';
import { Commands } from '../constants';
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;
}

+ 1
- 2
src/commands/copyMessageToClipboard.ts View File

@ -1,8 +1,7 @@
'use strict';
import { Iterables } from '../system';
import { TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand } from './commands';
import { Commands } from '../constants';
import { ActiveEditorCommand, Commands } from '../commands';
import GitProvider, { GitUri } from '../gitProvider';
import { Logger } from '../logger';
import { copy } from 'copy-paste';

+ 1
- 2
src/commands/copyShaToClipboard.ts View File

@ -1,8 +1,7 @@
'use strict';
import { Iterables } from '../system';
import { TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand } from './commands';
import { Commands } from '../constants';
import { ActiveEditorCommand, Commands } from '../commands';
import GitProvider, { GitUri } from '../gitProvider';
import { Logger } from '../logger';
import { copy } from 'copy-paste';

+ 2
- 2
src/commands/diffLineWithPrevious.ts View File

@ -1,7 +1,7 @@
'use strict';
import { commands, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import { EditorCommand } from './commands';
import { BuiltInCommands, Commands } from '../constants';
import { Commands, EditorCommand } from '../commands';
import { BuiltInCommands } from '../constants';
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
import { Logger } from '../logger';
import * as path from 'path';

+ 1
- 2
src/commands/diffLineWithWorking.ts View File

@ -1,7 +1,6 @@
'use strict';
import { commands, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import { EditorCommand } from './commands';
import { Commands } from '../constants';
import { Commands, EditorCommand } from '../commands';
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
import { Logger } from '../logger';

+ 2
- 2
src/commands/diffWithPrevious.ts View File

@ -1,8 +1,8 @@
'use strict';
import { Iterables } from '../system';
import { commands, Range, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import { EditorCommand } from './commands';
import { BuiltInCommands, Commands } from '../constants';
import { Commands, EditorCommand } from '../commands';
import { BuiltInCommands } from '../constants';
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
import { Logger } from '../logger';
import * as moment from 'moment';

+ 2
- 2
src/commands/diffWithWorking.ts View File

@ -1,8 +1,8 @@
'use strict';
import { Iterables } from '../system';
import { commands, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import { EditorCommand } from './commands';
import { BuiltInCommands, Commands } from '../constants';
import { Commands, EditorCommand } from '../commands';
import { BuiltInCommands } from '../constants';
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
import { Logger } from '../logger';
import * as path from 'path';

+ 1
- 2
src/commands/showBlame.ts View File

@ -1,8 +1,7 @@
'use strict';
import { TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import BlameAnnotationController from '../blameAnnotationController';
import { EditorCommand } from './commands';
import { Commands } from '../constants';
import { Commands, EditorCommand } from '../commands';
import { Logger } from '../logger';
export default class ShowBlameCommand extends EditorCommand {

+ 2
- 2
src/commands/showBlameHistory.ts View File

@ -1,7 +1,7 @@
'use strict';
import { commands, Position, Range, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import { EditorCommand } from './commands';
import { BuiltInCommands, Commands } from '../constants';
import { Commands, EditorCommand } from '../commands';
import { BuiltInCommands } from '../constants';
import GitProvider, { GitUri } from '../gitProvider';
import { Logger } from '../logger';

+ 2
- 2
src/commands/showFileHistory.ts View File

@ -1,7 +1,7 @@
'use strict';
import { commands, Position, Range, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import { EditorCommand } from './commands';
import { BuiltInCommands, Commands } from '../constants';
import { Commands, EditorCommand } from '../commands';
import { BuiltInCommands } from '../constants';
import GitProvider, { GitUri } from '../gitProvider';
import { Logger } from '../logger';

+ 1
- 2
src/commands/showQuickCommitDetails.ts View File

@ -1,8 +1,7 @@
'use strict';
import { Iterables } from '../system';
import { commands, TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand } from './commands';
import { Commands } from '../constants';
import { ActiveEditorCommand, Commands } from '../commands';
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
import { Logger } from '../logger';
import { CommandQuickPickItem, FileQuickPickItem } from './quickPickItems';

+ 1
- 2
src/commands/showQuickFileHistory.ts View File

@ -1,7 +1,6 @@
'use strict';
import { commands, TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand } from './commands';
import { Commands } from '../constants';
import { ActiveEditorCommand, Commands } from '../commands';
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
import { Logger } from '../logger';
import { CommandQuickPickItem } from './quickPickItems';

+ 1
- 2
src/commands/showQuickRepoHistory.ts View File

@ -1,7 +1,6 @@
'use strict';
import { commands, TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand } from './commands';
import { Commands } from '../constants';
import { ActiveEditorCommand, Commands } from '../commands';
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
import { Logger } from '../logger';
import { CommandQuickPickItem } from './quickPickItems';

+ 1
- 2
src/commands/toggleBlame.ts View File

@ -1,8 +1,7 @@
'use strict';
import { TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import BlameAnnotationController from '../blameAnnotationController';
import { EditorCommand } from './commands';
import { Commands } from '../constants';
import { Commands, EditorCommand } from '../commands';
import { Logger } from '../logger';
export default class ToggleBlameCommand extends EditorCommand {

+ 1
- 2
src/commands/toggleCodeLens.ts View File

@ -1,7 +1,6 @@
'use strict';
import { TextEditor, TextEditorEdit } from 'vscode';
import { EditorCommand } from './commands';
import { Commands } from '../constants';
import { Commands, EditorCommand } from '../commands';
import GitProvider from '../gitProvider';
export default class ToggleCodeLensCommand extends EditorCommand {

+ 1
- 1
src/configuration.ts View File

@ -1,5 +1,5 @@
'use strict';
import { Commands } from './constants';
import { Commands } from './commands';
export type BlameAnnotationStyle = 'compact' | 'expanded' | 'trailing';
export const BlameAnnotationStyle = {

+ 0
- 18
src/constants.ts View File

@ -16,24 +16,6 @@ export const BuiltInCommands = {
ToggleRenderWhitespace: 'editor.action.toggleRenderWhitespace' as BuiltInCommands
};
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.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,
ToggleBlame: 'gitlens.toggleBlame' as Commands,
ToggleCodeLens: 'gitlens.toggleCodeLens' as Commands
};
export type DocumentSchemes = 'file' | 'gitlens-git';
export const DocumentSchemes = {
File: 'file' as DocumentSchemes,

+ 2
- 1
src/gitCodeLensProvider.ts View File

@ -1,7 +1,8 @@
'use strict';
import { Functions, Iterables, Strings } from './system';
import { CancellationToken, CodeLens, CodeLensProvider, commands, DocumentSelector, Event, EventEmitter, ExtensionContext, Position, Range, SymbolInformation, SymbolKind, TextDocument, Uri, workspace } from 'vscode';
import { BuiltInCommands, Commands, DocumentSchemes } from './constants';
import { Commands } from './commands';
import { BuiltInCommands, DocumentSchemes } from './constants';
import { CodeLensCommand, CodeLensLocation, IConfig, ICodeLensLanguageLocation } from './configuration';
import GitProvider, { GitCommit, GitUri, IGitBlame, IGitBlameLines } from './gitProvider';
import { Logger } from './logger';

+ 2
- 1
src/gitRevisionCodeLensProvider.ts View File

@ -1,7 +1,8 @@
'use strict';
import { Iterables } from './system';
import { CancellationToken, CodeLens, CodeLensProvider, DocumentSelector, ExtensionContext, Range, TextDocument, Uri } from 'vscode';
import { Commands, DocumentSchemes } from './constants';
import { Commands } from './commands';
import { DocumentSchemes } from './constants';
import GitProvider, { GitCommit, GitUri } from './gitProvider';
export class GitDiffWithWorkingCodeLens extends CodeLens {

Loading…
Cancel
Save