Skip to content

Commit 4bb1428

Browse files
kolipakakondalAndriiFilippov
authored andcommitted
feat: Bundle CDT-LSP plugins with Espressif-IDE (#877)
* feat: Add CDT-LSP Preview plugins with IEP plugin * feat: Bundle lsp feature in espressif-ide * feat: Add com.espressif.idf.lsp plugin * fix: auto-detect clangd from the PATH and set in preferences * fix: editor color code issues * fix: Avoid errors with riscv toolchains
1 parent bfe8de3 commit 4bb1428

25 files changed

Lines changed: 381 additions & 27 deletions

File tree

bundles/com.espressif.idf.core/META-INF/MANIFEST.MF

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ Export-Package: com.espressif.idf.core,
4242
com.espressif.idf.core.util,
4343
com.espressif.idf.core.variable,
4444
org.json.simple,
45-
org.json.simple.parser
45+
org.json.simple.parser,
46+
org.yaml.snakeyaml,
47+
org.yaml.snakeyaml.parser,
48+
org.yaml.snakeyaml.util
4649
Bundle-ClassPath: .,
4750
lib/json-simple-1.1.1.jar,
4851
lib/commons-collections4-4.4.jar,

bundles/com.espressif.idf.core/src/com/espressif/idf/core/toolchain/ESPToolChainManager.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,14 @@ public File findDebugger(String target)
151151
.map(espToolChainElement -> findToolChain(getAllPaths(), espToolChainElement.debuggerPattern))
152152
.findFirst().orElse(null);
153153
}
154+
155+
public File findCompiler(String target)
156+
{
157+
return toolchainElements.values().stream()
158+
.filter(espToolChainElement -> espToolChainElement.name.equals(target))
159+
.map(espToolChainElement -> findToolChain(getAllPaths(), espToolChainElement.compilerPattern))
160+
.findFirst().orElse(null);
161+
}
154162

155163
public File findToolChain(List<String> paths, String filePattern)
156164
{

bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/IDFUtil.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@
3131
import org.eclipse.core.runtime.preferences.InstanceScope;
3232
import org.eclipse.debug.core.ILaunchConfiguration;
3333
import org.eclipse.launchbar.core.ILaunchBarManager;
34+
import org.eclipse.launchbar.core.target.ILaunchTarget;
3435
import org.osgi.service.prefs.BackingStoreException;
3536

3637
import com.espressif.idf.core.IDFConstants;
3738
import com.espressif.idf.core.IDFCorePlugin;
3839
import com.espressif.idf.core.IDFEnvironmentVariables;
3940
import com.espressif.idf.core.ProcessBuilderFactory;
4041
import com.espressif.idf.core.SystemExecutableFinder;
42+
import com.espressif.idf.core.build.IDFLaunchConstants;
4143
import com.espressif.idf.core.logging.Logger;
4244
import com.espressif.idf.core.toolchain.ESPToolChainManager;
4345

@@ -337,6 +339,31 @@ public static String getXtensaToolchainExecutablePath(IProject project)
337339
}
338340
return getXtensaToolchainExecutablePathByTarget(projectEspTarget);
339341
}
342+
343+
public static String getXtensaToolchainExePathForActiveTarget()
344+
{
345+
ILaunchBarManager launchBarManager = IDFCorePlugin.getService(ILaunchBarManager.class);
346+
try
347+
{
348+
ILaunchTarget launchTarget = launchBarManager.getActiveLaunchTarget();
349+
if (launchTarget != null)
350+
{
351+
File file = new ESPToolChainManager()
352+
.findCompiler(launchTarget.getAttribute(IDFLaunchConstants.ATTR_IDF_TARGET, StringUtil.EMPTY));
353+
if (file != null)
354+
{
355+
return file.getAbsolutePath();
356+
}
357+
358+
}
359+
}
360+
catch (CoreException e)
361+
{
362+
Logger.log(e);
363+
}
364+
365+
return null;
366+
}
340367

341368
public static String getXtensaToolchainExecutablePathByTarget(String projectEspTarget)
342369
{
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
4+
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5+
<classpathentry kind="src" path="src"/>
6+
<classpathentry kind="output" path="bin"/>
7+
</classpath>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/target/
2+
/bin/
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>com.espressif.idf.lsp</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.pde.ManifestBuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.pde.SchemaBuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
<buildCommand>
24+
<name>org.eclipse.pde.ds.core.builder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
28+
</buildSpec>
29+
<natures>
30+
<nature>org.eclipse.pde.PluginNature</nature>
31+
<nature>org.eclipse.jdt.core.javanature</nature>
32+
</natures>
33+
</projectDescription>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
eclipse.preferences.version=1
2+
encoding/<project>=UTF-8
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
3+
org.eclipse.jdt.core.compiler.compliance=17
4+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
5+
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
6+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7+
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
8+
org.eclipse.jdt.core.compiler.release=enabled
9+
org.eclipse.jdt.core.compiler.source=17
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Manifest-Version: 1.0
2+
Bundle-ManifestVersion: 2
3+
Bundle-SymbolicName: com.espressif.idf.lsp;singleton:=true
4+
Bundle-Vendor: ESPRESSIF SYSTEMS (SHANGHAI) CO., LTD
5+
Bundle-Version: 1.0.1.qualifier
6+
Export-Package: com.espressif.idf.lsp
7+
Require-Bundle: org.eclipse.ui,
8+
org.eclipse.core.runtime,
9+
org.eclipse.cdt.lsp.clangd,
10+
org.eclipse.core.resources,
11+
org.eclipse.cdt.lsp,
12+
com.espressif.idf.core,
13+
org.eclipse.cdt.core,
14+
org.apache.batik.i18n;bundle-version="1.16.0",
15+
org.apache.batik.css;bundle-version="1.16.0",
16+
org.apache.batik.util;bundle-version="1.16.0",
17+
org.apache.batik.constants;bundle-version="1.16.0"
18+
Bundle-RequiredExecutionEnvironment: JavaSE-17
19+
Automatic-Module-Name: com.espressif.idf.lsp
20+
Bundle-ActivationPolicy: lazy
21+
Bundle-Name: ESP-IDF LSP Plugin
22+
Service-Component: OSGI-INF/com.espressif.idf.lsp.preferences.IDFClangdEnable.xml,
23+
OSGI-INF/com.espressif.idf.lsp.preferences.IDFClangdOptionsDefaults.xml
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="com.espressif.idf.lsp.preferences.IDFClangdEnable">
3+
<property name="service.ranking" type="Integer" value="100"/>
4+
<service>
5+
<provide interface="org.eclipse.cdt.lsp.editor.LanguageServerEnable"/>
6+
</service>
7+
<implementation class="com.espressif.idf.lsp.preferences.IDFClangdEnable"/>
8+
</scr:component>

0 commit comments

Comments
 (0)