Skip to content

Refactor tooltip handling in TmfCommonXLineChart#383

Open
TranHoangThanhDuy wants to merge 1 commit intoeclipse-tracecompass:masterfrom
TranHoangThanhDuy:patch-1
Open

Refactor tooltip handling in TmfCommonXLineChart#383
TranHoangThanhDuy wants to merge 1 commit intoeclipse-tracecompass:masterfrom
TranHoangThanhDuy:patch-1

Conversation

@TranHoangThanhDuy
Copy link
Copy Markdown

@TranHoangThanhDuy TranHoangThanhDuy commented Mar 17, 2026

Refactor TmfCommonXLineChartTooltipProvider to make the tooltip population logic extensible for subclasses via protected hooks, while preserving the default tooltip behavior.

Also remove unused maxLen calculation that was left over from an earlier implementation.

Files:

  • org.eclipse.tracecompass.tmf.ui.viewers.xychart.linechart.TmfCommonXLineChartTooltipProvider

What it does

How to test

Follow-ups

Review checklist

  • As an author, I have thoroughly tested my changes and carefully followed the instructions in this template

Summary by CodeRabbit

  • Refactor
    • Centralized and simplified line-chart tooltip internals for easier maintenance and clearer control flow.
    • Tooltip eligibility and hovered-point detection were made more robust to avoid invalid or out-of-range renders.
  • New Features
    • Richer, color-aware tooltip formatting with consistent label handling.
    • Improved per-series value formatting and clearer timeline item presentation.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 17, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Refactors tooltip generation in TmfCommonXLineChartTooltipProvider: replaces the internal XYToolTipHandler with CommonToolTipHandler, extracts protected helper methods for hovered-index calculation, series validation, label/HTML formatting, and modularizes tooltip item construction; public API signatures remain unchanged.

Changes

Cohort / File(s) Summary
Tooltip handler refactor
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf.ui/viewers/xychart/linechart/TmfCommonXLineChartTooltipProvider.java
Replaces XYToolTipHandler with CommonToolTipHandler. Adds protected helpers: isTooltipAvailable, getHoveredIndex, isValidSeriesIndex, addAdditionalTooltipItems, addSeriesTooltipItem, formatSeriesLabel and a private inner class. Centralizes time/format retrieval, gates tooltip rendering, normalizes null series ids, and applies HTML color only when series color exists. No public API signature changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hopped through lines of tooltip lore,
Pruned the handlers, opened the door,
Helpers snugly in a row,
Same surface, cleaner flow,
I twitch my nose — code sings once more!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Refactor tooltip handling in TmfCommonXLineChart' directly and accurately describes the main change: refactoring the tooltip generation logic in the TmfCommonXLineChartTooltipProvider class.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xychart/linechart/TmfCommonXLineChartTooltipProvider.java (1)

138-177: Add focused regression tests for default parity and hook behavior.

