Skip to content

Commit 4aec363

Browse files
Merge pull request #1190 from espressif/lsp3
fix: Update lsp dependencies
2 parents 0345b84 + 711cdc1 commit 4aec363

File tree

45 files changed

+430
-539
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+430
-539
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,14 @@ jobs:
3838
with:
3939
maven-version: 3.9.6
4040

41-
- name: Set up JDK 17
42-
uses: actions/setup-java@v3
41+
- name: Set up JDK 21
42+
uses: actions/setup-java@v4
4343
with:
44-
java-version: '17'
44+
java-version: '21'
4545
distribution: 'temurin'
46-
46+
4747
- name: Build with Maven
48-
run: export NO_AT_BRIDGE=1 && mvn clean verify -Djarsigner.skip=true spotbugs:spotbugs -DskipTests=false -DtestWorkspace=/opt/actions-runner/_work/workspace
49-
- uses: jwgmeligmeyling/spotbugs-github-action@master
50-
with:
51-
path: '**/spotbugsXml.xml'
48+
run: export NO_AT_BRIDGE=1 && mvn clean verify -Djarsigner.skip=true -DskipTests=false -DtestWorkspace=/opt/actions-runner/_work/workspace
5249

5350
- name: Publish Test Reports
5451
if: ${{ always() }}
@@ -65,10 +62,10 @@ jobs:
6562
steps:
6663
- uses: actions/checkout@v2
6764

68-
- name: Set up JDK 17
69-
uses: actions/setup-java@v2
65+
- name: Set up JDK 21
66+
uses: actions/setup-java@v4
7067
with:
71-
java-version: '17'
68+
java-version: '21'
7269
distribution: 'temurin'
7370

