提交 ea09391f 编写于 作者: J Johannes Rieken

fix #49687

上级 72913b1a
......@@ -17,17 +17,17 @@ import { keys } from 'vs/base/common/map';
export class DiagnosticCollection implements vscode.DiagnosticCollection {
private static readonly _maxDiagnosticsPerFile: number = 250;
private readonly _name: string;
private readonly _maxDiagnosticsPerFile: number;
private readonly _onDidChangeDiagnostics: Emitter<(vscode.Uri | string)[]>;
private _proxy: MainThreadDiagnosticsShape;
private _isDisposed = false;
private _data = new Map<string, vscode.Diagnostic[]>();
constructor(name: string, proxy: MainThreadDiagnosticsShape, onDidChangeDiagnostics: Emitter<(vscode.Uri | string)[]>) {
constructor(name: string, maxDiagnosticsPerFile: number, proxy: MainThreadDiagnosticsShape, onDidChangeDiagnostics: Emitter<(vscode.Uri | string)[]>) {
this._name = name;
this._maxDiagnosticsPerFile = maxDiagnosticsPerFile;
this._proxy = proxy;
this._onDidChangeDiagnostics = onDidChangeDiagnostics;
}
......@@ -109,15 +109,15 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
let diagnostics = this._data.get(uri.toString());
if (diagnostics) {
// no more than 250 diagnostics per file
if (diagnostics.length > DiagnosticCollection._maxDiagnosticsPerFile) {
// no more than N diagnostics per file
if (diagnostics.length > this._maxDiagnosticsPerFile) {
marker = [];
const order = [DiagnosticSeverity.Error, DiagnosticSeverity.Warning, DiagnosticSeverity.Information, DiagnosticSeverity.Hint];
orderLoop: for (let i = 0; i < 4; i++) {
for (let diagnostic of diagnostics) {
if (diagnostic.severity === order[i]) {
const len = marker.push(converter.Diagnostic.from(diagnostic));
if (len === DiagnosticCollection._maxDiagnosticsPerFile) {
if (len === this._maxDiagnosticsPerFile) {
break orderLoop;
}
}
......@@ -126,8 +126,8 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
// add 'signal' marker for showing omitted errors/warnings
marker.push({
severity: MarkerSeverity.Error,
message: localize({ key: 'limitHit', comment: ['amount of errors/warning skipped due to limits'] }, "Not showing {0} further errors and warnings.", diagnostics.length - DiagnosticCollection._maxDiagnosticsPerFile),
severity: MarkerSeverity.Info,
message: localize({ key: 'limitHit', comment: ['amount of errors/warning skipped due to limits'] }, "Not showing {0} further errors and warnings.", diagnostics.length - this._maxDiagnosticsPerFile),
startLineNumber: marker[marker.length - 1].startLineNumber,
startColumn: marker[marker.length - 1].startColumn,
endLineNumber: marker[marker.length - 1].endLineNumber,
......@@ -201,6 +201,7 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
export class ExtHostDiagnostics implements ExtHostDiagnosticsShape {
private static _idPool: number = 0;
private static readonly _maxDiagnosticsPerFile: number = 1000;
private readonly _proxy: MainThreadDiagnosticsShape;
private readonly _collections: DiagnosticCollection[] = [];
......@@ -248,7 +249,7 @@ export class ExtHostDiagnostics implements ExtHostDiagnosticsShape {
const { _collections, _proxy, _onDidChangeDiagnostics } = this;
const result = new class extends DiagnosticCollection {
constructor() {
super(name, _proxy, _onDidChangeDiagnostics);
super(name, ExtHostDiagnostics._maxDiagnosticsPerFile, _proxy, _onDidChangeDiagnostics);
_collections.push(this);
}
dispose() {
......
......@@ -27,7 +27,7 @@ suite('ExtHostDiagnostics', () => {
test('disposeCheck', function () {
const collection = new DiagnosticCollection('test', new DiagnosticsShape(), new Emitter());
const collection = new DiagnosticCollection('test', 100, new DiagnosticsShape(), new Emitter());
collection.dispose();
collection.dispose(); // that's OK
......@@ -44,13 +44,13 @@ suite('ExtHostDiagnostics', () => {
test('diagnostic collection, forEach, clear, has', function () {
let collection = new DiagnosticCollection('test', new DiagnosticsShape(), new Emitter());
let collection = new DiagnosticCollection('test', 100, new DiagnosticsShape(), new Emitter());
assert.equal(collection.name, 'test');
collection.dispose();
assert.throws(() => collection.name);
let c = 0;
collection = new DiagnosticCollection('test', new DiagnosticsShape(), new Emitter());
collection = new DiagnosticCollection('test', 100, new DiagnosticsShape(), new Emitter());
collection.forEach(() => c++);
assert.equal(c, 0);
......@@ -87,7 +87,7 @@ suite('ExtHostDiagnostics', () => {
});
test('diagnostic collection, immutable read', function () {
let collection = new DiagnosticCollection('test', new DiagnosticsShape(), new Emitter());
let collection = new DiagnosticCollection('test', 100, new DiagnosticsShape(), new Emitter());
collection.set(URI.parse('foo:bar'), [
new Diagnostic(new Range(0, 0, 1, 1), 'message-1'),
new Diagnostic(new Range(0, 0, 1, 1), 'message-2')
......@@ -112,7 +112,7 @@ suite('ExtHostDiagnostics', () => {
test('diagnostics collection, set with dupliclated tuples', function () {
let collection = new DiagnosticCollection('test', new DiagnosticsShape(), new Emitter());
let collection = new DiagnosticCollection('test', 100, new DiagnosticsShape(), new Emitter());
let uri = URI.parse('sc:hightower');
collection.set([
[uri, [new Diagnostic(new Range(0, 0, 0, 1), 'message-1')]],
......@@ -163,7 +163,7 @@ suite('ExtHostDiagnostics', () => {
test('diagnostics collection, set tuple overrides, #11547', function () {
let lastEntries: [UriComponents, IMarkerData[]][];
let collection = new DiagnosticCollection('test', new class extends DiagnosticsShape {
let collection = new DiagnosticCollection('test', 100, new class extends DiagnosticsShape {
$changeMany(owner: string, entries: [UriComponents, IMarkerData[]][]): void {
lastEntries = entries;
return super.$changeMany(owner, entries);
......@@ -192,7 +192,7 @@ suite('ExtHostDiagnostics', () => {
test('diagnostics collection, tuples and undefined (small array), #15585', function () {
const collection = new DiagnosticCollection('test', new DiagnosticsShape(), new Emitter());
const collection = new DiagnosticCollection('test', 100, new DiagnosticsShape(), new Emitter());
let uri = URI.parse('sc:hightower');
let uri2 = URI.parse('sc:nomad');
let diag = new Diagnostic(new Range(0, 0, 0, 1), 'ffff');
......@@ -213,7 +213,7 @@ suite('ExtHostDiagnostics', () => {
test('diagnostics collection, tuples and undefined (large array), #15585', function () {
const collection = new DiagnosticCollection('test', new DiagnosticsShape(), new Emitter());
const collection = new DiagnosticCollection('test', 100, new DiagnosticsShape(), new Emitter());
const tuples: [URI, Diagnostic[]][] = [];
for (let i = 0; i < 500; i++) {
......@@ -237,7 +237,7 @@ suite('ExtHostDiagnostics', () => {
test('diagnostic capping', function () {
let lastEntries: [UriComponents, IMarkerData[]][];
let collection = new DiagnosticCollection('test', new class extends DiagnosticsShape {
let collection = new DiagnosticCollection('test', 250, new class extends DiagnosticsShape {
$changeMany(owner: string, entries: [UriComponents, IMarkerData[]][]): void {
lastEntries = entries;
return super.$changeMany(owner, entries);
......@@ -258,12 +258,12 @@ suite('ExtHostDiagnostics', () => {
assert.equal(lastEntries[0][1].length, 251);
assert.equal(lastEntries[0][1][0].severity, MarkerSeverity.Error);
assert.equal(lastEntries[0][1][200].severity, MarkerSeverity.Warning);
assert.equal(lastEntries[0][1][250].severity, MarkerSeverity.Error);
assert.equal(lastEntries[0][1][250].severity, MarkerSeverity.Info);
});
test('diagnostic eventing', async function () {
let emitter = new Emitter<(string | URI)[]>();
let collection = new DiagnosticCollection('ddd', new DiagnosticsShape(), emitter);
let collection = new DiagnosticCollection('ddd', 100, new DiagnosticsShape(), emitter);
let diag1 = new Diagnostic(new Range(1, 1, 2, 3), 'diag1');
let diag2 = new Diagnostic(new Range(1, 1, 2, 3), 'diag2');
......@@ -301,7 +301,7 @@ suite('ExtHostDiagnostics', () => {
test('vscode.languages.onDidChangeDiagnostics Does Not Provide Document URI #49582', async function () {
let emitter = new Emitter<(string | URI)[]>();
let collection = new DiagnosticCollection('ddd', new DiagnosticsShape(), emitter);
let collection = new DiagnosticCollection('ddd', 100, new DiagnosticsShape(), emitter);
let diag1 = new Diagnostic(new Range(1, 1, 2, 3), 'diag1');
......@@ -324,7 +324,7 @@ suite('ExtHostDiagnostics', () => {
test('diagnostics with related information', function (done) {
let collection = new DiagnosticCollection('ddd', new class extends DiagnosticsShape {
let collection = new DiagnosticCollection('ddd', 100, new class extends DiagnosticsShape {
$changeMany(owner: string, entries: [UriComponents, IMarkerData[]][]) {
let [[, data]] = entries;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册