Skip to content

Commit ae00469

Browse files
fix: handle NoSuchMethodError in SerialSettingsPage
- Add defensive error handling for EclipseUtil.getSelectedIDFProjectInExplorer() - Implement fallback to getSelectedProjectInExplorer() with IDF nature check - Prevent terminal opening crash when no project is selected - Gracefully handle bundle version conflicts in OSGi runtime
1 parent 14d4fd1 commit ae00469

File tree

1 file changed

+24
-1
lines changed
  • bundles/com.espressif.idf.terminal.connector.serial/src/com/espressif/idf/terminal/connector/serial/controls

1 file changed

+24
-1
lines changed

bundles/com.espressif.idf.terminal.connector.serial/src/com/espressif/idf/terminal/connector/serial/controls/SerialSettingsPage.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,30 @@ public void createControl(Composite parent)
101101

102102
projectCombo = new Combo(comp, SWT.NONE);
103103
projectCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
104-
Optional<IProject> optProject = Optional.ofNullable(EclipseUtil.getSelectedIDFProjectInExplorer());
104+
105+
// Safely get selected IDF project with error handling
106+
IProject selectedProject = null;
107+
try {
108+
selectedProject = EclipseUtil.getSelectedIDFProjectInExplorer();
109+
} catch (NoSuchMethodError e) {
110+
// Fallback: try to get any selected project
111+
try {
112+
selectedProject = EclipseUtil.getSelectedProjectInExplorer();
113+
if (selectedProject != null) {
114+
try {
115+
if (!selectedProject.hasNature(IDFProjectNature.ID)) {
116+
selectedProject = null; // Not an IDF project
117+
}
118+
} catch (CoreException ce) {
119+
selectedProject = null;
120+
}
121+
}
122+
} catch (Exception ex) {
123+
// If all else fails, selectedProject remains null
124+
}
125+
}
126+
127+
Optional<IProject> optProject = Optional.ofNullable(selectedProject);
105128
optProject.ifPresent(project -> projectCombo.setText(project.getName()));
106129
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
107130
for (IProject project : projects)

0 commit comments

Comments
 (0)