7471
- name: Build with Maven
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<classpath>
3-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
44
<attributes>
5-
<attribute name="module" value="true"/>
5+
<attribute name="maven.pomderived" value="true"/>
66
</attributes>
77
</classpathentry>
88
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
9+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
10+
<attributes>
11+
<attribute name="maven.pomderived" value="true"/>
12+
</attributes>
13+
</classpathentry>
914
<classpathentry kind="output" path="target/classes"/>
1015
</classpath>
Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,39 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<classpath>
3-
<classpathentry kind="src" path="src"/>
4-
<classpathentry exported="true" kind="lib" path="lib/commons-beanutils-1.9.4.jar"/>
5-
<classpathentry exported="true" kind="lib" path="lib/commons-text-1.10.0.jar"/>
6-
<classpathentry exported="true" kind="lib" path="lib/opencsv-5.7.0.jar"/>
7-
<classpathentry exported="true" kind="lib" path="lib/snakeyaml-1.30.jar"/>
8-
<classpathentry exported="true" kind="lib" path="lib/json-simple-1.1.1.jar"/>
9-
<classpathentry exported="true" kind="lib" path="lib/commons-io-2.9.0.jar" sourcepath="lib/commons-io-2.9.0-sources.jar">
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
104
<attributes>
11-
<attribute name="javadoc_location" value="jar:platform:/resource/com.espressif.idf.core/lib/commons-io-2.9.0-javadoc.jar!/"/>
5+
<attribute name="maven.pomderived" value="true"/>
6+
</attributes>
7+
</classpathentry>
8+
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
9+
<classpathentry kind="src" output="bin" path="src">
10+
<attributes>
11+
<attribute name="optional" value="true"/>
12+
<attribute name="maven.pomderived" value="true"/>
1213
</attributes>
1314
</classpathentry>
15+
<classpathentry exported="true" kind="lib" path="lib/json-simple-1.1.1.jar"/>
1416
<classpathentry exported="true" kind="lib" path="lib/commons-collections4-4.4.jar" sourcepath="lib/commons-collections4-4.4-sources.jar">
1517
<attributes>
1618
<attribute name="javadoc_location" value="jar:platform:/resource/com.espressif.idf.core/lib/commons-collections4-4.4-javadoc.jar!/"/>
1719
</attributes>
1820
</classpathentry>
21+
<classpathentry exported="true" kind="lib" path="lib/commons-io-2.9.0.jar" sourcepath="lib/commons-io-2.9.0-sources.jar">
22+
<attributes>
23+
<attribute name="javadoc_location" value="jar:platform:/resource/com.espressif.idf.core/lib/commons-io-2.9.0-javadoc.jar!/"/>
24+
</attributes>
25+
</classpathentry>
26+
<classpathentry exported="true" kind="lib" path="lib/commons-lang3-3.12.0.jar"/>
27+
<classpathentry exported="true" kind="lib" path="lib/snakeyaml-1.30.jar"/>
28+
<classpathentry exported="true" kind="lib" path="lib/opencsv-5.7.0.jar"/>
29+
<classpathentry exported="true" kind="lib" path="lib/commons-beanutils-1.9.4.jar"/>
30+
<classpathentry exported="true" kind="lib" path="lib/commons-text-1.10.0.jar"/>
1931
<classpathentry kind="lib" path="lib/commons-compress-1.21.jar"/>
2032
<classpathentry kind="lib" path="lib/xz-1.9.jar"/>
21-
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
22-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
33+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
2334
<attributes>
24-
<attribute name="module" value="true"/>
2535
<attribute name="maven.pomderived" value="true"/>
2636
</attributes>
2737
</classpathentry>
28-
<classpathentry kind="output" path="target/classes"/>
38+
<classpathentry kind="output" path="bin"/>
2939
</classpath>

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Bundle-Vendor: %Bundle-Vendor
88
Require-Bundle: org.eclipse.core.runtime,
99
org.eclipse.core.filesystem;visibility:=reexport,
1010
org.eclipse.core.resources;visibility:=reexport,
11-
org.eclipse.cdt.core;bundle-version="8.0.0",
11+
org.eclipse.cdt.core;bundle-version="9.0.0",
1212
org.eclipse.cdt.cmake.core;visibility:=reexport,
1313
org.eclipse.core.expressions;visibility:=reexport,
1414
org.eclipse.cdt.managedbuilder.core;visibility:=reexport,
@@ -30,9 +30,9 @@ Require-Bundle: org.eclipse.core.runtime,
3030
com.sun.jna,
3131
com.sun.jna.platform,
3232
org.eclipse.cdt.lsp.clangd,
33-
org.eclipse.cdt.lsp,
34-
org.eclipse.lsp4e,
35-
org.eclipse.lsp4j
33+
org.eclipse.cdt.lsp;bundle-version="3.0.0",
34+
org.eclipse.lsp4e;bundle-version="0.18.18",
35+
org.eclipse.lsp4j;bundle-version="0.24.0"
3636
Bundle-RequiredExecutionEnvironment: JavaSE-17
3737
Automatic-Module-Name: com.espressif.idf.core
3838
Bundle-ActivationPolicy: lazy

bundles/com.espressif.idf.core/src/com/espressif/idf/core/build/IDFBuildConfiguration.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,10 @@ public IDFBuildConfiguration(IBuildConfiguration config, String name) throws Cor
120120
super(config, name);
121121
}
122122

123-
public IDFBuildConfiguration(IBuildConfiguration config, String name, IToolChain toolChain)
124-
{
125-
this(config, name, toolChain, null, "run"); //$NON-NLS-1$
126-
}
127-
128123
public IDFBuildConfiguration(IBuildConfiguration config, String name, IToolChain toolChain,
129-
ICMakeToolChainFile toolChainFile, String launchMode)
124+
ICMakeToolChainFile toolChainFile, String launchMode, ILaunchTarget target)
130125
{
131-
super(config, name, toolChain, launchMode);
126+
super(config, name, toolChain, launchMode, target);
132127
this.toolChainFile = toolChainFile;
133128
}
134129

