Skip to content

Conversation

@sigmaaa
Copy link
Collaborator

@sigmaaa sigmaaa commented Dec 11, 2025

Description

Added pip show check for esp-idf-size package

Fixes # (IEP-1667)

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How has this been tested?

Install the the latest esp-idf 6.0, and make sure it includes the esp-idf-size package with at least version 2.0. Check it from the esp-idf venv Python.
Then check the application size analysis.

Test Configuration:

  • ESP-IDF Version:
  • OS (Windows,Linux and macOS):

Dependent components impacted by this PR:

  • Component 1
  • Component 2

Checklist

  • PR Self Reviewed
  • Applied Code formatting
  • Added Documentation
  • Added Unit Test
  • Verified on all platforms - Windows,Linux and macOS

Summary by CodeRabbit

  • New Features

    • Added archive and file-specific size/symbol queries and richer memory breakdowns shown in the size viewer.
  • Bug Fixes

    • Improved handling of missing/invalid size output to show a clear error message instead of failing; NaN values are now treated as zero.
  • Documentation

    • Added user-facing messages/localization for no-data and error states.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 11, 2025

Walkthrough

Reworks IDF size data handling: introduces a flexible command-argument builder for idf.py size calls, centralizes command construction (including flags like --archives and --file), improves JSON post-processing and data model population for libraries/memory/sections/symbols, and adds defensive UI handling and new localization keys for missing data.

Changes

Cohort / File(s) Change Summary
Core data manager
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/IDFSizeDataManager.java
Replaced ad-hoc command builders with getIDFSizeCommandArgs(pythonPath, file, String... additionalFlags); removed old getCommandArgs/getCommandArgsArchives; updated calls to use new builder (--archives, --file); moved NaN→0 JSON replacement into success path; switched Collections.EMPTY_LISTCollections.emptyList(); expanded getSizeRecord to fully populate MemoryType and Section objects and attach them to library models; updated symbol detail retrieval; minor whitespace/formatting edits.
Charts UI defensive handling
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/IDFSizeChartsComposite.java
Added null/empty overview handling in plotCharts to show a red centered error label and return early; updated getIDFSizeOverviewData to call IDFSizeDataManager.getIDFSizeOverview(IFile) and return null on exception; added localization marker comments.
Overview table defensive handling
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/IDFSizeOverviewComposite.java
Added validation in populateTable to handle missing/empty overview JSON by inserting a red error row (uses NoExpectedOutputMsg) and returning early; added non-NLS comments for several string literals and formatting.
Messages / localization
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/Messages.java, bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/messages.properties
Added two new message keys: IDFSizeOverviewComposite_NoExpectedOutputMsg and IDFSizeChartsComposite_NoMemoryDataAvailableLblMsg with corresponding localized strings.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Areas needing extra attention:
    • Correctness of the new command-argument builder and all call sites using variadic flags.
    • JSON post-processing relocation (NaN→0) and potential effects on error paths.
    • Thorough review of getSizeRecord changes populating nested MemoryType → Section → Symbol structures for completeness and null-safety.
    • UI defensive paths: ensure error-label creation/layout changes don't regress existing layouts or accessibility.
    • Ensure no remaining references to removed helper methods exist elsewhere.

Possibly related PRs

Suggested reviewers

  • AndriiFilippov
  • kolipakakondal
  • alirana01

Poem

🐇 I munched the map and parsed each size,

flags tucked in my pocket, neat and wise.
From archives to symbols I hop and see—
JSON neat, no NaNs, all tidy as can be. ✨

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ 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 clearly summarizes the main change: updating support for esp-idf-size 2.0 and using idf.py size command, which aligns with the file changes across IDFSizeDataManager, IDFSizeChartsComposite, and IDFSizeOverviewComposite.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch IEP-1667

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

@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 (3)
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/IDFSizeDataManager.java (3)

67-71: Runtime detection of esp-idf-size version looks correct; consider caching the result.

Using pip show esp_idf_size plus isNgArgSupported to decide whether to pass --ng aligns with esp-idf-size v2.0 guidance that --ng is no longer needed and becomes invalid in >=2.0. (github.com)
If getIDFSizeOverview is called frequently, you might want to cache the parsed major version or the useNg flag per Python environment instead of running pip show on every call, but this is an optimization and not required for correctness.


