Merge branch 'main' into joh/langStatus

This commit is contained in:
Johannes Rieken
2021-08-30 10:34:44 +02:00
60 changed files with 647 additions and 289 deletions

View File

@@ -156,7 +156,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
const extHostEditors = rpcProtocol.set(ExtHostContext.ExtHostEditors, new ExtHostEditors(rpcProtocol, extHostDocumentsAndEditors));
const extHostTreeViews = rpcProtocol.set(ExtHostContext.ExtHostTreeViews, new ExtHostTreeViews(rpcProtocol.getProxy(MainContext.MainThreadTreeViews), extHostCommands, extHostLogService));
const extHostEditorInsets = rpcProtocol.set(ExtHostContext.ExtHostEditorInsets, new ExtHostEditorInsets(rpcProtocol.getProxy(MainContext.MainThreadEditorInsets), extHostEditors, initData));
const extHostDiagnostics = rpcProtocol.set(ExtHostContext.ExtHostDiagnostics, new ExtHostDiagnostics(rpcProtocol, extHostLogService));
const extHostDiagnostics = rpcProtocol.set(ExtHostContext.ExtHostDiagnostics, new ExtHostDiagnostics(rpcProtocol, extHostLogService, extHostFileSystemInfo));
const extHostLanguageFeatures = rpcProtocol.set(ExtHostContext.ExtHostLanguageFeatures, new ExtHostLanguageFeatures(rpcProtocol, uriTransformer, extHostDocuments, extHostCommands, extHostDiagnostics, extHostLogService, extHostApiDeprecation));
const extHostFileSystem = rpcProtocol.set(ExtHostContext.ExtHostFileSystem, new ExtHostFileSystem(rpcProtocol, extHostLanguageFeatures));
const extHostFileSystemEvent = rpcProtocol.set(ExtHostContext.ExtHostFileSystemEventService, new ExtHostFileSystemEventService(rpcProtocol, extHostLogService, extHostDocumentsAndEditors));

View File

