Skip to content
This repository has been archived by the owner on Apr 1, 2020. It is now read-only.

Pass event names to all Event constructors #2355

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions browser/src/Editor/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ export interface IEditor extends Oni.Editor {
*/
export class Editor extends Disposable implements Oni.Editor {
private _currentMode: string
private _onBufferEnterEvent = new Event<Oni.EditorBufferEventArgs>()
private _onBufferLeaveEvent = new Event<Oni.EditorBufferEventArgs>()
private _onBufferChangedEvent = new Event<Oni.EditorBufferChangedEventArgs>()
private _onBufferSavedEvent = new Event<Oni.EditorBufferEventArgs>()
private _onBufferScrolledEvent = new Event<Oni.EditorBufferScrolledEventArgs>()
private _onCursorMoved = new Event<Oni.Cursor>()
private _onModeChangedEvent = new Event<Oni.Vim.Mode>()
private _onBufferEnterEvent = new Event<Oni.EditorBufferEventArgs>("Editor::onBufferEnterEvent")
private _onBufferLeaveEvent = new Event<Oni.EditorBufferEventArgs>("Editor::onBufferLeaveEvent")
private _onBufferChangedEvent = new Event<Oni.EditorBufferChangedEventArgs>(
"Editor::onBufferChangedEvent",
)
private _onBufferSavedEvent = new Event<Oni.EditorBufferEventArgs>("Editor::onBufferSavedEvent")
private _onBufferScrolledEvent = new Event<Oni.EditorBufferScrolledEventArgs>(
"Editor::onBufferScrolledEvent",
)
private _onCursorMoved = new Event<Oni.Cursor>("Editor::onCursorMoved")
private _onModeChangedEvent = new Event<Oni.Vim.Mode>("Editor::onModeChangedEvent")

public get mode(): string {
return this._currentMode
Expand Down
8 changes: 6 additions & 2 deletions browser/src/Editor/NeovimEditor/CompletionMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ import { ContextMenu } from "./../../Services/ContextMenu"
import * as CompletionUtility from "./../../Services/Completion/CompletionUtility"

export class CompletionMenu {
private _onItemFocusedEvent: Event<types.CompletionItem> = new Event<types.CompletionItem>()
private _onItemSelectedEvent: Event<types.CompletionItem> = new Event<types.CompletionItem>()
private _onItemFocusedEvent: Event<types.CompletionItem> = new Event<types.CompletionItem>(
"CompletionMenu::onItemFocusedEvent",
)
private _onItemSelectedEvent: Event<types.CompletionItem> = new Event<types.CompletionItem>(
"CompletionMenu::onItemSelectedEvent",
)

public get onItemFocused(): IEvent<types.CompletionItem> {
return this._onItemFocusedEvent
Expand Down
4 changes: 2 additions & 2 deletions browser/src/Editor/NeovimEditor/NeovimEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class NeovimEditor extends Editor implements IEditor {

private _pendingAnimationFrame: boolean = false

private _onEnterEvent: Event<void> = new Event<void>()
private _onEnterEvent: Event<void> = new Event<void>("NeovimEditor::onEnterEvent")

private _modeChanged$: Observable<Oni.Vim.Mode>
private _cursorMoved$: Observable<Oni.Cursor>
Expand Down Expand Up @@ -142,7 +142,7 @@ export class NeovimEditor extends Editor implements IEditor {
private _externalMenuOverlay: Overlay
private _bufferLayerManager: BufferLayerManager

private _onNeovimQuit: Event<void> = new Event<void>()
private _onNeovimQuit: Event<void> = new Event<void>("NeovimEditor::onNeovimQuit")

private _autoFocus: boolean = true

Expand Down
2 changes: 1 addition & 1 deletion browser/src/Input/Keyboard/KeyboardLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const augmentKeyMap = (keyMap: IKeyMap, language: string): IKeyMap => {

export class KeyboardLayoutManager {
private _keyMap: IKeyMap = null
private _onKeyMapChanged: Event<void> = new Event<void>()
private _onKeyMapChanged: Event<void> = new Event<void>("KeyboardLayout::onKeyMapChanged")

/**
* Event that is triggered when the keymap is changed,
Expand Down
12 changes: 9 additions & 3 deletions browser/src/Plugins/PluginInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,15 @@ export interface IPluginInstaller {
}

export class YarnPluginInstaller implements IPluginInstaller {
private _onOperationStarted = new Event<IPluginInstallerOperationEvent>()
private _onOperationCompleted = new Event<IPluginInstallerOperationEvent>()
private _onOperationError = new Event<IPluginInstallerOperationEvent>()
private _onOperationStarted = new Event<IPluginInstallerOperationEvent>(
"PluginInstaller::onOperationStarted",
)
private _onOperationCompleted = new Event<IPluginInstallerOperationEvent>(
"PluginInstaller::onOperationCompleted",
)
private _onOperationError = new Event<IPluginInstallerOperationEvent>(
"PluginInstaller::onOperationError",
)

public get onOperationStarted(): IEvent<IPluginInstallerOperationEvent> {
return this._onOperationStarted
Expand Down
4 changes: 2 additions & 2 deletions browser/src/Plugins/PluginSidebarPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ export class PluginSidebarItemView extends React.PureComponent<PluginSidebarItem
}

export class PluginsSidebarPane implements SidebarPane {
private _onEnter = new Event<void>()
private _onLeave = new Event<void>()
private _onEnter = new Event<void>("PluginSidebarPane::onEnter")
private _onLeave = new Event<void>("PluginSidebarPane::onLeave")

public get id(): string {
return "oni.sidebar.plugins"
Expand Down
4 changes: 2 additions & 2 deletions browser/src/Services/Bookmarks/BookmarksPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import { SidebarContainerView, SidebarItemView } from "./../../UI/components/Sid
import { VimNavigator } from "./../../UI/components/VimNavigator"

export class BookmarksPane implements SidebarPane {
private _onEnter = new Event<void>()
private _onLeave = new Event<void>()
private _onEnter = new Event<void>("BookmarksPane::onEnter")
private _onLeave = new Event<void>("BookmarksPane::onLeave")

constructor(private _bookmarksProvider: IBookmarksProvider) {}

Expand Down
2 changes: 1 addition & 1 deletion browser/src/Services/Bookmarks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const marksToBookmarks = (mark: INeovimMarkInfo): IBookmark => ({

export class NeovimBookmarksProvider implements IBookmarksProvider {
private _lastBookmarks: IBookmark[] = []
private _onBookmarksUpdated = new Event<void>()
private _onBookmarksUpdated = new Event<void>("Bookmarks::onBookmarksUpdated")

public get bookmarks(): IBookmark[] {
return this._lastBookmarks
Expand Down
16 changes: 8 additions & 8 deletions browser/src/Services/Browser/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ import {
import { BrowserView } from "./BrowserView"

export class BrowserLayer implements Oni.BufferLayer {
private _debugEvent = new Event<void>()
private _goBackEvent = new Event<void>()
private _goForwardEvent = new Event<void>()
private _reloadEvent = new Event<void>()
private _scrollUpEvent = new Event<void>()
private _scrollDownEvent = new Event<void>()
private _scrollRightEvent = new Event<void>()
private _scrollLeftEvent = new Event<void>()
private _debugEvent = new Event<void>("Browser::debugEvent")
private _goBackEvent = new Event<void>("Browser::goBackEvent")
private _goForwardEvent = new Event<void>("Browser::goForwardEvent")
private _reloadEvent = new Event<void>("Browser::reloadEvent")
private _scrollUpEvent = new Event<void>("Browser::scrollUpEvent")
private _scrollDownEvent = new Event<void>("Browser::scrollDownEvent")
private _scrollRightEvent = new Event<void>("Browser::scrollRightEvent")
private _scrollLeftEvent = new Event<void>("Browser::scrollLeftEvent")

private _webview: WebviewTag | null = null
private _activeTagName: string | null = null
Expand Down
2 changes: 1 addition & 1 deletion browser/src/Services/Colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface IColors extends OniApi.IColors {
export class Colors implements OniApi.IColors, IDisposable {
private _subscriptions: IDisposable[] = []
private _colors: ColorsDictionary = {}
private _onColorsChangedEvent: Event<void> = new Event<void>()
private _onColorsChangedEvent: Event<void> = new Event<void>("Colors::onColorsChangedEvent")

public get onColorsChanged(): IEvent<void> {
return this._onColorsChangedEvent
Expand Down
6 changes: 4 additions & 2 deletions browser/src/Services/Completion/Completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ export class Completion implements IDisposable {

private _onShowCompletionItemsEvent: Event<ICompletionShowEventArgs> = new Event<
ICompletionShowEventArgs
>()
private _onHideCompletionItemsEvent: Event<void> = new Event<void>()
>("Completion::onShowCompletionItemsEvent")
private _onHideCompletionItemsEvent: Event<void> = new Event<void>(
"Completion::onHideCompletionItemsEvent",
)

public get onShowCompletionItems(): IEvent<ICompletionShowEventArgs> {
return this._onShowCompletionItemsEvent
Expand Down
14 changes: 10 additions & 4 deletions browser/src/Services/Configuration/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,14 @@ export class Configuration implements Oni.Configuration {
private _configurationProviders: IConfigurationProvider[] = []
private _onConfigurationChangedEvent: Event<Partial<IConfigurationValues>> = new Event<
Partial<IConfigurationValues>
>()
private _onConfigurationErrorEvent: Event<Error> = new Event<Error>()
>("Configuration::onConfigurationChangedEvent")
private _onConfigurationErrorEvent: Event<Error> = new Event<Error>(
"Configuration::onConfigurationErrorEvent",
)

private _onConfigurationUpdatedEvent = new Event<IConfigurationUpdateEvent>()
private _onConfigurationUpdatedEvent = new Event<IConfigurationUpdateEvent>(
"Configuration::onConfigurationUpdatedEvent",
)

private _oniApi: Oni.Plugin.Api = null
private _config: GenericConfigurationValues = {}
Expand Down Expand Up @@ -158,7 +162,9 @@ export class Configuration implements Oni.Configuration {
this.setValue(name, options.defaultValue)
}

const newEvent = new Event<IConfigurationSettingValueChangedEvent<any>>()
const newEvent = new Event<IConfigurationSettingValueChangedEvent<any>>(
"Configuration::newEvent",
)
const subs: Array<Event<IConfigurationSettingValueChangedEvent<any>>> =
this._subscriptions[name] || []
this._subscriptions[name] = [...subs, newEvent]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ const CONFIG_UPDATE_DEBOUNCE_TIME = 100 /*ms */
export class FileConfigurationProvider implements IConfigurationProvider {
private _configurationFilePath: string
private _containingFolder: string
private _configurationChangedEvent = new Event<void>()
private _configurationErrorEvent = new Event<Error>()
private _configurationChangedEvent = new Event<void>(
"FileConfigurationProvider::configurationChangedEvent",
)
private _configurationErrorEvent = new Event<Error>(
"FileConfigurationProvider::configurationErrorEvent",
)
private _latestConfiguration: Partial<IConfigurationValues> = null
private _lastError: Error | null = null
private _configEverHadValue: boolean = false
Expand Down
8 changes: 4 additions & 4 deletions browser/src/Services/ContextMenu/ContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ export class ContextMenuManager {
}

export class ContextMenu {
private _onItemSelected = new Event<any>()
private _onFilterTextChanged = new Event<string>()
private _onHide = new Event<void>()
private _onSelectedItemChanged = new Event<any>()
private _onItemSelected = new Event<any>("ContextMenu::onItemSelected")
private _onFilterTextChanged = new Event<string>("ContextMenu::onFilterTextChanged")
private _onHide = new Event<void>("ContextMenu::onHide")
private _onSelectedItemChanged = new Event<any>("ContextMenu::onSelectedItemChanged")

private _lastItems: any = null

Expand Down
2 changes: 1 addition & 1 deletion browser/src/Services/Diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const getAllErrorsForFile = (fileName: string, errors: Errors): types.Dia

export class DiagnosticsDataSource {
private _errors: Errors = {}
private _onErrorsChangedEvent = new Event<void>()
private _onErrorsChangedEvent = new Event<void>("Diagnostics::onErrorsChangedEvent")

public get onErrorsChanged(): IEvent<void> {
return this._onErrorsChangedEvent
Expand Down
22 changes: 14 additions & 8 deletions browser/src/Services/EditorManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export class EditorManager implements Oni.EditorManager {
private _allEditors: Oni.Editor[] = []
private _activeEditor: Oni.Editor = null
private _anyEditorProxy: AnyEditorProxy = new AnyEditorProxy()
private _onActiveEditorChanged: Event<Oni.Editor> = new Event<Oni.Editor>()
private _onActiveEditorChanged: Event<Oni.Editor> = new Event<Oni.Editor>(
"EditorManager::onActiveEditorChanged",
)

private _closeWhenNoEditors: boolean = true

Expand Down Expand Up @@ -95,13 +97,17 @@ class AnyEditorProxy implements Oni.Editor {
private _activeEditor: Oni.Editor
private _subscriptions: IDisposable[] = []

private _onModeChanged = new Event<Oni.Vim.Mode>()
private _onBufferEnter = new Event<Oni.EditorBufferEventArgs>()
private _onBufferLeave = new Event<Oni.EditorBufferEventArgs>()
private _onBufferChanged = new Event<Oni.EditorBufferChangedEventArgs>()
private _onBufferSaved = new Event<Oni.EditorBufferEventArgs>()
private _onBufferScrolled = new Event<Oni.EditorBufferScrolledEventArgs>()
private _onCursorMoved = new Event<Oni.Cursor>()
private _onModeChanged = new Event<Oni.Vim.Mode>("EditorManager::onModeChanged")
private _onBufferEnter = new Event<Oni.EditorBufferEventArgs>("EditorManager::onBufferEnter")
private _onBufferLeave = new Event<Oni.EditorBufferEventArgs>("EditorManager::onBufferLeave")
private _onBufferChanged = new Event<Oni.EditorBufferChangedEventArgs>(
"EditorManager::onBufferChanged",
)
private _onBufferSaved = new Event<Oni.EditorBufferEventArgs>("EditorManager::onBufferSaved")
private _onBufferScrolled = new Event<Oni.EditorBufferScrolledEventArgs>(
"EditorManager::onBufferScrolled",
)
private _onCursorMoved = new Event<Oni.Cursor>("EditorManager::onCursorMoved")

/**
* API Methods
Expand Down
2 changes: 1 addition & 1 deletion browser/src/Services/Explorer/ExplorerSplit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { Explorer } from "./ExplorerView"
type Node = ExplorerSelectors.ExplorerNode

export class ExplorerSplit {
private _onEnterEvent: Event<void> = new Event<void>()
private _onEnterEvent: Event<void> = new Event<void>("ExplorerSplit::onEnterEvent")
private _selectedId: string = null
private _store: Store<IExplorerState>
private _watcher: FileSystemWatcher = null
Expand Down
12 changes: 6 additions & 6 deletions browser/src/Services/FileSystemWatcher/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ interface IStatsChangeEvent {
export class FileSystemWatcher {
private _watcher: chokidar.FSWatcher

private _onAdd = new Event<IFileChangeEvent>()
private _onAddDir = new Event<IStatsChangeEvent>()
private _onDelete = new Event<IFileChangeEvent>()
private _onDeleteDir = new Event<IFileChangeEvent>()
private _onMove = new Event<IFileChangeEvent>()
private _onChange = new Event<IFileChangeEvent>()
private _onAdd = new Event<IFileChangeEvent>("FileSystemWatcher::onAdd")
private _onAddDir = new Event<IStatsChangeEvent>("FileSystemWatcher::onAddDir")
private _onDelete = new Event<IFileChangeEvent>("FileSystemWatcher::onDelete")
private _onDeleteDir = new Event<IFileChangeEvent>("FileSystemWatcher::onDeleteDir")
private _onMove = new Event<IFileChangeEvent>("FileSystemWatcher::onMove")
private _onChange = new Event<IFileChangeEvent>("FileSystemWatcher::onChange")

constructor({ target, options }: IFSOptions) {
this._watcher = chokidar.watch(target, options)
Expand Down
4 changes: 3 additions & 1 deletion browser/src/Services/IconThemes/Icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ export interface IIconTheme {

export class Icons {
private _activeIconTheme: IIconTheme = null
private _onIconThemeChangedEvent: Event<void> = new Event<void>()
private _onIconThemeChangedEvent: Event<void> = new Event<void>(
"Icons::onIconThemeChangedEvent",
)

public get activeIconTheme(): IIconTheme {
return this._activeIconTheme
Expand Down
4 changes: 3 additions & 1 deletion browser/src/Services/Language/LanguageClientProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ export interface InitializationOptions {
export class LanguageClientProcess {
private _process: ChildProcess
private _connection: rpc.MessageConnection
private _onConnectionChangedEvent = new Event<rpc.MessageConnection>()
private _onConnectionChangedEvent = new Event<rpc.MessageConnection>(
"LanguageClientProcess::onConnectionChangedEvent",
)

private _lastWorkingDirectory: string = null
private _lastRootPath: string = null
Expand Down
16 changes: 11 additions & 5 deletions browser/src/Services/Language/LanguageEditorIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,17 @@ export class LanguageEditorIntegration implements OniTypes.IDisposable {

private _onShowDefinition: OniTypes.Event<IDefinitionResult> = new OniTypes.Event<
IDefinitionResult
>()
private _onHideDefinition: OniTypes.Event<void> = new OniTypes.Event<void>()

private _onShowHover: OniTypes.Event<IHoverResult> = new OniTypes.Event<IHoverResult>()
private _onHideHover: OniTypes.Event<void> = new OniTypes.Event<void>()
>("LanguageEditorIntegration::onShowDefinition")
private _onHideDefinition: OniTypes.Event<void> = new OniTypes.Event<void>(
"LanguageEditorIntegration::onHideDefinition",
)

private _onShowHover: OniTypes.Event<IHoverResult> = new OniTypes.Event<IHoverResult>(
"LanguageEditorIntegration::onShowHover",
)
private _onHideHover: OniTypes.Event<void> = new OniTypes.Event<void>(
"LanguageEditorIntegration::onHideHover",
)

public get onShowDefinition(): OniTypes.IEvent<IDefinitionResult> {
return this._onShowDefinition
Expand Down
2 changes: 1 addition & 1 deletion browser/src/Services/Language/LanguageManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ export class LanguageManager {
const currentSubscription = this._notificationSubscriptions[protocolMessage]

if (!currentSubscription) {
const evt = new Event<any>()
const evt = new Event<any>("LanguageManager::evt")
this._notificationSubscriptions[protocolMessage] = evt

const languageClients = Object.values(this._languageServerInfo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ export class AchievementsManager {
private _enabled: boolean

private _currentIdleCallback: number | null = null
private _onAchievementAccomplishedEvent = new Event<AchievementDefinition>()
private _onAchievementAccomplishedEvent = new Event<AchievementDefinition>(
"AchievementsManager::onAchievementAccomplishedEvent",
)

public get enabled(): boolean {
return this._enabled
Expand Down
4 changes: 2 additions & 2 deletions browser/src/Services/Learning/LearningPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import { ITutorialMetadataWithProgress, TutorialManager } from "./Tutorial/Tutor
import { noop } from "./../../Utility"

export class LearningPane implements SidebarPane {
private _onEnter = new Event<void>()
private _onLeave = new Event<void>()
private _onEnter = new Event<void>("LearningPane::onEnter")
private _onLeave = new Event<void>("LearningPane::onLeave")

constructor(
private _tutorialManager: TutorialManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class TutorialBufferLayer implements Oni.BufferLayer {
private _gameTracker: GameTracker = new GameTracker()
private _onStateChangedEvent: Event<ITutorialBufferLayerState> = new Event<
ITutorialBufferLayerState
>()
>("TutorialBufferLayer::onStateChangedEvent")

public get id(): string {
return "oni.layer.tutorial"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ export const TICK_RATE = 50 /* 50 ms, or 20 times pers second */
export class TutorialGameplayManager {
private _activeTutorial: ITutorial
private _currentStageIdx: number
private _onStateChanged = new Event<ITutorialState>()
private _onCompleted = new Event<boolean>()
private _onStateChanged = new Event<ITutorialState>("TutorialGameplayManager::onStateChanged")
private _onCompleted = new Event<boolean>("TutorialGameplayManager::onCompleted")
private _currentState: ITutorialState = null
private _onTick = new Event<void>()
private _onTick = new Event<void>("TutorialGameplayManager::onTick")

private _isTickInProgress: boolean = false
private _buf: Oni.Buffer
Expand Down
Loading