Skip to content

Commit 62c54d3

Browse files
committed
1 parent 73c17ef commit 62c54d3

6 files changed

Lines changed: 28 additions & 17 deletions

File tree

src/vs/editor/contrib/inlineCompletions/browser/structuredLogger.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import { Disposable } from '../../../../base/common/lifecycle.js';
77
import { IObservable, observableFromEvent } from '../../../../base/common/observable.js';
88
import { URI } from '../../../../base/common/uri.js';
9-
import { ICommandService } from '../../../../platform/commands/common/commands.js';
109
import { IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js';
10+
import { IDataChannelService } from '../../../../platform/dataChannel/common/dataChannel.js';
1111

1212
export interface IRecordableLogEntry {
1313
sourceId: string;
@@ -62,27 +62,24 @@ export class StructuredLogger<T extends IRecordableLogEntry> extends Disposable
6262
}
6363

6464
public readonly isEnabled;
65-
private readonly _contextKeyValue;
65+
private readonly _isEnabledContextKeyValue;
6666

6767
constructor(
68-
private readonly _contextKey: string,
68+
private readonly _key: string,
6969
@IContextKeyService private readonly _contextKeyService: IContextKeyService,
70-
@ICommandService private readonly _commandService: ICommandService
70+
@IDataChannelService private readonly _dataChannelService: IDataChannelService,
7171
) {
7272
super();
73-
this._contextKeyValue = observableContextKey<string>(this._contextKey, this._contextKeyService).recomputeInitiallyAndOnChange(this._store);
74-
this.isEnabled = this._contextKeyValue.map(v => v !== undefined);
73+
this._isEnabledContextKeyValue = observableContextKey<boolean>('structuredLogger.enabled:' + this._key, this._contextKeyService).recomputeInitiallyAndOnChange(this._store);
74+
this.isEnabled = this._isEnabledContextKeyValue.map(v => v !== undefined);
7575
}
7676

7777
public log(data: T): boolean {
78-
const commandId = this._contextKeyValue.get();
79-
if (!commandId) {
78+
const enabled = this._isEnabledContextKeyValue.get();
79+
if (!enabled) {
8080
return false;
8181
}
82-
try {
83-
this._commandService.executeCommand(commandId, data).catch(() => { });
84-
} catch (e) {
85-
}
82+
this._dataChannelService.getDataChannel<T>('structuredLogger:' + this._key).sendData(data);
8683
return true;
8784
}
8885
}

src/vs/editor/standalone/browser/standaloneServices.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ import { ResourceMap } from '../../../base/common/map.js';
100100
import { IWebWorkerDescriptor } from '../../../base/browser/webWorkerFactory.js';
101101
import { ITreeSitterLibraryService } from '../../common/services/treeSitter/treeSitterLibraryService.js';
102102
import { StandaloneTreeSitterLibraryService } from './standaloneTreeSitterLibraryService.js';
103+
import { CoreDataChannel, IDataChannelEvent, IDataChannelService } from '../../../platform/dataChannel/common/dataChannel.js';
103104

104105
class SimpleModel implements IResolvedTextEditorModel {
105106

@@ -1126,6 +1127,18 @@ class StandaloneAccessbilitySignalService implements IAccessibilitySignalService
11261127
}
11271128
}
11281129

1130+
class StandaloneDataChannelService implements IDataChannelService {
1131+
_serviceBrand: undefined;
1132+
get onDidSendData(): Event<IDataChannelEvent<unknown>> {
1133+
return Event.None;
1134+
}
1135+
getDataChannel<T>(_channelId: string): CoreDataChannel<T> {
1136+
return {
1137+
sendData: () => { },
1138+
};
1139+
}
1140+
}
1141+
11291142
export interface IEditorOverrideServices {
11301143
[index: string]: any;
11311144
}
@@ -1167,6 +1180,7 @@ registerSingleton(IMenuService, MenuService, InstantiationType.Eager);
11671180
registerSingleton(IAccessibilitySignalService, StandaloneAccessbilitySignalService, InstantiationType.Eager);
11681181
registerSingleton(ITreeSitterLibraryService, StandaloneTreeSitterLibraryService, InstantiationType.Eager);
11691182
registerSingleton(ILoggerService, NullLoggerService, InstantiationType.Eager);
1183+
registerSingleton(IDataChannelService, StandaloneDataChannelService, InstantiationType.Eager);
11701184

11711185
/**
11721186
* We don't want to eagerly instantiate services because embedders get a one time chance

src/vs/workbench/services/dataChannel/common/dataChannel.ts renamed to src/vs/platform/dataChannel/common/dataChannel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { Event } from '../../../../base/common/event.js';
7-
import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';
6+
import { Event } from '../../../base/common/event.js';
7+
import { createDecorator } from '../../instantiation/common/instantiation.js';
88

99
export const IDataChannelService = createDecorator<IDataChannelService>('dataChannelService');
1010

src/vs/workbench/api/browser/mainThreadDataChannels.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { Disposable } from '../../../base/common/lifecycle.js';
7-
import { IDataChannelService } from '../../services/dataChannel/common/dataChannel.js';
7+
import { IDataChannelService } from '../../../platform/dataChannel/common/dataChannel.js';
88
import { extHostNamedCustomer, IExtHostContext } from '../../services/extensions/common/extHostCustomers.js';
99
import { ExtHostContext, ExtHostDataChannelsShape, MainContext, MainThreadDataChannelsShape } from '../common/extHost.protocol.js';
1010

src/vs/workbench/contrib/editTelemetry/browser/telemetry/forwardingTelemetryService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { ClassifiedEvent, OmitMetadata, IGDPRProperty, StrictPropertyCheck } from '../../../../../platform/telemetry/common/gdprTypings.js';
77
import { ITelemetryData, ITelemetryService, TelemetryLevel } from '../../../../../platform/telemetry/common/telemetry.js';
8-
import { IDataChannelService } from '../../../../services/dataChannel/common/dataChannel.js';
8+
import { IDataChannelService } from '../../../../../platform/dataChannel/common/dataChannel.js';
99

1010
export class InterceptingTelemetryService implements ITelemetryService {
1111
_serviceBrand: undefined;

src/vs/workbench/services/dataChannel/browser/dataChannelService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { Emitter } from '../../../../base/common/event.js';
77
import { Disposable } from '../../../../base/common/lifecycle.js';
8-
import { IDataChannelService, CoreDataChannel, IDataChannelEvent } from '../common/dataChannel.js';
8+
import { IDataChannelService, CoreDataChannel, IDataChannelEvent } from '../../../../platform/dataChannel/common/dataChannel.js';
99
import { InstantiationType, registerSingleton } from '../../../../platform/instantiation/common/extensions.js';
1010

1111
export class DataChannelService extends Disposable implements IDataChannelService {

0 commit comments

Comments
 (0)