Convert EditorAction.supported usages to _precondition usages
This commit is contained in:
parent
d76757fa9e
commit
c54515ad4c
|
@ -457,7 +457,7 @@ export class DefineKeybindingAction extends EditorAction {
|
|||
true
|
||||
);
|
||||
|
||||
this._precondition = KbExpr.and(EditorContextKeys.TextFocus, EditorContextKeys.Writable);
|
||||
this._precondition = KbExpr.and(EditorContextKeys.TextFocus, EditorContextKeys.Writable, EditorContextKeys.LanguageId.isEqualTo('json'));
|
||||
|
||||
this.kbOpts = {
|
||||
kbExpr: EditorContextKeys.Focus,
|
||||
|
@ -465,14 +465,10 @@ export class DefineKeybindingAction extends EditorAction {
|
|||
};
|
||||
}
|
||||
|
||||
public supported(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): boolean {
|
||||
if (!super.supported(accessor, editor)) {
|
||||
return false;
|
||||
}
|
||||
return isInterestingEditorModel(editor);
|
||||
}
|
||||
|
||||
public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): void {
|
||||
if (!isInterestingEditorModel(editor)) {
|
||||
return;
|
||||
}
|
||||
var controller = DefineKeybindingController.get(editor);
|
||||
controller.launch();
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import {TPromise} from 'vs/base/common/winjs.base';
|
|||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import {KbExpr} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {ServicesAccessor, EditorAction, CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions';
|
||||
import {DocumentFormattingEditProviderRegistry, DocumentRangeFormattingEditProviderRegistry, OnTypeFormattingEditProviderRegistry} from 'vs/editor/common/modes';
|
||||
import {OnTypeFormattingEditProviderRegistry} from 'vs/editor/common/modes';
|
||||
import {getOnTypeFormattingEdits, getDocumentFormattingEdits, getDocumentRangeFormattingEdits} from '../common/format';
|
||||
import {EditOperationsCommand} from './formatCommand';
|
||||
import {Selection} from 'vs/editor/common/core/selection';
|
||||
|
@ -145,7 +145,7 @@ export class FormatAction extends EditorAction {
|
|||
true
|
||||
);
|
||||
|
||||
this._precondition = KbExpr.and(EditorContextKeys.TextFocus, EditorContextKeys.Writable);
|
||||
this._precondition = KbExpr.and(EditorContextKeys.TextFocus, EditorContextKeys.Writable, ModeContextKeys.hasFormattingProvider);
|
||||
|
||||
this.kbOpts = {
|
||||
kbExpr: KbExpr.and(EditorContextKeys.TextFocus, EditorContextKeys.Writable),
|
||||
|
@ -160,16 +160,6 @@ export class FormatAction extends EditorAction {
|
|||
};
|
||||
}
|
||||
|
||||
public supported(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): boolean {
|
||||
if (!super.supported(accessor, editor)) {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
DocumentFormattingEditProviderRegistry.has(editor.getModel())
|
||||
|| DocumentRangeFormattingEditProviderRegistry.has(editor.getModel())
|
||||
);
|
||||
}
|
||||
|
||||
public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): TPromise<void> {
|
||||
|
||||
const model = editor.getModel();
|
||||
|
|
|
@ -31,6 +31,7 @@ import {ReferencesModel} from 'vs/editor/contrib/referenceSearch/browser/referen
|
|||
import {IDisposable, dispose} from 'vs/base/common/lifecycle';
|
||||
import {IPeekViewService} from 'vs/editor/contrib/zoneWidget/browser/peekViewWidget';
|
||||
import {optional} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {KbExpr} from 'vs/platform/keybinding/common/keybinding';
|
||||
|
||||
import ModeContextKeys = editorCommon.ModeContextKeys;
|
||||
import EditorContextKeys = editorCommon.EditorContextKeys;
|
||||
|
@ -55,20 +56,6 @@ export class DefinitionAction extends EditorAction {
|
|||
this._configuration = configuration;
|
||||
}
|
||||
|
||||
public supported(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): boolean {
|
||||
if (!super.supported(accessor, editor)) {
|
||||
return false;
|
||||
}
|
||||
return DefinitionProviderRegistry.has(editor.getModel());
|
||||
}
|
||||
|
||||
public enabled(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): boolean {
|
||||
if (!super.enabled(accessor, editor)) {
|
||||
return false;
|
||||
}
|
||||
return DefinitionProviderRegistry.has(editor.getModel());
|
||||
}
|
||||
|
||||
public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): TPromise<void> {
|
||||
const messageService = accessor.get(IMessageService);
|
||||
const editorService = accessor.get(IEditorService);
|
||||
|
@ -172,7 +159,7 @@ export class GoToDefinitionAction extends DefinitionAction {
|
|||
new DefinitionActionConfig()
|
||||
);
|
||||
|
||||
this._precondition = EditorContextKeys.TextFocus;
|
||||
this._precondition = KbExpr.and(EditorContextKeys.TextFocus, ModeContextKeys.hasDefinitionProvider);
|
||||
|
||||
this.kbOpts = {
|
||||
kbExpr: EditorContextKeys.TextFocus,
|
||||
|
@ -199,7 +186,7 @@ export class OpenDefinitionToSideAction extends DefinitionAction {
|
|||
new DefinitionActionConfig(true)
|
||||
);
|
||||
|
||||
this._precondition = EditorContextKeys.TextFocus;
|
||||
this._precondition = KbExpr.and(EditorContextKeys.TextFocus, ModeContextKeys.hasDefinitionProvider);
|
||||
|
||||
this.kbOpts = {
|
||||
kbExpr: EditorContextKeys.TextFocus,
|
||||
|
@ -218,7 +205,7 @@ export class PeekDefinitionAction extends DefinitionAction {
|
|||
new DefinitionActionConfig(void 0, true, false)
|
||||
);
|
||||
|
||||
this._precondition = EditorContextKeys.TextFocus;
|
||||
this._precondition = KbExpr.and(EditorContextKeys.TextFocus, ModeContextKeys.hasDefinitionProvider);
|
||||
|
||||
this.kbOpts = {
|
||||
kbExpr: EditorContextKeys.TextFocus,
|
||||
|
|
|
@ -8,12 +8,11 @@ import * as nls from 'vs/nls';
|
|||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import { dispose } from 'vs/base/common/lifecycle';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ICommonCodeEditor, IEditorContribution, EditorContextKeys } from 'vs/editor/common/editorCommon';
|
||||
import { ICommonCodeEditor, IEditorContribution, EditorContextKeys, ModeContextKeys } from 'vs/editor/common/editorCommon';
|
||||
import { KbExpr } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { ServicesAccessor, EditorAction, EditorCommand, CommonEditorRegistry } from 'vs/editor/common/editorCommonExtensions';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { EditorBrowserRegistry } from 'vs/editor/browser/editorBrowserExtensions';
|
||||
import { SignatureHelpProviderRegistry } from 'vs/editor/common/modes';
|
||||
import { ParameterHintsWidget } from './parameterHintsWidget';
|
||||
import { Context } from '../common/parameterHints';
|
||||
|
||||
|
@ -68,7 +67,7 @@ export class TriggerParameterHintsAction extends EditorAction {
|
|||
false
|
||||
);
|
||||
|
||||
this._precondition = EditorContextKeys.TextFocus;
|
||||
this._precondition = KbExpr.and(EditorContextKeys.TextFocus, ModeContextKeys.hasSignatureHelpProvider);
|
||||
|
||||
this.kbOpts = {
|
||||
kbExpr: EditorContextKeys.TextFocus,
|
||||
|
@ -76,13 +75,6 @@ export class TriggerParameterHintsAction extends EditorAction {
|
|||
};
|
||||
}
|
||||
|
||||
public supported(accessor:ServicesAccessor, editor:ICommonCodeEditor): boolean {
|
||||
if (!super.supported(accessor, editor)) {
|
||||
return false;
|
||||
}
|
||||
return SignatureHelpProviderRegistry.has(editor.getModel());
|
||||
}
|
||||
|
||||
public run(accessor:ServicesAccessor, editor:ICommonCodeEditor): void {
|
||||
ParameterHintsController.get(editor).trigger();
|
||||
}
|
||||
|
|
|
@ -13,10 +13,9 @@ import {KbExpr, KbCtxKey, IKeybindingContextKey, IKeybindingService} from 'vs/pl
|
|||
import {IMarkerService} from 'vs/platform/markers/common/markers';
|
||||
import {IMessageService} from 'vs/platform/message/common/message';
|
||||
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
||||
import {ICommonCodeEditor, EditorContextKeys, IEditorContribution, IRange} from 'vs/editor/common/editorCommon';
|
||||
import {ICommonCodeEditor, EditorContextKeys, ModeContextKeys, IEditorContribution, IRange} from 'vs/editor/common/editorCommon';
|
||||
import {ServicesAccessor, EditorAction, EditorCommand, CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions';
|
||||
import {ICodeEditor} from 'vs/editor/browser/editorBrowser';
|
||||
import {CodeActionProviderRegistry} from 'vs/editor/common/modes';
|
||||
import {EditorBrowserRegistry} from 'vs/editor/browser/editorBrowserExtensions';
|
||||
import {IQuickFix2} from '../common/quickFix';
|
||||
import {QuickFixModel} from './quickFixModel';
|
||||
|
@ -125,7 +124,7 @@ export class QuickFixAction extends EditorAction {
|
|||
true
|
||||
);
|
||||
|
||||
this._precondition = KbExpr.and(EditorContextKeys.TextFocus, EditorContextKeys.Writable);
|
||||
this._precondition = KbExpr.and(EditorContextKeys.TextFocus, EditorContextKeys.Writable, ModeContextKeys.hasCodeActionsProvider);
|
||||
|
||||
this.kbOpts = {
|
||||
kbExpr: EditorContextKeys.TextFocus,
|
||||
|
@ -133,13 +132,6 @@ export class QuickFixAction extends EditorAction {
|
|||
};
|
||||
}
|
||||
|
||||
public supported(accessor:ServicesAccessor, editor:ICommonCodeEditor): boolean {
|
||||
if (!super.supported(accessor, editor)) {
|
||||
return false;
|
||||
}
|
||||
return CodeActionProviderRegistry.has(editor.getModel());
|
||||
}
|
||||
|
||||
public run(accessor:ServicesAccessor, editor:ICommonCodeEditor): void {
|
||||
QuickFixController.getQuickFixController(editor).run();
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import {BaseEditorQuickOpenAction, IDecorator} from './editorQuickOpen';
|
|||
import {getDocumentSymbols, IOutline} from 'vs/editor/contrib/quickOpen/common/quickOpen';
|
||||
import {ServicesAccessor} from 'vs/editor/common/editorCommonExtensions';
|
||||
import {KeyCode, KeyMod} from 'vs/base/common/keyCodes';
|
||||
import {KbExpr} from 'vs/platform/keybinding/common/keybinding';
|
||||
|
||||
let SCOPE_PREFIX = ':';
|
||||
|
||||
|
@ -117,7 +118,7 @@ export class QuickOutlineAction extends BaseEditorQuickOpenAction {
|
|||
nls.localize('quickOutlineActionInput', "Type the name of an identifier you wish to navigate to")
|
||||
);
|
||||
|
||||
this._precondition = EditorContextKeys.Focus;
|
||||
this._precondition = KbExpr.and(EditorContextKeys.Focus, ModeContextKeys.hasDocumentSymbolProvider);
|
||||
|
||||
this.kbOpts = {
|
||||
kbExpr: EditorContextKeys.Focus,
|
||||
|
@ -131,14 +132,6 @@ export class QuickOutlineAction extends BaseEditorQuickOpenAction {
|
|||
};
|
||||
}
|
||||
|
||||
public supported(accessor:ServicesAccessor, editor:ICommonCodeEditor): boolean {
|
||||
if (!super.supported(accessor, editor)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return DocumentSymbolProviderRegistry.has(editor.getModel());
|
||||
}
|
||||
|
||||
public run(accessor:ServicesAccessor, editor:ICommonCodeEditor): TPromise<void> {
|
||||
|
||||
let model = editor.getModel();
|
||||
|
|
|
@ -65,7 +65,7 @@ export class ReferenceAction extends EditorAction {
|
|||
false
|
||||
);
|
||||
|
||||
this._precondition = EditorContextKeys.TextFocus;
|
||||
this._precondition = KbExpr.and(EditorContextKeys.TextFocus, ModeContextKeys.hasReferenceProvider);
|
||||
|
||||
this.kbOpts = {
|
||||
kbExpr: EditorContextKeys.TextFocus,
|
||||
|
@ -79,13 +79,6 @@ export class ReferenceAction extends EditorAction {
|
|||
};
|
||||
}
|
||||
|
||||
public supported(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): boolean {
|
||||
if (!super.supported(accessor, editor)) {
|
||||
return false;
|
||||
}
|
||||
return ReferenceProviderRegistry.has(editor.getModel());
|
||||
}
|
||||
|
||||
public enabled(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): boolean {
|
||||
if (!super.enabled(accessor, editor)) {
|
||||
return false;
|
||||
|
|
|
@ -156,7 +156,7 @@ export class RenameAction extends EditorAction {
|
|||
true
|
||||
);
|
||||
|
||||
this._precondition = KbExpr.and(EditorContextKeys.TextFocus, EditorContextKeys.Writable);
|
||||
this._precondition = KbExpr.and(EditorContextKeys.TextFocus, EditorContextKeys.Writable, ModeContextKeys.hasRenameProvider);
|
||||
|
||||
this.kbOpts = {
|
||||
kbExpr: EditorContextKeys.TextFocus,
|
||||
|
@ -170,13 +170,6 @@ export class RenameAction extends EditorAction {
|
|||
};
|
||||
}
|
||||
|
||||
public supported(accessor:ServicesAccessor, editor:ICommonCodeEditor): boolean {
|
||||
if (!super.supported(accessor, editor)) {
|
||||
return false;
|
||||
}
|
||||
return RenameProviderRegistry.has(editor.getModel()) && !editor.getModel().hasEditableRange();
|
||||
}
|
||||
|
||||
public enabled(accessor:ServicesAccessor, editor:ICommonCodeEditor): boolean {
|
||||
if (!super.enabled(accessor, editor)) {
|
||||
return false;
|
||||
|
|
|
@ -9,7 +9,7 @@ import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
|||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { KbExpr } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { ICommonCodeEditor, IEditorContribution, EditorContextKeys } from 'vs/editor/common/editorCommon';
|
||||
import { ICommonCodeEditor, IEditorContribution, EditorContextKeys, ModeContextKeys } from 'vs/editor/common/editorCommon';
|
||||
import { ServicesAccessor, EditorAction, EditorCommand, CommonEditorRegistry } from 'vs/editor/common/editorCommonExtensions';
|
||||
import { ISuggestSupport, SuggestRegistry } from 'vs/editor/common/modes';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
|
@ -177,7 +177,7 @@ export class TriggerSuggestAction extends EditorAction {
|
|||
true
|
||||
);
|
||||
|
||||
this._precondition = KbExpr.and(EditorContextKeys.TextFocus, EditorContextKeys.Writable);
|
||||
this._precondition = KbExpr.and(EditorContextKeys.TextFocus, EditorContextKeys.Writable, ModeContextKeys.hasCompletionItemProvider);
|
||||
|
||||
this.kbOpts = {
|
||||
kbExpr: EditorContextKeys.TextFocus,
|
||||
|
@ -186,13 +186,6 @@ export class TriggerSuggestAction extends EditorAction {
|
|||
};
|
||||
}
|
||||
|
||||
public supported(accessor:ServicesAccessor, editor:ICommonCodeEditor): boolean {
|
||||
if (!super.supported(accessor, editor)) {
|
||||
return false;
|
||||
}
|
||||
return SuggestRegistry.has(editor.getModel());
|
||||
}
|
||||
|
||||
public run(accessor:ServicesAccessor, editor:ICommonCodeEditor): void {
|
||||
SuggestController.getController(editor).triggerSuggest();
|
||||
}
|
||||
|
|
|
@ -639,15 +639,6 @@ export class RunToCursorAction extends EditorAction {
|
|||
debugService.continue(debugService.getViewModel().getFocusedThreadId());
|
||||
});
|
||||
}
|
||||
|
||||
public supported(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): boolean {
|
||||
if (!super.supported(accessor, editor)) {
|
||||
return false;
|
||||
}
|
||||
const debugService = accessor.get(IDebugService);
|
||||
|
||||
return debugService.state === debug.State.Stopped;
|
||||
}
|
||||
}
|
||||
|
||||
export class AddWatchExpressionAction extends AbstractDebugAction {
|
||||
|
@ -696,16 +687,6 @@ export class SelectionToReplAction extends EditorAction {
|
|||
.then(() => panelService.openPanel(debug.REPL_ID, true))
|
||||
.then(_ => void 0);
|
||||
}
|
||||
|
||||
public supported(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): boolean {
|
||||
if (!super.supported(accessor, editor)) {
|
||||
return false;
|
||||
}
|
||||
const debugService = accessor.get(IDebugService);
|
||||
|
||||
const selection = editor.getSelection();
|
||||
return !!selection && !selection.isEmpty() && debugService.state !== debug.State.Disabled && debugService.state !== debug.State.Inactive;
|
||||
}
|
||||
}
|
||||
|
||||
export class ShowDebugHoverAction extends EditorAction {
|
||||
|
|
Loading…
Reference in a new issue