mirror of
https://github.com/Microsoft/vscode
synced 2024-10-04 02:14:06 +00:00
parent
8444fa68ef
commit
e50231341b
|
@ -264,3 +264,11 @@ export function createProxyObject<T extends object>(methodNames: string[], invok
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function mapValues<T extends {}, R>(obj: T, fn: (value: T[keyof T], key: string) => R): { [K in keyof T]: R } {
|
||||
const result: { [key: string]: R } = {};
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
result[key] = fn(<T[keyof T]>value, key);
|
||||
}
|
||||
return result as { [K in keyof T]: R };
|
||||
}
|
||||
|
|
|
@ -233,3 +233,19 @@ suite('Objects', () => {
|
|||
assert.strictEqual(obj1.mIxEdCaSe, objects.getCaseInsensitive(obj1, 'mixedcase'));
|
||||
});
|
||||
});
|
||||
|
||||
test('mapValues', () => {
|
||||
const obj = {
|
||||
a: 1,
|
||||
b: 2,
|
||||
c: 3
|
||||
};
|
||||
|
||||
const result = objects.mapValues(obj, (value, key) => `${key}: ${value * 2}`);
|
||||
|
||||
assert.deepStrictEqual(result, {
|
||||
a: 'a: 2',
|
||||
b: 'b: 4',
|
||||
c: 'c: 6',
|
||||
});
|
||||
});
|
||||
|
|
|
@ -19,6 +19,7 @@ import { ErrorNoTelemetry } from 'vs/base/common/errors';
|
|||
import { IDebugVisualizerService } from 'vs/workbench/contrib/debug/common/debugVisualizers';
|
||||
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { isDefined } from 'vs/base/common/types';
|
||||
|
||||
@extHostNamedCustomer(MainContext.MainThreadDebugService)
|
||||
export class MainThreadDebugService implements MainThreadDebugServiceShape, IDebugAdapterFactory {
|
||||
|
@ -210,18 +211,16 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
|
|||
|
||||
for (const dto of DTOs) {
|
||||
if (dto.type === 'sourceMulti') {
|
||||
const rawbps = dto.lines.map(l =>
|
||||
<IBreakpointData>{
|
||||
id: l.id,
|
||||
enabled: l.enabled,
|
||||
lineNumber: l.line + 1,
|
||||
column: l.character > 0 ? l.character + 1 : undefined, // a column value of 0 results in an omitted column attribute; see #46784
|
||||
condition: l.condition,
|
||||
hitCondition: l.hitCondition,
|
||||
logMessage: l.logMessage,
|
||||
mode: l.mode,
|
||||
}
|
||||
);
|
||||
const rawbps = dto.lines.map((l): IBreakpointData => ({
|
||||
id: l.id,
|
||||
enabled: l.enabled,
|
||||
lineNumber: l.line + 1,
|
||||
column: l.character > 0 ? l.character + 1 : undefined, // a column value of 0 results in an omitted column attribute; see #46784
|
||||
condition: l.condition,
|
||||
hitCondition: l.hitCondition,
|
||||
logMessage: l.logMessage,
|
||||
mode: l.mode,
|
||||
}));
|
||||
this.debugService.addBreakpoints(uri.revive(dto.uri), rawbps);
|
||||
} else if (dto.type === 'function') {
|
||||
this.debugService.addFunctionBreakpoint(dto.functionName, dto.id, dto.mode);
|
||||
|
@ -248,7 +247,7 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
|
|||
|
||||
public $registerDebugConfigurationProvider(debugType: string, providerTriggerKind: DebugConfigurationProviderTriggerKind, hasProvide: boolean, hasResolve: boolean, hasResolve2: boolean, handle: number): Promise<void> {
|
||||
|
||||
const provider = <IDebugConfigurationProvider>{
|
||||
const provider: IDebugConfigurationProvider = {
|
||||
type: debugType,
|
||||
triggerKind: providerTriggerKind
|
||||
};
|
||||
|
@ -283,7 +282,7 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
|
|||
|
||||
public $registerDebugAdapterDescriptorFactory(debugType: string, handle: number): Promise<void> {
|
||||
|
||||
const provider = <IDebugAdapterDescriptorFactory>{
|
||||
const provider: IDebugAdapterDescriptorFactory = {
|
||||
type: debugType,
|
||||
createDebugAdapterDescriptor: session => {
|
||||
return Promise.resolve(this._proxy.$provideDebugAdapter(handle, this.getSessionDto(session)));
|
||||
|
@ -435,8 +434,8 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
|
|||
private convertToDto(bps: (ReadonlyArray<IBreakpoint | IFunctionBreakpoint | IDataBreakpoint | IInstructionBreakpoint>)): Array<ISourceBreakpointDto | IFunctionBreakpointDto | IDataBreakpointDto> {
|
||||
return bps.map(bp => {
|
||||
if ('name' in bp) {
|
||||
const fbp = <IFunctionBreakpoint>bp;
|
||||
return <IFunctionBreakpointDto>{
|
||||
const fbp: IFunctionBreakpoint = bp;
|
||||
return {
|
||||
type: 'function',
|
||||
id: fbp.getId(),
|
||||
enabled: fbp.enabled,
|
||||
|
@ -444,9 +443,9 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
|
|||
hitCondition: fbp.hitCondition,
|
||||
logMessage: fbp.logMessage,
|
||||
functionName: fbp.name
|
||||
};
|
||||
} satisfies IFunctionBreakpointDto;
|
||||
} else if ('src' in bp) {
|
||||
const dbp = <IDataBreakpoint>bp;
|
||||
const dbp: IDataBreakpoint = bp;
|
||||
return {
|
||||
type: 'data',
|
||||
id: dbp.getId(),
|
||||
|
@ -459,9 +458,9 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
|
|||
label: dbp.description,
|
||||
canPersist: dbp.canPersist
|
||||
} satisfies IDataBreakpointDto;
|
||||
} else {
|
||||
const sbp = <IBreakpoint>bp;
|
||||
return <ISourceBreakpointDto>{
|
||||
} else if ('uri' in bp) {
|
||||
const sbp: IBreakpoint = bp;
|
||||
return {
|
||||
type: 'source',
|
||||
id: sbp.getId(),
|
||||
enabled: sbp.enabled,
|
||||
|
@ -471,9 +470,11 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
|
|||
uri: sbp.uri,
|
||||
line: sbp.lineNumber > 0 ? sbp.lineNumber - 1 : 0,
|
||||
character: (typeof sbp.column === 'number' && sbp.column > 0) ? sbp.column - 1 : 0,
|
||||
};
|
||||
} satisfies ISourceBreakpointDto;
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
}).filter(isDefined);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -413,11 +413,11 @@ export abstract class ExtHostDebugServiceBase implements IExtHostDebugService, E
|
|||
if (bp instanceof SourceBreakpoint) {
|
||||
let dto = map.get(bp.location.uri.toString());
|
||||
if (!dto) {
|
||||
dto = <ISourceMultiBreakpointDto>{
|
||||
dto = {
|
||||
type: 'sourceMulti',
|
||||
uri: bp.location.uri,
|
||||
lines: []
|
||||
};
|
||||
} satisfies ISourceMultiBreakpointDto;
|
||||
map.set(bp.location.uri.toString(), dto);
|
||||
dtos.push(dto);
|
||||
}
|
||||
|
@ -883,28 +883,28 @@ export abstract class ExtHostDebugServiceBase implements IExtHostDebugService, E
|
|||
private convertToDto(x: vscode.DebugAdapterDescriptor): Dto<IAdapterDescriptor> {
|
||||
|
||||
if (x instanceof DebugAdapterExecutable) {
|
||||
return <IDebugAdapterExecutable>{
|
||||
return {
|
||||
type: 'executable',
|
||||
command: x.command,
|
||||
args: x.args,
|
||||
options: x.options
|
||||
};
|
||||
} satisfies IDebugAdapterExecutable;
|
||||
} else if (x instanceof DebugAdapterServer) {
|
||||
return <IDebugAdapterServer>{
|
||||
return {
|
||||
type: 'server',
|
||||
port: x.port,
|
||||
host: x.host
|
||||
};
|
||||
} satisfies IDebugAdapterServer;
|
||||
} else if (x instanceof DebugAdapterNamedPipeServer) {
|
||||
return <IDebugAdapterNamedPipeServer>{
|
||||
return {
|
||||
type: 'pipeServer',
|
||||
path: x.path
|
||||
};
|
||||
} satisfies IDebugAdapterNamedPipeServer;
|
||||
} else if (x instanceof DebugAdapterInlineImplementation) {
|
||||
return <Dto<IAdapterDescriptor>>{
|
||||
return {
|
||||
type: 'implementation',
|
||||
implementation: x.implementation
|
||||
};
|
||||
} as Dto<IAdapterDescriptor>;
|
||||
} else {
|
||||
throw new Error('convertToDto unexpected type');
|
||||
}
|
||||
|
|
|
@ -259,7 +259,7 @@ export class StartDebugActionViewItem extends BaseActionViewItem {
|
|||
});
|
||||
});
|
||||
|
||||
this.selectBox.setOptions(this.debugOptions.map((data, index) => <ISelectOptionItem>{ text: data.label, isDisabled: disabledIdxs.indexOf(index) !== -1 }), this.selected);
|
||||
this.selectBox.setOptions(this.debugOptions.map((data, index): ISelectOptionItem => ({ text: data.label, isDisabled: disabledIdxs.indexOf(index) !== -1 })), this.selected);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -314,7 +314,7 @@ export class FocusSessionActionViewItem extends SelectActionViewItem<IDebugSessi
|
|||
|
||||
return label;
|
||||
});
|
||||
this.setOptions(names.map(data => <ISelectOptionItem>{ text: data }), session ? sessions.indexOf(session) : undefined);
|
||||
this.setOptions(names.map((data): ISelectOptionItem => ({ text: data })), session ? sessions.indexOf(session) : undefined);
|
||||
}
|
||||
|
||||
private getSelectedSession(): IDebugSession | undefined {
|
||||
|
|
|
@ -421,7 +421,7 @@ class WatchExpressionsDragAndDrop implements ITreeDragAndDrop<IExpression> {
|
|||
}
|
||||
}
|
||||
|
||||
return { accept: true, effect: { type: ListDragOverEffectType.Move, position: dropEffectPosition }, feedback: [targetIndex] } as ITreeDragOverReaction;
|
||||
return { accept: true, effect: { type: ListDragOverEffectType.Move, position: dropEffectPosition }, feedback: [targetIndex] } satisfies ITreeDragOverReaction;
|
||||
}
|
||||
|
||||
getDragURI(element: IExpression): string | null {
|
||||
|
|
|
@ -92,7 +92,7 @@ export class TestingExplorerFilter extends BaseActionViewItem {
|
|||
});
|
||||
}),
|
||||
].filter(r => !this.state.text.value.includes(r.label)),
|
||||
} as SuggestResultsProvider,
|
||||
} satisfies SuggestResultsProvider,
|
||||
resourceHandle: 'testing:filter',
|
||||
suggestOptions: {
|
||||
value: this.state.text.value,
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { mapValues } from 'vs/base/common/objects';
|
||||
import { TestResultState } from 'vs/workbench/contrib/testing/common/testTypes';
|
||||
|
||||
export type TreeStateNode = { statusNode: true; state: TestResultState; priority: number };
|
||||
|
@ -25,13 +26,10 @@ export const statePriority: { [K in TestResultState]: number } = {
|
|||
export const isFailedState = (s: TestResultState) => s === TestResultState.Errored || s === TestResultState.Failed;
|
||||
export const isStateWithResult = (s: TestResultState) => s === TestResultState.Errored || s === TestResultState.Failed || s === TestResultState.Passed;
|
||||
|
||||
export const stateNodes = Object.entries(statePriority).reduce(
|
||||
(acc, [stateStr, priority]) => {
|
||||
const state = Number(stateStr) as TestResultState;
|
||||
acc[state] = { statusNode: true, state, priority };
|
||||
return acc;
|
||||
}, {} as { [K in TestResultState]: TreeStateNode }
|
||||
);
|
||||
export const stateNodes: { [K in TestResultState]: TreeStateNode } = mapValues(statePriority, (priority, stateStr): TreeStateNode => {
|
||||
const state = Number(stateStr) as TestResultState;
|
||||
return { statusNode: true, state, priority };
|
||||
});
|
||||
|
||||
export const cmpPriority = (a: TestResultState, b: TestResultState) => statePriority[b] - statePriority[a];
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ class TestObjectTree<T> extends ObjectTree<T, any> {
|
|||
disposeElement: (_el, _index, { store }) => store.clear(),
|
||||
renderTemplate: container => ({ container, store: new DisposableStore() }),
|
||||
templateId: 'default'
|
||||
} as ITreeRenderer<T, any, { store: DisposableStore; container: HTMLElement }>
|
||||
} satisfies ITreeRenderer<T, any, { store: DisposableStore; container: HTMLElement }>
|
||||
],
|
||||
{
|
||||
sorter: sorter ?? {
|
||||
|
|
Loading…
Reference in a new issue