Given the internal flow rewrite, tests should assert: (1) default tooltip content parity, and (2) subclass overrides (addAdditionalTooltipItems, formatSeriesLabel, isValidSeriesIndex) are invoked as intended.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xychart/linechart/TmfCommonXLineChartTooltipProvider.java`
around lines 138 - 177, Add focused regression tests for
TmfCommonXLineChartTooltipProvider to assert default tooltip content parity and
to verify subclass hook invocation: create tests that exercise fill(...) by
simulating mouse events and compare tooltip content produced by
TmfCommonXLineChartTooltipProvider against the previous/default expected output
(default parity), and create a test subclass/mock of
TmfCommonXLineChartTooltipProvider that overrides addAdditionalTooltipItems,
formatSeriesLabel, and isValidSeriesIndex to record invocations; then assert
those overrides are called with the expected parameters when fill(...) runs (use
getXAxis(), getSeries(), and getHoveredIndex behavior to drive the hovered
index). Ensure tests cover the case where xCoordinate < 0 and index < 0 as well
to confirm no hooks are invoked.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xychart/linechart/TmfCommonXLineChartTooltipProvider.java`:
- Around line 124-134: The series label `key` is embedded into HTML unescaped in
formatSeriesLabel (class TmfCommonXLineChartTooltipProvider), which can break
tooltip rendering or allow markup injection; fix by HTML-escaping `key` before
building the label (e.g., compute an escapedKey from `key` that replaces & < > "
' or use a standard utility such as StringEscapeUtils.escapeHtml4) and then use
escapedKey (not raw key) when calling String.format(HTML_COLOR_TOOLTIP, ... ,
label) so the tooltip HTML is safe.

---

Nitpick comments:
In
`@tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xychart/linechart/TmfCommonXLineChartTooltipProvider.java`:
- Around line 138-177: Add focused regression tests for
TmfCommonXLineChartTooltipProvider to assert default tooltip content parity and
to verify subclass hook invocation: create tests that exercise fill(...) by
simulating mouse events and compare tooltip content produced by
TmfCommonXLineChartTooltipProvider against the previous/default expected output
(default parity), and create a test subclass/mock of
TmfCommonXLineChartTooltipProvider that overrides addAdditionalTooltipItems,
formatSeriesLabel, and isValidSeriesIndex to record invocations; then assert
those overrides are called with the expected parameters when fill(...) runs (use
getXAxis(), getSeries(), and getHoveredIndex behavior to drive the hovered
index). Ensure tests cover the case where xCoordinate < 0 and index < 0 as well
to confirm no hooks are invoked.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a71cc108-a85e-4bb3-a590-55efb4311739

📥 Commits

Reviewing files that changed from the base of the PR and between d2fde0d and cf91de6.

📒 Files selected for processing (1)
  • tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xychart/linechart/TmfCommonXLineChartTooltipProvider.java

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xychart/linechart/TmfCommonXLineChartTooltipProvider.java (1)

145-148: Consider adding defensive null/bounds check for Y-axis array access.

The access chartViewer.getSwtChart().getAxisSet().getYAxes()[0] assumes at least one Y-axis exists and that the array is non-null. While this pattern appears consistent with other code in the codebase (e.g., TmfCommonXAxisChartViewer uses similar access), a defensive check would prevent potential ArrayIndexOutOfBoundsException in edge cases.

♻️ Optional defensive check
             Format format = null;
             if (getChartViewer() instanceof TmfCommonXAxisChartViewer chartViewer) {
-                format = chartViewer.getSwtChart().getAxisSet().getYAxes()[0].getTick().getFormat();
+                IAxis[] yAxes = chartViewer.getSwtChart().getAxisSet().getYAxes();
+                if (yAxes != null && yAxes.length > 0) {
+                    format = yAxes[0].getTick().getFormat();
+                }
             }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xychart/linechart/TmfCommonXLineChartTooltipProvider.java`
around lines 145 - 148, The code in TmfCommonXLineChartTooltipProvider assumes a
non-null, non-empty Y-axes array when calling
chartViewer.getSwtChart().getAxisSet().getYAxes()[0]; add defensive checks to
ensure getSwtChart(), getAxisSet(), and getYAxes() are non-null and that
getYAxes().length > 0 before indexing, and fall back to a safe default (e.g.,
leave format null or use a sensible fallback format) so the code in the block
that uses `format` cannot throw ArrayIndexOutOfBoundsException or NPE; locate
this logic around the getChartViewer() instanceof TmfCommonXAxisChartViewer
branch and update there.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xychart/linechart/TmfCommonXLineChartTooltipProvider.java`:
- Around line 99-112: The compilation fails because addSeriesTooltipItem() in
TmfCommonXLineChartTooltipProvider calls addItem() which is defined on
TmfAbstractToolTipHandler, not the outer class; update addSeriesTooltipItem(...)
to use the tooltip handler instance (fToolTipHandler) to add items instead of
calling addItem() directly: replace the direct addItem(...) calls with
fToolTipHandler.addItem(...) (or change the method signature to accept a
TmfAbstractToolTipHandler parameter and call handler.addItem(...)); ensure
formatSeriesLabel(...) remains accessible (move into CommonToolTipHandler or
make it package-private/static if needed) and update any callers accordingly
(e.g., CommonToolTipHandler.fill() should call
addSeriesTooltipItem(fToolTipHandler, ... ) or the modified method that accepts
the handler).

---

Nitpick comments:
In
`@tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xychart/linechart/TmfCommonXLineChartTooltipProvider.java`:
- Around line 145-148: The code in TmfCommonXLineChartTooltipProvider assumes a
non-null, non-empty Y-axes array when calling
chartViewer.getSwtChart().getAxisSet().getYAxes()[0]; add defensive checks to
ensure getSwtChart(), getAxisSet(), and getYAxes() are non-null and that
getYAxes().length > 0 before indexing, and fall back to a safe default (e.g.,
leave format null or use a sensible fallback format) so the code in the block
that uses `format` cannot throw ArrayIndexOutOfBoundsException or NPE; locate
this logic around the getChartViewer() instanceof TmfCommonXAxisChartViewer
branch and update there.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ca319e3b-06f6-4599-b24c-c1d18902f2af

📥 Commits

Reviewing files that changed from the base of the PR and between cf91de6 and f7a2611.

📒 Files selected for processing (1)
  • tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xychart/linechart/TmfCommonXLineChartTooltipProvider.java

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xychart/linechart/TmfCommonXLineChartTooltipProvider.java (1)

145-148: Add defensive check before accessing getYAxes()[0].

The code accesses getYAxes()[0] without verifying the array is non-empty. While line charts typically have at least one Y axis, a defensive check would prevent a potential ArrayIndexOutOfBoundsException in edge cases.

🛡️ Proposed fix
             Format format = null;
             if (getChartViewer() instanceof TmfCommonXAxisChartViewer chartViewer) {
-                format = chartViewer.getSwtChart().getAxisSet().getYAxes()[0].getTick().getFormat();
+                org.eclipse.swtchart.IAxis[] yAxes = chartViewer.getSwtChart().getAxisSet().getYAxes();
+                if (yAxes.length > 0) {
+                    format = yAxes[0].getTick().getFormat();
+                }
             }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xychart/linechart/TmfCommonXLineChartTooltipProvider.java`
around lines 145 - 148, The code in TmfCommonXLineChartTooltipProvider accesses
chartViewer.getSwtChart().getAxisSet().getYAxes()[0] without verifying the Y
axes array is present or non-empty; change the logic to fetch the YAxes array
into a local variable (e.g., Axis[] yAxes =
chartViewer.getSwtChart().getAxisSet().getYAxes()), check that yAxes != null &&
yAxes.length > 0 before calling yAxes[0].getTick().getFormat(), and leave format
as null or use a safe fallback if the check fails so no
ArrayIndexOutOfBoundsException occurs.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xychart/linechart/TmfCommonXLineChartTooltipProvider.java`:
- Around line 145-148: The code in TmfCommonXLineChartTooltipProvider accesses
chartViewer.getSwtChart().getAxisSet().getYAxes()[0] without verifying the Y
axes array is present or non-empty; change the logic to fetch the YAxes array
into a local variable (e.g., Axis[] yAxes =
chartViewer.getSwtChart().getAxisSet().getYAxes()), check that yAxes != null &&
yAxes.length > 0 before calling yAxes[0].getTick().getFormat(), and leave format
as null or use a safe fallback if the check fails so no
ArrayIndexOutOfBoundsException occurs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8b222e55-2bb7-4f10-8689-e68af601c08c

📥 Commits

Reviewing files that changed from the base of the PR and between f7a2611 and 38d85da.

📒 Files selected for processing (1)
  • tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xychart/linechart/TmfCommonXLineChartTooltipProvider.java

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (2)
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xychart/linechart/TmfCommonXLineChartTooltipProvider.java (2)

114-121: ⚠️ Potential issue | 🟠 Major

Escape key before embedding it into HTML tooltip markup.

Line 115/Line 120 uses raw series IDs inside HTML. Labels containing <, &, or quotes can break rendering and inject unintended markup.

Proposed fix
     protected String formatSeriesLabel(IXYSeries series, String key) {
-        String label = (key == null) ? "" : key; //$NON-NLS-1$
+        String label = escapeHtml((key == null) ? "" : key); //$NON-NLS-1$
         Color color = series.getColor();
         if (color != null) {
             RGBA rgba = color.getRGBA();
             RGBAColor rgbaColor = new RGBAColor(rgba.rgb.red, rgba.rgb.green, rgba.rgb.blue, rgba.alpha);
             label = String.format(TmfCommonXLineChartTooltipProvider.HTML_COLOR_TOOLTIP, rgbaColor, label);
         }
         return label;
     }
+
+    private static String escapeHtml(String value) {
+        return value
+                .replace("&", "&amp;") //$NON-NLS-1$ //$NON-NLS-2$
+                .replace("<", "&lt;") //$NON-NLS-1$ //$NON-NLS-2$
+                .replace(">", "&gt;") //$NON-NLS-1$ //$NON-NLS-2$
+                .replace("\"", "&quot;") //$NON-NLS-1$ //$NON-NLS-2$
+                .replace("'", "&#39;"); //$NON-NLS-1$ //$NON-NLS-2$
+    }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xychart/linechart/TmfCommonXLineChartTooltipProvider.java`
around lines 114 - 121, The series label is inserted raw into HTML in
formatSeriesLabel(IXYSeries series, String key), which can break rendering or
allow injection; before using key (the series ID) in the String.format(...) with
HTML_COLOR_TOOLTIP, HTML-escape special characters (&, <, >, " and ') and
preserve the existing null/empty handling so the escaped value is used instead
of the raw key; update formatSeriesLabel to replace or use a utility to perform
HTML escaping on key prior to embedding it in the tooltip string.

99-112: ⚠️ Potential issue | 🔴 Critical

Compilation issue: addItem(...) is invoked outside TmfAbstractToolTipHandler context.

At Line 108 and Line 110, addItem(...) is called from TmfCommonXLineChartTooltipProvider. That method is defined on the tooltip handler, so this call site is invalid and breaks compilation.

Proposed fix
+    `@FunctionalInterface`
+    protected interface TooltipItemSink {
+        void add(ToolTipString label, ToolTipString value);
+    }
+
-    protected void addSeriesTooltipItem(IXYSeries series, String key, int index, Format format) {
+    protected void addSeriesTooltipItem(IXYSeries series, String key, int index, Format format, TooltipItemSink sink) {
         double[] ySeries = series.getYSeries();
         if (ySeries == null || index < 0 || index >= ySeries.length) {
             return;
         }

         String label = formatSeriesLabel(series, key);
         double yValue = ySeries[index];
-        if (format == null) {
-            addItem(null, ToolTipString.fromHtml(label), ToolTipString.fromDecimal(yValue));
-        } else {
-            addItem(null, ToolTipString.fromHtml(label), ToolTipString.fromString(format.format(yValue)));
-        }
+        ToolTipString value = (format == null)
+                ? ToolTipString.fromDecimal(yValue)
+                : ToolTipString.fromString(format.format(yValue));
+        sink.add(ToolTipString.fromHtml(label), value);
     }
@@
-                addSeriesTooltipItem(xySeries, key, index, format);
+                addSeriesTooltipItem(xySeries, key, index, format, (label, value) -> addItem(null, label, value));

Also applies to: 162-162

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xychart/linechart/TmfCommonXLineChartTooltipProvider.java`
around lines 99 - 112, The calls to addItem(...) inside
TmfCommonXLineChartTooltipProvider are invalid because addItem is a method on
TmfAbstractToolTipHandler; update addSeriesTooltipItem (and the similar call in
addEventsTooltipItem) to obtain the tooltip handler (via getToolTipHandler())
and invoke handler.addItem(...), guarding with a null check on the handler
before calling; ensure you pass the same arguments
(ToolTipString.fromHtml(label), ToolTipString.fromDecimal/
fromString(format...)) and remove the direct addItem(...) calls in
TmfCommonXLineChartTooltipProvider.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In
`@tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xychart/linechart/TmfCommonXLineChartTooltipProvider.java`:
- Around line 114-121: The series label is inserted raw into HTML in
formatSeriesLabel(IXYSeries series, String key), which can break rendering or
allow injection; before using key (the series ID) in the String.format(...) with
HTML_COLOR_TOOLTIP, HTML-escape special characters (&, <, >, " and ') and
preserve the existing null/empty handling so the escaped value is used instead
of the raw key; update formatSeriesLabel to replace or use a utility to perform
HTML escaping on key prior to embedding it in the tooltip string.
- Around line 99-112: The calls to addItem(...) inside
TmfCommonXLineChartTooltipProvider are invalid because addItem is a method on
TmfAbstractToolTipHandler; update addSeriesTooltipItem (and the similar call in
addEventsTooltipItem) to obtain the tooltip handler (via getToolTipHandler())
and invoke handler.addItem(...), guarding with a null check on the handler
before calling; ensure you pass the same arguments
(ToolTipString.fromHtml(label), ToolTipString.fromDecimal/
fromString(format...)) and remove the direct addItem(...) calls in
TmfCommonXLineChartTooltipProvider.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6527fdc3-f10e-4b10-9d1f-1a74fb0812fc

📥 Commits

Reviewing files that changed from the base of the PR and between 38d85da and 7e4f1aa.

📒 Files selected for processing (1)
  • tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xychart/linechart/TmfCommonXLineChartTooltipProvider.java

@TranHoangThanhDuy
Copy link
Copy Markdown
Author

Hello @jonahgraham , @MatthewKhouzam ,

This is a refactor of TmfCommonXLineChartTooltipProvider.
The goal is to make the tooltip handling easier to extend (via small overridable hooks) while preserving the existing default behavior (time item + per-series value).
I’d appreciate a quick check for any functional regressions or API/style concerns.

Could someone please review my change?
Thank you in advance.
Duy Tran

Copy link
Copy Markdown
Contributor

@jonahgraham jonahgraham left a comment

Choose a reason for hiding this comment

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

Hi @TranHoangThanhDuy

The goal is to make the tooltip handling easier to extend (via small overridable hooks) while preserving the existing default behavior (time item + per-series value).

Thanks for the PR - the general idea seems good to me. In addition I like removing the calculation of maxLen that was no longer used anymore.

I am concerned that too much new API is added that isn't maintainable in the future, or makes this class too hard to update/evolve. Each new API method should be documented for its purpose and only make methods API that are need to be API.

Therefore, please change the new protected methods to private or document them.

Additionally, can you also complete the "what it does/how to test/etc" fields from the PR template in the top comment.

Copy link
Copy Markdown
Contributor

@MatthewKhouzam MatthewKhouzam left a comment

Choose a reason for hiding this comment

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

I like this, let's get it in. I gave a light nit on the logic.

@MatthewKhouzam
Copy link
Copy Markdown
Contributor

Also, please ssh / gpg sign your commit to prevent impersonation attacks.

@jonahgraham
Copy link
Copy Markdown
Contributor

Note that this code does not compile. Please let me know if you are having trouble setting up the development environment so you can develop and test your changes properly

Error from the build log:

Error: Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:4.0.11:compile (default-compile) on project org.eclipse.tracecompass.tmf.ui: Compilation failure: Compilation failure:
Error: /home/runner/work/org.eclipse.tracecompass/org.eclipse.tracecompass/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xychart/linechart/TmfCommonXLineChartTooltipProvider.java:[99]
Error: addItem(null,
Error: ^^^^^^^
Error: The method addItem(null, TmfAbstractToolTipHandler.ToolTipString, TmfAbstractToolTipHandler.ToolTipString) is undefined for the type TmfCommonXLineChartTooltipProvider
Error: /home/runner/work/org.eclipse.tracecompass/org.eclipse.tracecompass/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xychart/linechart/TmfCommonXLineChartTooltipProvider.java:[113]
Error: addItem(null, ToolTipString.fromHtml(label), ToolTipString.fromDecimal(yValue));
Error: ^^^^^^^
Error: The method addItem(null, TmfAbstractToolTipHandler.ToolTipString, TmfAbstractToolTipHandler.ToolTipString) is undefined for the type TmfCommonXLineChartTooltipProvider
Error: /home/runner/work/org.eclipse.tracecompass/org.eclipse.tracecompass/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xychart/linechart/TmfCommonXLineChartTooltipProvider.java:[115]
Error: addItem(null, ToolTipString.fromHtml(label), ToolTipString.fromString(format.format(yValue)));
Error: ^^^^^^^
Error: The method addItem(null, TmfAbstractToolTipHandler.ToolTipString, TmfAbstractToolTipHandler.ToolTipString) is undefined for the type TmfCommonXLineChartTooltipProvider

@TranHoangThanhDuy
Copy link
Copy Markdown
Author

Hi @jonahgraham ,
Apologies for the delay in this Pull Request.
I'm spending a considerable amount of time building the code.
Currently, I'm building using Maven via the command line, and it takes quite a long time to build even with small changes.
I tried installing Eclipse RCP but encountered platform issues, so I haven't been able to debug with Eclipse yet.

@TranHoangThanhDuy
Copy link
Copy Markdown
Author

@jonahgraham , @MatthewKhouzam ,
I'm building it using the command line and it will take some time to confirm the build results.
However, I've used this source code for another project that uses Trace Compass and it worked normally.
Therefore, I think we can continue reviewing this PR.

@TranHoangThanhDuy TranHoangThanhDuy force-pushed the patch-1 branch 7 times, most recently from ad88702 to 398e0c3 Compare April 2, 2026 10:48
Copy link
Copy Markdown
Contributor

@jonahgraham jonahgraham left a comment

Choose a reason for hiding this comment

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

I'll run this change up in my dev environment once the CI reports it compiles - at which point I can complete my review.

@jonahgraham , @MatthewKhouzam , I'm building it using the command line and it will take some time to confirm the build results. However, I've used this source code for another project that uses Trace Compass and it worked normally. Therefore, I think we can continue reviewing this PR.

@TranHoangThanhDuy this sounds like you have not setup a dev environment to edit and test out changes in TraceCompass - please follow instructions in https://github.com/eclipse-tracecompass/org.eclipse.tracecompass/blob/master/DEVELOPMENT_ENV_SETUP.md

I recommend "Using the Eclipse Installer (Oomph)" part of the document. I have just tested it and the instructions worked fine. There are three errors in the workspace that can be ignored #387

void addItem(ToolTipString key, ToolTipString value);
}

protected void addAdditionalTooltipItems(ITooltipItemAdder adder, double xCoordinate) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Methods that are API should be documented as to their purpose (to be overridden or only called by subclasses)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I added the description for APIs.

return label;
}

protected String getFirstValidSeriesKey() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unused method?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sorry for missing it.
That method is designed for using in the subclass.
In fact, I needed to get the first valid series key in the subclass implementation, so I created this method.

@TranHoangThanhDuy
Copy link
Copy Markdown
Author

I'll run this change up in my dev environment once the CI reports it compiles - at which point I can complete my review.

@jonahgraham , @MatthewKhouzam , I'm building it using the command line and it will take some time to confirm the build results. However, I've used this source code for another project that uses Trace Compass and it worked normally. Therefore, I think we can continue reviewing this PR.

@TranHoangThanhDuy this sounds like you have not setup a dev environment to edit and test out changes in TraceCompass - please follow instructions in https://github.com/eclipse-tracecompass/org.eclipse.tracecompass/blob/master/DEVELOPMENT_ENV_SETUP.md

I recommend "Using the Eclipse Installer (Oomph)" part of the document. I have just tested it and the instructions worked fine. There are three errors in the workspace that can be ignored #387

Hi @jonahgraham -san,
Thanks for your kind help.
I successfully setup the development environment using the Eclipse Installer (Oomph).

Besides the three errors you pointed out, I encountered another one, but it wasn't a major issue:
image
I have resolved these three errors with the source code of master branch and initially succeeded in debugging Trace Compass.
I will use this env to debug with my PR and confirm the results later.

@jonahgraham
Copy link
Copy Markdown
Contributor

The project is working towards a release in the coming days, once that is done a full review from a project committer can be completed. We discussed this during today's project meeting

@TranHoangThanhDuy
Copy link
Copy Markdown
Author

Hi @jonahgraham, @MatthewKhouzam,
All tests were passed.
Could you please continue your review?
Thank you.

Copy link
Copy Markdown
Contributor

@arfio arfio left a comment

Choose a reason for hiding this comment

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

Thank you for this patch, just minor fixes and I will gladly approve. I like to remove as many warnings as possible as sometimes, they will highlight possible errors.


import java.text.Format;
import java.util.Arrays;
import java.util.function.BiConsumer;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When using Eclipse IDE, use ctrl+shift+o to fix/sort imports.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thank you for this helpful guide.

* time offset).
* @since 9.2
*/
protected void addAdditionalTooltipItems(BiConsumer<ToolTipString, ToolTipString> adder, double xCoordinate) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use @nonnull to suppress type annotation warnings when using this method ->
addAdditionalTooltipItems(BiConsumer<@NonNull ToolTipString, @NonNull ToolTipString> adder, double xCoordinate)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I added @nonnull. Could you please check it again?

ITmfTimestamp time = TmfTimestamp.fromNanos(timeNanos);
adder.accept(
ToolTipString.fromString(Messages.TmfCommonXLineChartTooltipProvider_time),
ToolTipString.fromTimestamp(time.toString(), time.toNanos()));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use Objects.requireNonNull() method to suppress null annotation warning. This method is ok to use when it is guaranteed that the value will never be null. In this case the timestamp is derived from an unboxed value, so it should not be null and the message is a constant.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I used Objects.requireNonNull() method. Could you please check it again?

* formatter). If {@code null}, a default decimal formatting is used.
* @since 9.2
*/
protected void addSeriesTooltipItem(BiConsumer<ToolTipString, ToolTipString> adder, IXYSeries xySeries, int index, Format format) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same as above, use @nonnull on the ToolTipString types

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I updated it.

} else {
adder.accept(
ToolTipString.fromHtml(label),
ToolTipString.fromString(format.format(yValue)));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use Objects.requireNonNull() as the yValue is unboxed, it should never be null

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I updated it.

* @return The formatted label (potentially containing HTML).
* @since 9.2
*/
protected static final String formatSeriesLabel(IXYSeries xySeries) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This method never returns null so the return type should be annotated with @nonnull

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I added @nonnull. Could you please check it again?

* The hovered X coordinate in data space (i.e., in the same domain as
* the series X values, typically nanoseconds relative to the viewer's
* time offset).
* @since 9.2
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The version number should be upgrade from 9.2.0 to 9.3.0 in the file tmf/org.eclipse.tracecompass.tmf.ui/META-INF/MANIFEST.MF. Then all these descriptions should be updated to since 9.3

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks.
I have upgraded version number in MANIFEST.MF to 9.3.0 and method descriptions are also updated.
Please check it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I forgot that you also need to update the pom.xml

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hi @arfio ,
I updated the pom.xml in my local env

...
<artifactId>org.eclipse.tracecompass.tmf.ui</artifactId>
<version>9.3.0-SNAPSHOT</version> <!-- this line was updated -->
...

Then some errors occur.
It requires some locations update to 9.3.0

/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/dialogs/MultiTreePatternFilter.java
image

/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/tree/AbstractSelectTreeViewer3.java
image

Should I update those?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hi @arfio

I have updated to fix issue I mentioned above in the files

  • /org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/dialogs/MultiTreePatternFilter.java

  • /org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/tree/AbstractSelectTreeViewer3.java

If this is unnecessary, please let me know.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I removed these changes, and the build works without any errors. Also, as these files were not changed, I think you should change it back to 9.2.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hi @arfio , I have changed those back to 9.2.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@TranHoangThanhDuy Sorry I should have been clearer, you should keep the pom.xml and the MANIFEST.MF change and the 9.3 in the file you modified. The errors that you have in the other 2 files are because the baseline was updated and I think you need to refresh it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hi @arfio , thank you for making it clear.
I have synchronized my branch with eclipse-tracecompass:master.
Then, I updated pom.xml, MANIFEST.MF and the file I modified to 9.3.
Please help me confirm.

Refactor TmfCommonXLineChartTooltipProvider to make the tooltip population logic extensible for subclasses via protected hooks, while preserving the default tooltip behavior.

Also remove unused maxLen calculation that was left over from an earlier implementation.

Files:
- org.eclipse.tracecompass.tmf.ui.viewers.xychart.linechart.TmfCommonXLineChartTooltipProvider
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants