Skip to content

Commit

Permalink
[markers] add problem decorator fontData
Browse files Browse the repository at this point in the history
- added `fontData` to the problem decorators in the explorer which
decorates the node with a foreground color with the highest marker
severity.
- added a new method `getPriority()` which takes as argument
a marker diagnostic and returns it's priority which is used when
decorating. Markers with a higher severity have a higher priority.

Signed-off-by: vince-fugnitto <vincent.fugnitto@ericsson.com>
  • Loading branch information
vince-fugnitto committed Mar 26, 2020
1 parent f5433ec commit b0eb8e2
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion packages/markers/src/browser/problem/problem-decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,12 @@ export class ProblemDecorator implements TreeDecorator {
const position = TreeDecoration.IconOverlayPosition.BOTTOM_RIGHT;
const icon = this.getOverlayIcon(marker);
const color = this.getOverlayIconColor(marker);
const priority = this.getPriority(marker);
return {
priority,
fontData: {
color,
},
iconOverlay: {
position,
icon,
Expand All @@ -139,7 +144,7 @@ export class ProblemDecorator implements TreeDecorator {
shape: 'circle',
color: 'transparent'
}
}
},
};
}

Expand All @@ -163,6 +168,21 @@ export class ProblemDecorator implements TreeDecorator {
}
}

/**
* Get the decoration for a given marker diagnostic.
* Markers with higher severity have a higher priority and should be displayed.
* @param marker the diagnostic marker.
*/
protected getPriority(marker: Marker<Diagnostic>): number {
const { severity } = marker.data;
switch (severity) {
case 1: return 30; // Errors.
case 2: return 20; // Warnings.
case 3: return 10; // Infos.
default: return 0;
}
}

/**
* Returns `true` if the diagnostic (`data`) of the marker argument has `Error`, `Warning`, or `Information` severity.
* Otherwise, returns `false`.
Expand Down

0 comments on commit b0eb8e2

Please sign in to comment.