@@ -581,9 +576,13 @@ public IToolChain getToolChain() throws CoreException
581576
String id = getProperty(TOOLCHAIN_ID);
582577
IToolChainManager toolChainManager = CCorePlugin.<IToolChainManager>getService(IToolChainManager.class);
583578
ILaunchBarManager launchBarManager = CCorePlugin.getService(ILaunchBarManager.class);
584-
Collection<IToolChain> matchedToolChains = toolChainManager
585-
.getToolChainsMatching(Map.of(IToolChain.ATTR_OS, launchBarManager.getActiveLaunchTarget()
586-
.getAttribute(LaunchBarTargetConstants.TARGET, StringUtil.EMPTY), TOOLCHAIN_TYPE, typeId));
579+
ILaunchTarget activeTarget = launchBarManager.getActiveLaunchTarget();
580+
if (activeTarget == null)
581+
{
582+
return super.getToolChain();
583+
}
584+
Collection<IToolChain> matchedToolChains = toolChainManager.getToolChainsMatching(Map.of(IToolChain.ATTR_OS,
585+
activeTarget.getAttribute(LaunchBarTargetConstants.TARGET, StringUtil.EMPTY), TOOLCHAIN_TYPE, typeId));
587586
return matchedToolChains.stream().findAny().orElse(toolChainManager.getToolChain(typeId, id));
588587
}
589588

bundles/com.espressif.idf.core/src/com/espressif/idf/core/build/IDFBuildConfigurationProvider.java

Lines changed: 13 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import org.eclipse.cdt.core.build.ICBuildConfigurationManager;
1818
import org.eclipse.cdt.core.build.ICBuildConfigurationProvider;
1919
import org.eclipse.cdt.core.build.IToolChain;
20-
import org.eclipse.cdt.core.build.IToolChainManager;
2120
import org.eclipse.core.resources.IBuildConfiguration;
2221
import org.eclipse.core.resources.IProject;
2322
import org.eclipse.core.runtime.CoreException;
@@ -27,7 +26,6 @@
2726

2827
import com.espressif.idf.core.IDFCorePlugin;
2928
import com.espressif.idf.core.logging.Logger;
30-
import com.espressif.idf.core.toolchain.ESPToolchain;
3129

