@codingame/monaco-vscode-extensions-service-override
Version:
VSCode public API plugged on the monaco editor - extensions service-override
70 lines (67 loc) • 3.03 kB
JavaScript
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
import { IMarkerService } from 'vscode/vscode/vs/platform/markers/common/markers.service';
import { URI } from 'vscode/vscode/vs/base/common/uri';
import { ExtHostContext, MainContext } from 'vscode/vscode/vs/workbench/api/common/extHost.protocol';
import { extHostNamedCustomer } from '../../services/extensions/common/extHostCustomers.js';
import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity.service';
let MainThreadDiagnostics = class MainThreadDiagnostics {
constructor(extHostContext, _markerService, _uriIdentService) {
this._markerService = _markerService;
this._uriIdentService = _uriIdentService;
this._activeOwners = ( new Set());
this._proxy = ( extHostContext.getProxy(ExtHostContext.ExtHostDiagnostics));
this._markerListener = this._markerService.onMarkerChanged(this._forwardMarkers, this);
}
dispose() {
this._markerListener.dispose();
this._activeOwners.forEach(owner => this._markerService.changeAll(owner, []));
this._activeOwners.clear();
}
_forwardMarkers(resources) {
const data = [];
for (const resource of resources) {
const allMarkerData = this._markerService.read({ resource });
if (allMarkerData.length === 0) {
data.push([resource, []]);
}
else {
const forgeinMarkerData = allMarkerData.filter(marker => !( this._activeOwners.has(marker.owner)));
if (forgeinMarkerData.length > 0) {
data.push([resource, forgeinMarkerData]);
}
}
}
if (data.length > 0) {
this._proxy.$acceptMarkersChange(data);
}
}
$changeMany(owner, entries) {
for (const entry of entries) {
const [uri, markers] = entry;
if (markers) {
for (const marker of markers) {
if (marker.relatedInformation) {
for (const relatedInformation of marker.relatedInformation) {
relatedInformation.resource = URI.revive(relatedInformation.resource);
}
}
if (marker.code && typeof marker.code !== 'string') {
marker.code.target = URI.revive(marker.code.target);
}
}
}
this._markerService.changeOne(owner, this._uriIdentService.asCanonicalUri(URI.revive(uri)), markers);
}
this._activeOwners.add(owner);
}
$clear(owner) {
this._markerService.changeAll(owner, []);
this._activeOwners.delete(owner);
}
};
MainThreadDiagnostics = __decorate([
extHostNamedCustomer(MainContext.MainThreadDiagnostics),
( __param(1, IMarkerService)),
( __param(2, IUriIdentityService))
], MainThreadDiagnostics);
export { MainThreadDiagnostics };