mirror of
https://github.com/microsoft/vscode.git
synced 2026-08-28 23:58:23 +01:00
Move more marker specific logic to markerHoverParticipant
This commit is contained in:
@@ -22,11 +22,10 @@ import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegis
|
||||
import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||
import { editorHoverBackground, editorHoverBorder, editorHoverHighlight, textCodeBlockBackground, textLinkForeground, editorHoverStatusBarBackground, editorHoverForeground } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||
import { IMarkerDecorationsService } from 'vs/editor/common/services/markersDecorationService';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility';
|
||||
import { GotoDefinitionAtPositionEditorContribution } from 'vs/editor/contrib/gotoSymbol/link/goToDefinitionAtPosition';
|
||||
import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
export class ModesHoverController implements IEditorContribution {
|
||||
|
||||
@@ -64,10 +63,9 @@ export class ModesHoverController implements IEditorContribution {
|
||||
}
|
||||
|
||||
constructor(private readonly _editor: ICodeEditor,
|
||||
@IInstantiationService private readonly _instantiationService: IInstantiationService,
|
||||
@IOpenerService private readonly _openerService: IOpenerService,
|
||||
@IModeService private readonly _modeService: IModeService,
|
||||
@IMarkerDecorationsService private readonly _markerDecorationsService: IMarkerDecorationsService,
|
||||
@IKeybindingService private readonly _keybindingService: IKeybindingService,
|
||||
@IThemeService private readonly _themeService: IThemeService,
|
||||
@IContextKeyService _contextKeyService: IContextKeyService
|
||||
) {
|
||||
@@ -233,7 +231,7 @@ export class ModesHoverController implements IEditorContribution {
|
||||
}
|
||||
|
||||
private _createHoverWidgets() {
|
||||
this._contentWidget.value = new ModesContentHoverWidget(this._editor, this._hoverVisibleKey, this._markerDecorationsService, this._keybindingService, this._themeService, this._modeService, this._openerService);
|
||||
this._contentWidget.value = new ModesContentHoverWidget(this._editor, this._hoverVisibleKey, this._instantiationService, this._themeService, this._modeService, this._openerService);
|
||||
this._glyphWidget.value = new ModesGlyphHoverWidget(this._editor, this._modeService, this._openerService);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,14 +7,14 @@ import * as nls from 'vs/nls';
|
||||
import * as dom from 'vs/base/browser/dom';
|
||||
import { IDisposable, toDisposable, DisposableStore, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { IRange, Range } from 'vs/editor/common/core/range';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { CodeActionTriggerType } from 'vs/editor/common/modes';
|
||||
import { isNonEmptyArray } from 'vs/base/common/arrays';
|
||||
import { IMarker, IMarkerData, MarkerSeverity } from 'vs/platform/markers/common/markers';
|
||||
import { basename } from 'vs/base/common/resources';
|
||||
import { IMarkerDecorationsService } from 'vs/editor/common/services/markersDecorationService';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { IOpenerService, NullOpenerService } from 'vs/platform/opener/common/opener';
|
||||
import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||
import { MarkerController, NextMarkerAction } from 'vs/editor/contrib/gotoError/gotoError';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { CancelablePromise, createCancelablePromise, disposableTimeout } from 'vs/base/common/async';
|
||||
@@ -26,15 +26,22 @@ import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
import { Progress } from 'vs/platform/progress/common/progress';
|
||||
import { ITextEditorOptions } from 'vs/platform/editor/common/editor';
|
||||
import { renderHoverAction } from 'vs/base/browser/ui/hover/hoverWidget';
|
||||
import { IEditorHover, IEditorHoverParticipant } from 'vs/editor/contrib/hover/modesContentHover';
|
||||
import { HoverPart, IEditorHover, IEditorHoverParticipant, IHoverPart } from 'vs/editor/contrib/hover/modesContentHover';
|
||||
|
||||
const $ = dom.$;
|
||||
|
||||
export class MarkerHover {
|
||||
export class MarkerHover implements IHoverPart {
|
||||
constructor(
|
||||
public readonly range: IRange,
|
||||
public readonly range: Range,
|
||||
public readonly marker: IMarker,
|
||||
) { }
|
||||
|
||||
public equals(other: IHoverPart | HoverPart): boolean {
|
||||
if (other instanceof MarkerHover) {
|
||||
return IMarkerData.makeKey(this.marker) === IMarkerData.makeKey(other.marker);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const markerCodeActionTrigger: CodeActionTrigger = {
|
||||
@@ -49,9 +56,9 @@ export class MarkerHoverParticipant implements IEditorHoverParticipant<MarkerHov
|
||||
constructor(
|
||||
private readonly _editor: ICodeEditor,
|
||||
private readonly _hover: IEditorHover,
|
||||
private readonly _markerDecorationsService: IMarkerDecorationsService,
|
||||
private readonly _keybindingService: IKeybindingService,
|
||||
private readonly _openerService: IOpenerService = NullOpenerService,
|
||||
@IMarkerDecorationsService private readonly _markerDecorationsService: IMarkerDecorationsService,
|
||||
@IKeybindingService private readonly _keybindingService: IKeybindingService,
|
||||
@IOpenerService private readonly _openerService: IOpenerService,
|
||||
) {
|
||||
}
|
||||
|
||||
|
||||
@@ -23,10 +23,7 @@ import { HoverOperation, HoverStartMode, IHoverComputer } from 'vs/editor/contri
|
||||
import { MarkdownRenderer } from 'vs/editor/browser/core/markdownRenderer';
|
||||
import { IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||
import { coalesce, asArray } from 'vs/base/common/arrays';
|
||||
import { IMarkerData } from 'vs/platform/markers/common/markers';
|
||||
import { IMarkerDecorationsService } from 'vs/editor/common/services/markersDecorationService';
|
||||
import { IOpenerService, NullOpenerService } from 'vs/platform/opener/common/opener';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { IIdentifiedSingleEditOperation, IModelDecoration, ITextModel, TrackedRangeStickiness } from 'vs/editor/common/model';
|
||||
import { ConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
@@ -38,9 +35,15 @@ import { Widget } from 'vs/base/browser/ui/widget';
|
||||
import { KeyCode } from 'vs/base/common/keyCodes';
|
||||
import { HoverWidget } from 'vs/base/browser/ui/hover/hoverWidget';
|
||||
import { MarkerHover, MarkerHoverParticipant } from 'vs/editor/contrib/hover/markerHoverParticipant';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
const $ = dom.$;
|
||||
|
||||
export interface IHoverPart {
|
||||
readonly range: Range;
|
||||
equals(other: IHoverPart | HoverPart): boolean;
|
||||
}
|
||||
|
||||
export interface IEditorHover {
|
||||
hide(): void;
|
||||
}
|
||||
@@ -59,7 +62,7 @@ class ColorHover {
|
||||
) { }
|
||||
}
|
||||
|
||||
type HoverPart = MarkdownHover | ColorHover | MarkerHover;
|
||||
export type HoverPart = MarkdownHover | ColorHover | MarkerHover;
|
||||
|
||||
class ModesContentComputer implements IHoverComputer<HoverPart[]> {
|
||||
|
||||
@@ -227,15 +230,14 @@ export class ModesContentHoverWidget extends Widget implements IContentWidget {
|
||||
constructor(
|
||||
editor: ICodeEditor,
|
||||
private readonly _hoverVisibleKey: IContextKey<boolean>,
|
||||
markerDecorationsService: IMarkerDecorationsService,
|
||||
private readonly _keybindingService: IKeybindingService,
|
||||
instantiationService: IInstantiationService,
|
||||
private readonly _themeService: IThemeService,
|
||||
private readonly _modeService: IModeService,
|
||||
private readonly _openerService: IOpenerService = NullOpenerService,
|
||||
) {
|
||||
super();
|
||||
|
||||
this._markerHoverParticipant = new MarkerHoverParticipant(editor, this, markerDecorationsService, this._keybindingService, this._openerService);
|
||||
this._markerHoverParticipant = instantiationService.createInstance(MarkerHoverParticipant, editor, this);
|
||||
|
||||
this._hover = this._register(new HoverWidget());
|
||||
this._id = ModesContentHoverWidget.ID;
|
||||
@@ -644,16 +646,15 @@ function hoverContentsEquals(first: HoverPart[], second: HoverPart[]): boolean {
|
||||
for (let i = 0; i < first.length; i++) {
|
||||
const firstElement = first[i];
|
||||
const secondElement = second[i];
|
||||
if (firstElement instanceof MarkerHover && secondElement instanceof MarkerHover) {
|
||||
return IMarkerData.makeKey(firstElement.marker) === IMarkerData.makeKey(secondElement.marker);
|
||||
}
|
||||
if (firstElement instanceof ColorHover || secondElement instanceof ColorHover) {
|
||||
if (firstElement instanceof MarkerHover) {
|
||||
if (!firstElement.equals(secondElement)) {
|
||||
return false;
|
||||
}
|
||||
} else if (firstElement instanceof ColorHover || secondElement instanceof ColorHover) {
|
||||
return false;
|
||||
}
|
||||
if (firstElement instanceof MarkerHover || secondElement instanceof MarkerHover) {
|
||||
} else if (firstElement instanceof MarkerHover || secondElement instanceof MarkerHover) {
|
||||
return false;
|
||||
}
|
||||
if (!markedStringsEquals(firstElement.contents, secondElement.contents)) {
|
||||
} else if (!markedStringsEquals(firstElement.contents, secondElement.contents)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user