3230
/**
3331
* @author Kondal Kolipaka <[email protected]>
@@ -51,80 +49,38 @@ public String getId()
5149
public synchronized ICBuildConfiguration getCBuildConfiguration(IBuildConfiguration config, String name)
5250
throws CoreException
5351
{
52+
ILaunchBarManager barManager = IDFCorePlugin.getService(ILaunchBarManager.class);
53+
ILaunchTarget target = barManager != null ? barManager.getActiveLaunchTarget() : null;
5454
if (config.getName().equals(IBuildConfiguration.DEFAULT_CONFIG_NAME))
5555
{
56-
IToolChain toolChain = null;
57-
58-
// try the toolchain for the current target
59-
IToolChainManager toolChainManager = IDFCorePlugin.getService(IToolChainManager.class);
60-
ILaunchBarManager barManager = IDFCorePlugin.getService(ILaunchBarManager.class);
61-
try
62-
{
63-
ILaunchTarget target = barManager.getActiveLaunchTarget();
64-
if (target == null)
65-
{
66-
return null;
67-
}
68-
for (IToolChain tc : toolChainManager.getToolChainsMatching(target.getAttributes()))
69-
{
70-
if (tc instanceof ESPToolchain)
71-
{
72-
toolChain = tc;
73-
break;
74-
}
75-
}
76-
}
77-
catch (CoreException e)
78-
{
79-
Logger.log(e);
80-
}
81-
82-
// current didn't work, try and find one that does
83-
if (toolChain == null)
84-
{
85-
for (IToolChain tc : toolChainManager.getToolChainsMatching(new HashMap<>()))
86-
{
87-
if (tc instanceof ESPToolchain)
88-
{
89-
toolChain = tc;
90-
break;
91-
}
92-
}
93-
94-
}
95-
96-
if (toolChain != null)
97-
{
98-
return new IDFBuildConfiguration(config, name, toolChain);
99-
}
100-
else
101-
{
102-
// No valid combinations
103-
return null;
104-
}
56+
Logger.log("Default config name is not supported"); //$NON-NLS-1$
57+
return null;
10558
}
10659
IDFBuildConfiguration cmakeConfig = new IDFBuildConfiguration(config, name);
10760
ICMakeToolChainFile tcFile = cmakeConfig.getToolChainFile();
10861
IToolChain toolChain = cmakeConfig.getToolChain();
10962
if (toolChain == null)
11063
{
64+
Logger.log("Toolchain is null"); //$NON-NLS-1$
11165
// config not complete
11266
return null;
11367
}
11468
if (tcFile != null && !toolChain.equals(tcFile.getToolChain()))
11569
{
11670
// toolchain changed
117-
return new IDFBuildConfiguration(config, name, tcFile.getToolChain(), tcFile, cmakeConfig.getLaunchMode());
71+
return new IDFBuildConfiguration(config, name, tcFile.getToolChain(), tcFile, cmakeConfig.getLaunchMode(),
72+
target);
11873
}
11974
else
12075
{
12176
return cmakeConfig;
12277
}
78+
12379
}
12480

12581
@Override
126-
public ICBuildConfiguration createBuildConfiguration(IProject project, IToolChain toolChain, String launchMode,
127-
IProgressMonitor monitor) throws CoreException
82+
public ICBuildConfiguration createCBuildConfiguration(IProject project, IToolChain toolChain, String launchMode,
83+
ILaunchTarget launchTarget, IProgressMonitor monitor) throws CoreException
12884
{
12985
// get matching toolchain file if any
13086
Map<String, String> properties = new HashMap<>();
@@ -150,7 +106,7 @@ public ICBuildConfiguration createBuildConfiguration(IProject project, IToolChai
150106
}
151107

152108
// Let's generate build artifacts directly under the build folder so that CLI and eclipse IDF will be in sync
153-
String name = ICBuildConfiguration.DEFAULT_NAME;
109+
String name = ICBuildConfiguration.TOOLCHAIN_ID;
154110
IBuildConfiguration buildConfig;
155111
if (configManager.hasConfiguration(this, project, name))
156112
{
@@ -162,7 +118,8 @@ public ICBuildConfiguration createBuildConfiguration(IProject project, IToolChai
162118

163119
}
164120

165-
CBuildConfiguration cmakeConfig = new IDFBuildConfiguration(buildConfig, name, toolChain, file, launchMode);
121+
CBuildConfiguration cmakeConfig = new IDFBuildConfiguration(buildConfig, name, toolChain, file, launchMode,
122+
launchTarget);
166123
configManager.addBuildConfiguration(buildConfig, cmakeConfig);
167124
return cmakeConfig;
168125
}

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

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import org.eclipse.lsp4e.LanguageServiceAccessor;
1717
import org.eclipse.ui.PlatformUI;
1818

19+
import com.espressif.idf.core.ILSPConstants;
20+
1921
@SuppressWarnings("restriction")
2022
public class LspService
2123
{
@@ -45,49 +47,40 @@ public void restartLspServers()
4547

4648
public void updateAdditionalOptions(String additionalOptions)
4749
{
48-
if (configuration.metadata() instanceof ClangdMetadata metadata)
49-
{
50-
String qualifier = configuration.qualifier();
51-
InstanceScope.INSTANCE.getNode(qualifier).put(metadata.additionalOptions().identifer(), additionalOptions);
52-
}
50+
String qualifier = configuration.qualifier();
51+
InstanceScope.INSTANCE.getNode(qualifier).put(ClangdMetadata.Predefined.additionalOptions.identifer(),
52+
additionalOptions);
5353
}
5454

5555
public void updateLspQueryDrivers()
5656
{
57-
if (configuration.metadata() instanceof ClangdMetadata metadata)
58-
{
59-
String qualifier = configuration.qualifier();
60-
InstanceScope.INSTANCE.getNode(qualifier).put(metadata.queryDriver().identifer(),
61-
metadata.queryDriver().defaultValue());
62-
}
57+
String qualifier = configuration.qualifier();
58+
// By passing --query-driver argument to clangd helps to resolve the
59+
// cross-compiler toolchain headers.
60+
String toolchainPath = IDFUtil.getToolchainExePathForActiveTarget();
61+
InstanceScope.INSTANCE.getNode(qualifier).put(ClangdMetadata.Predefined.queryDriver.identifer(), toolchainPath);
6362
}
6463

6564
public void updateClangdPath()
6665
{
67-
if (configuration.metadata() instanceof ClangdMetadata metadata)
68-
{
69-
String qualifier = configuration.qualifier();
70-
InstanceScope.INSTANCE.getNode(qualifier).put(metadata.clangdPath().identifer(),
71-
metadata.clangdPath().defaultValue());
72-
}
66+
String qualifier = configuration.qualifier();
67+
InstanceScope.INSTANCE.getNode(qualifier).put(ClangdMetadata.Predefined.clangdPath.identifer(),
68+
IDFUtil.findCommandFromBuildEnvPath(ILSPConstants.CLANGD_EXECUTABLE));
7369
}
7470

7571
public void updateCompileCommandsDir(String buildDir)
7672
{
77-
if (configuration.metadata() instanceof ClangdMetadata metadata)
78-
{
79-
String qualifier = configuration.qualifier();
80-
String identifier = metadata.additionalOptions().identifer();
81-
IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(qualifier);
73+
String qualifier = configuration.qualifier();
74+
String identifier = ClangdMetadata.Predefined.additionalOptions.identifer();
75+
IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(qualifier);
8276

83-
String existingOptions = preferences.get(identifier, StringUtil.EMPTY);
84-
String compileCommandsDirString = "--compile-commands-dir="; //$NON-NLS-1$
85-
String newCompuileCommandsDirString = compileCommandsDirString + buildDir;
86-
String updatedOptions = existingOptions.contains(compileCommandsDirString)
87-
? existingOptions.replaceAll(compileCommandsDirString + ".+", //$NON-NLS-1$
88-
Matcher.quoteReplacement(newCompuileCommandsDirString))
89-
: newCompuileCommandsDirString;
90-
preferences.put(identifier, updatedOptions);
91-
}
77+
String existingOptions = preferences.get(identifier, StringUtil.EMPTY);
78+
String compileCommandsDirString = "--compile-commands-dir="; //$NON-NLS-1$
79+
String newCompuileCommandsDirString = compileCommandsDirString + buildDir;
80+
String updatedOptions = existingOptions.contains(compileCommandsDirString)
81+
? existingOptions.replaceAll(compileCommandsDirString + ".+", //$NON-NLS-1$
82+
Matcher.quoteReplacement(newCompuileCommandsDirString))
83+
: newCompuileCommandsDirString;
84+
preferences.put(identifier, updatedOptions);
9285
}
9386
}
Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<classpath>
3-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
44
<attributes>
5-
<attribute name="module" value="true"/>
5+
<attribute name="maven.pomderived" value="true"/>
66
</attributes>
77
</classpathentry>
88
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
9-
<classpathentry kind="src" path="src"/>
9+
<classpathentry kind="src" output="target/classes" path="src">
10+
<attributes>
11+
<attribute name="optional" value="true"/>
12+
<attribute name="maven.pomderived" value="true"/>
13+
</attributes>
14+
</classpathentry>
15+
<classpathentry exported="true" kind="lib" path="svd" sourcepath="svd"/>
16+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
17+
<attributes>
18+
<attribute name="maven.pomderived" value="true"/>
19+
</attributes>
20+
</classpathentry>
1021
<classpathentry kind="output" path="target/classes"/>
1122
</classpath>

0 commit comments

Comments
 (0)