More adoption, improve deprecated messages

This commit is contained in:
Daniel Imms 2024-04-03 06:40:22 -07:00
parent f93eb1c974
commit 21cf21eb43
No known key found for this signature in database
GPG key ID: E5CF412B63651C69
4 changed files with 16 additions and 15 deletions

View file

@ -11,7 +11,6 @@ import { IActionViewItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { IContextViewProvider } from 'vs/base/browser/ui/contextview/contextview';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { IHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate';
import { setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { ISelectBoxOptions, ISelectBoxStyles, ISelectOptionItem, SelectBox } from 'vs/base/browser/ui/selectBox/selectBox';
import { IToggleStyles } from 'vs/base/browser/ui/toggle/toggle';
import { Action, ActionRunner, IAction, IActionChangeEvent, IActionRunner, Separator } from 'vs/base/common/actions';
@ -21,6 +20,7 @@ import * as types from 'vs/base/common/types';
import 'vs/css!./actionbar';
import * as nls from 'vs/nls';
import type { IUpdatableHover } from 'vs/base/browser/ui/hover/hover';
import { getBaseLayerHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate2';
export interface IBaseActionViewItemOptions {
draggable?: boolean;
@ -233,7 +233,7 @@ export class BaseActionViewItem extends Disposable implements IActionViewItem {
} else {
if (!this.customHover && title !== '') {
const hoverDelegate = this.options.hoverDelegate ?? getDefaultHoverDelegate('element');
this.customHover = this._store.add(setupCustomHover(hoverDelegate, this.element, title));
this.customHover = this._store.add(getBaseLayerHoverDelegate().setupUpdatableHover(hoverDelegate, this.element, title));
} else if (this.customHover) {
this.customHover.update(title);
}

View file

@ -16,17 +16,12 @@ let hoverDelegateFactory: (placement: 'mouse' | 'element', enableInstantHover: b
const defaultHoverDelegateMouse = new Lazy<IHoverDelegate>(() => hoverDelegateFactory('mouse', false));
const defaultHoverDelegateElement = new Lazy<IHoverDelegate>(() => hoverDelegateFactory('element', false));
/**
* @deprecated Use `setBaseLayerHoverDelegate` instead.
*/
// TODO: Remove when getDefaultHoverDelegate is no longer used
export function setHoverDelegateFactory(hoverDelegateProvider: ((placement: 'mouse' | 'element', enableInstantHover: boolean) => IScopedHoverDelegate)): void {
hoverDelegateFactory = hoverDelegateProvider;
}
/**
* @deprecated If in the `base/` layer use `getBaseLayerHoverDelegate` instead, if in `platform/`
* and higher use `IHoverService.setupUpdatableHover` instead.
*/
// TODO: Refine type for use in new IHoverService interface
export function getDefaultHoverDelegate(placement: 'mouse' | 'element'): IHoverDelegate {
if (placement === 'element') {
return defaultHoverDelegateElement.value;

View file

@ -132,7 +132,8 @@ function getHoverTargetElement(element: HTMLElement, stopElement?: HTMLElement):
}
/**
* @deprecated Use `IHoverService.createUpdatableHover` instead.
* @deprecated If in the `base/` layer use `getBaseLayerHoverDelegate.setupUpdatableHover` instead,
* if in `platform/` and higher use `IHoverService.setupUpdatableHover` instead.
*/
export function setupCustomHover(hoverDelegate: IHoverDelegate, htmlElement: HTMLElement, content: IUpdatableHoverContentOrFactory, options?: IUpdatableHoverOptions): IUpdatableHover {
htmlElement.setAttribute('custom-hover', 'true');

View file

@ -10,7 +10,6 @@ import { ActionBar, IActionViewItem } from 'vs/base/browser/ui/actionbar/actionb
import { Button } from 'vs/base/browser/ui/button/button';
import type { IUpdatableHover } from 'vs/base/browser/ui/hover/hover';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { renderLabelWithIcons } from 'vs/base/browser/ui/iconLabel/iconLabels';
import { IIdentityProvider, IKeyboardNavigationLabelProvider, IListVirtualDelegate } from 'vs/base/browser/ui/list/list';
import { DefaultKeyboardNavigationDelegate, IListAccessibilityProvider } from 'vs/base/browser/ui/list/listWidget';
@ -37,6 +36,7 @@ import { ICommandService } from 'vs/platform/commands/common/commands';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IHoverService } from 'vs/platform/hover/browser/hover';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IOpenerService } from 'vs/platform/opener/common/opener';
@ -466,6 +466,7 @@ class ResultSummaryView extends Disposable {
@ITestingContinuousRunService private readonly crService: ITestingContinuousRunService,
@IConfigurationService configurationService: IConfigurationService,
@IInstantiationService instantiationService: IInstantiationService,
@IHoverService hoverService: IHoverService,
) {
super();
@ -478,7 +479,7 @@ class ResultSummaryView extends Disposable {
}
}));
this.countHover = this._register(setupCustomHover(getDefaultHoverDelegate('mouse'), this.elements.count, ''));
this.countHover = this._register(hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), this.elements.count, ''));
const ab = this._register(new ActionBar(this.elements.rerun, {
actionViewItemProvider: (action, options) => createActionViewItem(instantiationService, action, options),
@ -1317,7 +1318,10 @@ class ErrorRenderer implements ITreeRenderer<TestTreeErrorMessage, FuzzyScore, I
private readonly renderer: MarkdownRenderer;
constructor(@IInstantiationService instantionService: IInstantiationService) {
constructor(
@IHoverService private readonly hoverService: IHoverService,
@IInstantiationService instantionService: IInstantiationService,
) {
this.renderer = instantionService.createInstance(MarkdownRenderer, {});
}
@ -1339,7 +1343,7 @@ class ErrorRenderer implements ITreeRenderer<TestTreeErrorMessage, FuzzyScore, I
const result = this.renderer.render(element.message, { inline: true });
data.label.appendChild(result.element);
}
data.disposable.add(setupCustomHover(getDefaultHoverDelegate('mouse'), data.label, element.description));
data.disposable.add(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), data.label, element.description));
}
disposeTemplate(data: IErrorTemplateData): void {
@ -1369,6 +1373,7 @@ class TestItemRenderer extends Disposable
@IContextKeyService private readonly contextKeyService: IContextKeyService,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@ITestingContinuousRunService private readonly crService: ITestingContinuousRunService,
@IHoverService private readonly hoverService: IHoverService,
) {
super();
}
@ -1459,7 +1464,7 @@ class TestItemRenderer extends Disposable
data.icon.className += ' retired';
}
data.elementDisposable.add(setupCustomHover(getDefaultHoverDelegate('mouse'), data.label, getLabelForTestTreeElement(node.element)));
data.elementDisposable.add(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), data.label, getLabelForTestTreeElement(node.element)));
if (node.element.test.item.label.trim()) {
dom.reset(data.label, ...renderLabelWithIcons(node.element.test.item.label));
} else {