Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement order for info-marker-nodes #9691

Merged
merged 1 commit into from
Oct 20, 2021

Conversation

LukasBoll
Copy link
Contributor

What it does

Fixes #8983

Previously info-marker-nodes were ordered by the time they have been reported to the problem-tree-model. This led to an unexpected order of the nodes in the problem view. (See #8983)
In this commit info-marker-nodes will be inserted to the tree-model based on the following rules:
-nodes will be sorted based on the most severe marker they contain
-if nodes contain equally severe markers, they are sorted by the URI

How to test

Download test workspace from here:
https://github.com/eclipse-theia/theia/files/5859357/problems-view.zip

You should be able to:

  • Open and close all files. The nodes concerning the specific file should be added in the defined order to the previous nodes.

  • Change settings without the order of nodes being changed.

  • Add or remove warning or errors to a file. The order in the problem-view should be adjusted.

  • Rename files. The order in the problem-view should be adjusted.

Review checklist

Reminder for reviewers

@LukasBoll
Copy link
Contributor Author

I also tried the implementation with 33k markers from the eclipse.jdt.ls workspace
The time it took to load all errors, once the first error got reported (in seconds):

Master Sorted
12.7 16.6
14.1 16.2
12.6 16.1

The Application is responsive, during that time (but reacting slow).

Copy link

@max-elia max-elia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code was built and tested and the Marker's sorting works as described in the PR:

  • When new files are opened their Markers are inserted in the right place.
  • Setting changes do not change the marker's order.
  • Changes in the file, add/remove markers in the right place.
  • Renaming files results in reordering of markers with same severity.

The tests are passing, but should be adjusted to match the description.

Should be rebased onto recent commits of master.

});
it('should sort warnings higher than infos', () => {
const markerA = createMockMarker({ start: { line: 0, character: 10 }, end: { line: 0, character: 10 } }, DiagnosticSeverity.Error);
const markerB = createMockMarker({ start: { line: 0, character: 10 }, end: { line: 0, character: 10 } }, DiagnosticSeverity.Hint);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DiagnosticSeverity should be Warning and Info

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LukasBoll any reason not to change the severity here? The test-case is for should sort warnings higher than infos but we are comparing to hint.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I have overlooked that one. I will fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, the test should be correct now.

expect(markerInfoNodeB.previousSibling).to.equal(markerInfoNodeA);
});
it('should sort infos higher than hints', () => {
const markerA = createMockMarker({ start: { line: 0, character: 10 }, end: { line: 0, character: 10 } }, DiagnosticSeverity.Error);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DiagnosticSeverity.Information


it('should sort markersInfo based on URI if severities are equal', () => {
const markerA = createMockMarker({ start: { line: 0, character: 10 }, end: { line: 0, character: 10 } }, DiagnosticSeverity.Error);
const markerB = createMockMarker({ start: { line: 0, character: 10 }, end: { line: 0, character: 10 } }, DiagnosticSeverity.Hint);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have equal severity

@vince-fugnitto vince-fugnitto added markers issues related to problem markers problems issues related to the problems widget labels Jul 5, 2021
@LukasBoll LukasBoll force-pushed the fix/markernodes-order branch from 797a4ff to a910d74 Compare July 6, 2021 14:39
@LukasBoll
Copy link
Contributor Author

Thank you, I just updated the tests and rebased on Master.


let rootNode: MarkerRootNode = {
visible: false,
id: 'theia-' + 'problem' + '-marker-widget',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: any reason to do string concatenation?

Suggested change
id: 'theia-' + 'problem' + '-marker-widget',
id: 'theia-problem-marker-widget',

disableJSDOM();
});

describe('Problem Composite Tree Node', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor:

Suggested change
describe('Problem Composite Tree Node', () => {
describe('problem-composite-tree-node', () => {

or

describe('ProblemCompositeTreeNode', () => {

@@ -0,0 +1,84 @@
/********************************************************************************
* Copyright (C) 2021 Ericsson and others.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LukasBoll you would either put your company name, or actual name. I don't believe you work at Ericsson?

@@ -0,0 +1,310 @@
/********************************************************************************
* Copyright (C) 2021 Ericsson and others.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the other copyright comment.

@LukasBoll LukasBoll force-pushed the fix/markernodes-order branch from a910d74 to af6138b Compare July 7, 2021 10:47
@LukasBoll
Copy link
Contributor Author

Thank you for the hints, I changed the copyright and integrated all your suggestions.

Copy link
Member

@msujew msujew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes behave well and the tests are looking good. 👍

@vince-fugnitto
Copy link
Member

@LukasBoll any reason why the pull-request is a wip, or is it ready to perform a full review?

@LukasBoll
Copy link
Contributor Author

@LukasBoll any reason why the pull-request is a wip, or is it ready to perform a full review?

It´s ready for the full review!

@LukasBoll LukasBoll changed the title WIP: Implement order for info-marker-nodes Implement order for info-marker-nodes Jul 23, 2021
packages/markers/src/browser/marker-tree.ts Show resolved Hide resolved
Comment on lines 29 to 34
export function setSeverity(parent: MarkerInfoNode, markers: Marker<Diagnostic>[]): void {
let maxServerity: DiagnosticSeverity | undefined;
markers.forEach(marker => {
if (ProblemUtils.severityCompare(marker.data.severity, maxServerity) < 0) {
maxServerity = marker.data.severity;
}
});
parent.severity = maxServerity;
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typos:

Suggested change
export function setSeverity(parent: MarkerInfoNode, markers: Marker<Diagnostic>[]): void {
let maxServerity: DiagnosticSeverity | undefined;
markers.forEach(marker => {
if (ProblemUtils.severityCompare(marker.data.severity, maxServerity) < 0) {
maxServerity = marker.data.severity;
}
});
parent.severity = maxServerity;
};
export function setSeverity(parent: MarkerInfoNode, markers: Marker<Diagnostic>[]): void {
let maxSeverity: DiagnosticSeverity | undefined;
markers.forEach(marker => {
if (ProblemUtils.severityCompare(marker.data.severity, maxSeverity) < 0) {
maxSeverity = marker.data.severity;
}
});
parent.severity = maxSeverity;
};

Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address all outstanding comments and feedback and we can perform subsequent reviews.

Comment on lines 36 to 43
let rootNode: MarkerRootNode = {
visible: false,
id: 'theia-problem-marker-widget',
name: 'MarkerTree',
kind: 'problem',
children: [],
parent: undefined
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you set it already on beforeEach:

Suggested change
let rootNode: MarkerRootNode = {
visible: false,
id: 'theia-problem-marker-widget',
name: 'MarkerTree',
kind: 'problem',
children: [],
parent: undefined
};
let rootNode: MarkerRootNode;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the pull request and followed all your suggestions. I didn´t change the “severity” attribute in the MarkerInfoNote. Should I perform one of my suggested changes or is it fine like this?

@tsmaeder
Copy link
Contributor

tsmaeder commented Sep 9, 2021

@vince-fugnitto @msujew Please merge if appropriate.

expect(markerInfoNodeB.previousSibling).to.equal(markerInfoNodeA);
});

it('change marker content', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: consistency with should ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added should to all descriptions.

expect(rootNode.children[0]).to.equal(markerInfoNodeA);
});

it('change marker content leading to lower rank', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: consistency with should ...

expect(markerInfoNodeA.previousSibling).to.equal(markerInfoNodeB);
});

it('change marker content leading to higher rank', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: consistency with should ...

Comment on lines 69 to 72
if (uri1 === uri2) {
return 0;
}
return compareStr(uri1.path.toString(), uri2.path.toString());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can make use of our utility method that exists already:

isEqual(uri: URI, caseSensitive: boolean = true): boolean {
if (!this.hasSameOrigin(uri)) {
return false;
}
return caseSensitive
? this.toString() === uri.toString()
: this.toString().toLowerCase() === uri.toString().toLowerCase();
}

And localeCompare rather than compareStr?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could resolve this with localeCompare

@vince-fugnitto
Copy link
Member

@LukasBoll please ping me when you are ready for a final review 👍 I believe there are still unaddressed feedback from previous reviews.

@LukasBoll LukasBoll force-pushed the fix/markernodes-order branch from f05f888 to 5ed0fc5 Compare September 22, 2021 20:38
@LukasBoll
Copy link
Contributor Author

@vince-fugnitto I think everything has already been addressed.
I just rebased on master since there have been some new changes.

Copy link
Contributor

@colin-grant-work colin-grant-work left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionally this is working well for me; just one question before it's ready to go.

Fixes eclipse-theia#8983

Previously info-marker-nodes were ordered by the time they have been reported.
This commit will sort the info-marker-nodes based on the following rules:
- nodes will be sorted based on the most severe marker they contain
- if nodes contain equally severe markers, they are sorted by the URI

Signed-off-by: Lukas Boll <lukas-bool@web.de>
Copy link
Contributor

@colin-grant-work colin-grant-work left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is working well and the code looks good. @msujew, merge at your leisure.

@msujew msujew merged commit 5261983 into eclipse-theia:master Oct 20, 2021
@vince-fugnitto vince-fugnitto added this to the 1.19.0 milestone Oct 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
markers issues related to problem markers problems issues related to the problems widget
Projects
None yet
Development

Successfully merging this pull request may close these issues.

problems-view: problems order changes on preference changes
6 participants