diff --git a/bundles/org.eclipse.cdt.lsp.clangd/META-INF/MANIFEST.MF b/bundles/org.eclipse.cdt.lsp.clangd/META-INF/MANIFEST.MF index d09ac73..9b62c72 100644 --- a/bundles/org.eclipse.cdt.lsp.clangd/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.cdt.lsp.clangd/META-INF/MANIFEST.MF @@ -29,9 +29,10 @@ Require-Bundle: org.eclipse.cdt.lsp;bundle-version="0.0.0", org.eclipse.ui.editors;bundle-version="0.0.0", org.eclipse.ui.ide;bundle-version="0.0.0", org.eclipse.ui.workbench;bundle-version="0.0.0", - org.eclipse.ui.workbench.texteditor;bundle-version="0.0.0" -Bundle-Activator: org.eclipse.cdt.lsp.internal.clangd.editor.ClangdPlugin + org.eclipse.ui.workbench.texteditor;bundle-version="0.0.0", + org.eclipse.core.variables Service-Component: OSGI-INF/org.eclipse.cdt.lsp.clangd.BuiltinClangdOptionsDefaults.xml, OSGI-INF/org.eclipse.cdt.lsp.internal.clangd.ClangdConfigurationAccess.xml, OSGI-INF/org.eclipse.cdt.lsp.internal.clangd.ClangdFallbackManager.xml, OSGI-INF/org.eclipse.cdt.lsp.internal.clangd.ClangdMetadataDefaults.xml +Bundle-Activator: org.eclipse.cdt.lsp.internal.clangd.editor.ClangdPlugin diff --git a/bundles/org.eclipse.cdt.lsp.clangd/src/org/eclipse/cdt/lsp/internal/clangd/ClangdLanguageServerProvider.java b/bundles/org.eclipse.cdt.lsp.clangd/src/org/eclipse/cdt/lsp/internal/clangd/ClangdLanguageServerProvider.java index 1ad7d3f..413e718 100644 --- a/bundles/org.eclipse.cdt.lsp.clangd/src/org/eclipse/cdt/lsp/internal/clangd/ClangdLanguageServerProvider.java +++ b/bundles/org.eclipse.cdt.lsp.clangd/src/org/eclipse/cdt/lsp/internal/clangd/ClangdLanguageServerProvider.java @@ -19,6 +19,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; import org.eclipse.cdt.lsp.clangd.ClangdConfiguration; import org.eclipse.cdt.lsp.clangd.ClangdFallbackFlags; @@ -26,7 +27,9 @@ import org.eclipse.cdt.lsp.editor.LanguageServerEnable; import org.eclipse.cdt.lsp.server.ICLanguageServerProvider; import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.ServiceCaller; +import org.eclipse.core.variables.VariablesPlugin; public final class ClangdLanguageServerProvider implements ICLanguageServerProvider { @@ -47,10 +50,19 @@ public Object getInitializationOptions(URI rootUri) { @Override public List getCommands(URI rootUri) { List result = new ArrayList<>(); - configuration.call(c -> result.addAll(c.commands(rootUri))); + configuration.call(c -> result.addAll(c.commands(rootUri).stream() + .map(ClangdLanguageServerProvider::resolveVariables).collect(Collectors.toList()))); return result; } + private static String resolveVariables(String cmd) { + try { + return VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(cmd); + } catch (CoreException e) { + return cmd; + } + } + @Override public boolean isEnabledFor(IProject project) { boolean[] enabled = new boolean[1];