-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add service to provide enabler to set database path in .clangd file
- Loading branch information
1 parent
0e3e89b
commit aceeab9
Showing
8 changed files
with
58 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
...clangd.ClangdConfigurationFileManager.xml → ...config.ClangdConfigurationFileManager.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" name="org.eclipse.cdt.lsp.clangd.ClangdConfigurationFileManager"> | ||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" name="org.eclipse.cdt.lsp.clangd.internal.config.ClangdConfigurationFileManager"> | ||
<property name="service.ranking" type="Integer" value="0"/> | ||
<service> | ||
<provide interface="org.eclipse.cdt.lsp.clangd.ClangdCProjectDescriptionListener"/> | ||
</service> | ||
<reference cardinality="1..1" field="build" interface="org.eclipse.cdt.core.build.ICBuildConfigurationManager" name="build"/> | ||
<implementation class="org.eclipse.cdt.lsp.clangd.ClangdConfigurationFileManager"/> | ||
<reference cardinality="1..1" field="settings" interface="org.eclipse.cdt.lsp.clangd.ClangdCompilationDatabaseSettings" name="settings"/> | ||
<implementation class="org.eclipse.cdt.lsp.clangd.internal.config.ClangdConfigurationFileManager"/> | ||
</scr:component> |
8 changes: 8 additions & 0 deletions
8
...F/org.eclipse.cdt.lsp.clangd.internal.config.DefaultClangdCompilationDatabaseSettings.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.cdt.lsp.clangd.internal.config.DefaultClangdCompilationDatabaseSettings"> | ||
<property name="service.ranking" type="Integer" value="0"/> | ||
<service> | ||
<provide interface="org.eclipse.cdt.lsp.clangd.ClangdCompilationDatabaseSettings"/> | ||
</service> | ||
<implementation class="org.eclipse.cdt.lsp.clangd.internal.config.DefaultClangdCompilationDatabaseSettings"/> | ||
</scr:component> |
15 changes: 15 additions & 0 deletions
15
...ipse.cdt.lsp.clangd/src/org/eclipse/cdt/lsp/clangd/ClangdCompilationDatabaseSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.eclipse.cdt.lsp.clangd; | ||
|
||
import org.eclipse.core.resources.IProject; | ||
|
||
public interface ClangdCompilationDatabaseSettings { | ||
|
||
/** | ||
* Enabler for {@link org.eclipse.cdt.lsp.clangd.internal.config.ClangdConfigurationFileManager#setCompilationDatabase(IProject, String)}. | ||
* Can be overriden for customization. | ||
* @param project | ||
* @return true if the database path should be written to .clangd file in the project root. | ||
*/ | ||
boolean enableSetCompilationDatabasePath(IProject project); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
.../org/eclipse/cdt/lsp/clangd/internal/config/DefaultClangdCompilationDatabaseSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.eclipse.cdt.lsp.clangd.internal.config; | ||
|
||
import java.util.Optional; | ||
|
||
import org.eclipse.cdt.lsp.clangd.ClangdCompilationDatabaseSettings; | ||
import org.eclipse.cdt.lsp.plugin.LspPlugin; | ||
import org.eclipse.core.resources.IProject; | ||
import org.osgi.service.component.annotations.Component; | ||
|
||
@Component(property = { "service.ranking:Integer=0" }) | ||
public class DefaultClangdCompilationDatabaseSettings implements ClangdCompilationDatabaseSettings { | ||
|
||
@Override | ||
public boolean enableSetCompilationDatabasePath(IProject project) { | ||
return Optional.ofNullable(LspPlugin.getDefault()).map(LspPlugin::getCLanguageServerProvider) | ||
.map(provider -> provider.isEnabledFor(project)).orElse(Boolean.FALSE); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters