-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Conversation
I also tried the implementation with 33k markers from the eclipse.jdt.ls workspace
The Application is responsive, during that time (but reacting slow). |
There was a problem hiding this 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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
packages/markers/src/browser/problem/problem-composite-tree-node.spec.ts
Outdated
Show resolved
Hide resolved
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should have equal severity
797a4ff
to
a910d74
Compare
Thank you, I just updated the tests and rebased on Master. |
|
||
let rootNode: MarkerRootNode = { | ||
visible: false, | ||
id: 'theia-' + 'problem' + '-marker-widget', |
There was a problem hiding this comment.
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?
id: 'theia-' + 'problem' + '-marker-widget', | |
id: 'theia-problem-marker-widget', |
disableJSDOM(); | ||
}); | ||
|
||
describe('Problem Composite Tree Node', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor:
describe('Problem Composite Tree Node', () => { | |
describe('problem-composite-tree-node', () => { |
or
describe('ProblemCompositeTreeNode', () => {
packages/markers/src/browser/problem/problem-composite-tree-node.spec.ts
Show resolved
Hide resolved
@@ -0,0 +1,84 @@ | |||
/******************************************************************************** | |||
* Copyright (C) 2021 Ericsson and others. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
a910d74
to
af6138b
Compare
Thank you for the hints, I changed the copyright and integrated all your suggestions. |
There was a problem hiding this 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. 👍
@LukasBoll any reason why the pull-request is a |
It´s ready for the full review! |
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; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typos:
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; | |
}; |
There was a problem hiding this 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.
let rootNode: MarkerRootNode = { | ||
visible: false, | ||
id: 'theia-problem-marker-widget', | ||
name: 'MarkerTree', | ||
kind: 'problem', | ||
children: [], | ||
parent: undefined | ||
}; |
There was a problem hiding this comment.
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
:
let rootNode: MarkerRootNode = { | |
visible: false, | |
id: 'theia-problem-marker-widget', | |
name: 'MarkerTree', | |
kind: 'problem', | |
children: [], | |
parent: undefined | |
}; | |
let rootNode: MarkerRootNode; |
There was a problem hiding this comment.
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?
af6138b
to
4bf86c3
Compare
4bf86c3
to
c4ffcc6
Compare
@vince-fugnitto @msujew Please merge if appropriate. |
expect(markerInfoNodeB.previousSibling).to.equal(markerInfoNodeA); | ||
}); | ||
|
||
it('change marker content', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: consistency with should ...
There was a problem hiding this comment.
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', () => { |
There was a problem hiding this comment.
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', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: consistency with should ...
if (uri1 === uri2) { | ||
return 0; | ||
} | ||
return compareStr(uri1.path.toString(), uri2.path.toString()); |
There was a problem hiding this comment.
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:
theia/packages/core/src/common/uri.ts
Lines 202 to 210 in 8618183
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
?
There was a problem hiding this comment.
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
c4ffcc6
to
f05f888
Compare
@LukasBoll please ping me when you are ready for a final review 👍 I believe there are still unaddressed feedback from previous reviews. |
f05f888
to
5ed0fc5
Compare
@vince-fugnitto I think everything has already been addressed. |
packages/markers/src/browser/problem/problem-composite-tree-node.spec.ts
Outdated
Show resolved
Hide resolved
packages/markers/src/browser/problem/problem-composite-tree-node.ts
Outdated
Show resolved
Hide resolved
5ed0fc5
to
fffd271
Compare
There was a problem hiding this 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.
packages/markers/src/browser/problem/problem-composite-tree-node.ts
Outdated
Show resolved
Hide resolved
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>
fffd271
to
9097bbf
Compare
There was a problem hiding this 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.
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