提交 56087d67 编写于 作者: B Benjamin Pasero

debt - strict function

上级 32b28614
......@@ -53,7 +53,7 @@ export const QuickOpenItemAccessor = new QuickOpenItemAccessorClass();
export class QuickOpenEntry {
private id: string;
private labelHighlights: IHighlight[];
private labelHighlights?: IHighlight[];
private descriptionHighlights?: IHighlight[];
private detailHighlights?: IHighlight[];
private hidden: boolean | undefined;
......@@ -160,7 +160,7 @@ export class QuickOpenEntry {
/**
* Allows to set highlight ranges that should show up for the entry label and optionally description if set.
*/
setHighlights(labelHighlights: IHighlight[], descriptionHighlights?: IHighlight[], detailHighlights?: IHighlight[]): void {
setHighlights(labelHighlights?: IHighlight[], descriptionHighlights?: IHighlight[], detailHighlights?: IHighlight[]): void {
this.labelHighlights = labelHighlights;
this.descriptionHighlights = descriptionHighlights;
this.detailHighlights = detailHighlights;
......@@ -169,7 +169,7 @@ export class QuickOpenEntry {
/**
* Allows to return highlight ranges that should show up for the entry label and description.
*/
getHighlights(): [IHighlight[] /* Label */, IHighlight[] | undefined /* Description */, IHighlight[] | undefined /* Detail */] {
getHighlights(): [IHighlight[] | undefined /* Label */, IHighlight[] | undefined /* Description */, IHighlight[] | undefined /* Detail */] {
return [this.labelHighlights, this.descriptionHighlights, this.detailHighlights];
}
......@@ -260,7 +260,7 @@ export class QuickOpenEntryGroup extends QuickOpenEntry {
return this.entry;
}
getHighlights(): [IHighlight[], IHighlight[] | undefined, IHighlight[] | undefined] {
getHighlights(): [IHighlight[] | undefined, IHighlight[] | undefined, IHighlight[] | undefined] {
return this.entry ? this.entry.getHighlights() : super.getHighlights();
}
......@@ -268,7 +268,7 @@ export class QuickOpenEntryGroup extends QuickOpenEntry {
return this.entry ? this.entry.isHidden() : super.isHidden();
}
setHighlights(labelHighlights: IHighlight[], descriptionHighlights?: IHighlight[], detailHighlights?: IHighlight[]): void {
setHighlights(labelHighlights?: IHighlight[], descriptionHighlights?: IHighlight[], detailHighlights?: IHighlight[]): void {
this.entry ? this.entry.setHighlights(labelHighlights, descriptionHighlights, detailHighlights) : super.setHighlights(labelHighlights, descriptionHighlights, detailHighlights);
}
......
......@@ -163,15 +163,19 @@ export class GlobalActivityActionViewItem extends ActivityActionViewItem {
export class PlaceHolderViewletActivityAction extends ViewletActivityAction {
constructor(
id: string, name: string, iconUrl: URI,
id: string,
name: string,
iconUrl: URI | undefined,
@IViewletService viewletService: IViewletService,
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService,
@ITelemetryService telemetryService: ITelemetryService
) {
super({ id, name: id, cssClass: `extensionViewlet-placeholder-${id.replace(/\./g, '-')}` }, viewletService, layoutService, telemetryService);
const iconClass = `.monaco-workbench .activitybar .monaco-action-bar .action-label.${this.class}`; // Generate Placeholder CSS to show the icon in the activity bar
DOM.createCSSRule(iconClass, `-webkit-mask: ${DOM.asCSSUrl(iconUrl)} no-repeat 50% 50%; -webkit-mask-size: 24px;`);
if (iconUrl) {
const iconClass = `.monaco-workbench .activitybar .monaco-action-bar .action-label.${this.class}`; // Generate Placeholder CSS to show the icon in the activity bar
DOM.createCSSRule(iconClass, `-webkit-mask: ${DOM.asCSSUrl(iconUrl)} no-repeat 50% 50%; -webkit-mask-size: 24px;`);
}
}
setActivity(activity: IActivity): void {
......
......@@ -110,7 +110,7 @@ export class ActivitybarPart extends Part implements IActivityBarService {
openComposite: (compositeId: string) => this.viewletService.openViewlet(compositeId, true),
getActivityAction: (compositeId: string) => this.getCompositeActions(compositeId).activityAction,
getCompositePinnedAction: (compositeId: string) => this.getCompositeActions(compositeId).pinnedAction,
getOnCompositeClickAction: (compositeId: string) => this.instantiationService.createInstance(ToggleViewletAction, this.viewletService.getViewlet(compositeId)),
getOnCompositeClickAction: (compositeId: string) => this.instantiationService.createInstance(ToggleViewletAction, assertIsDefined(this.viewletService.getViewlet(compositeId))),
getContextMenuActions: () => [this.instantiationService.createInstance(ToggleActivityBarVisibilityAction, ToggleActivityBarVisibilityAction.ID, nls.localize('hideActivitBar', "Hide Activity Bar"))],
getDefaultCompositeId: () => this.viewletService.getDefaultViewletId(),
hidePart: () => this.layoutService.setSideBarHidden(true),
......
......@@ -439,7 +439,7 @@ export class CompositeActionViewItem extends ActivityActionViewItem {
constructor(
private compositeActivityAction: ActivityAction,
private toggleCompositePinnedAction: Action,
private contextMenuActionsProvider: () => Action[],
private contextMenuActionsProvider: () => ReadonlyArray<Action>,
colors: (theme: ITheme) => ICompositeBarColors,
icon: boolean,
private compositeBar: ICompositeBar,
......
......@@ -123,7 +123,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
openComposite: (compositeId: string) => Promise.resolve(this.openPanel(compositeId, true)),
getActivityAction: (compositeId: string) => this.getCompositeActions(compositeId).activityAction,
getCompositePinnedAction: (compositeId: string) => this.getCompositeActions(compositeId).pinnedAction,
getOnCompositeClickAction: (compositeId: string) => this.instantiationService.createInstance(PanelActivityAction, this.getPanel(compositeId)),
getOnCompositeClickAction: (compositeId: string) => this.instantiationService.createInstance(PanelActivityAction, assertIsDefined(this.getPanel(compositeId))),
getContextMenuActions: () => [
this.instantiationService.createInstance(TogglePanelPositionAction, TogglePanelPositionAction.ID, TogglePanelPositionAction.LABEL),
this.instantiationService.createInstance(TogglePanelAction, TogglePanelAction.ID, localize('hidePanel', "Hide Panel"))
......@@ -330,7 +330,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
let compositeActions = this.compositeActions.get(compositeId);
if (!compositeActions) {
compositeActions = {
activityAction: this.instantiationService.createInstance(PanelActivityAction, this.getPanel(compositeId)),
activityAction: this.instantiationService.createInstance(PanelActivityAction, assertIsDefined(this.getPanel(compositeId))),
pinnedAction: new ToggleCompositePinnedAction(this.getPanel(compositeId), this.compositeBar)
};
......
......@@ -3,9 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as nls from 'vs/nls';
import * as arrays from 'vs/base/common/arrays';
import * as types from 'vs/base/common/types';
import { localize } from 'vs/nls';
import { distinct } from 'vs/base/common/arrays';
import { withNullAsUndefined, isFunction } from 'vs/base/common/types';
import { Language } from 'vs/base/common/platform';
import { Action, WorkbenchActionExecutedEvent, WorkbenchActionExecutedClassification } from 'vs/base/common/actions';
import { Mode, IEntryRunContext, IAutoFocus, IModel, IQuickNavigateConfiguration } from 'vs/base/parts/quickopen/common/quickOpen';
......@@ -137,7 +137,7 @@ class CommandsHistory extends Disposable {
export class ShowAllCommandsAction extends Action {
static readonly ID = 'workbench.action.showCommands';
static readonly LABEL = nls.localize('showTriggerActions', "Show All Commands");
static readonly LABEL = localize('showTriggerActions', "Show All Commands");
constructor(
id: string,
......@@ -167,7 +167,7 @@ export class ShowAllCommandsAction extends Action {
export class ClearCommandHistoryAction extends Action {
static readonly ID = 'workbench.action.clearCommandHistory';
static readonly LABEL = nls.localize('clearCommandHistory', "Clear Command History");
static readonly LABEL = localize('clearCommandHistory', "Clear Command History");
constructor(
id: string,
......@@ -196,7 +196,7 @@ class CommandPaletteEditorAction extends EditorAction {
constructor() {
super({
id: ShowAllCommandsAction.ID,
label: nls.localize('showCommands.label', "Command Palette..."),
label: localize('showCommands.label', "Command Palette..."),
alias: 'Command Palette',
precondition: undefined,
menuOpts: {
......@@ -224,10 +224,10 @@ abstract class BaseCommandEntry extends QuickOpenEntryGroup {
constructor(
private commandId: string,
private keybinding: ResolvedKeybinding,
private keybinding: ResolvedKeybinding | undefined,
private label: string,
alias: string,
highlights: { label: IHighlight[], alias?: IHighlight[] },
alias: string | undefined,
highlights: { label: IHighlight[] | null, alias: IHighlight[] | null },
private onBeforeRun: (commandId: string) => void,
@INotificationService private readonly notificationService: INotificationService,
@ITelemetryService protected telemetryService: ITelemetryService
......@@ -240,10 +240,10 @@ abstract class BaseCommandEntry extends QuickOpenEntryGroup {
if (this.label !== alias) {
this.alias = alias;
} else {
highlights.alias = undefined;
highlights.alias = null;
}
this.setHighlights(highlights.label, undefined, highlights.alias);
this.setHighlights(withNullAsUndefined(highlights.label), undefined, withNullAsUndefined(highlights.alias));
}
getCommandId(): string {
......@@ -266,7 +266,7 @@ abstract class BaseCommandEntry extends QuickOpenEntryGroup {
this.description = description;
}
getKeybinding(): ResolvedKeybinding {
getKeybinding(): ResolvedKeybinding | undefined {
return this.keybinding;
}
......@@ -276,10 +276,10 @@ abstract class BaseCommandEntry extends QuickOpenEntryGroup {
getAriaLabel(): string {
if (this.keybindingAriaLabel) {
return nls.localize('entryAriaLabelWithKey', "{0}, {1}, commands", this.getLabel(), this.keybindingAriaLabel);
return localize('entryAriaLabelWithKey', "{0}, {1}, commands", this.getLabel(), this.keybindingAriaLabel);
}
return nls.localize('entryAriaLabel', "{0}, commands", this.getLabel());
return localize('entryAriaLabel', "{0}, commands", this.getLabel());
}
run(mode: Mode, context: IEntryRunContext): boolean {
......@@ -319,7 +319,7 @@ abstract class BaseCommandEntry extends QuickOpenEntryGroup {
this.onError(error);
}
} else {
this.notificationService.info(nls.localize('actionNotEnabled', "Command '{0}' is not enabled in the current context.", this.getLabel()));
this.notificationService.info(localize('actionNotEnabled', "Command '{0}' is not enabled in the current context.", this.getLabel()));
}
}, 50);
}
......@@ -329,7 +329,7 @@ abstract class BaseCommandEntry extends QuickOpenEntryGroup {
return;
}
this.notificationService.error(error || nls.localize('canNotRun', "Command '{0}' resulted in an error.", this.label));
this.notificationService.error(error || localize('canNotRun', "Command '{0}' resulted in an error.", this.label));
}
}
......@@ -337,10 +337,10 @@ class EditorActionCommandEntry extends BaseCommandEntry {
constructor(
commandId: string,
keybinding: ResolvedKeybinding,
keybinding: ResolvedKeybinding | undefined,
label: string,
meta: string,
highlights: { label: IHighlight[], alias: IHighlight[] },
meta: string | undefined,
highlights: { label: IHighlight[] | null, alias: IHighlight[] | null },
private action: IEditorAction,
onBeforeRun: (commandId: string) => void,
@INotificationService notificationService: INotificationService,
......@@ -358,10 +358,10 @@ class ActionCommandEntry extends BaseCommandEntry {
constructor(
commandId: string,
keybinding: ResolvedKeybinding,
keybinding: ResolvedKeybinding | undefined,
label: string,
alias: string,
highlights: { label: IHighlight[], alias: IHighlight[] },
alias: string | undefined,
highlights: { label: IHighlight[] | null, alias: IHighlight[] | null },
private action: Action,
onBeforeRun: (commandId: string) => void,
@INotificationService notificationService: INotificationService,
......@@ -439,7 +439,7 @@ export class CommandsHandler extends QuickOpenHandler implements IDisposable {
// Editor Actions
const activeTextEditorWidget = this.editorService.activeTextEditorWidget;
let editorActions: IEditorAction[] = [];
if (activeTextEditorWidget && types.isFunction(activeTextEditorWidget.getSupportedActions)) {
if (activeTextEditorWidget && isFunction(activeTextEditorWidget.getSupportedActions)) {
editorActions = activeTextEditorWidget.getSupportedActions();
}
......@@ -456,7 +456,7 @@ export class CommandsHandler extends QuickOpenHandler implements IDisposable {
let entries = [...editorEntries, ...commandEntries];
// Remove duplicates
entries = arrays.distinct(entries, entry => `${entry.getLabel()}${entry.getGroupLabel()}${entry.getCommandId()}`);
entries = distinct(entries, entry => `${entry.getLabel()}${entry.getGroupLabel()}${entry.getCommandId()}`);
// Handle label clashes
const commandLabels = new Set<string>();
......@@ -494,12 +494,12 @@ export class CommandsHandler extends QuickOpenHandler implements IDisposable {
// only if we have recently used commands in the result set
const firstEntry = entries[0];
if (firstEntry && this.commandsHistory.peek(firstEntry.getCommandId())) {
firstEntry.setGroupLabel(nls.localize('recentlyUsed', "recently used"));
firstEntry.setGroupLabel(localize('recentlyUsed', "recently used"));
for (let i = 1; i < entries.length; i++) {
const entry = entries[i];
if (!this.commandsHistory.peek(entry.getCommandId())) {
entry.setShowBorder(true);
entry.setGroupLabel(nls.localize('morecCommands', "other commands"));
entry.setGroupLabel(localize('morecCommands', "other commands"));
break;
}
}
......@@ -520,7 +520,7 @@ export class CommandsHandler extends QuickOpenHandler implements IDisposable {
if (label) {
// Alias for non default languages
const alias = !Language.isDefaultVariant() ? action.alias : null;
const alias = !Language.isDefaultVariant() ? action.alias : undefined;
const labelHighlights = wordFilter(searchValue, label);
const aliasHighlights = alias ? wordFilter(searchValue, alias) : null;
......@@ -547,15 +547,15 @@ export class CommandsHandler extends QuickOpenHandler implements IDisposable {
let category, label = title;
if (action.item.category) {
category = typeof action.item.category === 'string' ? action.item.category : action.item.category.value;
label = nls.localize('cat.title', "{0}: {1}", category, title);
label = localize('cat.title', "{0}: {1}", category, title);
}
if (label) {
const labelHighlights = wordFilter(searchValue, label);
// Add an 'alias' in original language when running in different locale
const aliasTitle = (!Language.isDefaultVariant() && typeof action.item.title !== 'string') ? action.item.title.original : null;
const aliasCategory = (!Language.isDefaultVariant() && category && action.item.category && typeof action.item.category !== 'string') ? action.item.category.original : null;
const aliasTitle = (!Language.isDefaultVariant() && typeof action.item.title !== 'string') ? action.item.title.original : undefined;
const aliasCategory = (!Language.isDefaultVariant() && category && action.item.category && typeof action.item.category !== 'string') ? action.item.category.original : undefined;
let alias;
if (aliasTitle && category) {
alias = aliasCategory ? `${aliasCategory}: ${aliasTitle}` : `${category}: ${aliasTitle}`;
......@@ -590,7 +590,7 @@ export class CommandsHandler extends QuickOpenHandler implements IDisposable {
}
getEmptyLabel(searchString: string): string {
return nls.localize('noCommandsMatching', "No commands matching");
return localize('noCommandsMatching', "No commands matching");
}
onClose(canceled: boolean): void {
......
......@@ -195,7 +195,7 @@ class SymbolEntry extends EditorQuickOpenEntryGroup {
return this.deprecated ? { extraClasses: ['deprecated'] } : undefined;
}
getHighlights(): [IHighlight[], IHighlight[] | undefined, IHighlight[] | undefined] {
getHighlights(): [IHighlight[] | undefined, IHighlight[] | undefined, IHighlight[] | undefined] {
return [
this.deprecated ? [] : filters.createMatches(this.score),
undefined,
......
......@@ -10,7 +10,6 @@ import { basename } from 'vs/base/common/resources';
import { IDisposable, dispose, Disposable, DisposableStore, combinedDisposable } from 'vs/base/common/lifecycle';
import { ViewletPanel, IViewletPanelOptions } from 'vs/workbench/browser/parts/views/panelViewlet';
import { append, $, toggleClass } from 'vs/base/browser/dom';
import { List } from 'vs/base/browser/ui/list/listWidget';
import { IListVirtualDelegate, IListRenderer, IListContextMenuEvent, IListEvent } from 'vs/base/browser/ui/list/list';
import { ISCMService, ISCMRepository } from 'vs/workbench/contrib/scm/common/scm';
import { CountBadge } from 'vs/base/browser/ui/countBadge/countBadge';
......@@ -173,7 +172,7 @@ export class MainPanel extends ViewletPanel {
static readonly ID = 'scm.mainPanel';
static readonly TITLE = localize('scm providers', "Source Control Providers");
private list!: List<ISCMRepository>;
private list!: WorkbenchList<ISCMRepository>;
constructor(
protected viewModel: IViewModel,
......
......@@ -47,7 +47,7 @@ class SymbolEntry extends EditorQuickOpenEntry {
this.score = score;
}
getHighlights(): [IHighlight[] /* Label */, IHighlight[] | undefined /* Description */, IHighlight[] | undefined /* Detail */] {
getHighlights(): [IHighlight[] | undefined /* Label */, IHighlight[] | undefined /* Description */, IHighlight[] | undefined /* Detail */] {
return [this.isDeprecated() ? [] : filters.createMatches(this.score), undefined, undefined];
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册