Skip to content

Commit

Permalink
Format code with Prettier
Browse files Browse the repository at this point in the history
This commit applies the changes made by running yarn format:write to
format the source code of the three the three packages traceviewer-base,
traceviewer-react-components, and theia-traceviewer using Prettier.

Resolves #861.

Signed-off-by: Hoang Thuan Pham <hoang.pham@calian.ca>
  • Loading branch information
hoangphamEclipse committed May 15, 2023
1 parent b2f94a4 commit 6e3116b
Show file tree
Hide file tree
Showing 94 changed files with 3,847 additions and 2,795 deletions.
20 changes: 10 additions & 10 deletions packages/base/src/experiment-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,16 @@ import { TspClientResponse } from 'tsp-typescript-client/lib/protocol/tsp-client
import { signalManager, Signals } from './signals/signal-manager';

export class ExperimentManager {

private fOpenExperiments: Map<string, Experiment> = new Map();
private fTspClient: TspClient;
private fTraceManager: TraceManager;

constructor(
tspClient: TspClient,
traceManager: TraceManager
) {
constructor(tspClient: TspClient, traceManager: TraceManager) {
this.fTspClient = tspClient;
this.fTraceManager = traceManager;
signalManager().on(Signals.EXPERIMENT_DELETED, (experiment: Experiment) => this.onExperimentDeleted(experiment));
signalManager().on(Signals.EXPERIMENT_DELETED, (experiment: Experiment) =>
this.onExperimentDeleted(experiment)
);
}

/**
Expand Down Expand Up @@ -82,10 +80,12 @@ export class ExperimentManager {
}

const tryCreate = async function (tspClient: TspClient, retry: number): Promise<TspClientResponse<Experiment>> {
return tspClient.createExperiment(new Query({
'name': retry === 0 ? name : name + '(' + retry + ')',
'traces': traceURIs
}));
return tspClient.createExperiment(
new Query({
name: retry === 0 ? name : name + '(' + retry + ')',
traces: traceURIs
})
);
};
let tryNb = 0;
let experimentResponse: TspClientResponse<Experiment> | undefined;
Expand Down
6 changes: 3 additions & 3 deletions packages/base/src/lazy-tsp-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { TspClient } from 'tsp-typescript-client';
* Only keep methods, discard properties.
*/
export type LazyTspClient = {
[K in keyof TspClient]: TspClient[K] extends (...args: infer A) => (infer R | Promise<infer R>)
[K in keyof TspClient]: TspClient[K] extends (...args: infer A) => infer R | Promise<infer R>
? (...args: A) => Promise<R>
: never // Discard property.
: never; // Discard property.
};

export type LazyTspClientFactory = typeof LazyTspClientFactory;
Expand All @@ -25,7 +25,7 @@ export function LazyTspClientFactory(url: Promise<string>): TspClient {
let method = target[property];
if (!method) {
target[property] = method = async (...args: any[]) => {
const tspClient = await tspClientPromise as any;
const tspClient = (await tspClientPromise) as any;
return tspClient[property](...args);
};
}
Expand Down
13 changes: 5 additions & 8 deletions packages/base/src/message-manager.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export enum MessageCategory {
TRACE_CONTEXT,
SERVER_MESSAGE,
SERVER_STATUS,
SERVER_STATUS
}

export enum MessageSeverity {
Expand All @@ -18,22 +18,19 @@ export interface StatusMessage {
}

export declare interface MessageManager {

addStatusMessage(messageKey: string, message: StatusMessage): void;
removeStatusMessage(messageKey: string): void;

}

export class MessageManager implements MessageManager {

addStatusMessage(messageKey: string, {text,
category = MessageCategory.SERVER_MESSAGE,
severity = MessageSeverity.INFO }: StatusMessage): void {
addStatusMessage(
messageKey: string,
{ text, category = MessageCategory.SERVER_MESSAGE, severity = MessageSeverity.INFO }: StatusMessage
): void {
console.log('New status message', messageKey, text, category, severity);
}

removeStatusMessage(messageKey: string): void {
console.log('Removing status message status message', messageKey);
}

}
19 changes: 9 additions & 10 deletions packages/base/src/signals/signal-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export declare interface SignalManager {
fireResetZoomSignal(): void;
fireMarkerCategoriesFetchedSignal(): void;
fireMarkerSetsFetchedSignal(): void;
fireMarkerCategoryClosedSignal(payload: { traceViewerId: string, markerCategory: string }): void;
fireMarkerCategoryClosedSignal(payload: { traceViewerId: string; markerCategory: string }): void;
fireTraceServerStartedSignal(): void;
fireUndoSignal(): void;
fireRedoSignal(): void;
Expand All @@ -35,8 +35,8 @@ export declare interface SignalManager {
firePinView(output: OutputDescriptor, payload?: any): void;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
fireUnPinView(output: OutputDescriptor, payload?: any): void;
fireOverviewOutputSelectedSignal(payload: { traceId: string, outputDescriptor: OutputDescriptor}): void;
fireSaveAsCsv(payload: {traceId: string, data: string}): void;
fireOverviewOutputSelectedSignal(payload: { traceId: string; outputDescriptor: OutputDescriptor }): void;
fireSaveAsCsv(payload: { traceId: string; data: string }): void;
fireSelectionRangeUpdated(payload: TimeRangeUpdatePayload): void;
fireViewRangeUpdated(payload: TimeRangeUpdatePayload): void;
fireRequestSelectionRangeChange(payload: TimeRangeUpdatePayload): void;
Expand Down Expand Up @@ -73,7 +73,7 @@ export const Signals = {
SAVE_AS_CSV: 'save as csv',
VIEW_RANGE_UPDATED: 'view range updated',
SELECTION_RANGE_UPDATED: 'selection range updated',
REQUEST_SELECTION_RANGE_CHANGE: 'change selection range',
REQUEST_SELECTION_RANGE_CHANGE: 'change selection range'
};

export class SignalManager extends EventEmitter implements SignalManager {
Expand Down Expand Up @@ -104,13 +104,13 @@ export class SignalManager extends EventEmitter implements SignalManager {
fireOutputAddedSignal(payload: OutputAddedSignalPayload): void {
this.emit(Signals.OUTPUT_ADDED, payload);
}
fireItemPropertiesSignalUpdated(properties?: { [key: string]: string; }): void {
fireItemPropertiesSignalUpdated(properties?: { [key: string]: string }): void {
this.emit(Signals.ITEM_PROPERTIES_UPDATED, properties);
}
fireThemeChangedSignal(theme: string): void {
this.emit(Signals.THEME_CHANGED, theme);
}
fireSelectionChangedSignal(payload: { [key: string]: string; }): void {
fireSelectionChangedSignal(payload: { [key: string]: string }): void {
this.emit(Signals.SELECTION_CHANGED, payload);
}
fireCloseTraceViewerTabSignal(traceUUID: string): void {
Expand All @@ -131,7 +131,7 @@ export class SignalManager extends EventEmitter implements SignalManager {
fireMarkerSetsFetchedSignal(): void {
this.emit(Signals.MARKERSETS_FETCHED);
}
fireMarkerCategoryClosedSignal(payload: { traceViewerId: string, markerCategory: string }): void {
fireMarkerCategoryClosedSignal(payload: { traceViewerId: string; markerCategory: string }): void {
this.emit(Signals.MARKER_CATEGORY_CLOSED, payload);
}
fireTraceServerStartedSignal(): void {
Expand All @@ -154,10 +154,10 @@ export class SignalManager extends EventEmitter implements SignalManager {
fireOpenOverviewOutputSignal(traceId: string): void {
this.emit(Signals.OPEN_OVERVIEW_OUTPUT, traceId);
}
fireOverviewOutputSelectedSignal(payload: { traceId: string, outputDescriptor: OutputDescriptor}): void {
fireOverviewOutputSelectedSignal(payload: { traceId: string; outputDescriptor: OutputDescriptor }): void {
this.emit(Signals.OVERVIEW_OUTPUT_SELECTED, payload);
}
fireSaveAsCsv(payload: {traceId: string, data: string}): void {
fireSaveAsCsv(payload: { traceId: string; data: string }): void {
this.emit(Signals.SAVE_AS_CSV, payload);
}
fireViewRangeUpdated(payload: TimeRangeUpdatePayload): void {
Expand All @@ -169,7 +169,6 @@ export class SignalManager extends EventEmitter implements SignalManager {
fireRequestSelectionRangeChange(payload: TimeRangeUpdatePayload): void {
this.emit(Signals.REQUEST_SELECTION_RANGE_CHANGE, payload);
}

}

let instance: SignalManager = new SignalManager();
Expand Down
4 changes: 2 additions & 2 deletions packages/base/src/signals/time-range-data-signal-payloads.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TimeRange } from '../utils/time-range';

export interface TimeRangeUpdatePayload {
experimentUUID: string,
timeRange?: TimeRange,
experimentUUID: string;
timeRange?: TimeRange;
}
18 changes: 8 additions & 10 deletions packages/base/src/trace-manager.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@

import { Trace } from 'tsp-typescript-client/lib/models/trace';
import { TspClient } from 'tsp-typescript-client/lib/protocol/tsp-client';
import { Query } from 'tsp-typescript-client/lib/models/query/query';
import { OutputDescriptor } from 'tsp-typescript-client/lib/models/output-descriptor';
import { TspClientResponse } from 'tsp-typescript-client/lib/protocol/tsp-client-response';
import { signalManager} from './signals/signal-manager';
import { signalManager } from './signals/signal-manager';

export class TraceManager {

private fOpenTraces: Map<string, Trace> = new Map();
private fTspClient: TspClient;

constructor(
tspClient: TspClient
) {
constructor(tspClient: TspClient) {
this.fTspClient = tspClient;
}

Expand Down Expand Up @@ -74,10 +70,12 @@ export class TraceManager {
const name = traceName ? traceName : traceURI.replace(/\/$/, '').replace(/(.*\/)?/, '');

const tryOpen = async function (tspClient: TspClient, retry: number): Promise<TspClientResponse<Trace>> {
return tspClient.openTrace(new Query({
'name': retry === 0 ? name : name + '(' + retry + ')',
'uri': traceURI
}));
return tspClient.openTrace(
new Query({
name: retry === 0 ? name : name + '(' + retry + ')',
uri: traceURI
})
);
};
let tryNb = 0;
let traceResponse: TspClientResponse<Trace> | undefined;
Expand Down
12 changes: 8 additions & 4 deletions packages/base/src/utils/convert-color-string-to-hex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ export function convertColorStringToHexNumber(rgb: string): number {
// Working with RGB String
const match = rgb.match(/\d+/g);
if (match) {
string = '0x' + match.map(x => {
x = parseInt(x).toString(16);
return (x.length === 1) ? '0' + x : x;
}).join('');
string =
'0x' +
match
.map(x => {
x = parseInt(x).toString(16);
return x.length === 1 ? '0' + x : x;
})
.join('');
string = string.slice(0, 8);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/base/src/utils/value-hash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const hash = (str: string): number => {
let hashCode = 0;
for (let i = 0; i < str.length; i++) {
const chr = str.charCodeAt(i);
hashCode = ((hashCode << 5) - hashCode) + chr;
hashCode = (hashCode << 5) - hashCode + chr;
hashCode |= 0; // Convert to 32bit integer
}
return hashCode;
Expand Down
Loading

0 comments on commit 6e3116b

Please sign in to comment.