提交 86757168 编写于 作者: A Alex Dima

Remove usages of @commonEditorContribution (#37212)

上级 6217946d
......@@ -225,7 +225,7 @@ export function registerEditorCommand<T extends EditorCommand>(editorCommand: T)
return editorCommand;
}
export function commonEditorContribution(ctor: ICommonEditorContributionCtor): void {
export function registerCommonEditorContribution(ctor: ICommonEditorContributionCtor): void {
EditorContributionRegistry.INSTANCE.registerEditorContribution(ctor);
}
......
......@@ -13,7 +13,7 @@ import { Position } from 'vs/editor/common/core/position';
import { Selection } from 'vs/editor/common/core/selection';
import { RunOnceScheduler } from 'vs/base/common/async';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { registerEditorAction, commonEditorContribution, ServicesAccessor, EditorAction } from 'vs/editor/common/editorCommonExtensions';
import { registerEditorAction, registerCommonEditorContribution, ServicesAccessor, EditorAction } from 'vs/editor/common/editorCommonExtensions';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { editorBracketMatchBackground, editorBracketMatchBorder } from 'vs/editor/common/view/editorColorRegistry';
......@@ -54,7 +54,6 @@ class BracketsData {
}
}
@commonEditorContribution
export class BracketMatchingController extends Disposable implements editorCommon.IEditorContribution {
private static ID = 'editor.contrib.bracketMatchingController';
......@@ -225,6 +224,7 @@ export class BracketMatchingController extends Disposable implements editorCommo
}
}
registerCommonEditorContribution(BracketMatchingController);
registerEditorAction(new SelectBracketAction());
registerThemingParticipant((theme, collector) => {
let bracketMatchBackground = theme.getColor(editorBracketMatchBackground);
......
......@@ -11,7 +11,7 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { TPromise } from 'vs/base/common/winjs.base';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { registerEditorAction, ServicesAccessor, EditorAction, commonEditorContribution, IActionOptions } from 'vs/editor/common/editorCommonExtensions';
import { registerEditorAction, ServicesAccessor, EditorAction, registerCommonEditorContribution, IActionOptions } from 'vs/editor/common/editorCommonExtensions';
import { OnTypeFormattingEditProviderRegistry, DocumentRangeFormattingEditProviderRegistry } from 'vs/editor/common/modes';
import { getOnTypeFormattingEdits, getDocumentFormattingEdits, getDocumentRangeFormattingEdits, NoProviderError } from '../common/format';
import { EditOperationsCommand } from '../common/formatCommand';
......@@ -53,8 +53,6 @@ function alertFormattingEdits(edits: editorCommon.ISingleEditOperation[]): void
}
}
@commonEditorContribution
// @ts-ignore @editorAction uses the class
class FormatOnType implements editorCommon.IEditorContribution {
private static ID = 'editor.contrib.autoFormat';
......@@ -180,8 +178,6 @@ class FormatOnType implements editorCommon.IEditorContribution {
}
}
@commonEditorContribution
// @ts-ignore @editorAction uses the class
class FormatOnPaste implements editorCommon.IEditorContribution {
private static ID = 'editor.contrib.formatOnPaste';
......@@ -356,6 +352,8 @@ export class FormatSelectionAction extends AbstractFormatAction {
}
}
registerCommonEditorContribution(FormatOnType);
registerCommonEditorContribution(FormatOnPaste);
registerEditorAction(new FormatDocumentAction());
registerEditorAction(new FormatSelectionAction());
......
......@@ -11,7 +11,7 @@ import { Range } from 'vs/editor/common/core/range';
import { Selection } from 'vs/editor/common/core/selection';
import { IEditorContribution, ICommonCodeEditor, IModelDecorationsChangeAccessor } from 'vs/editor/common/editorCommon';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { registerEditorAction, ServicesAccessor, EditorAction, commonEditorContribution } from 'vs/editor/common/editorCommonExtensions';
import { registerEditorAction, ServicesAccessor, EditorAction, registerCommonEditorContribution } from 'vs/editor/common/editorCommonExtensions';
import { IInplaceReplaceSupportResult } from 'vs/editor/common/modes';
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
import { InPlaceReplaceCommand } from './inPlaceReplaceCommand';
......@@ -20,7 +20,6 @@ import { registerThemingParticipant } from 'vs/platform/theme/common/themeServic
import { editorBracketMatchBorder } from 'vs/editor/common/view/editorColorRegistry';
import { ModelDecorationOptions } from 'vs/editor/common/model/textModelWithDecorations';
@commonEditorContribution
class InPlaceReplaceController implements IEditorContribution {
private static ID = 'editor.contrib.inPlaceReplaceController';
......@@ -186,6 +185,7 @@ class InPlaceReplaceDown extends EditorAction {
}
}
registerCommonEditorContribution(InPlaceReplaceController);
registerEditorAction(new InPlaceReplaceUp());
registerEditorAction(new InPlaceReplaceDown());
......
......@@ -9,7 +9,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
import * as strings from 'vs/base/common/strings';
import { ICommonCodeEditor, IEditorContribution, IIdentifiedSingleEditOperation, ICommand, ICursorStateComputerData, IEditOperationBuilder, ITokenizedModel, EndOfLineSequence } from 'vs/editor/common/editorCommon';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { registerEditorAction, ServicesAccessor, IActionOptions, EditorAction, commonEditorContribution } from 'vs/editor/common/editorCommonExtensions';
import { registerEditorAction, ServicesAccessor, IActionOptions, EditorAction, registerCommonEditorContribution } from 'vs/editor/common/editorCommonExtensions';
import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen';
import { IModelService } from 'vs/editor/common/services/modelService';
import { Range } from 'vs/editor/common/core/range';
......@@ -376,7 +376,6 @@ export class AutoIndentOnPasteCommand implements ICommand {
}
}
@commonEditorContribution
export class AutoIndentOnPaste implements IEditorContribution {
private static ID = 'editor.contrib.autoIndentOnPaste';
......@@ -616,6 +615,7 @@ export class IndentationToTabsCommand implements ICommand {
}
}
registerCommonEditorContribution(AutoIndentOnPaste);
registerEditorAction(new IndentationToSpacesAction());
registerEditorAction(new IndentationToTabsAction());
registerEditorAction(new IndentUsingTabs());
......
......@@ -12,14 +12,13 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { alert } from 'vs/base/browser/ui/aria/aria';
import { Range } from 'vs/editor/common/core/range';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { commonEditorContribution, CommonEditorRegistry, EditorCommand } from 'vs/editor/common/editorCommonExtensions';
import { registerCommonEditorContribution, CommonEditorRegistry, EditorCommand } from 'vs/editor/common/editorCommonExtensions';
import { ICodeEditor, IContentWidget, IContentWidgetPosition, ContentWidgetPositionPreference } from 'vs/editor/browser/editorBrowser';
import { IContextKeyService, RawContextKey, IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { IPosition } from 'vs/editor/common/core/position';
import { registerThemingParticipant, HIGH_CONTRAST } from 'vs/platform/theme/common/themeService';
import { inputValidationInfoBorder, inputValidationInfoBackground } from 'vs/platform/theme/common/colorRegistry';
@commonEditorContribution
export class MessageController {
private static _id = 'editor.contrib.messageController';
......@@ -174,6 +173,8 @@ class MessageWidget implements IContentWidget {
}
}
registerCommonEditorContribution(MessageController);
registerThemingParticipant((theme, collector) => {
let border = theme.getColor(inputValidationInfoBorder);
if (border) {
......
......@@ -10,7 +10,7 @@ import { KeyCode, KeyMod, KeyChord } from 'vs/base/common/keyCodes';
import { RunOnceScheduler } from 'vs/base/common/async';
import { ICommonCodeEditor, ScrollType, IEditorContribution, FindMatch, TrackedRangeStickiness, OverviewRulerLane, IModel } from 'vs/editor/common/editorCommon';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { registerEditorAction, commonEditorContribution, ServicesAccessor, EditorAction } from 'vs/editor/common/editorCommonExtensions';
import { registerEditorAction, registerCommonEditorContribution, ServicesAccessor, EditorAction } from 'vs/editor/common/editorCommonExtensions';
import { Range } from 'vs/editor/common/core/range';
import { Selection } from 'vs/editor/common/core/selection';
import { CursorChangeReason, ICursorSelectionChangedEvent } from 'vs/editor/common/controller/cursorEvents';
......@@ -300,7 +300,6 @@ export class MultiCursorSession {
}
}
@commonEditorContribution
export class MultiCursorSelectionController extends Disposable implements IEditorContribution {
private static ID = 'editor.contrib.multiCursorController';
......@@ -653,7 +652,6 @@ class SelectionHighlighterState {
}
}
@commonEditorContribution
export class SelectionHighlighter extends Disposable implements IEditorContribution {
private static ID = 'editor.contrib.selectionHighlighter';
......@@ -902,6 +900,9 @@ function getValueInRange(model: IModel, range: Range, toLowerCase: boolean): str
return (toLowerCase ? text.toLowerCase() : text);
}
registerCommonEditorContribution(MultiCursorSelectionController);
registerCommonEditorContribution(SelectionHighlighter);
registerEditorAction(new InsertCursorAbove());
registerEditorAction(new InsertCursorBelow());
registerEditorAction(new InsertCursorAtEndOfEachLineSelected());
......
......@@ -15,7 +15,7 @@ import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRe
import { Position, IPosition } from 'vs/editor/common/core/position';
import { Range } from 'vs/editor/common/core/range';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { registerEditorAction, ServicesAccessor, EditorAction, CommonEditorRegistry, commonEditorContribution } from 'vs/editor/common/editorCommonExtensions';
import { registerEditorAction, ServicesAccessor, EditorAction, CommonEditorRegistry, registerCommonEditorContribution } from 'vs/editor/common/editorCommonExtensions';
import { Location, ReferenceProviderRegistry } from 'vs/editor/common/modes';
import { PeekContext, getOuterEditor } from './peekViewWidget';
import { ReferencesController, RequestOptions, ctxReferenceSearchVisible } from './referencesController';
......@@ -31,7 +31,6 @@ const defaultReferenceSearchOptions: RequestOptions = {
}
};
@commonEditorContribution
export class ReferenceController implements editorCommon.IEditorContribution {
private static ID = 'editor.contrib.referenceController';
......@@ -87,6 +86,8 @@ export class ReferenceAction extends EditorAction {
}
}
registerCommonEditorContribution(ReferenceController);
registerEditorAction(new ReferenceAction());
let findReferencesCommand: ICommandHandler = (accessor: ServicesAccessor, resource: URI, position: IPosition) => {
......
......@@ -12,7 +12,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { Range } from 'vs/editor/common/core/range';
import { ICommonCodeEditor, IEditorContribution } from 'vs/editor/common/editorCommon';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { registerEditorAction, ServicesAccessor, IActionOptions, EditorAction, commonEditorContribution } from 'vs/editor/common/editorCommonExtensions';
import { registerEditorAction, ServicesAccessor, IActionOptions, EditorAction, registerCommonEditorContribution } from 'vs/editor/common/editorCommonExtensions';
import { TokenSelectionSupport, ILogicalSelectionEntry } from './tokenSelectionSupport';
import { ICursorPositionChangedEvent } from 'vs/editor/common/controller/cursorEvents';
......@@ -39,7 +39,6 @@ var ignoreSelection = false;
// -- action implementation
@commonEditorContribution
class SmartSelectController implements IEditorContribution {
private static ID = 'editor.contrib.smartSelectController';
......@@ -195,5 +194,6 @@ class ShrinkSelectionAction extends AbstractSmartSelect {
}
}
registerCommonEditorContribution(SmartSelectController);
registerEditorAction(new GrowSelectionAction());
registerEditorAction(new ShrinkSelectionAction());
......@@ -7,7 +7,7 @@
import { RawContextKey, IContextKey, IContextKeyService, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { ICommonCodeEditor } from 'vs/editor/common/editorCommon';
import { commonEditorContribution, CommonEditorRegistry, EditorCommand } from 'vs/editor/common/editorCommonExtensions';
import { registerCommonEditorContribution, CommonEditorRegistry, EditorCommand } from 'vs/editor/common/editorCommonExtensions';
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
import { SnippetSession } from './snippetSession';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
......@@ -18,7 +18,6 @@ import { Selection } from 'vs/editor/common/core/selection';
import { Choice } from 'vs/editor/contrib/snippet/browser/snippetParser';
import { repeat } from 'vs/base/common/strings';
@commonEditorContribution
export class SnippetController2 {
static get(editor: ICommonCodeEditor): SnippetController2 {
......@@ -183,6 +182,8 @@ export class SnippetController2 {
}
registerCommonEditorContribution(SnippetController2);
const CommandCtor = EditorCommand.bindToContribution<SnippetController2>(SnippetController2.get);
CommonEditorRegistry.registerEditorCommand(new CommandCtor({
......
......@@ -11,7 +11,7 @@ import { onUnexpectedExternalError } from 'vs/base/common/errors';
import { TPromise } from 'vs/base/common/winjs.base';
import { Range } from 'vs/editor/common/core/range';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { CommonEditorRegistry, commonEditorContribution, EditorAction, IActionOptions, registerEditorAction } from 'vs/editor/common/editorCommonExtensions';
import { CommonEditorRegistry, registerCommonEditorContribution, EditorAction, IActionOptions, registerEditorAction } from 'vs/editor/common/editorCommonExtensions';
import { DocumentHighlight, DocumentHighlightKind, DocumentHighlightProviderRegistry } from 'vs/editor/common/modes';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { Position } from 'vs/editor/common/core/position';
......@@ -397,9 +397,6 @@ class WordHighlighter {
}
}
@commonEditorContribution
class WordHighlighterContribution implements editorCommon.IEditorContribution {
private static ID = 'editor.contrib.wordHighlighter';
......@@ -444,28 +441,6 @@ class WordHighlighterContribution implements editorCommon.IEditorContribution {
}
}
registerThemingParticipant((theme, collector) => {
let selectionHighlight = theme.getColor(editorSelectionHighlight);
if (selectionHighlight) {
collector.addRule(`.monaco-editor .focused .selectionHighlight { background-color: ${selectionHighlight}; }`);
collector.addRule(`.monaco-editor .selectionHighlight { background-color: ${selectionHighlight.transparent(0.5)}; }`);
}
let wordHighlight = theme.getColor(editorWordHighlight);
if (wordHighlight) {
collector.addRule(`.monaco-editor .wordHighlight { background-color: ${wordHighlight}; }`);
}
let wordHighlightStrong = theme.getColor(editorWordHighlightStrong);
if (wordHighlightStrong) {
collector.addRule(`.monaco-editor .wordHighlightStrong { background-color: ${wordHighlightStrong}; }`);
}
let hcOutline = theme.getColor(activeContrastBorder);
if (hcOutline) {
collector.addRule(`.monaco-editor .selectionHighlight { border: 1px dotted ${hcOutline}; box-sizing: border-box; }`);
collector.addRule(`.monaco-editor .wordHighlight { border: 1px dashed ${hcOutline}; box-sizing: border-box; }`);
collector.addRule(`.monaco-editor .wordHighlightStrong { border: 1px dashed ${hcOutline}; box-sizing: border-box; }`);
}
});
class WordHighlightNavigationAction extends EditorAction {
......@@ -520,5 +495,29 @@ class PrevWordHighlightAction extends WordHighlightNavigationAction {
}
}
registerCommonEditorContribution(WordHighlighterContribution);
registerEditorAction(new NextWordHighlightAction());
registerEditorAction(new PrevWordHighlightAction());
registerThemingParticipant((theme, collector) => {
let selectionHighlight = theme.getColor(editorSelectionHighlight);
if (selectionHighlight) {
collector.addRule(`.monaco-editor .focused .selectionHighlight { background-color: ${selectionHighlight}; }`);
collector.addRule(`.monaco-editor .selectionHighlight { background-color: ${selectionHighlight.transparent(0.5)}; }`);
}
let wordHighlight = theme.getColor(editorWordHighlight);
if (wordHighlight) {
collector.addRule(`.monaco-editor .wordHighlight { background-color: ${wordHighlight}; }`);
}
let wordHighlightStrong = theme.getColor(editorWordHighlightStrong);
if (wordHighlightStrong) {
collector.addRule(`.monaco-editor .wordHighlightStrong { background-color: ${wordHighlightStrong}; }`);
}
let hcOutline = theme.getColor(activeContrastBorder);
if (hcOutline) {
collector.addRule(`.monaco-editor .selectionHighlight { border: 1px dotted ${hcOutline}; box-sizing: border-box; }`);
collector.addRule(`.monaco-editor .wordHighlight { border: 1px dashed ${hcOutline}; box-sizing: border-box; }`);
collector.addRule(`.monaco-editor .wordHighlightStrong { border: 1px dashed ${hcOutline}; box-sizing: border-box; }`);
}
});
......@@ -8,7 +8,7 @@ import 'vs/css!./media/codeEditor';
import * as nls from 'vs/nls';
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { ICommonCodeEditor, IEditorContribution, IModel } from 'vs/editor/common/editorCommon';
import { registerEditorAction, ServicesAccessor, EditorAction, commonEditorContribution } from 'vs/editor/common/editorCommonExtensions';
import { registerEditorAction, ServicesAccessor, EditorAction, registerCommonEditorContribution } from 'vs/editor/common/editorCommonExtensions';
import { ICodeEditorService } from 'vs/editor/common/services/codeEditorService';
import { MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
......@@ -173,8 +173,6 @@ class ToggleWordWrapAction extends EditorAction {
}
}
@commonEditorContribution
// @ts-ignore @editorAction uses the class
class ToggleWordWrapController extends Disposable implements IEditorContribution {
private static _ID = 'editor.contrib.toggleWordWrapController';
......@@ -250,6 +248,9 @@ function canToggleWordWrap(uri: URI): boolean {
return (uri.scheme !== 'output' && uri.scheme !== 'vscode');
}
registerCommonEditorContribution(ToggleWordWrapController);
registerEditorAction(new ToggleWordWrapAction());
MenuRegistry.appendMenuItem(MenuId.EditorTitle, {
......
......@@ -16,14 +16,13 @@ import { endsWith } from 'vs/base/common/strings';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { Range } from 'vs/editor/common/core/range';
import { CommonEditorRegistry, commonEditorContribution, EditorCommand } from 'vs/editor/common/editorCommonExtensions';
import { CommonEditorRegistry, registerCommonEditorContribution, EditorCommand } from 'vs/editor/common/editorCommonExtensions';
import { SnippetController2 } from 'vs/editor/contrib/snippet/browser/snippetController2';
import { showSimpleSuggestions } from 'vs/editor/contrib/suggest/browser/suggest';
import { IConfigurationRegistry, Extensions as ConfigExt } from 'vs/platform/configuration/common/configurationRegistry';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
@commonEditorContribution
export class TabCompletionController implements editorCommon.IEditorContribution {
private static ID = 'editor.tabCompletionController';
......@@ -132,6 +131,8 @@ export class TabCompletionController implements editorCommon.IEditorContribution
}
}
registerCommonEditorContribution(TabCompletionController);
const TabCompletionCommand = EditorCommand.bindToContribution<TabCompletionController>(TabCompletionController.get);
CommonEditorRegistry.registerEditorCommand(new TabCompletionCommand({
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册