Skip to content

Commit

Permalink
Merge pull request #605 from mathuo/603-sonarcloud-cleanups
Browse files Browse the repository at this point in the history
chore: cleanup code
  • Loading branch information
mathuo authored May 14, 2024
2 parents 9ee2b82 + d29052e commit 84d02b9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
10 changes: 5 additions & 5 deletions packages/dockview-core/src/api/dockviewGroupPanelApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ export interface DockviewGroupPanelFloatingChangeEvent {
readonly location: DockviewGroupLocation;
}

// TODO find a better way to initialize and avoid needing null checks
const NOT_INITIALIZED_MESSAGE = 'DockviewGroupPanelApiImpl not initialized';
const NOT_INITIALIZED_MESSAGE = 'dockview: DockviewGroupPanelApiImpl not initialized';

export class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
private readonly _mutableDisposable = new MutableDisposable();
Expand Down Expand Up @@ -130,15 +129,16 @@ export class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
}

initialize(group: DockviewGroupPanel): void {
this._group = group;

/**
* TODO: Annoying initialization order caveat
* TODO: Annoying initialization order caveat, find a better way to initialize and avoid needing null checks
*
* Due to the order on initialization we know that the model isn't defined until later in the same stack-frame of setup.
* By queuing a microtask we can ensure the setup is completed within the same stack-frame, but after everything else has
* finished ensuring the `model` is defined.
*/

this._group = group;

queueMicrotask(() => {
this._mutableDisposable.value =
this._group!.model.onDidActivePanelChange((event) => {
Expand Down
4 changes: 1 addition & 3 deletions packages/dockview-core/src/dnd/dataTransfer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
class TransferObject {
constructor() {
// intentionally empty class
}
// intentionally empty class
}

export class PanelTransfer extends TransferObject {
Expand Down
4 changes: 2 additions & 2 deletions packages/dockview-core/src/dockview/dockviewComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ export class DockviewComponent
this.updateWatermark();
})
.catch((err) => {
console.error(err);
console.error('dockview: failed to create popout window', err);
});
}

Expand Down Expand Up @@ -2104,7 +2104,7 @@ export class DockviewComponent

if (id && this._groups.has(options.id!)) {
console.warn(
`Duplicate group id ${options?.id}. reassigning group id to avoid errors`
`dockview: Duplicate group id ${options?.id}. reassigning group id to avoid errors`
);
id = undefined;
}
Expand Down
9 changes: 6 additions & 3 deletions packages/dockview-core/src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Stacktrace {
private constructor(readonly value: string) {}

print(): void {
console.warn(this.value);
console.warn('dockview: stacktrace', this.value);
}
}

Expand Down Expand Up @@ -124,7 +124,7 @@ export class Emitter<T> implements IDisposable {
this._listeners.splice(index, 1);
} else if (Emitter.ENABLE_TRACKING) {
// console.warn(
// `Listener already disposed`,
// `dockview: listener already disposed`,
// Stacktrace.create().print()
// );
}
Expand Down Expand Up @@ -158,7 +158,10 @@ export class Emitter<T> implements IDisposable {
queueMicrotask(() => {
// don't check until stack of execution is completed to allow for out-of-order disposals within the same execution block
for (const listener of this._listeners) {
console.warn(listener.stacktrace?.print());
console.warn(
'dockview: stacktrace',
listener.stacktrace?.print()
);
}
});
}
Expand Down

0 comments on commit 84d02b9

Please sign in to comment.