@@ -14,27 +14,37 @@ import { Event, Emitter, DebounceEmitter } from 'vs/base/common/event';
import { ILogService } from 'vs/platform/log/common/log';
import { ResourceMap } from 'vs/base/common/map';
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
import { IExtHostFileSystemInfo } from 'vs/workbench/api/common/extHostFileSystemInfo';
import { IExtUri } from 'vs/base/common/resources';
export class DiagnosticCollection implements vscode.DiagnosticCollection {
readonly #proxy: MainThreadDiagnosticsShape | undefined;
readonly #onDidChangeDiagnostics: Emitter<vscode.Uri[]>;
readonly #data: ResourceMap<vscode.Diagnostic[]>;
private _isDisposed = false;
private _data = new ResourceMap<vscode.Diagnostic[]>();
constructor(
private readonly _name: string,
private readonly _owner: string,
private readonly _maxDiagnosticsPerFile: number,
private readonly _proxy: MainThreadDiagnosticsShape | undefined,
private readonly _onDidChangeDiagnostics: Emitter<vscode.Uri[]>
) { }
extUri: IExtUri,
proxy: MainThreadDiagnosticsShape | undefined,
onDidChangeDiagnostics: Emitter<vscode.Uri[]>
) {
this.#data = new ResourceMap(uri => extUri.getComparisonKey(uri));
this.#proxy = proxy;
this.#onDidChangeDiagnostics = onDidChangeDiagnostics;
}
dispose(): void {
if (!this._isDisposed) {
this._onDidChangeDiagnostics.fire([...this._data.keys()]);
if (this._proxy) {
this._proxy.$clear(this._owner);
this.#onDidChangeDiagnostics.fire([...this.#data.keys()]);
if (this.#proxy) {
this.#proxy.$clear(this._owner);
}
this._data = undefined!;
this.#data.clear();
this._isDisposed = true;
}
}
@@ -68,7 +78,7 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
}
// update single row
this._data.set(first, diagnostics.slice());
this.#data.set(first, diagnostics.slice());
toSync = [first];
} else if (Array.isArray(first)) {
@@ -82,22 +92,22 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
for (const tuple of first) {
const [uri, diagnostics] = tuple;
if (!lastUri || uri.toString() !== lastUri.toString()) {
if (lastUri && this._data.get(lastUri)!.length === 0) {
this._data.delete(lastUri);
if (lastUri && this.#data.get(lastUri)!.length === 0) {
this.#data.delete(lastUri);
}
lastUri = uri;
toSync.push(uri);
this._data.set(uri, []);
this.#data.set(uri, []);
}
if (!diagnostics) {
// [Uri, undefined] means clear this
const currentDiagnostics = this._data.get(uri);
const currentDiagnostics = this.#data.get(uri);
if (currentDiagnostics) {
currentDiagnostics.length = 0;
}
} else {
const currentDiagnostics = this._data.get(uri);
const currentDiagnostics = this.#data.get(uri);
if (currentDiagnostics) {
currentDiagnostics.push(...diagnostics);
}
@@ -106,16 +116,16 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
}
// send event for extensions
this._onDidChangeDiagnostics.fire(toSync);
this.#onDidChangeDiagnostics.fire(toSync);
// compute change and send to main side
if (!this._proxy) {
if (!this.#proxy) {
return;
}
const entries: [URI, IMarkerData[]][] = [];
for (let uri of toSync) {
let marker: IMarkerData[] = [];
const diagnostics = this._data.get(uri);
const diagnostics = this.#data.get(uri);
if (diagnostics) {
// no more than N diagnostics per file
@@ -149,37 +159,37 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
entries.push([uri, marker]);
}
this._proxy.$changeMany(this._owner, entries);
this.#proxy.$changeMany(this._owner, entries);
}
delete(uri: vscode.Uri): void {
this._checkDisposed();
this._onDidChangeDiagnostics.fire([uri]);
this._data.delete(uri);
if (this._proxy) {
this._proxy.$changeMany(this._owner, [[uri, undefined]]);
this.#onDidChangeDiagnostics.fire([uri]);
this.#data.delete(uri);
if (this.#proxy) {
this.#proxy.$changeMany(this._owner, [[uri, undefined]]);
}
}
clear(): void {
this._checkDisposed();
this._onDidChangeDiagnostics.fire([...this._data.keys()]);
this._data.clear();
if (this._proxy) {
this._proxy.$clear(this._owner);
this.#onDidChangeDiagnostics.fire([...this.#data.keys()]);
this.#data.clear();
if (this.#proxy) {
this.#proxy.$clear(this._owner);
}
}
forEach(callback: (uri: URI, diagnostics: ReadonlyArray<vscode.Diagnostic>, collection: DiagnosticCollection) => any, thisArg?: any): void {
this._checkDisposed();
for (let uri of this._data.keys()) {
for (let uri of this.#data.keys()) {
callback.apply(thisArg, [uri, this.get(uri), this]);
}
}
get(uri: URI): ReadonlyArray<vscode.Diagnostic> {
this._checkDisposed();
const result = this._data.get(uri);
const result = this.#data.get(uri);
if (Array.isArray(result)) {
return <ReadonlyArray<vscode.Diagnostic>>Object.freeze(result.slice(0));
}
@@ -188,7 +198,7 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
has(uri: URI): boolean {
this._checkDisposed();
return Array.isArray(this._data.get(uri));
return Array.isArray(this.#data.get(uri));
}
private _checkDisposed() {
@@ -227,13 +237,17 @@ export class ExtHostDiagnostics implements ExtHostDiagnosticsShape {
readonly onDidChangeDiagnostics: Event<vscode.DiagnosticChangeEvent> = Event.map(this._onDidChangeDiagnostics.event, ExtHostDiagnostics._mapper);
constructor(mainContext: IMainContext, @ILogService private readonly _logService: ILogService) {
constructor(
mainContext: IMainContext,
@ILogService private readonly _logService: ILogService,
@IExtHostFileSystemInfo private readonly _fileSystemInfoService: IExtHostFileSystemInfo,
) {
this._proxy = mainContext.getProxy(MainContext.MainThreadDiagnostics);
}
createDiagnosticCollection(extensionId: ExtensionIdentifier, name?: string): vscode.DiagnosticCollection {
const { _collections, _proxy, _onDidChangeDiagnostics, _logService } = this;
const { _collections, _proxy, _onDidChangeDiagnostics, _logService, _fileSystemInfoService } = this;
const loggingProxy = new class implements MainThreadDiagnosticsShape {
$changeMany(owner: string, entries: [UriComponents, IMarkerData[] | undefined][]): void {
@@ -265,7 +279,7 @@ export class ExtHostDiagnostics implements ExtHostDiagnosticsShape {
const result = new class extends DiagnosticCollection {
constructor() {
super(name!, owner, ExtHostDiagnostics._maxDiagnosticsPerFile, loggingProxy, _onDidChangeDiagnostics);
super(name!, owner, ExtHostDiagnostics._maxDiagnosticsPerFile, _fileSystemInfoService.extUri, loggingProxy, _onDidChangeDiagnostics);
_collections.set(owner, this);
}
override dispose() {
@@ -317,7 +331,7 @@ export class ExtHostDiagnostics implements ExtHostDiagnosticsShape {
if (!this._mirrorCollection) {
const name = '_generated_mirror';
const collection = new DiagnosticCollection(name, name, ExtHostDiagnostics._maxDiagnosticsPerFile, undefined, this._onDidChangeDiagnostics);
const collection = new DiagnosticCollection(name, name, ExtHostDiagnostics._maxDiagnosticsPerFile, this._fileSystemInfoService.extUri, undefined, this._onDidChangeDiagnostics);
this._collections.set(name, collection);
this._mirrorCollection = collection;
}

View File

@@ -4,6 +4,8 @@
*--------------------------------------------------------------------------------------------*/
import { Schemas } from 'vs/base/common/network';
import { ExtUri, IExtUri } from 'vs/base/common/resources';
import { FileSystemProviderCapabilities } from 'vs/platform/files/common/files';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { ExtHostFileSystemInfoShape } from 'vs/workbench/api/common/extHost.protocol';
@@ -14,6 +16,23 @@ export class ExtHostFileSystemInfo implements ExtHostFileSystemInfoShape {
private readonly _systemSchemes = new Set(Object.keys(Schemas));
private readonly _providerInfo = new Map<string, number>();
readonly extUri: IExtUri;
constructor() {
this.extUri = new ExtUri(uri => {
const capabilities = this._providerInfo.get(uri.scheme);
if (capabilities === undefined) {
// default: not ignore
return false;
}
if (capabilities & FileSystemProviderCapabilities.PathCaseSensitive) {
// configured as case sensitive
return false;
}
return true;
});
}
$acceptProviderInfos(scheme: string, capabilities: number | null): void {
if (capabilities === null) {
this._providerInfo.delete(scheme);
@@ -31,5 +50,7 @@ export class ExtHostFileSystemInfo implements ExtHostFileSystemInfoShape {
}
}
export interface IExtHostFileSystemInfo extends ExtHostFileSystemInfo { }
export interface IExtHostFileSystemInfo extends ExtHostFileSystemInfo {
readonly extUri: IExtUri;
}
export const IExtHostFileSystemInfo = createDecorator<IExtHostFileSystemInfo>('IExtHostFileSystemInfo');