Skip to content

Commit 2bb3d6b

Browse files
Merge pull request #1171 from espressif/IEP-1467
IEP-1467 Update clangd path based on the esp-idf and tools
2 parents a8d8c4a + 8d47c8e commit 2bb3d6b

File tree

6 files changed

+30
-18
lines changed

6 files changed

+30
-18
lines changed

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

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

19-
import com.espressif.idf.core.logging.Logger;
20-
2119
@SuppressWarnings("restriction")
2220
public class LspService
2321
{
@@ -29,6 +27,7 @@ public LspService()
2927
this(PlatformUI.getWorkbench().getService(ClangdConfiguration.class),
3028
LanguageServiceAccessor.getStartedWrappers(null, true).stream()
3129
.filter(w -> "org.eclipse.cdt.lsp.server".equals(w.serverDefinition.id)).toList()); //$NON-NLS-1$
30+
3231
}
3332

3433
public LspService(Configuration configuration, List<LanguageServerWrapper> languageServerWrappers)
@@ -39,16 +38,9 @@ public LspService(Configuration configuration, List<LanguageServerWrapper> langu
3938

4039
public void restartLspServers()
4140
{
42-
languageServerWrappers.forEach(w -> {
43-
try
44-
{
45-
w.restart();
46-
}
47-
catch (Exception e)
48-
{
49-
Logger.log(e);
50-
}
51-
});
41+
languageServerWrappers.forEach(w ->
42+
// ensures that the LS is initialized before proceeding.
43+
w.execute(ls -> ls.shutdown()).thenRun(w::restart));
5244
}
5345

5446
public void updateAdditionalOptions(String additionalOptions)
@@ -70,6 +62,16 @@ public void updateLspQueryDrivers()
7062
}
7163
}
7264

65+
public void updateClangdPath()
66+
{
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+
}
73+
}
74+
7375
public void updateCompileCommandsDir(String buildDir)
7476
{
7577
if (configuration.metadata() instanceof ClangdMetadata metadata)

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
* @author Kondal Kolipaka <[email protected]>
1111
*
1212
*/
13-
public class Messages extends NLS {
13+
public class Messages extends NLS
14+
{
1415
private static final String BUNDLE_NAME = "com.espressif.idf.core.util.messages"; //$NON-NLS-1$
1516
public static String FileUtil_CopyingMsg;
1617
public static String FileUtil_DesDirNotavailable;
@@ -43,15 +44,20 @@ public class Messages extends NLS {
4344
public static String NvsValidation_EncodingValidationErr_1;
4445
public static String NvsValidation_KeyValidationErr_1;
4546
public static String NvsValidation_KeyValidationErr_2;
46-
47+
4748
public static String PortChecker_AttemptLimitExceededMsg;
4849
public static String PortChecker_PortIsAvailable;
4950
public static String PortChecker_PortNotAvailable;
5051

51-
static {
52+
public static String LspService_RestartJobMsg;
53+
54+
static
55+
{
5256
// initialize resource bundle
5357
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
5458
}
55-
private Messages() {
59+
60+
private Messages()
61+
{
5662
}
5763
}

bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/messages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ NvsValidation_KeyValidationErr_2=Maximum key length is 15 characters
3232
PortChecker_AttemptLimitExceededMsg=The port selection attempt limit was exceeded. Returning last checked port
3333
PortChecker_PortIsAvailable=Port %d is available
3434
PortChecker_PortNotAvailable=Port %d is not available, trying next port: %d
35+
LspService_RestartJobMsg=Restarting LSP server...

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ Bundle-ManifestVersion: 2
33
Bundle-SymbolicName: com.espressif.idf.lsp;singleton:=true
44
Bundle-Vendor: ESPRESSIF SYSTEMS (SHANGHAI) CO., LTD
55
Bundle-Version: 1.0.1.qualifier
6-
Export-Package: com.espressif.idf.lsp
6+
Export-Package: com.espressif.idf.lsp,
7+
com.espressif.idf.lsp.preferences
78
Require-Bundle: org.eclipse.ui,
89
org.eclipse.core.runtime,
910
org.eclipse.cdt.lsp.clangd,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,4 @@ Bundle-ClassPath: .,
5959
lib/ini4j-0.5.4.jar,
6060
lib/gson-2.8.7.jar,
6161
lib/commonmark-0.16.1.jar
62+
Import-Package: com.espressif.idf.lsp.preferences

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/ToolsActivationJob.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.espressif.idf.core.toolchain.ESPToolChainManager;
2929
import com.espressif.idf.core.tools.vo.IDFToolSet;
3030
import com.espressif.idf.core.util.IDFUtil;
31+
import com.espressif.idf.core.util.LspService;
3132
import com.espressif.idf.core.util.StringUtil;
3233
import com.espressif.idf.ui.UIPlugin;
3334
import com.espressif.idf.ui.update.ExportIDFTools;
@@ -94,7 +95,7 @@ protected IStatus run(IProgressMonitor monitor)
9495

9596
toolSetConfigurationManager.export(idfToolSet);
9697
console.println("Tools Activated");
97-
98+
new LspService().updateClangdPath();
9899
Preferences scopedPreferenceStore = InstanceScope.INSTANCE.getNode(UIPlugin.PLUGIN_ID);
99100
scopedPreferenceStore.putBoolean(INSTALL_TOOLS_FLAG, true);
100101
try

0 commit comments

Comments
 (0)