mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 19:18:59 +01:00
back to simple getDiagnostics-function, #30075
This commit is contained in:
@@ -236,11 +236,9 @@ export function createApiFactory(
|
||||
checkProposedApiEnabled(extension);
|
||||
return extHostDiagnostics.onDidChangeDiagnostics;
|
||||
},
|
||||
diagnostics: {
|
||||
has: proposedApiFunction(extension, uri => extHostDiagnostics.hasDiagnostics(uri)),
|
||||
get: proposedApiFunction(extension, uri => extHostDiagnostics.getDiagnostics(uri)),
|
||||
all: proposedApiFunction(extension, () => extHostDiagnostics.getAllDiagnostics())
|
||||
},
|
||||
getDiagnostics: proposedApiFunction(extension, resource => {
|
||||
return extHostDiagnostics.getDiagnostics(resource);
|
||||
}),
|
||||
getLanguages(): TPromise<string[]> {
|
||||
return extHostLanguages.getLanguages();
|
||||
},
|
||||
|
||||
@@ -287,38 +287,18 @@ export class ExtHostDiagnostics implements ExtHostDiagnosticsShape {
|
||||
return result;
|
||||
}
|
||||
|
||||
hasDiagnostics(resource: vscode.Uri): boolean {
|
||||
for (const collection of this._collections) {
|
||||
if (collection.has(resource)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
getDiagnostics(resource: vscode.Uri): vscode.Diagnostic[] {
|
||||
getDiagnostics(resource?: vscode.Uri): vscode.Diagnostic[] {
|
||||
let res: vscode.Diagnostic[] = [];
|
||||
for (const collection of this._collections) {
|
||||
if (collection.has(resource)) {
|
||||
res = res.concat(collection.get(resource));
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
getAllDiagnostics(): [vscode.Uri, vscode.Diagnostic[]][] {
|
||||
let map = new Map<string, number>();
|
||||
let res: [vscode.Uri, vscode.Diagnostic[]][] = [];
|
||||
for (const collection of this._collections) {
|
||||
collection.forEach((resource: vscode.Uri, diagnostics: vscode.Diagnostic[]) => {
|
||||
let index = map.get(resource.toString());
|
||||
if (typeof index === 'undefined') {
|
||||
index = res.length;
|
||||
res.push([resource, []]);
|
||||
map.set(resource.toString(), index);
|
||||
if (resource) {
|
||||
// filtered
|
||||
if (collection.has(resource)) {
|
||||
res = res.concat(collection.get(resource));
|
||||
}
|
||||
res[index][1] = res[index][1].concat(diagnostics);
|
||||
});
|
||||
} else {
|
||||
// all
|
||||
collection.forEach((uri, diag) => res = res.concat(diag));
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user