-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Multiple LS server instances per workspace
- Loading branch information
1 parent
360b056
commit 9a805b4
Showing
19 changed files
with
478 additions
and
60 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
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
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
27 changes: 27 additions & 0 deletions
27
...t.lsp.editor.ui/src/org/eclipse/cdt/lsp/editor/ui/preference/LsPreferenceInitializer.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,27 @@ | ||
package org.eclipse.cdt.lsp.editor.ui.preference; | ||
|
||
import org.eclipse.cdt.lsp.LspPlugin; | ||
import org.eclipse.cdt.lsp.editor.ui.LspEditorUiPlugin; | ||
import org.eclipse.cdt.lsp.editor.ui.properties.LspEditorPropertiesPage; | ||
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; | ||
import org.eclipse.jface.preference.IPreferenceStore; | ||
|
||
public class LsPreferenceInitializer extends AbstractPreferenceInitializer { | ||
private static final IPreferenceStore preferenceStore = LspEditorUiPlugin.getDefault().getLsPreferences(); | ||
|
||
@Override | ||
public void initializeDefaultPreferences() { | ||
var cLanguageServerProvider = LspPlugin.getDefault().getCLanguageServerProvider(); | ||
if (cLanguageServerProvider == null) { | ||
LspEditorUiPlugin.logError("Cannot determine language server provider"); | ||
return; | ||
} | ||
preferenceStore.setDefault(LspEditorPreferences.SERVER_PATH, cLanguageServerProvider.getDefaultServerPath()); | ||
preferenceStore.setDefault(LspEditorPreferences.SERVER_OPTIONS, cLanguageServerProvider.getDefaultOptionsAsString()); | ||
preferenceStore.setDefault(LspEditorPropertiesPage.COMPILE_COMMANDS_DIR, LspEditorPropertiesPage.DEFAULT_COMPILE_COMMANDS_DIR); | ||
|
||
preferenceStore.setValue(LspEditorPreferences.SERVER_PATH, cLanguageServerProvider.getServerPath()); | ||
preferenceStore.setValue(LspEditorPreferences.SERVER_OPTIONS, cLanguageServerProvider.getOptionsAsString()); | ||
preferenceStore.setValue(LspEditorPropertiesPage.COMPILE_COMMANDS_DIR, LspEditorPropertiesPage.DEFAULT_COMPILE_COMMANDS_DIR); | ||
} | ||
} |
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
41 changes: 41 additions & 0 deletions
41
....ui/src/org/eclipse/cdt/lsp/editor/ui/properties/PropertiesCompileCommandsDirLocator.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,41 @@ | ||
package org.eclipse.cdt.lsp.editor.ui.properties; | ||
|
||
import java.net.URI; | ||
|
||
import org.eclipse.cdt.lsp.LspPlugin; | ||
import org.eclipse.cdt.lsp.editor.ui.LspEditorUiPlugin; | ||
import org.eclipse.cdt.lsp.server.ICompileCommandsDirLocator; | ||
import org.eclipse.core.resources.IContainer; | ||
import org.eclipse.core.resources.IProject; | ||
import org.eclipse.core.resources.ProjectScope; | ||
import org.eclipse.core.runtime.IPath; | ||
import org.eclipse.core.runtime.preferences.IEclipsePreferences; | ||
|
||
public class PropertiesCompileCommandsDirLocator implements ICompileCommandsDirLocator { | ||
|
||
@Override | ||
public IPath getCompileCommandsDir(URI uri) { | ||
var project = getProject(uri); | ||
if (project == null) { | ||
return null; | ||
} | ||
IEclipsePreferences node = new ProjectScope(project).getNode(LspEditorUiPlugin.PLUGIN_ID); | ||
if (node == null) { | ||
return null; | ||
} | ||
var relativePath = node.get(LspEditorPropertiesPage.COMPILE_COMMANDS_DIR, "build/default"); | ||
return project.getLocation().append(relativePath); | ||
} | ||
|
||
private IProject getProject(URI uri) { | ||
var scheme = uri.getScheme(); | ||
if ("file".equals(scheme)) { | ||
IContainer[] container = LspPlugin.getDefault().getWorkspace().getRoot().findContainersForLocationURI(uri); | ||
if (container.length > 0) { | ||
return container[0].getProject(); | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
} |
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
102 changes: 102 additions & 0 deletions
102
bundles/org.eclipse.cdt.lsp/schema/compileCommands.exsd
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,102 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<!-- Schema file written by PDE --> | ||
<schema targetNamespace="org.eclipse.cdt.lsp" xmlns="http://www.w3.org/2001/XMLSchema"> | ||
<annotation> | ||
<appinfo> | ||
<meta.schema plugin="org.eclipse.cdt.lsp" id="compileCommands" name="Directory locator for compile_commands.json file"/> | ||
</appinfo> | ||
<documentation> | ||
Defines a locator for a directory containing the compile_commands.json file for a given file URI | ||
</documentation> | ||
</annotation> | ||
|
||
<element name="extension"> | ||
<annotation> | ||
<appinfo> | ||
<meta.element /> | ||
</appinfo> | ||
</annotation> | ||
<complexType> | ||
<sequence> | ||
<element ref="locator"/> | ||
</sequence> | ||
<attribute name="point" type="string" use="required"> | ||
<annotation> | ||
<documentation> | ||
|
||
</documentation> | ||
</annotation> | ||
</attribute> | ||
<attribute name="id" type="string"> | ||
<annotation> | ||
<documentation> | ||
|
||
</documentation> | ||
</annotation> | ||
</attribute> | ||
<attribute name="name" type="string"> | ||
<annotation> | ||
<documentation> | ||
|
||
</documentation> | ||
<appinfo> | ||
<meta.attribute translatable="true"/> | ||
</appinfo> | ||
</annotation> | ||
</attribute> | ||
</complexType> | ||
</element> | ||
|
||
<element name="locator"> | ||
<complexType> | ||
<attribute name="class" type="string" use="required"> | ||
<annotation> | ||
<documentation> | ||
Class implementing the ICompileCommandsDirLocator inferface. | ||
</documentation> | ||
<appinfo> | ||
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.lsp.server.ICompileCommandsDirLocator"/> | ||
</appinfo> | ||
</annotation> | ||
</attribute> | ||
</complexType> | ||
</element> | ||
|
||
<annotation> | ||
<appinfo> | ||
<meta.section type="since"/> | ||
</appinfo> | ||
<documentation> | ||
[Enter the first release in which this extension point appears.] | ||
</documentation> | ||
</annotation> | ||
|
||
<annotation> | ||
<appinfo> | ||
<meta.section type="examples"/> | ||
</appinfo> | ||
<documentation> | ||
[Enter extension point usage example here.] | ||
</documentation> | ||
</annotation> | ||
|
||
<annotation> | ||
<appinfo> | ||
<meta.section type="apiinfo"/> | ||
</appinfo> | ||
<documentation> | ||
[Enter API information here.] | ||
</documentation> | ||
</annotation> | ||
|
||
<annotation> | ||
<appinfo> | ||
<meta.section type="implementation"/> | ||
</appinfo> | ||
<documentation> | ||
[Enter information about supplied implementation of this extension point.] | ||
</documentation> | ||
</annotation> | ||
|
||
|
||
</schema> |
Oops, something went wrong.