Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.espressif.idf.core.IDFEnvironmentVariables;
import com.espressif.idf.core.logging.Logger;
import com.espressif.idf.core.tools.vo.IdfInstalled;
import com.espressif.idf.core.util.StringUtil;

/**
* Utility class for Tools Management operations
Expand All @@ -27,7 +28,7 @@ public class ToolsUtility
public static String getIdfVersion(IdfInstalled idfInstalled, String gitPath)
{
String activationScript = idfInstalled.getActivationScript();
String espIdfVersion = null;
String espIdfVersion = StringUtil.EMPTY;

try
{
Expand All @@ -47,9 +48,9 @@ public static String getIdfVersion(IdfInstalled idfInstalled, String gitPath)
String line;
while ((line = reader.readLine()) != null)
{
if (line.startsWith("ESP_IDF_VERSION=")) //$NON-NLS-1$
if (line.startsWith("ESP_IDF_VERSION=") && line.split("=").length >= 2) //$NON-NLS-1$ //$NON-NLS-2$
{
espIdfVersion = line.split("=")[1]; //$NON-NLS-1$
espIdfVersion = line.split("=")[1].trim(); //$NON-NLS-1$
break;
Comment on lines +51 to 54
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Handle quoted-empty version values before returning.

On Line 53, ESP_IDF_VERSION="" is parsed as "" (non-empty text), so the UI empty check won’t trigger the “Detection Failed” path. This misses the PR’s target scenario.

Proposed fix
-					if (line.startsWith("ESP_IDF_VERSION=") && line.split("=").length >= 2) //$NON-NLS-1$ //$NON-NLS-2$
+					if (line.startsWith("ESP_IDF_VERSION=")) //$NON-NLS-1$
 					{
-						espIdfVersion = line.split("=")[1].trim(); //$NON-NLS-1$
+						String parsed = line.substring("ESP_IDF_VERSION=".length()).trim(); //$NON-NLS-1$
+						if (parsed.length() >= 2
+								&& ((parsed.startsWith("\"") && parsed.endsWith("\"")) //$NON-NLS-1$ //$NON-NLS-2$
+										|| (parsed.startsWith("'") && parsed.endsWith("'")))) //$NON-NLS-1$ //$NON-NLS-2$
+						{
+							parsed = parsed.substring(1, parsed.length() - 1).trim();
+						}
+						espIdfVersion = parsed;
 						break;
 					}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@bundles/com.espressif.idf.core/src/com/espressif/idf/core/tools/util/ToolsUtility.java`
around lines 51 - 54, The current parsing sets espIdfVersion =
line.split("=")[1].trim() which leaves quoted-empty values like "" as non-empty;
update the parsing in ToolsUtility.java (the block that checks
line.startsWith("ESP_IDF_VERSION=") and assigns espIdfVersion) to strip
surrounding double quotes (if present) and treat the result as empty when it
becomes an empty string (e.g., remove leading/trailing '"' after trim or check
for a literal "\"\"" and set espIdfVersion to null/empty), so downstream UI
empty checks correctly trigger the “Detection Failed” path.

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ public class Messages extends NLS

public static String ESPIDFMainTablePage_StatusColumnName;

public static String ESPIDFMainTablePage_VersionDetectionFailedMsg;

public static String ESPIDFMainTablePage_VersionErrorToolTip;

public static String ESPIDFMainTablePage_VersionToolTip;

public static String MsgYes;
public static String MsgNo;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.eclipse.jface.layout.TableColumnLayout;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
Expand All @@ -32,6 +33,8 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.console.MessageConsoleStream;
import org.osgi.service.prefs.BackingStoreException;

Expand Down Expand Up @@ -259,7 +262,34 @@ public Image getImage(Object element)
@Override
public String getText(Object e)
{
return ((IdfRow) e).version();
var version = ((IdfRow) e).version();
if (StringUtil.isEmpty(version))
{
return Messages.ESPIDFMainTablePage_VersionDetectionFailedMsg;
}
return version;
}

@Override
public Image getImage(Object element)
{
if (StringUtil.isEmpty(((IdfRow) element).version()))
{
return PlatformUI.getWorkbench().getSharedImages()
.getImage(ISharedImages.IMG_OBJS_WARN_TSK);
}
return super.getImage(element);
}

@Override
public String getToolTipText(Object element)
{
var version = ((IdfRow) element).version();
if (StringUtil.isEmpty(version))
{
return Messages.ESPIDFMainTablePage_VersionErrorToolTip;
}
return Messages.ESPIDFMainTablePage_VersionToolTip + version;
}
});

Expand All @@ -280,6 +310,8 @@ public String getText(Object e)
return ((IdfRow) e).path();
}
});

ColumnViewerToolTipSupport.enableFor(viewer);
}

private void createCol(TableViewer viewer, TableColumnLayout layout, String title, int weight, int sortIndex,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@ ESPIDFMainTablePage_RefreshEnvBtnName=Refresh Environment
ESPIDFMainTablePage_RefreshEnvBtnTooltip=Refresh toolchains, Python virtual environment, and IDE settings for the CURRENTLY ACTIVE version
ESPIDFMainTablePage_SettingUpLbl=Setting up...
ESPIDFMainTablePage_StatusColumnName=Status
ESPIDFMainTablePage_VersionDetectionFailedMsg=Detection Failed
ESPIDFMainTablePage_VersionErrorToolTip=Version detection failed. Please re-install this IDF using EIM.
ESPIDFMainTablePage_VersionToolTip=ESP-IDF Version:
MsgYes=Yes
MsgNo=No
Loading