From 751c50a7a57a5c8cc833250a457dec4228c09b2e Mon Sep 17 00:00:00 2001 From: Kondal Kolipaka Date: Tue, 26 Dec 2023 16:46:38 +0530 Subject: [PATCH 01/18] feat: Add CDT-LSP Preview plugins with IEP plugin This will enable the user to install the all the required features in one go! --- releng/com.espressif.idf.update/category.xml | 39 +++++++++----------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/releng/com.espressif.idf.update/category.xml b/releng/com.espressif.idf.update/category.xml index fa1599296..a9f973d07 100644 --- a/releng/com.espressif.idf.update/category.xml +++ b/releng/com.espressif.idf.update/category.xml @@ -19,7 +19,7 @@ - + @@ -37,52 +37,52 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -98,9 +98,4 @@ ESP-IDF Eclipse Plugin for developing ESP32 based IoT applications - - - Additional features which can be used with the Espressif-IDE - - From bbe9210791a6e530de8de2919de965039de3611c Mon Sep 17 00:00:00 2001 From: Kondal Kolipaka Date: Tue, 26 Dec 2023 17:28:49 +0530 Subject: [PATCH 02/18] feat: Bundle lsp feature in espressif-ide --- releng/com.espressif.idf.product/idf.product | 1 + 1 file changed, 1 insertion(+) diff --git a/releng/com.espressif.idf.product/idf.product b/releng/com.espressif.idf.product/idf.product index b087df044..9c2fd79c5 100644 --- a/releng/com.espressif.idf.product/idf.product +++ b/releng/com.espressif.idf.product/idf.product @@ -75,6 +75,7 @@ + From 3946d8bfb341add882fd4f3b6b88a11833f9e42b Mon Sep 17 00:00:00 2001 From: Kondal Kolipaka Date: Thu, 28 Dec 2023 11:58:24 +0530 Subject: [PATCH 03/18] feat: Add com.espressif.idf.lsp plugin com.espressif.idf.lsp plugin contributes idf specific changes to espressif-ide --- bundles/com.espressif.idf.lsp/.classpath | 7 +++ bundles/com.espressif.idf.lsp/.project | 33 ++++++++++++ .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 9 ++++ .../META-INF/MANIFEST.MF | 17 ++++++ ...if.idf.lsp.preferences.IDFClangdEnable.xml | 8 +++ ...p.preferences.IDFClangdOptionsDefaults.xml | 8 +++ bundles/com.espressif.idf.lsp/bin/.gitignore | 1 + .../com.espressif.idf.lsp/build.properties | 18 +++++++ .../idf/lsp/preferences/IDFClangdEnable.java | 26 ++++++++++ .../preferences/IDFClangdOptionsDefaults.java | 21 ++++++++ .../com.espressif.idf.ui/META-INF/MANIFEST.MF | 4 +- .../idf/ui/lsp/EspClangdOptions.java | 52 +++++++++++++++++++ 13 files changed, 205 insertions(+), 1 deletion(-) create mode 100644 bundles/com.espressif.idf.lsp/.classpath create mode 100644 bundles/com.espressif.idf.lsp/.project create mode 100644 bundles/com.espressif.idf.lsp/.settings/org.eclipse.core.resources.prefs create mode 100644 bundles/com.espressif.idf.lsp/.settings/org.eclipse.jdt.core.prefs create mode 100644 bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF create mode 100644 bundles/com.espressif.idf.lsp/OSGI-INF/com.espressif.idf.lsp.preferences.IDFClangdEnable.xml create mode 100644 bundles/com.espressif.idf.lsp/OSGI-INF/com.espressif.idf.lsp.preferences.IDFClangdOptionsDefaults.xml create mode 100644 bundles/com.espressif.idf.lsp/bin/.gitignore create mode 100644 bundles/com.espressif.idf.lsp/build.properties create mode 100644 bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdEnable.java create mode 100644 bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdOptionsDefaults.java create mode 100644 bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/lsp/EspClangdOptions.java diff --git a/bundles/com.espressif.idf.lsp/.classpath b/bundles/com.espressif.idf.lsp/.classpath new file mode 100644 index 000000000..81fe078c2 --- /dev/null +++ b/bundles/com.espressif.idf.lsp/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/bundles/com.espressif.idf.lsp/.project b/bundles/com.espressif.idf.lsp/.project new file mode 100644 index 000000000..6d41995b1 --- /dev/null +++ b/bundles/com.espressif.idf.lsp/.project @@ -0,0 +1,33 @@ + + + com.espressif.idf.lsp + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + org.eclipse.pde.ds.core.builder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/bundles/com.espressif.idf.lsp/.settings/org.eclipse.core.resources.prefs b/bundles/com.espressif.idf.lsp/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 000000000..99f26c020 --- /dev/null +++ b/bundles/com.espressif.idf.lsp/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/bundles/com.espressif.idf.lsp/.settings/org.eclipse.jdt.core.prefs b/bundles/com.espressif.idf.lsp/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..62ef3488c --- /dev/null +++ b/bundles/com.espressif.idf.lsp/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,9 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF b/bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF new file mode 100644 index 000000000..e3f8d25cf --- /dev/null +++ b/bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF @@ -0,0 +1,17 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %Bundle-Name +Bundle-SymbolicName: com.espressif.idf.lsp.preferences;singleton:=true +Bundle-Vendor: %Bundle-Vendor +Bundle-Version: 1.0.0.qualifier +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.cdt.lsp.clangd, + org.eclipse.core.resources, + org.eclipse.cdt.lsp, + com.espressif.idf.core +Bundle-RequiredExecutionEnvironment: JavaSE-17 +Automatic-Module-Name: com.espressif.idf.lsp.preferences +Bundle-ActivationPolicy: lazy +Service-Component: OSGI-INF/com.espressif.idf.lsp.preferences.IDFClangdEnable.xml, + OSGI-INF/com.espressif.idf.lsp.preferences.IDFClangdOptionsDefaults.xml diff --git a/bundles/com.espressif.idf.lsp/OSGI-INF/com.espressif.idf.lsp.preferences.IDFClangdEnable.xml b/bundles/com.espressif.idf.lsp/OSGI-INF/com.espressif.idf.lsp.preferences.IDFClangdEnable.xml new file mode 100644 index 000000000..f8dca2aa7 --- /dev/null +++ b/bundles/com.espressif.idf.lsp/OSGI-INF/com.espressif.idf.lsp.preferences.IDFClangdEnable.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/bundles/com.espressif.idf.lsp/OSGI-INF/com.espressif.idf.lsp.preferences.IDFClangdOptionsDefaults.xml b/bundles/com.espressif.idf.lsp/OSGI-INF/com.espressif.idf.lsp.preferences.IDFClangdOptionsDefaults.xml new file mode 100644 index 000000000..c72675c75 --- /dev/null +++ b/bundles/com.espressif.idf.lsp/OSGI-INF/com.espressif.idf.lsp.preferences.IDFClangdOptionsDefaults.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/bundles/com.espressif.idf.lsp/bin/.gitignore b/bundles/com.espressif.idf.lsp/bin/.gitignore new file mode 100644 index 000000000..c2d9872a1 --- /dev/null +++ b/bundles/com.espressif.idf.lsp/bin/.gitignore @@ -0,0 +1 @@ +/com/ diff --git a/bundles/com.espressif.idf.lsp/build.properties b/bundles/com.espressif.idf.lsp/build.properties new file mode 100644 index 000000000..d01885b40 --- /dev/null +++ b/bundles/com.espressif.idf.lsp/build.properties @@ -0,0 +1,18 @@ +############################################################################### +# Copyright (c) 2023 Contributors to the Eclipse Foundation. +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Public License 2.0 which is available at +# https://www.eclipse.org/legal/epl-2.0/. +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# See git history +############################################################################### + +bin.includes = META-INF/,\ + .,\ + OSGI-INF/ +source.. = src/ +output.. = bin/ diff --git a/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdEnable.java b/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdEnable.java new file mode 100644 index 000000000..3368f1789 --- /dev/null +++ b/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdEnable.java @@ -0,0 +1,26 @@ +package com.espressif.idf.lsp.preferences; + +import org.eclipse.cdt.lsp.editor.LanguageServerEnable; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.osgi.service.component.annotations.Component; + +import com.espressif.idf.core.IDFProjectNature; +import com.espressif.idf.core.logging.Logger; + +@Component(property = { "service.ranking:Integer=100" }) +public class IDFClangdEnable implements LanguageServerEnable { + + @Override + public boolean isEnabledFor(IProject project) { + if (project != null) { + try { + return project.hasNature(IDFProjectNature.ID); //IDF nature + } catch (CoreException e) { + Logger.log(e); + } + } + return false; + } + +} diff --git a/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdOptionsDefaults.java b/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdOptionsDefaults.java new file mode 100644 index 000000000..88328e122 --- /dev/null +++ b/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdOptionsDefaults.java @@ -0,0 +1,21 @@ +package com.espressif.idf.lsp.preferences; + +import org.eclipse.cdt.lsp.clangd.BuiltinClangdOptionsDefaults; +import org.eclipse.cdt.lsp.clangd.ClangdOptionsDefaults; +import org.osgi.service.component.annotations.Component; + +@SuppressWarnings("restriction") +@Component(service = ClangdOptionsDefaults.class, property = { "service.ranking:Integer=100" }) +public class IDFClangdOptionsDefaults extends BuiltinClangdOptionsDefaults { + + @Override + public String clangdPath() { + return super.clangdPath();//TODO: esp-clangd path + } + + @Override + public String queryDriver() { + return super.queryDriver(); //TODO:esp xtensa-gcc path + } + +} diff --git a/bundles/com.espressif.idf.ui/META-INF/MANIFEST.MF b/bundles/com.espressif.idf.ui/META-INF/MANIFEST.MF index f32b0e141..f29927e01 100644 --- a/bundles/com.espressif.idf.ui/META-INF/MANIFEST.MF +++ b/bundles/com.espressif.idf.ui/META-INF/MANIFEST.MF @@ -43,7 +43,9 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.tools.templates.core, org.eclipse.tools.templates.ui, org.freemarker.freemarker, - org.eclipse.tools.templates.freemarker + org.eclipse.tools.templates.freemarker, + org.eclipse.cdt.lsp;bundle-version="1.0.0", + org.eclipse.cdt.lsp.clangd;bundle-version="1.0.0" Automatic-Module-Name: com.espressif.idf.ui Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-11 diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/lsp/EspClangdOptions.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/lsp/EspClangdOptions.java new file mode 100644 index 000000000..2447b4323 --- /dev/null +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/lsp/EspClangdOptions.java @@ -0,0 +1,52 @@ +package com.espressif.idf.ui.lsp; + +import java.util.Collections; +import java.util.List; +import java.util.Optional; + +import org.eclipse.cdt.lsp.clangd.ClangdOptionsDefaults; +import org.eclipse.cdt.utils.PathUtil; +import org.eclipse.core.runtime.IPath; + +public class EspClangdOptions implements ClangdOptionsDefaults { + + @Override + public String clangdPath() { + return Optional.ofNullable(PathUtil.findProgramLocation("clangd", null)) //$NON-NLS-1$ + .map(IPath::toOSString)// + .orElse("clangd"); // //$NON-NLS-1$ + } + + @Override + public boolean useTidy() { + return true; + } + + @Override + public boolean useBackgroundIndex() { + return true; + } + + @Override + public String completionStyle() { + return "detailed"; + } + + @Override + public boolean prettyPrint() { + return true; + } + + @Override + public String queryDriver() { + return Optional.ofNullable(PathUtil.findProgramLocation("gcc", null)) //$NON-NLS-1$ + .map(p -> p.removeLastSegments(1).append(IPath.SEPARATOR + "*"))// //$NON-NLS-1$ + .map(IPath::toString)// + .orElse(""); // //$NON-NLS-1$ + } + + @Override + public List additionalOptions() { + return Collections.emptyList(); + } +} From fba6c164048fde974cfa3ce3293299d087282098 Mon Sep 17 00:00:00 2001 From: Kondal Kolipaka Date: Thu, 28 Dec 2023 13:04:09 +0530 Subject: [PATCH 04/18] fix: auto-detect clangd from the PATH and set in preferences --- bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF | 3 ++- .../idf/lsp/preferences/IDFClangdOptionsDefaults.java | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF b/bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF index e3f8d25cf..ba2749650 100644 --- a/bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF +++ b/bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF @@ -9,7 +9,8 @@ Require-Bundle: org.eclipse.ui, org.eclipse.cdt.lsp.clangd, org.eclipse.core.resources, org.eclipse.cdt.lsp, - com.espressif.idf.core + com.espressif.idf.core, + org.eclipse.cdt.core Bundle-RequiredExecutionEnvironment: JavaSE-17 Automatic-Module-Name: com.espressif.idf.lsp.preferences Bundle-ActivationPolicy: lazy diff --git a/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdOptionsDefaults.java b/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdOptionsDefaults.java index 88328e122..55fb61ec1 100644 --- a/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdOptionsDefaults.java +++ b/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdOptionsDefaults.java @@ -1,21 +1,26 @@ package com.espressif.idf.lsp.preferences; +import java.util.Optional; + import org.eclipse.cdt.lsp.clangd.BuiltinClangdOptionsDefaults; import org.eclipse.cdt.lsp.clangd.ClangdOptionsDefaults; import org.osgi.service.component.annotations.Component; +import com.espressif.idf.core.util.IDFUtil; + @SuppressWarnings("restriction") @Component(service = ClangdOptionsDefaults.class, property = { "service.ranking:Integer=100" }) public class IDFClangdOptionsDefaults extends BuiltinClangdOptionsDefaults { @Override public String clangdPath() { - return super.clangdPath();//TODO: esp-clangd path + return Optional.ofNullable(IDFUtil.findCommandFromBuildEnvPath("clangd")) //$NON-NLS-1$ + .orElse("clangd"); //$NON-NLS-1$ } @Override public String queryDriver() { - return super.queryDriver(); //TODO:esp xtensa-gcc path + return super.queryDriver(); // TODO:esp xtensa-gcc path } } From 0b6a14ee9704ceb323337841722944cfe8cb79cf Mon Sep 17 00:00:00 2001 From: Kondal Kolipaka Date: Thu, 28 Dec 2023 19:02:58 +0530 Subject: [PATCH 05/18] fix: update query driver in the preference --- .../idf/core/toolchain/ESPToolChainManager.java | 8 ++++++++ .../src/com/espressif/idf/core/util/IDFUtil.java | 15 +++++++++++++++ .../lsp/preferences/IDFClangdOptionsDefaults.java | 5 ++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/bundles/com.espressif.idf.core/src/com/espressif/idf/core/toolchain/ESPToolChainManager.java b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/toolchain/ESPToolChainManager.java index d3e763373..b29bee6c7 100644 --- a/bundles/com.espressif.idf.core/src/com/espressif/idf/core/toolchain/ESPToolChainManager.java +++ b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/toolchain/ESPToolChainManager.java @@ -151,6 +151,14 @@ public File findDebugger(String target) .map(espToolChainElement -> findToolChain(getAllPaths(), espToolChainElement.debuggerPattern)) .findFirst().orElse(null); } + + public File findCompiler(String target) + { + return toolchainElements.values().stream() + .filter(espToolChainElement -> espToolChainElement.name.equals(target)) + .map(espToolChainElement -> findToolChain(getAllPaths(), espToolChainElement.compilerPattern)) + .findFirst().orElse(null); + } public File findToolChain(List paths, String filePattern) { diff --git a/bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/IDFUtil.java b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/IDFUtil.java index 351c22135..e821182c4 100644 --- a/bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/IDFUtil.java +++ b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/IDFUtil.java @@ -337,6 +337,21 @@ public static String getXtensaToolchainExecutablePath(IProject project) } return getXtensaToolchainExecutablePathByTarget(projectEspTarget); } + + public static String getXtensaToolchainExePathForActiveTarget() + { + String target = IDFUtil.getCurrentTarget(); + if (target != null) + { + File file = new ESPToolChainManager().findCompiler(target); + if (file != null) + { + return file.getAbsolutePath(); + } + + } + return null; + } public static String getXtensaToolchainExecutablePathByTarget(String projectEspTarget) { diff --git a/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdOptionsDefaults.java b/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdOptionsDefaults.java index 55fb61ec1..9c5059a04 100644 --- a/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdOptionsDefaults.java +++ b/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdOptionsDefaults.java @@ -20,7 +20,10 @@ public String clangdPath() { @Override public String queryDriver() { - return super.queryDriver(); // TODO:esp xtensa-gcc path + + return Optional.ofNullable(IDFUtil.getXtensaToolchainExePathForActiveTarget()) + .orElse(super.queryDriver()); + } } From f0807a7422e8c3a5d75042f7b364572ce28ada3e Mon Sep 17 00:00:00 2001 From: Kondal Kolipaka Date: Thu, 28 Dec 2023 19:09:53 +0530 Subject: [PATCH 06/18] fix: set empty if the query is not found --- .../espressif/idf/lsp/preferences/IDFClangdOptionsDefaults.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdOptionsDefaults.java b/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdOptionsDefaults.java index 9c5059a04..f367c1d95 100644 --- a/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdOptionsDefaults.java +++ b/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdOptionsDefaults.java @@ -22,7 +22,7 @@ public String clangdPath() { public String queryDriver() { return Optional.ofNullable(IDFUtil.getXtensaToolchainExePathForActiveTarget()) - .orElse(super.queryDriver()); + .orElse(""); } From a1823378617f930ff3feee250c466f572bde4e7c Mon Sep 17 00:00:00 2001 From: Kondal Kolipaka Date: Thu, 29 Feb 2024 01:25:09 +0530 Subject: [PATCH 07/18] fix: resolve conflicts and merge new changes --- .../idf/ui/wizard/NewIDFProjectWizard.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/wizard/NewIDFProjectWizard.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/wizard/NewIDFProjectWizard.java index 35e3e2cb8..13b1a7e79 100644 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/wizard/NewIDFProjectWizard.java +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/wizard/NewIDFProjectWizard.java @@ -7,7 +7,9 @@ import java.io.File; import org.eclipse.cdt.debug.internal.core.InternalDebugCoreMessages; +import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; @@ -110,6 +112,7 @@ public boolean performFinish() String projectName = projectCreationWizardPage.getProjectName(); IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); selProvider.setSelection(new StructuredSelection(project)); + createClangdFile(project); } } @@ -138,6 +141,24 @@ public void widgetDisposed(DisposeEvent event) return performFinish; } + private void createClangdFile(IProject project) + { + String fileContent = "CompileFlags:\n" //$NON-NLS-1$ + + " Remove: [-fno-tree-switch-conversion, -fstrict-volatile-bitfields]\n" //$NON-NLS-1$ + + ""; //$NON-NLS-1$ + + try { + IFile file = project.getFile(".clangd"); //$NON-NLS-1$ + file.create( + new java.io.ByteArrayInputStream(fileContent.getBytes()), + IResource.FORCE | IResource.KEEP_HISTORY, + null + ); + } catch (Exception e) { + Logger.log(e); + } + } + private void createDefaultDebugConfig() { Shell activeShell = Display.getDefault().getActiveShell(); From dcd5d57ef1626477416b073036e043d6c2b1ae27 Mon Sep 17 00:00:00 2001 From: Kondal Kolipaka Date: Thu, 14 Mar 2024 22:22:32 +0530 Subject: [PATCH 08/18] fix: Address plugin loading issues --- bundles/com.espressif.idf.lsp/.gitignore | 2 ++ bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF | 6 +++--- bundles/com.espressif.idf.lsp/bin/.gitignore | 1 - 3 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 bundles/com.espressif.idf.lsp/.gitignore delete mode 100644 bundles/com.espressif.idf.lsp/bin/.gitignore diff --git a/bundles/com.espressif.idf.lsp/.gitignore b/bundles/com.espressif.idf.lsp/.gitignore new file mode 100644 index 000000000..0f630157f --- /dev/null +++ b/bundles/com.espressif.idf.lsp/.gitignore @@ -0,0 +1,2 @@ +/target/ +/bin/ diff --git a/bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF b/bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF index ba2749650..5257e2668 100644 --- a/bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF +++ b/bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF @@ -1,8 +1,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 -Bundle-Name: %Bundle-Name -Bundle-SymbolicName: com.espressif.idf.lsp.preferences;singleton:=true -Bundle-Vendor: %Bundle-Vendor +Bundle-SymbolicName: com.espressif.idf.lsp;singleton:=true +Bundle-Vendor: ESPRESSIF SYSTEMS (SHANGHAI) CO., LTD Bundle-Version: 1.0.0.qualifier Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, @@ -14,5 +13,6 @@ Require-Bundle: org.eclipse.ui, Bundle-RequiredExecutionEnvironment: JavaSE-17 Automatic-Module-Name: com.espressif.idf.lsp.preferences Bundle-ActivationPolicy: lazy +Bundle-Name: ESP-IDF LSP Plugin Service-Component: OSGI-INF/com.espressif.idf.lsp.preferences.IDFClangdEnable.xml, OSGI-INF/com.espressif.idf.lsp.preferences.IDFClangdOptionsDefaults.xml diff --git a/bundles/com.espressif.idf.lsp/bin/.gitignore b/bundles/com.espressif.idf.lsp/bin/.gitignore deleted file mode 100644 index c2d9872a1..000000000 --- a/bundles/com.espressif.idf.lsp/bin/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/com/ From 441527c1aaf9d34fc4010be6104d4970287cfa1b Mon Sep 17 00:00:00 2001 From: Kondal Kolipaka Date: Fri, 15 Mar 2024 13:21:13 +0530 Subject: [PATCH 09/18] fix: update clangd file changes with v1.1 --- .../META-INF/MANIFEST.MF | 5 +- .../META-INF/MANIFEST.MF | 3 +- .../idf/lsp/ClangdConfigFileHandler.java | 65 +++++++++++++++++++ .../com/espressif/idf/lsp/ILSPConstants.java | 14 ++++ .../idf/lsp/preferences/IDFClangdEnable.java | 25 +++++-- .../preferences/IDFClangdOptionsDefaults.java | 29 +++++++-- .../com.espressif.idf.ui/META-INF/MANIFEST.MF | 3 +- .../idf/ui/lsp/EspClangdOptions.java | 52 --------------- .../idf/ui/wizard/NewIDFProjectWizard.java | 21 ++---- 9 files changed, 134 insertions(+), 83 deletions(-) create mode 100644 bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/ClangdConfigFileHandler.java create mode 100644 bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/ILSPConstants.java delete mode 100644 bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/lsp/EspClangdOptions.java diff --git a/bundles/com.espressif.idf.core/META-INF/MANIFEST.MF b/bundles/com.espressif.idf.core/META-INF/MANIFEST.MF index eddf6ea27..e2c226d4c 100644 --- a/bundles/com.espressif.idf.core/META-INF/MANIFEST.MF +++ b/bundles/com.espressif.idf.core/META-INF/MANIFEST.MF @@ -42,7 +42,10 @@ Export-Package: com.espressif.idf.core, com.espressif.idf.core.util, com.espressif.idf.core.variable, org.json.simple, - org.json.simple.parser + org.json.simple.parser, + org.yaml.snakeyaml, + org.yaml.snakeyaml.parser, + org.yaml.snakeyaml.util Bundle-ClassPath: ., lib/json-simple-1.1.1.jar, lib/commons-collections4-4.4.jar, diff --git a/bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF b/bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF index 5257e2668..62cb02649 100644 --- a/bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF +++ b/bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF @@ -3,6 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-SymbolicName: com.espressif.idf.lsp;singleton:=true Bundle-Vendor: ESPRESSIF SYSTEMS (SHANGHAI) CO., LTD Bundle-Version: 1.0.0.qualifier +Export-Package: com.espressif.idf.lsp Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, org.eclipse.cdt.lsp.clangd, @@ -11,7 +12,7 @@ Require-Bundle: org.eclipse.ui, com.espressif.idf.core, org.eclipse.cdt.core Bundle-RequiredExecutionEnvironment: JavaSE-17 -Automatic-Module-Name: com.espressif.idf.lsp.preferences +Automatic-Module-Name: com.espressif.idf.lsp Bundle-ActivationPolicy: lazy Bundle-Name: ESP-IDF LSP Plugin Service-Component: OSGI-INF/com.espressif.idf.lsp.preferences.IDFClangdEnable.xml, diff --git a/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/ClangdConfigFileHandler.java b/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/ClangdConfigFileHandler.java new file mode 100644 index 000000000..be883ca51 --- /dev/null +++ b/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/ClangdConfigFileHandler.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright 2024 Espressif Systems (Shanghai) PTE LTD. All rights reserved. + * Use is subject to license terms. + *******************************************************************************/ +package com.espressif.idf.lsp; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.IOException; +import java.io.Writer; +import java.util.Map; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.yaml.snakeyaml.Yaml; + +import com.espressif.idf.core.logging.Logger; + +/** + * @author Kondal Kolipaka + */ +public class ClangdConfigFileHandler +{ + @SuppressWarnings("unchecked") + public void update(IProject project) throws FileNotFoundException + { + File file = getClangdConfigFile(project); + + // Load existing clangd file + FileInputStream inputStream = new FileInputStream(file); + Yaml yaml = new Yaml(); + Object obj = yaml.load(inputStream); + if (obj instanceof Map) + { + Map data = (Map) obj; + + // Add new attribute to CompileFlags + Map compileFlags = (Map) data.get("CompileFlags"); //$NON-NLS-1$ + compileFlags.put("Remove", new String[] { "-fno-tree-switch-conversion", "-fstrict-volatile-bitfields" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + + // Write updated clangd back to file + try (Writer writer = new FileWriter(file)) + { + yaml.dump(data, writer); + } + catch (IOException e) + { + Logger.log("Error writing .clangd file: " + e.getMessage()); //$NON-NLS-1$ + } + } + else + { + Logger.log("Invalid .clangd file format."); //$NON-NLS-1$ + } + } + + private File getClangdConfigFile(IProject project) + { + // Path to the existing clangd file + IFile file = project.getFile(ILSPConstants.CLANGD_CONFIG_FILE); + return file.getLocation().toFile(); + } +} diff --git a/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/ILSPConstants.java b/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/ILSPConstants.java new file mode 100644 index 000000000..112257f4e --- /dev/null +++ b/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/ILSPConstants.java @@ -0,0 +1,14 @@ +/******************************************************************************* + * Copyright 2024 Espressif Systems (Shanghai) PTE LTD. All rights reserved. + * Use is subject to license terms. + *******************************************************************************/ +package com.espressif.idf.lsp; + +/** + * @author Kondal Kolipaka + */ +public interface ILSPConstants +{ + String CLANGD_EXECUTABLE = "clangd"; //$NON-NLS-1$ + String CLANGD_CONFIG_FILE = ".clangd"; // $NON-NLS-1$ +} diff --git a/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdEnable.java b/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdEnable.java index 3368f1789..e00abab8e 100644 --- a/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdEnable.java +++ b/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdEnable.java @@ -1,3 +1,7 @@ +/******************************************************************************* + * Copyright 2024 Espressif Systems (Shanghai) PTE LTD. All rights reserved. + * Use is subject to license terms. + *******************************************************************************/ package com.espressif.idf.lsp.preferences; import org.eclipse.cdt.lsp.editor.LanguageServerEnable; @@ -8,15 +12,24 @@ import com.espressif.idf.core.IDFProjectNature; import com.espressif.idf.core.logging.Logger; +/** + * @author Kondal Kolipaka + */ @Component(property = { "service.ranking:Integer=100" }) -public class IDFClangdEnable implements LanguageServerEnable { +public class IDFClangdEnable implements LanguageServerEnable +{ @Override - public boolean isEnabledFor(IProject project) { - if (project != null) { - try { - return project.hasNature(IDFProjectNature.ID); //IDF nature - } catch (CoreException e) { + public boolean isEnabledFor(IProject project) + { + if (project != null) + { + try + { + return project.hasNature(IDFProjectNature.ID); // IDF nature + } + catch (CoreException e) + { Logger.log(e); } } diff --git a/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdOptionsDefaults.java b/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdOptionsDefaults.java index f367c1d95..fc6ea8a51 100644 --- a/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdOptionsDefaults.java +++ b/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdOptionsDefaults.java @@ -1,3 +1,7 @@ +/******************************************************************************* + * Copyright 2024 Espressif Systems (Shanghai) PTE LTD. All rights reserved. + * Use is subject to license terms. + *******************************************************************************/ package com.espressif.idf.lsp.preferences; import java.util.Optional; @@ -6,23 +10,34 @@ import org.eclipse.cdt.lsp.clangd.ClangdOptionsDefaults; import org.osgi.service.component.annotations.Component; +import com.espressif.idf.core.logging.Logger; import com.espressif.idf.core.util.IDFUtil; +import com.espressif.idf.lsp.ILSPConstants; +/** + * @author Kondal Kolipaka + * + */ @SuppressWarnings("restriction") @Component(service = ClangdOptionsDefaults.class, property = { "service.ranking:Integer=100" }) -public class IDFClangdOptionsDefaults extends BuiltinClangdOptionsDefaults { +public class IDFClangdOptionsDefaults extends BuiltinClangdOptionsDefaults +{ @Override - public String clangdPath() { - return Optional.ofNullable(IDFUtil.findCommandFromBuildEnvPath("clangd")) //$NON-NLS-1$ - .orElse("clangd"); //$NON-NLS-1$ + public String clangdPath() + { + String clandPath = IDFUtil.findCommandFromBuildEnvPath(ILSPConstants.CLANGD_EXECUTABLE); + Logger.log("clangd: " + clandPath); //$NON-NLS-1$ + return Optional.ofNullable(clandPath).orElse(ILSPConstants.CLANGD_EXECUTABLE); } @Override - public String queryDriver() { + public String queryDriver() + { - return Optional.ofNullable(IDFUtil.getXtensaToolchainExePathForActiveTarget()) - .orElse(""); + String driverpath = IDFUtil.getXtensaToolchainExePathForActiveTarget(); + Logger.log("queryDriver: " + driverpath); //$NON-NLS-1$ + return Optional.ofNullable(driverpath).orElse(""); //$NON-NLS-1$ } diff --git a/bundles/com.espressif.idf.ui/META-INF/MANIFEST.MF b/bundles/com.espressif.idf.ui/META-INF/MANIFEST.MF index f29927e01..39f9d7e26 100644 --- a/bundles/com.espressif.idf.ui/META-INF/MANIFEST.MF +++ b/bundles/com.espressif.idf.ui/META-INF/MANIFEST.MF @@ -45,7 +45,8 @@ Require-Bundle: org.eclipse.core.runtime, org.freemarker.freemarker, org.eclipse.tools.templates.freemarker, org.eclipse.cdt.lsp;bundle-version="1.0.0", - org.eclipse.cdt.lsp.clangd;bundle-version="1.0.0" + org.eclipse.cdt.lsp.clangd;bundle-version="1.0.0", + com.espressif.idf.lsp Automatic-Module-Name: com.espressif.idf.ui Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-11 diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/lsp/EspClangdOptions.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/lsp/EspClangdOptions.java deleted file mode 100644 index 2447b4323..000000000 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/lsp/EspClangdOptions.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.espressif.idf.ui.lsp; - -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -import org.eclipse.cdt.lsp.clangd.ClangdOptionsDefaults; -import org.eclipse.cdt.utils.PathUtil; -import org.eclipse.core.runtime.IPath; - -public class EspClangdOptions implements ClangdOptionsDefaults { - - @Override - public String clangdPath() { - return Optional.ofNullable(PathUtil.findProgramLocation("clangd", null)) //$NON-NLS-1$ - .map(IPath::toOSString)// - .orElse("clangd"); // //$NON-NLS-1$ - } - - @Override - public boolean useTidy() { - return true; - } - - @Override - public boolean useBackgroundIndex() { - return true; - } - - @Override - public String completionStyle() { - return "detailed"; - } - - @Override - public boolean prettyPrint() { - return true; - } - - @Override - public String queryDriver() { - return Optional.ofNullable(PathUtil.findProgramLocation("gcc", null)) //$NON-NLS-1$ - .map(p -> p.removeLastSegments(1).append(IPath.SEPARATOR + "*"))// //$NON-NLS-1$ - .map(IPath::toString)// - .orElse(""); // //$NON-NLS-1$ - } - - @Override - public List additionalOptions() { - return Collections.emptyList(); - } -} diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/wizard/NewIDFProjectWizard.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/wizard/NewIDFProjectWizard.java index 13b1a7e79..d57981d8b 100644 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/wizard/NewIDFProjectWizard.java +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/wizard/NewIDFProjectWizard.java @@ -5,11 +5,10 @@ package com.espressif.idf.ui.wizard; import java.io.File; +import java.io.FileNotFoundException; import org.eclipse.cdt.debug.internal.core.InternalDebugCoreMessages; -import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; @@ -43,6 +42,7 @@ import com.espressif.idf.core.IDFConstants; import com.espressif.idf.core.build.IDFLaunchConstants; import com.espressif.idf.core.logging.Logger; +import com.espressif.idf.lsp.ClangdConfigFileHandler; import com.espressif.idf.ui.UIPlugin; import com.espressif.idf.ui.handlers.EclipseHandler; import com.espressif.idf.ui.handlers.NewProjectHandlerUtil; @@ -112,7 +112,7 @@ public boolean performFinish() String projectName = projectCreationWizardPage.getProjectName(); IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); selProvider.setSelection(new StructuredSelection(project)); - createClangdFile(project); + updateClangdFile(project); } } @@ -141,20 +141,11 @@ public void widgetDisposed(DisposeEvent event) return performFinish; } - private void createClangdFile(IProject project) + private void updateClangdFile(IProject project) { - String fileContent = "CompileFlags:\n" //$NON-NLS-1$ - + " Remove: [-fno-tree-switch-conversion, -fstrict-volatile-bitfields]\n" //$NON-NLS-1$ - + ""; //$NON-NLS-1$ - try { - IFile file = project.getFile(".clangd"); //$NON-NLS-1$ - file.create( - new java.io.ByteArrayInputStream(fileContent.getBytes()), - IResource.FORCE | IResource.KEEP_HISTORY, - null - ); - } catch (Exception e) { + new ClangdConfigFileHandler().update(project); + } catch (FileNotFoundException e) { Logger.log(e); } } From 6cd7e568bede0192d3101b61ac7816b4f63dfda4 Mon Sep 17 00:00:00 2001 From: Kondal Kolipaka Date: Fri, 15 Mar 2024 16:32:05 +0530 Subject: [PATCH 10/18] fix: Add lsp plugin to bundles list --- bundles/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/bundles/pom.xml b/bundles/pom.xml index 5d3f27ba8..5588728e2 100644 --- a/bundles/pom.xml +++ b/bundles/pom.xml @@ -29,6 +29,7 @@ com.espressif.idf.debug.gdbjtag.openocd com.espressif.idf.serial.monitor com.espressif.idf.wokwi + com.espressif.idf.lsp From 9b9d3f1f809bb9dc7b65620d18788b119d43ca59 Mon Sep 17 00:00:00 2001 From: Kondal Kolipaka Date: Fri, 15 Mar 2024 19:29:44 +0530 Subject: [PATCH 11/18] fix: build issues and update lsp version --- bundles/com.espressif.idf.lsp/pom.xml | 15 +++++++++++++++ .../com.espressif.idf.target.target | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 bundles/com.espressif.idf.lsp/pom.xml diff --git a/bundles/com.espressif.idf.lsp/pom.xml b/bundles/com.espressif.idf.lsp/pom.xml new file mode 100644 index 000000000..4a74b87e2 --- /dev/null +++ b/bundles/com.espressif.idf.lsp/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + com.espressif.idf.lsp + 1.0.0-SNAPSHOT + eclipse-plugin + + + com.espressif.idf + com.espressif.idf.bundles + 1.0.0-SNAPSHOT + + \ No newline at end of file diff --git a/releng/com.espressif.idf.target/com.espressif.idf.target.target b/releng/com.espressif.idf.target/com.espressif.idf.target.target index 14a0e7af2..ea35d2369 100644 --- a/releng/com.espressif.idf.target/com.espressif.idf.target.target +++ b/releng/com.espressif.idf.target/com.espressif.idf.target.target @@ -112,7 +112,7 @@ - + From e200cd7b56cc0b39485c5f8f7cb7e6c4c41d085c Mon Sep 17 00:00:00 2001 From: Kondal Kolipaka Date: Fri, 15 Mar 2024 22:25:15 +0530 Subject: [PATCH 12/18] fix: editor color code issues --- .../com.espressif.idf.target.target | 6 +++++- releng/com.espressif.idf.update/category.xml | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/releng/com.espressif.idf.target/com.espressif.idf.target.target b/releng/com.espressif.idf.target/com.espressif.idf.target.target index ea35d2369..79f006219 100644 --- a/releng/com.espressif.idf.target/com.espressif.idf.target.target +++ b/releng/com.espressif.idf.target/com.espressif.idf.target.target @@ -76,7 +76,11 @@ - + + + + + diff --git a/releng/com.espressif.idf.update/category.xml b/releng/com.espressif.idf.update/category.xml index a9f973d07..65bdc3116 100644 --- a/releng/com.espressif.idf.update/category.xml +++ b/releng/com.espressif.idf.update/category.xml @@ -93,6 +93,9 @@ + + + ESP-IDF Eclipse Plugin for developing ESP32 based IoT applications From 1a82b79c4c735e416edbf4b1aa8640f6706bb4fc Mon Sep 17 00:00:00 2001 From: Kondal Kolipaka Date: Sat, 16 Mar 2024 10:07:38 +0530 Subject: [PATCH 13/18] fix: tag specific lsp version --- features/com.espressif.idf.feature/feature.xml | 4 ++++ .../com.espressif.idf.target/com.espressif.idf.target.target | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/features/com.espressif.idf.feature/feature.xml b/features/com.espressif.idf.feature/feature.xml index 8e55c6a57..dc4f1cac4 100644 --- a/features/com.espressif.idf.feature/feature.xml +++ b/features/com.espressif.idf.feature/feature.xml @@ -157,4 +157,8 @@ You may add additional accurate notices of copyright ownership. id="com.espressif.idf.wokwi" version="0.0.0"/> + + diff --git a/releng/com.espressif.idf.target/com.espressif.idf.target.target b/releng/com.espressif.idf.target/com.espressif.idf.target.target index 79f006219..8b7863eca 100644 --- a/releng/com.espressif.idf.target/com.espressif.idf.target.target +++ b/releng/com.espressif.idf.target/com.espressif.idf.target.target @@ -117,7 +117,8 @@ - + + From f9cfddd4e8e101b87da1a763775019d386f48ea4 Mon Sep 17 00:00:00 2001 From: Kondal Kolipaka Date: Sat, 16 Mar 2024 16:00:38 +0530 Subject: [PATCH 14/18] fix: batik.css 1.16.0 required for lsp editor --- bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF b/bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF index 62cb02649..b8443f7be 100644 --- a/bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF +++ b/bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF @@ -10,7 +10,8 @@ Require-Bundle: org.eclipse.ui, org.eclipse.core.resources, org.eclipse.cdt.lsp, com.espressif.idf.core, - org.eclipse.cdt.core + org.eclipse.cdt.core, + org.apache.batik.css;bundle-version="1.16.0" Bundle-RequiredExecutionEnvironment: JavaSE-17 Automatic-Module-Name: com.espressif.idf.lsp Bundle-ActivationPolicy: lazy From 854467b2ac896ff5717fc58490d30a805c5b687d Mon Sep 17 00:00:00 2001 From: Kondal Kolipaka Date: Fri, 22 Mar 2024 19:58:40 +0530 Subject: [PATCH 15/18] fix: Avoid errors with riscv toolchains Invalid arch name 'rv32imac_zicsr_zifencei', unsupported standard user-level extension 'zicsr' --- .../src/com/espressif/idf/lsp/ClangdConfigFileHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/ClangdConfigFileHandler.java b/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/ClangdConfigFileHandler.java index be883ca51..d3e700235 100644 --- a/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/ClangdConfigFileHandler.java +++ b/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/ClangdConfigFileHandler.java @@ -38,7 +38,7 @@ public void update(IProject project) throws FileNotFoundException // Add new attribute to CompileFlags Map compileFlags = (Map) data.get("CompileFlags"); //$NON-NLS-1$ - compileFlags.put("Remove", new String[] { "-fno-tree-switch-conversion", "-fstrict-volatile-bitfields" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + compileFlags.put("Remove", new String[] { "-m*", "-f*" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ // Write updated clangd back to file try (Writer writer = new FileWriter(file)) From 798d40cc910bf6c6a8ee5155b9d1b046ec769399 Mon Sep 17 00:00:00 2001 From: Kondal Kolipaka Date: Sat, 23 Mar 2024 12:29:42 +0530 Subject: [PATCH 16/18] fix: Unable to update on existing ide due to batik.util depen --- bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF | 3 ++- releng/com.espressif.idf.update/category.xml | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF b/bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF index b8443f7be..114eb1fcc 100644 --- a/bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF +++ b/bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF @@ -11,7 +11,8 @@ Require-Bundle: org.eclipse.ui, org.eclipse.cdt.lsp, com.espressif.idf.core, org.eclipse.cdt.core, - org.apache.batik.css;bundle-version="1.16.0" + org.apache.batik.css;bundle-version="1.16.0", + org.apache.batik.util;bundle-version="1.16.0" Bundle-RequiredExecutionEnvironment: JavaSE-17 Automatic-Module-Name: com.espressif.idf.lsp Bundle-ActivationPolicy: lazy diff --git a/releng/com.espressif.idf.update/category.xml b/releng/com.espressif.idf.update/category.xml index 65bdc3116..1ace4c774 100644 --- a/releng/com.espressif.idf.update/category.xml +++ b/releng/com.espressif.idf.update/category.xml @@ -95,6 +95,9 @@ + + + From e98e726d3fc2b2ff022fdbd07a91f10685e5602f Mon Sep 17 00:00:00 2001 From: Kondal Kolipaka Date: Sat, 23 Mar 2024 13:01:25 +0530 Subject: [PATCH 17/18] fix: Address updatesite issues --- bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF | 6 ++++-- bundles/com.espressif.idf.lsp/pom.xml | 2 +- releng/com.espressif.idf.update/category.xml | 8 +++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF b/bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF index 114eb1fcc..fd98ec73a 100644 --- a/bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF +++ b/bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: com.espressif.idf.lsp;singleton:=true Bundle-Vendor: ESPRESSIF SYSTEMS (SHANGHAI) CO., LTD -Bundle-Version: 1.0.0.qualifier +Bundle-Version: 1.0.1.qualifier Export-Package: com.espressif.idf.lsp Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, @@ -11,8 +11,10 @@ Require-Bundle: org.eclipse.ui, org.eclipse.cdt.lsp, com.espressif.idf.core, org.eclipse.cdt.core, + org.apache.batik.i18n;bundle-version="1.16.0", org.apache.batik.css;bundle-version="1.16.0", - org.apache.batik.util;bundle-version="1.16.0" + org.apache.batik.util;bundle-version="1.16.0", + org.apache.batik.constants;bundle-version="1.16.0" Bundle-RequiredExecutionEnvironment: JavaSE-17 Automatic-Module-Name: com.espressif.idf.lsp Bundle-ActivationPolicy: lazy diff --git a/bundles/com.espressif.idf.lsp/pom.xml b/bundles/com.espressif.idf.lsp/pom.xml index 4a74b87e2..68762edde 100644 --- a/bundles/com.espressif.idf.lsp/pom.xml +++ b/bundles/com.espressif.idf.lsp/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 com.espressif.idf.lsp - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT eclipse-plugin diff --git a/releng/com.espressif.idf.update/category.xml b/releng/com.espressif.idf.update/category.xml index 1ace4c774..e8bd0b27a 100644 --- a/releng/com.espressif.idf.update/category.xml +++ b/releng/com.espressif.idf.update/category.xml @@ -96,7 +96,13 @@ - + + + + + + + From 7becbd9bf726cee19549658fd6e9d2ae7f4d14fe Mon Sep 17 00:00:00 2001 From: Kondal Kolipaka Date: Wed, 27 Mar 2024 19:35:29 +0530 Subject: [PATCH 18/18] fix: code clean up relalated to query driver --- .../com/espressif/idf/core/util/IDFUtil.java | 24 ++++++++++++++----- .../com.espressif.idf.lsp/build.properties | 3 ++- bundles/com.espressif.idf.lsp/plugin.xml | 5 ++++ .../preferences/IDFClangdOptionsDefaults.java | 10 -------- 4 files changed, 25 insertions(+), 17 deletions(-) create mode 100644 bundles/com.espressif.idf.lsp/plugin.xml diff --git a/bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/IDFUtil.java b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/IDFUtil.java index e821182c4..4e04e0f3a 100644 --- a/bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/IDFUtil.java +++ b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/IDFUtil.java @@ -31,6 +31,7 @@ import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.launchbar.core.ILaunchBarManager; +import org.eclipse.launchbar.core.target.ILaunchTarget; import org.osgi.service.prefs.BackingStoreException; import com.espressif.idf.core.IDFConstants; @@ -38,6 +39,7 @@ import com.espressif.idf.core.IDFEnvironmentVariables; import com.espressif.idf.core.ProcessBuilderFactory; import com.espressif.idf.core.SystemExecutableFinder; +import com.espressif.idf.core.build.IDFLaunchConstants; import com.espressif.idf.core.logging.Logger; import com.espressif.idf.core.toolchain.ESPToolChainManager; @@ -340,16 +342,26 @@ public static String getXtensaToolchainExecutablePath(IProject project) public static String getXtensaToolchainExePathForActiveTarget() { - String target = IDFUtil.getCurrentTarget(); - if (target != null) + ILaunchBarManager launchBarManager = IDFCorePlugin.getService(ILaunchBarManager.class); + try { - File file = new ESPToolChainManager().findCompiler(target); - if (file != null) + ILaunchTarget launchTarget = launchBarManager.getActiveLaunchTarget(); + if (launchTarget != null) { - return file.getAbsolutePath(); + File file = new ESPToolChainManager() + .findCompiler(launchTarget.getAttribute(IDFLaunchConstants.ATTR_IDF_TARGET, StringUtil.EMPTY)); + if (file != null) + { + return file.getAbsolutePath(); + } + } - } + catch (CoreException e) + { + Logger.log(e); + } + return null; } diff --git a/bundles/com.espressif.idf.lsp/build.properties b/bundles/com.espressif.idf.lsp/build.properties index d01885b40..2a0665109 100644 --- a/bundles/com.espressif.idf.lsp/build.properties +++ b/bundles/com.espressif.idf.lsp/build.properties @@ -13,6 +13,7 @@ bin.includes = META-INF/,\ .,\ - OSGI-INF/ + OSGI-INF/,\ + plugin.xml source.. = src/ output.. = bin/ diff --git a/bundles/com.espressif.idf.lsp/plugin.xml b/bundles/com.espressif.idf.lsp/plugin.xml new file mode 100644 index 000000000..5535690d3 --- /dev/null +++ b/bundles/com.espressif.idf.lsp/plugin.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdOptionsDefaults.java b/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdOptionsDefaults.java index fc6ea8a51..efe661568 100644 --- a/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdOptionsDefaults.java +++ b/bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/preferences/IDFClangdOptionsDefaults.java @@ -31,14 +31,4 @@ public String clangdPath() return Optional.ofNullable(clandPath).orElse(ILSPConstants.CLANGD_EXECUTABLE); } - @Override - public String queryDriver() - { - - String driverpath = IDFUtil.getXtensaToolchainExePathForActiveTarget(); - Logger.log("queryDriver: " + driverpath); //$NON-NLS-1$ - return Optional.ofNullable(driverpath).orElse(""); //$NON-NLS-1$ - - } - }