326-335: Version-based --ng detection logic aligns with esp-idf-size 2.0 behavior.

Parsing the Version: line from pip show esp_idf_size and enabling --ng only when major < 2 is consistent with the esp-idf-size 2.0 migration guide, where --ng is no longer needed and becomes invalid in 2.x and above. (github.com)

Optional: you could log the detected version and whether --ng is being used at debug level to help diagnose issues when users have mismatched esp-idf-size versions in their environment.


337-354: Major-version extraction is robust for standard pip versions; optional enhancement.

extractMajorVersion correctly handles typical PEP 440-style version strings from pip (e.g. 2.1.0, 1.0.0rc1, 1.0.0.dev0) by trimming the Version: prefix, slicing up to the first dot, and parsing the numeric prefix, returning null on any parsing issues.

If you want to be extra defensive, you could strip leading non-digit characters before parsing (in case some future tooling decorates the version line), but current pip output doesn’t require this.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e297d94 and f2d6737.

📒 Files selected for processing (1)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/IDFSizeDataManager.java (6 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: build_windows
  • GitHub Check: build_macos
  • GitHub Check: build_linux
🔇 Additional comments (4)
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/IDFSizeDataManager.java (4)

114-115: Child symbol records reuse the updated getSizeRecord path – LGTM.

Reusing getSizeRecord for symbol children keeps the construction of LibraryMemoryComponent consistent with the new memory-type aware representation.


259-263: Minor readability-only change – no behavioral impact.

Adding a blank line before parsing versions in isVersionAtLeast is fine and doesn’t affect logic.


277-290: New esp-idf-size invocation looks correct; verify minimum supported ESP‑IDF / esp-idf-size versions.

Switching from the script path to python -m esp_idf_size with --format json2 and optional --ng matches the esp-idf-size 2.x CLI (which supports --format {…,json2,…} and removed the need for --ng, making it invalid in >=2.0). (docs.espressif.com)

Two things to double-check:

  1. Minimum esp-idf-size / ESP‑IDF version: For older installations that may not support json2 or the module entrypoint, this could be a behavior change. Ensure the plugin’s documented minimum ESP‑IDF / esp-idf-size version matches this assumption.
  2. Target name no longer used: getIDFSizeOverview still takes targetName but the new command no longer passes any target-related argument. Confirm that this is intentional and that esp-idf-size no longer needs target-specific flags for the overview report.

292-302: pip show command construction is straightforward and portable – LGTM.

Using pythonExecutablePath -m pip show esp_idf_size is the standard way to query the package from the selected interpreter and should work across platforms where pip is installed in that environment.

Comment on lines 127 to 166
String[] keySplit = key.split("/");
String nameToSet = keySplit[keySplit.length - 1] + " -> " + key;
library.setName(nameToSet);
library.setAbbrevName((String) object.get("abbrev_name"));
library.setSize(getValue(object.get("size")));
library.setSizeDiff(getValue(object.get("size_diff")));
Map<String, MemoryType> memoryTypesMap = new LinkedHashMap<>();
JSONObject memoryTypesJson = (JSONObject) object.get("memory_types");
library.setSize(getValue(object.get("size")));
library.setSizeDiff(getValue(object.get("size_diff")));
Map<String, MemoryType> memoryTypesMap = new LinkedHashMap<>();
JSONObject memoryTypesJson = (JSONObject) object.get("memory_types");

for (Object memoryKeyObj : memoryTypesJson.keySet()) {
String memoryKey = (String) memoryKeyObj;
JSONObject memoryTypeJson = (JSONObject) memoryTypesJson.get(memoryKey);
for (Object memoryKeyObj : memoryTypesJson.keySet())
{
String memoryKey = (String) memoryKeyObj;
JSONObject memoryTypeJson = (JSONObject) memoryTypesJson.get(memoryKey);

MemoryType memoryType = new MemoryType();
memoryType.setSize(getValue(memoryTypeJson.get("size")));
memoryType.setSizeDiff(getValue(memoryTypeJson.get("size_diff")));
MemoryType memoryType = new MemoryType();
memoryType.setSize(getValue(memoryTypeJson.get("size")));
memoryType.setSizeDiff(getValue(memoryTypeJson.get("size_diff")));

JSONObject sectionsJson = (JSONObject) memoryTypeJson.get("sections");
Map<String, Section> sectionsMap = new LinkedHashMap<>();
JSONObject sectionsJson = (JSONObject) memoryTypeJson.get("sections");
Map<String, Section> sectionsMap = new LinkedHashMap<>();

for (Object sectionKeyObj : sectionsJson.keySet()) {
String sectionKey = (String) sectionKeyObj;
JSONObject sectionJson = (JSONObject) sectionsJson.get(sectionKey);
for (Object sectionKeyObj : sectionsJson.keySet())
{
String sectionKey = (String) sectionKeyObj;
JSONObject sectionJson = (JSONObject) sectionsJson.get(sectionKey);

Section section = new Section();
section.setSize(getValue(sectionJson.get("size")));
section.setSizeDiff(getValue(sectionJson.get("size_diff")));
section.setAbbrevName((String) sectionJson.get("abbrev_name"));
Section section = new Section();
section.setSize(getValue(sectionJson.get("size")));
section.setSizeDiff(getValue(sectionJson.get("size_diff")));
section.setAbbrevName((String) sectionJson.get("abbrev_name"));

sectionsMap.put(sectionKey, section);
}
sectionsMap.put(sectionKey, section);
}

memoryType.setSections(sectionsMap);
memoryTypesMap.put(memoryKey, memoryType);
}
memoryType.setSections(sectionsMap);
memoryTypesMap.put(memoryKey, memoryType);
}

library.setMemoryTypes(memoryTypesMap);

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Guard against missing memory_types / sections to avoid NPEs.

The new parsing logic assumes that for every archive object:

  • object.get("memory_types") is a non-null JSONObject.
  • For every memory type, memoryTypeJson.get("sections") is a non-null JSONObject.

If older esp-idf-size outputs (e.g. legacy JSON or partially populated JSON2) omit memory_types or sections for some entries, this will throw a NullPointerException during .keySet() iteration and break the whole view.

To make this robust across versions and slightly malformed outputs, you can defensively skip missing structures:

-        Map<String, MemoryType> memoryTypesMap = new LinkedHashMap<>();
-        JSONObject memoryTypesJson = (JSONObject) object.get("memory_types");
-
-        for (Object memoryKeyObj : memoryTypesJson.keySet())
-        {
+        Map<String, MemoryType> memoryTypesMap = new LinkedHashMap<>();
+        JSONObject memoryTypesJson = (JSONObject) object.get("memory_types");
+        if (memoryTypesJson != null)
+        {
+            for (Object memoryKeyObj : memoryTypesJson.keySet())
+            {
             String memoryKey = (String) memoryKeyObj;
             JSONObject memoryTypeJson = (JSONObject) memoryTypesJson.get(memoryKey);
@@
-            JSONObject sectionsJson = (JSONObject) memoryTypeJson.get("sections");
-            Map<String, Section> sectionsMap = new LinkedHashMap<>();
-
-            for (Object sectionKeyObj : sectionsJson.keySet())
-            {
+            JSONObject sectionsJson = (JSONObject) memoryTypeJson.get("sections");
+            Map<String, Section> sectionsMap = new LinkedHashMap<>();
+            if (sectionsJson != null)
+            {
+                for (Object sectionKeyObj : sectionsJson.keySet())
+                {
                 String sectionKey = (String) sectionKeyObj;
                 JSONObject sectionJson = (JSONObject) sectionsJson.get(sectionKey);
@@
-                sectionsMap.put(sectionKey, section);
-            }
+                    sectionsMap.put(sectionKey, section);
+                }
+            }
@@
-            memoryType.setSections(sectionsMap);
-            memoryTypesMap.put(memoryKey, memoryType);
-        }
+            memoryType.setSections(sectionsMap);
+            memoryTypesMap.put(memoryKey, memoryType);
+        }

This keeps new functionality while failing gracefully if some fields are missing.

@AndriiFilippov
Copy link
Collaborator

@sigmaaa hi !

Tested under:
OS - Linux Ubuntu / Mac ARM64
ESP-IDF: release/v6.0 / 6.0-beta

Application Size Analysis works as expected ✔️
LGTM 👍

@sigmaaa sigmaaa changed the title WIP: feat: support esp-idf-size 2.0 IEP-1667 Missing --ng in esp-idf-size 2.0.0 Breaks Size Analysis Editor Dec 11, 2025
Copy link
Collaborator

@kolipakakondal kolipakakondal left a comment

Choose a reason for hiding this comment

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

Hi @sigmaaa Thanks for the PR. Could you take a look at the PR comments? Otherwise, it looks good to me.

@sigmaaa
Copy link
Collaborator Author

sigmaaa commented Dec 12, 2025

Hi @kolipakakondal,

Thanks for the review. I’ve completely changed the approach in the latest commit and switched to using idf.py size --format instead. Please take another look. I’ve also added some guard checks to prevent the UI from breaking in case of unexpected output from the idf.py size command.
image

@sigmaaa
Copy link
Collaborator Author

sigmaaa commented Dec 12, 2025

@AndriiFilippov, since the new commit introduces completely new logic, it needs to be retested.

Copy link

@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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/IDFSizeChartsComposite.java (1)

147-169: Good defensive “no data” UI path; also validate layout type (and avoid SWT image leaks when re-plotting).

  • Consider hardening the guard to handle layout not being a JSONArray (not just missing).
  • plotCharts() is called on every toggle/unit change; displayChartAsImage() creates SWT Images that are never disposed → likely memory/resource leak over time.

Suggested fix for the leak (preferred: dispose with the widget that owns it):

@@
 			Image swtImg = new Image(parent.getDisplay(), imgData);
 			Label imgLabel = new Label(parent, SWT.NONE);
 			imgLabel.setImage(swtImg);
+			imgLabel.addDisposeListener(e -> {
+				if (!swtImg.isDisposed())
+					swtImg.dispose();
+			});

And optional type-check hardening around layout:

-		JSONArray layoutArray = (JSONArray) overviewJson.get(IDFSizeConstants.LAYOUT);
+		Object layoutObj = overviewJson.get(IDFSizeConstants.LAYOUT);
+		if (!(layoutObj instanceof JSONArray layoutArray))
+			return;
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/IDFSizeDataManager.java (2)

253-263: Version.parse() can throw on non-semver ESP-IDF versions (e.g., “6.0-beta”) — add a safe fallback.

 	public boolean isVersionAtLeast(String currentIDFVersion, String minimumIDFVersion)
 	{
 		if (currentIDFVersion.equalsIgnoreCase("master")) //$NON-NLS-1$
 		{
 			return true;
 		}
 
-		Version currentVersion = Version.parse(currentIDFVersion);
-		Version minVersion = Version.parse(minimumIDFVersion);
-		return currentVersion.compareTo(minVersion) >= 0;
+		try
+		{
+			Version currentVersion = Version.parse(currentIDFVersion);
+			Version minVersion = Version.parse(minimumIDFVersion);
+			return currentVersion.compareTo(minVersion) >= 0;
+		}
+		catch (IllegalArgumentException e)
+		{
+			// Fallback: strip non-numeric suffix/prefix (e.g., "v6.0-beta" -> "6.0")
+			String normalized = currentIDFVersion.replaceFirst("^[^0-9]*", "").replaceFirst("[^0-9.].*$", ""); //$NON-NLS-1$ //$NON-NLS-2$
+			if (StringUtil.isEmpty(normalized))
+				return false;
+			Version currentVersion = Version.parse(normalized);
+			Version minVersion = Version.parse(minimumIDFVersion);
+			return currentVersion.compareTo(minVersion) >= 0;
+		}
 	}

Please also confirm what exact format IDFEnvironmentVariables.ESP_IDF_VERSION uses on all supported platforms (stable, beta, “release/v6.0”, etc.).


49-75: Fix CLI argument order: map file must come after options, not before.

The getIDFSizeCommandArgs() method (lines 219–232) builds arguments in the wrong order for esp-idf-size:

  • Current: [python, idf_size.py, **map_file**, --archives, --format, json2]
  • Expected: [python, idf_size.py, **--archives, --format, json2, map_file**]

According to esp-idf-size CLI convention, all options/flags must come before the map file. Reorder line 224 to come after the additional flags and JSON arguments are added.

♻️ Duplicate comments (1)
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/IDFSizeDataManager.java (1)

121-163: Add null-guards when parsing memory_types / sections to avoid NPEs on partial/legacy JSON.

This still assumes memory_types and sections always exist.

@@
 		Map<String, MemoryType> memoryTypesMap = new LinkedHashMap<>();
 		JSONObject memoryTypesJson = (JSONObject) object.get("memory_types");
 
-		for (Object memoryKeyObj : memoryTypesJson.keySet())
+		if (memoryTypesJson != null)
 		{
-			String memoryKey = (String) memoryKeyObj;
-			JSONObject memoryTypeJson = (JSONObject) memoryTypesJson.get(memoryKey);
+			for (Object memoryKeyObj : memoryTypesJson.keySet())
+			{
+				String memoryKey = (String) memoryKeyObj;
+				JSONObject memoryTypeJson = (JSONObject) memoryTypesJson.get(memoryKey);
 
 				MemoryType memoryType = new MemoryType();
 				memoryType.setSize(getValue(memoryTypeJson.get("size")));
 				memoryType.setSizeDiff(getValue(memoryTypeJson.get("size_diff")));
 
 				JSONObject sectionsJson = (JSONObject) memoryTypeJson.get("sections");
 				Map<String, Section> sectionsMap = new LinkedHashMap<>();
 
-				for (Object sectionKeyObj : sectionsJson.keySet())
+				if (sectionsJson != null)
 				{
-					String sectionKey = (String) sectionKeyObj;
-					JSONObject sectionJson = (JSONObject) sectionsJson.get(sectionKey);
+					for (Object sectionKeyObj : sectionsJson.keySet())
+					{
+						String sectionKey = (String) sectionKeyObj;
+						JSONObject sectionJson = (JSONObject) sectionsJson.get(sectionKey);
 
-					Section section = new Section();
-					section.setSize(getValue(sectionJson.get("size")));
-					section.setSizeDiff(getValue(sectionJson.get("size_diff")));
-					section.setAbbrevName((String) sectionJson.get("abbrev_name"));
+						Section section = new Section();
+						section.setSize(getValue(sectionJson.get("size")));
+						section.setSizeDiff(getValue(sectionJson.get("size_diff")));
+						section.setAbbrevName((String) sectionJson.get("abbrev_name"));
 
-					sectionsMap.put(sectionKey, section);
+						sectionsMap.put(sectionKey, section);
+					}
 				}
 
 				memoryType.setSections(sectionsMap);
 				memoryTypesMap.put(memoryKey, memoryType);
+			}
 		}
🧹 Nitpick comments (1)
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/IDFSizeOverviewComposite.java (1)

102-108: Consider localizing the new/visible table headers (or at least centralize them).

Right now the table headers are hard-coded; if the rest of the editor is localized via Messages, these likely should be too.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f2d6737 and 27c0930.

📒 Files selected for processing (5)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/IDFSizeChartsComposite.java (4 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/IDFSizeDataManager.java (7 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/IDFSizeOverviewComposite.java (5 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/Messages.java (1 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/messages.properties (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/IDFSizeOverviewComposite.java (1)
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/Messages.java (1)
  • Messages (5-51)
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/IDFSizeDataManager.java (2)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/StringUtil.java (1)
  • StringUtil (11-25)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/IDFUtil.java (1)
  • IDFUtil (58-1044)
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/IDFSizeChartsComposite.java (2)
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/IDFSizeConstants.java (1)
  • IDFSizeConstants (24-93)
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/Messages.java (1)
  • Messages (5-51)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: build_macos
  • GitHub Check: build_linux
  • GitHub Check: build_windows
🔇 Additional comments (4)
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/Messages.java (1)

29-35: New NLS keys wired correctly (Messages ↔ properties).

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/messages.properties (1)

31-32: New “no memory data available” message looks good.

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/IDFSizeOverviewComposite.java (1)

237-247: Good alignment with the data-manager API change; please ensure the now-unused targetName is intentionally kept for compatibility.

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/IDFSizeChartsComposite.java (1)

320-330: Signature update confirmed safe. No remaining callers use the removed targetName parameter—verified across the codebase with no 2-arg call sites found, and the definition exists only as getIDFSizeOverview(IFile).

Comment on lines +122 to 144
// Defensive check: Handle unexpected empty data gracefully to prevent UI crash.
if (overviewJson == null || overviewJson.isEmpty() || !overviewJson.containsKey("layout")) //$NON-NLS-1$
{
TableItem errorItem = new TableItem(table, SWT.NONE);
errorItem.setText(0,
Messages.IDFSizeOverviewComposite_NoExpectedOutputMsg);
errorItem.setForeground(0, table.getDisplay().getSystemColor(SWT.COLOR_RED));
return;
}

JSONArray layout = (JSONArray) overviewJson.get("layout"); //$NON-NLS-1$
long grandUsed = 0;
long grandFree = 0;

int rowIndex = 0;
for (Object obj : layout)
{
JSONObject section = (JSONObject) obj;
String name = (String) section.get("name");
long used = (long) section.get("used");
long free = (long) section.get("free");
long total = (long) section.get("total");
String name = (String) section.get("name"); //$NON-NLS-1$
long used = (long) section.get("used"); //$NON-NLS-1$
long free = (long) section.get("free"); //$NON-NLS-1$
long total = (long) section.get("total"); //$NON-NLS-1$

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Use the shared constant + add minimal type checks to avoid ClassCastException on malformed JSON.

-		if (overviewJson == null || overviewJson.isEmpty() || !overviewJson.containsKey("layout")) //$NON-NLS-1$
+		if (overviewJson == null || overviewJson.isEmpty()
+				|| !overviewJson.containsKey(IDFSizeConstants.LAYOUT))
 		{
@@
-		JSONArray layout = (JSONArray) overviewJson.get("layout"); //$NON-NLS-1$
+		Object layoutObj = overviewJson.get(IDFSizeConstants.LAYOUT);
+		if (!(layoutObj instanceof JSONArray layout))
+			return;

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/IDFSizeOverviewComposite.java
around lines 122 to 144, replace the hard-coded "layout" string with the shared
constant (e.g. LayoutKeys.LAYOUT) and add defensive type checks before casting
to avoid ClassCastException: verify overviewJson.get(LayoutKeys.LAYOUT) is an
instance of JSONArray and skip/handle if not; inside the loop verify each
element is a JSONObject and that the "name", "used", "free", "total" entries
exist and are numbers (instanceof Number) before calling longValue(), provide
sensible defaults or continue the loop on malformed entries, and log or surface
an errorItem for unexpected types so the UI does not crash.

Comment on lines +22 to 23
IDFSizeOverviewComposite_NoExpectedOutputMsg=No memory data available.'idf.py size' output not as expected

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix user-facing punctuation/spacing in the new “unexpected output” message.

-IDFSizeOverviewComposite_NoExpectedOutputMsg=No memory data available.'idf.py size' output not as expected
+IDFSizeOverviewComposite_NoExpectedOutputMsg=No memory data available. 'idf.py size' output not as expected.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
IDFSizeOverviewComposite_NoExpectedOutputMsg=No memory data available.'idf.py size' output not as expected
IDFSizeOverviewComposite_NoExpectedOutputMsg=No memory data available. 'idf.py size' output not as expected.
🤖 Prompt for AI Agents
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/size/messages.properties
lines 22-23: the user-facing message contains incorrect punctuation/spacing ("No
memory data available.'idf.py size' output not as expected"); replace with a
properly spaced and punctuated string such as "No memory data available —
'idf.py size' output not as expected" or "No memory data available; 'idf.py
size' output not as expected" so there is a space after the period/appropriate
separator and proper quotation spacing around idf.py size.

Copy link
Collaborator

@kolipakakondal kolipakakondal left a comment

Choose a reason for hiding this comment

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

LGTM

@kolipakakondal kolipakakondal changed the title IEP-1667 Missing --ng in esp-idf-size 2.0.0 Breaks Size Analysis Editor IEP-1667 support esp-idf-size 2.0 and use idf.py size command Dec 12, 2025
Copy link
Collaborator

@alirana01 alirana01 left a comment

Choose a reason for hiding this comment

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

LGTM!

@AndriiFilippov
Copy link
Collaborator

@sigmaaa hi !

Tested:
OS - Windows 11 / Mac ARM64

LGTM 👍

@kolipakakondal kolipakakondal merged commit 26e9f94 into master Dec 15, 2025
4 of 6 checks passed
@kolipakakondal kolipakakondal deleted the IEP-1667 branch December 15, 2025 14:35
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