Skip to main content
summaryrefslogtreecommitdiffstats
path: root/lsp
diff options
context:
space:
mode:
authorDoug Schaefer2018-11-09 14:53:47 +0000
committerDoug Schaefer2018-11-10 19:09:43 +0000
commitafe7d1879386391a0d88ef2ff3f23c6d789c7287 (patch)
tree86c9671d4cabb88f8bbafb52383956e83b5b3ba8 /lsp
parentf9250cb361c54bc7d4117b7ab85649cdbacc2f87 (diff)
downloadorg.eclipse.cdt-afe7d1879386391a0d88ef2ff3f23c6d789c7287.tar.gz
org.eclipse.cdt-afe7d1879386391a0d88ef2ff3f23c6d789c7287.tar.xz
org.eclipse.cdt-afe7d1879386391a0d88ef2ff3f23c6d789c7287.zip
Bug 540978 Rename lsp plugins to be org.eclipse.cdt.lsp.*
To make it clear these are CDT's future :). Change-Id: I64935e3998a46632f4f4006589a17eb01959eb27
Diffstat (limited to 'lsp')
-rw-r--r--lsp/org.eclipse.cdt.lsp-feature/.project17
-rw-r--r--lsp/org.eclipse.cdt.lsp-feature/.settings/org.eclipse.core.resources.prefs2
-rw-r--r--lsp/org.eclipse.cdt.lsp-feature/.settings/org.eclipse.core.runtime.prefs2
-rw-r--r--lsp/org.eclipse.cdt.lsp-feature/build.properties2
-rw-r--r--lsp/org.eclipse.cdt.lsp-feature/feature.properties20
-rw-r--r--lsp/org.eclipse.cdt.lsp-feature/feature.xml28
-rw-r--r--lsp/org.eclipse.cdt.lsp.core.tests/.classpath7
-rw-r--r--lsp/org.eclipse.cdt.lsp.core.tests/.project28
-rw-r--r--lsp/org.eclipse.cdt.lsp.core.tests/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--lsp/org.eclipse.cdt.lsp.core.tests/META-INF/MANIFEST.MF13
-rw-r--r--lsp/org.eclipse.cdt.lsp.core.tests/build.properties4
-rw-r--r--lsp/org.eclipse.cdt.lsp.core.tests/pom.xml40
-rw-r--r--lsp/org.eclipse.cdt.lsp.core.tests/src/org/eclipse/cdt/lsp/core/tests/cquery/CqueryJsonParseTest.java114
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/.classpath7
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/.gitignore1
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/.project28
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/.settings/org.eclipse.core.resources.prefs2
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/.settings/org.eclipse.core.runtime.prefs2
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/.settings/org.eclipse.jdt.core.prefs419
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/.settings/org.eclipse.jdt.ui.prefs66
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/.settings/org.eclipse.pde.prefs32
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/META-INF/MANIFEST.MF29
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/OSGI-INF/l10n/bundle.properties12
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/build.properties7
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/plugin.xml72
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/Activator.java70
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/AutoIndentStrategyCPP.java24
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/CPPLanguageServerPreferencePage.java66
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/CPPResourceChangeListener.java118
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/CPPStreamConnectionProvider.java156
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/ClangdLanguageServer.java20
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/CqueryLanguageServer.java37
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/ICPPLanguageServer.java19
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/LineBackgroundListenerCPP.java63
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/Messages.java24
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/Messages.properties14
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/PreferenceConstants.java22
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/PreferenceInitializer.java32
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/PresentationReconcilerCPP.java374
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/Server2ClientProtocolExtension.java244
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/cquery/CqueryInactiveRegions.java31
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/cquery/CquerySemanticHighlights.java30
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/cquery/CquerySymbolKind.java40
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/cquery/ExtendedSymbolKindType.java65
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/cquery/HighlightSymbol.java94
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/cquery/IndexingProgressStats.java57
-rw-r--r--lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/cquery/StorageClass.java31
-rw-r--r--lsp/pom.xml15
48 files changed, 2607 insertions, 0 deletions
diff --git a/lsp/org.eclipse.cdt.lsp-feature/.project b/lsp/org.eclipse.cdt.lsp-feature/.project
new file mode 100644
index 00000000000..976f2116970
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp-feature/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.cdt.lsp-feature</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.pde.FeatureBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.FeatureNature</nature>
+ </natures>
+</projectDescription>
diff --git a/lsp/org.eclipse.cdt.lsp-feature/.settings/org.eclipse.core.resources.prefs b/lsp/org.eclipse.cdt.lsp-feature/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 00000000000..99f26c0203a
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp-feature/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/lsp/org.eclipse.cdt.lsp-feature/.settings/org.eclipse.core.runtime.prefs b/lsp/org.eclipse.cdt.lsp-feature/.settings/org.eclipse.core.runtime.prefs
new file mode 100644
index 00000000000..5a0ad22d2a7
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp-feature/.settings/org.eclipse.core.runtime.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+line.separator=\n
diff --git a/lsp/org.eclipse.cdt.lsp-feature/build.properties b/lsp/org.eclipse.cdt.lsp-feature/build.properties
new file mode 100644
index 00000000000..b3a611b5c93
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp-feature/build.properties
@@ -0,0 +1,2 @@
+bin.includes = feature.xml,\
+ feature.properties
diff --git a/lsp/org.eclipse.cdt.lsp-feature/feature.properties b/lsp/org.eclipse.cdt.lsp-feature/feature.properties
new file mode 100644
index 00000000000..6fc612faeb8
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp-feature/feature.properties
@@ -0,0 +1,20 @@
+###############################################################################
+# Copyright (c) 2017 Ericsson
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+###############################################################################
+
+featureName=LSP4E C/C++ Support
+
+description=Plug-ins to support C/C++ language servers in LSP4E.
+
+featureProvider=Eclipse CDT
+
+copyright=Copyright (c) 2017 Ericsson and others.\n\
+All rights reserved. This program and the accompanying materials\n\
+are made available under the terms of the Eclipse Public License v1.0\n\
+which accompanies this distribution, and is available at\n\
+http://www.eclipse.org/legal/epl-v10.html
diff --git a/lsp/org.eclipse.cdt.lsp-feature/feature.xml b/lsp/org.eclipse.cdt.lsp-feature/feature.xml
new file mode 100644
index 00000000000..4ef4c89937a
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp-feature/feature.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+ id="org.eclipse.cdt.lsp"
+ label="%featureName"
+ version="9.6.0.qualifier"
+ provider-name="%featureProvider"
+ license-feature="org.eclipse.license"
+ license-feature-version="0.0.0">
+
+ <description>
+ %description
+ </description>
+
+ <copyright>
+ %copyright
+ </copyright>
+
+ <license url="%licenseURL">
+ %license
+ </license>
+
+ <plugin
+ id="org.eclipse.cdt.lsp.core"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"/>
+
+</feature>
diff --git a/lsp/org.eclipse.cdt.lsp.core.tests/.classpath b/lsp/org.eclipse.cdt.lsp.core.tests/.classpath
new file mode 100644
index 00000000000..eca7bdba8f0
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core.tests/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/lsp/org.eclipse.cdt.lsp.core.tests/.project b/lsp/org.eclipse.cdt.lsp.core.tests/.project
new file mode 100644
index 00000000000..a93e06df0ce
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core.tests/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.cdt.lsp.core.tests</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/lsp/org.eclipse.cdt.lsp.core.tests/.settings/org.eclipse.jdt.core.prefs b/lsp/org.eclipse.cdt.lsp.core.tests/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..0c68a61dca8
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core.tests/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/lsp/org.eclipse.cdt.lsp.core.tests/META-INF/MANIFEST.MF b/lsp/org.eclipse.cdt.lsp.core.tests/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..9d2a4e9fd1b
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: "Tests for LSP4E C/C++ Support"
+Bundle-SymbolicName: org.eclipse.cdt.lsp.core.tests
+Bundle-Version: 1.0.0.qualifier
+Automatic-Module-Name: org.eclipse.lsp4e.cpp.language.tests
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Require-Bundle: org.eclipse.lsp4e,
+ org.eclipse.lsp4j,
+ org.eclipse.lsp4j.jsonrpc,
+ org.eclipse.cdt.lsp.core,
+ com.google.gson;bundle-version="2.8.2",
+ org.junit
diff --git a/lsp/org.eclipse.cdt.lsp.core.tests/build.properties b/lsp/org.eclipse.cdt.lsp.core.tests/build.properties
new file mode 100644
index 00000000000..34d2e4d2dad
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core.tests/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/lsp/org.eclipse.cdt.lsp.core.tests/pom.xml b/lsp/org.eclipse.cdt.lsp.core.tests/pom.xml
new file mode 100644
index 00000000000..7a57fca02ce
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core.tests/pom.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.eclipse.cdt</groupId>
+ <artifactId>cdt-parent</artifactId>
+ <version>9.6.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <version>1.0.0-SNAPSHOT</version>
+ <artifactId>org.eclipse.cdt.lsp.core.tests</artifactId>
+ <packaging>eclipse-test-plugin</packaging>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-surefire-plugin</artifactId>
+ <configuration>
+ <!-- If you have any UI tests, use this block -->
+ <useUIHarness>true</useUIHarness>
+ <useUIThread>true</useUIThread>
+ <argLine>${tycho.testArgLine} ${base.ui.test.vmargs}</argLine>
+ <!-- else, if you have no UI tests, use this block -->
+ <!-- <useUIHarness>false</useUIHarness>
+ <useUIThread>false</useUIThread>
+ <argLine>${tycho.testArgLine} ${base.test.vmargs}</argLine> -->
+ <!-- endif -->
+ <includes>
+ <include>**/*Test.*</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/lsp/org.eclipse.cdt.lsp.core.tests/src/org/eclipse/cdt/lsp/core/tests/cquery/CqueryJsonParseTest.java b/lsp/org.eclipse.cdt.lsp.core.tests/src/org/eclipse/cdt/lsp/core/tests/cquery/CqueryJsonParseTest.java
new file mode 100644
index 00000000000..eb014dc01e5
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core.tests/src/org/eclipse/cdt/lsp/core/tests/cquery/CqueryJsonParseTest.java
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Manish Khurana , Nathan Ridge and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.cdt.lsp.core.tests.cquery;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.lsp.core.Server2ClientProtocolExtension;
+import org.eclipse.cdt.lsp.core.cquery.*;
+import org.eclipse.lsp4j.Position;
+import org.eclipse.lsp4j.Range;
+import org.eclipse.lsp4j.jsonrpc.json.JsonRpcMethod;
+import org.eclipse.lsp4j.jsonrpc.json.MessageJsonHandler;
+import org.eclipse.lsp4j.jsonrpc.messages.*;
+import org.eclipse.lsp4j.jsonrpc.services.ServiceEndpoints;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class CqueryJsonParseTest {
+ Map<String, JsonRpcMethod> methods = ServiceEndpoints.getSupportedMethods(Server2ClientProtocolExtension.class);
+ private MessageJsonHandler jsonHandler = new MessageJsonHandler(methods);
+
+ private void assertParse(final String json, final NotificationMessage expectedResult) {
+ Assert.assertEquals(expectedResult.toString(), jsonHandler.parseMessage(json).toString());
+ }
+
+ @Test
+ public void testProgress(){
+ String json = "{\"jsonrpc\": \"2.0\",\"method\": \"$cquery/progress\",\"params\": {" //$NON-NLS-1$
+ + "\"indexRequestCount\": 4,\"doIdMapCount\": 5,\"loadPreviousIndexCount\": 6," //$NON-NLS-1$
+ + "\"onIdMappedCount\": 7,\"onIndexedCount\": 8,\"activeThreads\": 9}}"; //$NON-NLS-1$
+
+ IndexingProgressStats expectedIndex = new IndexingProgressStats(4, 5, 6, 7, 8, 9);
+ NotificationMessage expectedResult = new NotificationMessage();
+ expectedResult.setJsonrpc("2.0"); //$NON-NLS-1$
+ expectedResult.setMethod("$cquery/progress"); //$NON-NLS-1$
+ expectedResult.setParams(expectedIndex);
+ assertParse(json, expectedResult);
+ }
+
+ @Test
+ public void testSetInactiveRegions() {
+ String json = "{\"jsonrpc\": \"2.0\",\"method\": \"$cquery/setInactiveRegions\",\"params\": {" //$NON-NLS-1$
+ + "\"uri\": \"file:///home/foobar.cpp\",\"inactiveRegions\": [{\"start\": {\"line\": " //$NON-NLS-1$
+ + "25,\"character\": 4},\"end\": {\"line\": 25,\"character\": 10}},{\"start\": {\"line\"" //$NON-NLS-1$
+ + ": 35,\"character\": 8},\"end\": {\"line\": 35,\"character\": 15}}]}}"; //$NON-NLS-1$
+
+ URI uri = URI.create("file:///home/foobar.cpp"); //$NON-NLS-1$
+ Position pos1 = new Position(25, 4);
+ Position pos2 = new Position(25, 10);
+ Position pos3 = new Position(35, 8);
+ Position pos4 = new Position(35, 15);
+ Range range1 = new Range(pos1,pos2);
+ Range range2 = new Range(pos3,pos4);
+ List<Range> regions = new ArrayList<>();
+ regions.add(range1);
+ regions.add(range2);
+ CqueryInactiveRegions expectedRegions = new CqueryInactiveRegions(uri, regions);
+
+ NotificationMessage expectedResult = new NotificationMessage();
+ expectedResult.setJsonrpc("2.0"); //$NON-NLS-1$
+ expectedResult.setMethod("$cquery/setInactiveRegions"); //$NON-NLS-1$
+ expectedResult.setParams(expectedRegions);
+ assertParse(json, expectedResult);
+ }
+
+ @Test
+ public void testPublishSemanticHighlighting() {
+ String json = "{\"jsonrpc\": \"2.0\",\"method\": \"$cquery/publishSemanticHighlighting\"," //$NON-NLS-1$
+ + "\"params\": {\"uri\": \"file:///home/foobar.cpp\",\"symbols\": [{\"stableId\": 21," //$NON-NLS-1$
+ + "\"parentKind\": 8,\"kind\": 0,\"storage\": 3,\"ranges\": [{\"start\": {\"line\": 41," //$NON-NLS-1$
+ + "\"character\": 1},\"end\": {\"line\": 41,\"character\": 5}}]},{\"stableId\": 19," //$NON-NLS-1$
+ + "\"parentKind\": 12,\"kind\": 253,\"storage\": 5,\"ranges\": [{\"start\": {\"line\": 39," //$NON-NLS-1$
+ + "\"character\": 9},\"end\": {\"line\": 39,\"character\": 10}}]}]}}"; //$NON-NLS-1$
+
+ URI uri = URI.create("file:///home/foobar.cpp"); //$NON-NLS-1$
+ Position pos1 = new Position(41, 1);
+ Position pos2 = new Position(41, 5);
+ Position pos3 = new Position(39, 9);
+ Position pos4 = new Position(39, 10);
+ Range range1 = new Range(pos1,pos2);
+ Range range2 = new Range(pos3,pos4);
+ List<Range> ranges1 = new ArrayList<>();
+ List<Range> ranges2 = new ArrayList<>();
+ ranges1.add(range1);
+ ranges2.add(range2);
+ ExtendedSymbolKindType parentKind1 = new ExtendedSymbolKindType(8);
+ ExtendedSymbolKindType parentKind2 = new ExtendedSymbolKindType(12);
+ ExtendedSymbolKindType kind1 = new ExtendedSymbolKindType(0);
+ ExtendedSymbolKindType kind2 = new ExtendedSymbolKindType(253);
+ StorageClass storage1 = StorageClass.Static;
+ StorageClass storage2 = StorageClass.Auto;
+ HighlightSymbol symbol1 = new HighlightSymbol(21, parentKind1, kind1, storage1, ranges1);
+ HighlightSymbol symbol2 = new HighlightSymbol(19, parentKind2, kind2, storage2, ranges2);
+ List<HighlightSymbol> symbols = new ArrayList<>();
+ symbols.add(symbol1);
+ symbols.add(symbol2);
+ CquerySemanticHighlights exceptedHighlights = new CquerySemanticHighlights(uri, symbols);
+
+ NotificationMessage expectedResult = new NotificationMessage();
+ expectedResult.setJsonrpc("2.0"); //$NON-NLS-1$
+ expectedResult.setMethod("$cquery/publishSemanticHighlighting"); //$NON-NLS-1$
+ expectedResult.setParams(exceptedHighlights);
+ assertParse(json, expectedResult);
+ }
+}
diff --git a/lsp/org.eclipse.cdt.lsp.core/.classpath b/lsp/org.eclipse.cdt.lsp.core/.classpath
new file mode 100644
index 00000000000..eca7bdba8f0
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/lsp/org.eclipse.cdt.lsp.core/.gitignore b/lsp/org.eclipse.cdt.lsp.core/.gitignore
new file mode 100644
index 00000000000..ae3c1726048
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/.gitignore
@@ -0,0 +1 @@
+/bin/
diff --git a/lsp/org.eclipse.cdt.lsp.core/.project b/lsp/org.eclipse.cdt.lsp.core/.project
new file mode 100644
index 00000000000..2524436d04a
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.cdt.lsp.core</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/lsp/org.eclipse.cdt.lsp.core/.settings/org.eclipse.core.resources.prefs b/lsp/org.eclipse.cdt.lsp.core/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 00000000000..99f26c0203a
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/lsp/org.eclipse.cdt.lsp.core/.settings/org.eclipse.core.runtime.prefs b/lsp/org.eclipse.cdt.lsp.core/.settings/org.eclipse.core.runtime.prefs
new file mode 100644
index 00000000000..5a0ad22d2a7
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/.settings/org.eclipse.core.runtime.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+line.separator=\n
diff --git a/lsp/org.eclipse.cdt.lsp.core/.settings/org.eclipse.jdt.core.prefs b/lsp/org.eclipse.cdt.lsp.core/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..6bb02050ad5
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,419 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.codeComplete.argumentPrefixes=
+org.eclipse.jdt.core.codeComplete.argumentSuffixes=
+org.eclipse.jdt.core.codeComplete.fieldPrefixes=f
+org.eclipse.jdt.core.codeComplete.fieldSuffixes=
+org.eclipse.jdt.core.codeComplete.localPrefixes=
+org.eclipse.jdt.core.codeComplete.localSuffixes=
+org.eclipse.jdt.core.codeComplete.staticFieldPrefixes=
+org.eclipse.jdt.core.codeComplete.staticFieldSuffixes=
+org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes=
+org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes=
+org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
+org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
+org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
+org.eclipse.jdt.core.compiler.annotation.nonnull.secondary=
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary=
+org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
+org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
+org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
+org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
+org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning
+org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
+org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
+org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.8
+org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647
+org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_assignment=0
+org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
+org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
+org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0
+org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
+org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
+org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0
+org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0
+org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
+org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_after_package=1
+org.eclipse.jdt.core.formatter.blank_lines_before_field=0
+org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
+org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
+org.eclipse.jdt.core.formatter.blank_lines_before_method=1
+org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
+org.eclipse.jdt.core.formatter.blank_lines_before_package=0
+org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
+org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
+org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
+org.eclipse.jdt.core.formatter.comment.format_block_comments=true
+org.eclipse.jdt.core.formatter.comment.format_header=false
+org.eclipse.jdt.core.formatter.comment.format_html=true
+org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
+org.eclipse.jdt.core.formatter.comment.format_line_comments=true
+org.eclipse.jdt.core.formatter.comment.format_source_code=true
+org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
+org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
+org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
+org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
+org.eclipse.jdt.core.formatter.comment.line_length=80
+org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
+org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
+org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false
+org.eclipse.jdt.core.formatter.compact_else_if=true
+org.eclipse.jdt.core.formatter.continuation_indentation=2
+org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
+org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
+org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
+org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
+org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
+org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_empty_lines=false
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
+org.eclipse.jdt.core.formatter.indentation.size=4
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
+org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
+org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
+org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.join_lines_in_comments=true
+org.eclipse.jdt.core.formatter.join_wrapped_lines=true
+org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.lineSplit=120
+org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
+org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
+org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines
+org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
+org.eclipse.jdt.core.formatter.tabulation.char=tab
+org.eclipse.jdt.core.formatter.tabulation.size=4
+org.eclipse.jdt.core.formatter.use_on_off_tags=false
+org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
+org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false
+org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
+org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
+org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter
diff --git a/lsp/org.eclipse.cdt.lsp.core/.settings/org.eclipse.jdt.ui.prefs b/lsp/org.eclipse.cdt.lsp.core/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 00000000000..145186810bd
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,66 @@
+cleanup_settings_version=2
+eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+formatter_profile=org.eclipse.jdt.ui.default.eclipse_profile
+formatter_settings_version=12
+org.eclipse.jdt.ui.exception.name=e
+org.eclipse.jdt.ui.gettersetter.use.is=true
+org.eclipse.jdt.ui.keywordthis=false
+org.eclipse.jdt.ui.overrideannotation=true
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_missing_override_annotations_interface_methods=true
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_functional_interfaces=false
+sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.correct_indentation=false
+sp_cleanup.format_source_code=false
+sp_cleanup.format_source_code_changes_only=false
+sp_cleanup.insert_inferred_type_arguments=false
+sp_cleanup.make_local_variable_final=true
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=false
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=true
+sp_cleanup.organize_imports=false
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_redundant_type_arguments=true
+sp_cleanup.remove_trailing_whitespaces=true
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=true
+sp_cleanup.remove_unused_imports=false
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_anonymous_class_creation=false
+sp_cleanup.use_blocks=true
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_lambda=true
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=false
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=false
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
diff --git a/lsp/org.eclipse.cdt.lsp.core/.settings/org.eclipse.pde.prefs b/lsp/org.eclipse.cdt.lsp.core/.settings/org.eclipse.pde.prefs
new file mode 100644
index 00000000000..01d624df119
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/.settings/org.eclipse.pde.prefs
@@ -0,0 +1,32 @@
+compilers.f.unresolved-features=1
+compilers.f.unresolved-plugins=1
+compilers.incompatible-environment=1
+compilers.p.build=1
+compilers.p.build.bin.includes=0
+compilers.p.build.encodings=2
+compilers.p.build.java.compiler=2
+compilers.p.build.java.compliance=1
+compilers.p.build.missing.output=2
+compilers.p.build.output.library=1
+compilers.p.build.source.library=0
+compilers.p.build.src.includes=0
+compilers.p.deprecated=1
+compilers.p.discouraged-class=1
+compilers.p.internal=1
+compilers.p.missing-packages=1
+compilers.p.missing-version-export-package=2
+compilers.p.missing-version-import-package=2
+compilers.p.missing-version-require-bundle=2
+compilers.p.no-required-att=0
+compilers.p.not-externalized-att=1
+compilers.p.unknown-attribute=1
+compilers.p.unknown-class=1
+compilers.p.unknown-element=1
+compilers.p.unknown-identifier=1
+compilers.p.unknown-resource=1
+compilers.p.unresolved-ex-points=0
+compilers.p.unresolved-import=0
+compilers.s.create-docs=false
+compilers.s.doc-folder=doc
+compilers.s.open-tags=1
+eclipse.preferences.version=1
diff --git a/lsp/org.eclipse.cdt.lsp.core/META-INF/MANIFEST.MF b/lsp/org.eclipse.cdt.lsp.core/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..85979c35a0b
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/META-INF/MANIFEST.MF
@@ -0,0 +1,29 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name
+Bundle-SymbolicName: org.eclipse.cdt.lsp.core;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Require-Bundle: org.apache.commons.io,
+ org.eclipse.core.runtime,
+ org.eclipse.lsp4e,
+ org.eclipse.ui.genericeditor;bundle-version="1.0.0",
+ org.eclipse.jface.text,
+ org.eclipse.cdt.ui,
+ org.eclipse.cdt.core,
+ org.eclipse.jface,
+ org.eclipse.ui,
+ org.eclipse.lsp4j,
+ org.eclipse.core.commands,
+ org.eclipse.core.expressions,
+ org.eclipse.core.resources,
+ com.google.gson;bundle-version="2.8.2",
+ org.eclipse.lsp4j.jsonrpc
+Bundle-Vendor: %Bundle-Vendor
+Export-Package: org.eclipse.cdt.lsp.core,
+ org.eclipse.cdt.lsp.core.cquery
+Bundle-Activator: org.eclipse.cdt.lsp.core.Activator
+Bundle-ActivationPolicy: lazy
+Import-Package: org.eclipse.ui.editors.text,
+ org.eclipse.ui.texteditor
+Automatic-Module-Name: org.eclipse.lsp4e.cpp.language
diff --git a/lsp/org.eclipse.cdt.lsp.core/OSGI-INF/l10n/bundle.properties b/lsp/org.eclipse.cdt.lsp.core/OSGI-INF/l10n/bundle.properties
new file mode 100644
index 00000000000..19675c4c963
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/OSGI-INF/l10n/bundle.properties
@@ -0,0 +1,12 @@
+#Properties file for org.eclipse.lsp4e.cpp.language
+Bundle-Vendor = Eclipse CDT
+Bundle-Name = LSP4E C/C++ Support Plug-in
+content-type.name = C/C++
+server.label = C/C++ Language Server
+
+reindex.command.name = Reindex
+reindex.command.label = Reindex
+
+cDocumentSetupParticipant =C Document Setup Participant
+
+PreferencePageTitle=C/C++ Language Server
diff --git a/lsp/org.eclipse.cdt.lsp.core/build.properties b/lsp/org.eclipse.cdt.lsp.core/build.properties
new file mode 100644
index 00000000000..04fa2eee8dd
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/build.properties
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ OSGI-INF/,\
+ OSGI-INF/l10n/bundle.properties
diff --git a/lsp/org.eclipse.cdt.lsp.core/plugin.xml b/lsp/org.eclipse.cdt.lsp.core/plugin.xml
new file mode 100644
index 00000000000..717d395a306
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/plugin.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.core.contenttype.contentTypes">
+ <content-type
+ base-type="org.eclipse.core.runtime.text"
+ file-extensions="cpp,c,h,cxx,cc,hxx,hpp"
+ id="org.eclipse.lsp4e.languages.cpp"
+ name="%content-type.name"
+ priority="normal">
+ </content-type>
+ </extension>
+ <extension
+ point="org.eclipse.lsp4e.languageServer">
+ <server
+ class="org.eclipse.cdt.lsp.core.CPPStreamConnectionProvider"
+ id="org.eclipse.lsp4e.languages.cpp"
+ label="%server.label"
+ clientImpl="org.eclipse.cdt.lsp.core.Server2ClientProtocolExtension" >
+ </server>
+ <contentTypeMapping
+ contentType="org.eclipse.lsp4e.languages.cpp"
+ id="org.eclipse.lsp4e.languages.cpp">
+ </contentTypeMapping>
+ </extension>
+ <extension
+ id="org.eclipse.lsp4e.cpp.language.CDocumentSetupParticipant"
+ name="%cDocumentSetupParticipant"
+ point="org.eclipse.core.filebuffers.documentSetup">
+ <participant
+ class="org.eclipse.cdt.internal.ui.editor.CDocumentSetupParticipant"
+ contentTypeId="org.eclipse.lsp4e.languages.cpp">
+ </participant>
+ </extension>
+ <extension
+ point="org.eclipse.ui.editors">
+ <editorContentTypeBinding
+ contentTypeId="org.eclipse.lsp4e.languages.cpp"
+ editorId="org.eclipse.ui.genericeditor.GenericEditor">
+ </editorContentTypeBinding>
+ </extension>
+ <extension
+ point="org.eclipse.ui.genericeditor.presentationReconcilers">
+ <presentationReconciler
+ class="org.eclipse.cdt.lsp.core.PresentationReconcilerCPP"
+ contentType="org.eclipse.lsp4e.languages.cpp">
+ </presentationReconciler>
+ </extension>
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ class="org.eclipse.cdt.lsp.core.CPPLanguageServerPreferencePage"
+ category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
+ id="org.eclipse.lsp4e.cpp.language.CPPLanguageServerPreferencePage"
+ name="%PreferencePageTitle">
+ </page>
+ </extension>
+ <extension
+ point="org.eclipse.core.runtime.preferences">
+ <initializer
+ class="org.eclipse.cdt.lsp.core.PreferenceInitializer">
+ </initializer>
+ </extension>
+ <extension
+ point="org.eclipse.ui.genericeditor.autoEditStrategies">
+ <autoEditStrategy
+ class="org.eclipse.cdt.lsp.core.AutoIndentStrategyCPP"
+ contentType="org.eclipse.lsp4e.languages.cpp">
+ </autoEditStrategy>
+ </extension>
+</plugin>
diff --git a/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/Activator.java b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/Activator.java
new file mode 100644
index 00000000000..46d6c189028
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/Activator.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Manish Khurana , Nathan Ridge and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.cdt.lsp.core;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+public class Activator extends AbstractUIPlugin {
+
+ public Activator() {
+ }
+
+ public static final String PLUGIN_ID = "org.eclipse.lsp4e.cpp.language"; //$NON-NLS-1$
+
+ private static Activator plugin;
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Creates an error status.
+ *
+ * @noreference This method is not intended to be referenced by clients.
+ */
+ public static Status createErrorStatus(String message, Throwable e) {
+ return new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, message, e);
+ }
+
+ /**
+ * @noreference This method is not intended to be referenced by clients.
+ */
+ public static void log(Throwable e) {
+ log("Error", e); //$NON-NLS-1$
+ }
+
+ /**
+ * @noreference This method is not intended to be referenced by clients.
+ */
+ public static void log(String message, Throwable e) {
+ log(createErrorStatus(message, e));
+ }
+
+ /**
+ * @noreference This method is not intended to be referenced by clients.
+ */
+ public static void log(IStatus status) {
+ getDefault().getLog().log(status);
+ }
+}
diff --git a/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/AutoIndentStrategyCPP.java b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/AutoIndentStrategyCPP.java
new file mode 100644
index 00000000000..c375b9bf38d
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/AutoIndentStrategyCPP.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Manish Khurana , Nathan Ridge and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.cdt.lsp.core;
+
+import org.eclipse.cdt.internal.ui.text.CAutoIndentStrategy;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/*
+ * Class to re-use existing auto-indentation support of CEditor in Generic Editor of LSP4E-CPP.
+ */
+
+public class AutoIndentStrategyCPP extends CAutoIndentStrategy {
+
+ public AutoIndentStrategyCPP() {
+ // TODO: Pass in the project so the auto edit strategy respects the project's preferences.
+ super(CUIPlugin.getDefault().getTextTools().getDocumentPartitioning(), null, true);
+ }
+}
diff --git a/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/CPPLanguageServerPreferencePage.java b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/CPPLanguageServerPreferencePage.java
new file mode 100644
index 00000000000..baab3792325
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/CPPLanguageServerPreferencePage.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Manish Khurana , Nathan Ridge and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.cdt.lsp.core;
+
+import java.io.File;
+
+import org.eclipse.jface.preference.*;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * This class represents the preference page for C/C++ Language Server.
+ */
+
+public class CPPLanguageServerPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
+
+ private FileFieldEditor serverPath;
+ private RadioGroupFieldEditor serverChoice;
+ private StringFieldEditor serverOptions;
+
+ public CPPLanguageServerPreferencePage() {
+ super(GRID);
+ setPreferenceStore(Activator.getDefault().getPreferenceStore());
+ setDescription(Messages.PreferencePageDescription);
+ }
+
+ @Override
+ public void createFieldEditors() {
+
+ serverChoice = new RadioGroupFieldEditor(PreferenceConstants.P_SERVER_CHOICE, Messages.ServerChoiceLabel, 1,
+ new String[][] { { "ClangD", CPPStreamConnectionProvider.CLANGD_ID }, //$NON-NLS-1$
+ { "CQuery", CPPStreamConnectionProvider.CQUERY_ID } }, //$NON-NLS-1$
+ getFieldEditorParent());
+ addField(serverChoice);
+
+ serverPath = new FileFieldEditor(PreferenceConstants.P_SERVER_PATH, Messages.ServerPathLabel,
+ getFieldEditorParent());
+ addField(serverPath);
+
+ serverOptions = new StringFieldEditor(PreferenceConstants.P_SERVER_OPTIONS, Messages.ServerOptionsLabel,
+ getFieldEditorParent());
+ addField(serverOptions);
+ }
+
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getSource() == serverChoice && event.getProperty() == FieldEditor.VALUE) {
+ File changedLSLocation = CPPStreamConnectionProvider.getDefaultLSLocation((String) event.getNewValue());
+ if(changedLSLocation != null) {
+ serverPath.setStringValue(changedLSLocation.getAbsolutePath());
+ }
+ }
+ super.propertyChange(event);
+ }
+
+ @Override
+ public void init(IWorkbench workbench) {
+ }
+} \ No newline at end of file
diff --git a/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/CPPResourceChangeListener.java b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/CPPResourceChangeListener.java
new file mode 100644
index 00000000000..8bf4da8e4f5
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/CPPResourceChangeListener.java
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Ericsson and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.cdt.lsp.core;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.lsp4e.LanguageServersRegistry;
+import org.eclipse.lsp4e.LanguageServersRegistry.LanguageServerDefinition;
+import org.eclipse.lsp4e.LanguageServiceAccessor;
+import org.eclipse.lsp4e.ProjectSpecificLanguageServerWrapper;
+import org.eclipse.lsp4j.DidChangeWatchedFilesParams;
+import org.eclipse.lsp4j.FileChangeType;
+import org.eclipse.lsp4j.FileEvent;
+
+/**
+ * A resource listener used to generate FileEvents, as part of the LSP. This
+ * only listens to Added, Changed, Removed event on a specific project that as a
+ * C/C++ language server started.
+ */
+@SuppressWarnings("restriction")
+final class CPPResourceChangeListener implements IResourceChangeListener {
+ private final IProject fProject;
+
+ CPPResourceChangeListener(IProject project) {
+ fProject = project;
+ }
+
+ @Override
+ public void resourceChanged(IResourceChangeEvent event) {
+ LanguageServerDefinition definition = LanguageServersRegistry.getInstance().getDefinition(CPPStreamConnectionProvider.ID);
+ ProjectSpecificLanguageServerWrapper wrapper = getLanguageSeverWrapper(definition);
+ if (event.getType() != IResourceChangeEvent.POST_CHANGE || !isRelevantDelta(event.getDelta())
+ || wrapper == null) {
+ return;
+ }
+
+ sendFileEvents(wrapper, createFileEventsFromResourceEvent(event));
+ }
+
+ private static void sendFileEvents(ProjectSpecificLanguageServerWrapper wrapper, List<FileEvent> fileEvents) {
+ if (!fileEvents.isEmpty()) {
+ DidChangeWatchedFilesParams params = new DidChangeWatchedFilesParams(fileEvents);
+ wrapper.getServer().getWorkspaceService().didChangeWatchedFiles(params);
+ }
+ }
+
+ private static List<FileEvent> createFileEventsFromResourceEvent(IResourceChangeEvent event) {
+ List<FileEvent> fileEvents = new ArrayList<>();
+ try {
+ event.getDelta().accept((delta) -> {
+ if (delta.getResource() instanceof IFile && isRelevantDelta(delta)) {
+ FileEvent fileEvent = createFileEventFromDelta(delta);
+ if (fileEvent != null) {
+ fileEvents.add(fileEvent);
+ }
+ }
+ return true;
+ }, false);
+ } catch (CoreException e) {
+ // Do nothing
+ }
+ return fileEvents;
+ }
+
+ private ProjectSpecificLanguageServerWrapper getLanguageSeverWrapper(LanguageServerDefinition definition) {
+ try {
+ return LanguageServiceAccessor.getLSWrapperForConnection(fProject, definition);
+ } catch (IOException e) {
+ // Do nothing
+ return null;
+ }
+ }
+
+ private static boolean isRelevantDelta(IResourceDelta delta) {
+ int kind = delta.getKind();
+ int flags = delta.getFlags();
+ if (delta.getResource() instanceof IFile && kind == IResourceDelta.CHANGED) {
+ return (flags & IResourceDelta.CONTENT) != 0;
+ }
+
+ return kind == IResourceDelta.ADDED || kind == IResourceDelta.CHANGED || kind == IResourceDelta.REMOVED;
+ }
+
+ private static FileEvent createFileEventFromDelta(IResourceDelta delta) {
+ URI locationURI = delta.getResource().getLocationURI();
+ if (locationURI == null) {
+ return null;
+ }
+
+ FileChangeType changeType = null;
+ if (delta.getKind() == IResourceDelta.ADDED) {
+ changeType = FileChangeType.Created;
+ } else if (delta.getKind() == IResourceDelta.CHANGED) {
+ changeType = FileChangeType.Changed;
+ } else if (delta.getKind() == IResourceDelta.REMOVED) {
+ changeType = FileChangeType.Deleted;
+ } else {
+ throw new IllegalStateException("Unsupported resource delta kind: " + delta.getKind()); //$NON-NLS-1$
+ }
+
+ return new FileEvent(locationURI.toString(), changeType);
+ }
+} \ No newline at end of file
diff --git a/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/CPPStreamConnectionProvider.java b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/CPPStreamConnectionProvider.java
new file mode 100644
index 00000000000..5f787554322
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/CPPStreamConnectionProvider.java
@@ -0,0 +1,156 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Ericsson and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.cdt.lsp.core;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.io.IOUtils;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.lsp4e.server.ProcessStreamConnectionProvider;
+
+
+public class CPPStreamConnectionProvider extends ProcessStreamConnectionProvider {
+
+ public static final String ID = "org.eclipse.lsp4e.languages.cpp"; //$NON-NLS-1$
+
+ private IResourceChangeListener fResourceListener;
+
+ private static final IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+
+ private ICPPLanguageServer languageServer;
+
+ public static final String CLANGD_ID = "clangd"; //$NON-NLS-1$
+
+ public static final String CQUERY_ID = "cquery"; //$NON-NLS-1$
+
+ public CPPStreamConnectionProvider() throws UnsupportedOperationException {
+ List<String> commands = new ArrayList<>();
+ if (store.getString(PreferenceConstants.P_SERVER_CHOICE).equals(CQUERY_ID)) {
+ languageServer = new CqueryLanguageServer();
+ } else if (store.getString(PreferenceConstants.P_SERVER_CHOICE).equals(CLANGD_ID)) {
+ languageServer = new ClangdLanguageServer();
+ } else {
+ throw new UnsupportedOperationException("Unsupported Language Server"); //$NON-NLS-1$
+ }
+ File defaultLSLocation = getDefaultLSLocation(store.getString(PreferenceConstants.P_SERVER_CHOICE));
+ if(defaultLSLocation != null) {
+ store.setDefault(PreferenceConstants.P_SERVER_PATH, defaultLSLocation.getAbsolutePath());
+ }
+ File languageServerLocation = getLanguageServerLocation();
+ String parent = ""; //$NON-NLS-1$
+ String flags = store.getString(PreferenceConstants.P_SERVER_OPTIONS);
+ if (languageServerLocation != null) {
+ commands.add(languageServerLocation.getAbsolutePath());
+ if (!flags.isEmpty()) {
+ commands.add(flags);
+ }
+ parent = languageServerLocation.getParent();
+ }
+ setWorkingDirectory(parent);
+ setCommands(commands);
+ }
+
+ @Override
+ public void stop() {
+ super.stop();
+ if (fResourceListener != null) {
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(fResourceListener);
+ fResourceListener = null;
+ }
+ }
+
+ @Override
+ public Object getInitializationOptions(URI rootPath) {
+ installResourceChangeListener(rootPath);
+ Object defaultInitOptions = super.getInitializationOptions(rootPath);
+ return languageServer.getLSSpecificInitializationOptions(defaultInitOptions, rootPath);
+ }
+
+ private void installResourceChangeListener(URI rootPath) {
+ if (rootPath == null || fResourceListener != null) {
+ return;
+ }
+
+ IContainer[] containers = ResourcesPlugin.getWorkspace().getRoot().findContainersForLocationURI(rootPath);
+ if (containers.length == 0) {
+ return;
+ }
+
+ for (IContainer c : containers) {
+ if (!(c instanceof IProject)) {
+ continue;
+ }
+ IProject project = (IProject) c;
+ fResourceListener = new CPPResourceChangeListener(project);
+ project.getWorkspace().addResourceChangeListener(fResourceListener);
+
+ break;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "C/C++ Language Server: " + super.toString(); //$NON-NLS-1$
+ }
+
+ private static File getLanguageServerLocation() {
+ String path = store.getString(PreferenceConstants.P_SERVER_PATH);
+
+ if (path.isEmpty()) {
+ return null;
+ }
+ File f = new File(path);
+ if (f.canExecute()) {
+ return f;
+ }
+
+ return null;
+ }
+
+ static File getDefaultLSLocation(String selectedLanguageServer) {
+ String res = null;
+ String[] command = new String[] {"/bin/bash", "-c", "which " + selectedLanguageServer}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if (Platform.getOS().equals(Platform.OS_WIN32)) {
+ command = new String[] {"cmd", "/c", "where " + selectedLanguageServer}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ BufferedReader reader = null;
+ try {
+ Process p = Runtime.getRuntime().exec(command);
+ reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ res = reader.readLine();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ IOUtils.closeQuietly(reader);
+ }
+
+ if (res == null) {
+ return null;
+ }
+
+ File f = new File(res);
+ if (f.canExecute()) {
+ return f;
+ }
+
+ return null;
+ }
+}
+
diff --git a/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/ClangdLanguageServer.java b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/ClangdLanguageServer.java
new file mode 100644
index 00000000000..0ed9c9c3d30
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/ClangdLanguageServer.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Manish Khurana , Nathan Ridge and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.cdt.lsp.core;
+
+import java.net.URI;
+
+public class ClangdLanguageServer implements ICPPLanguageServer {
+
+ @Override
+ public Object getLSSpecificInitializationOptions(Object defaultInitOptions, URI rootPath) {
+ return defaultInitOptions;
+ }
+
+}
diff --git a/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/CqueryLanguageServer.java b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/CqueryLanguageServer.java
new file mode 100644
index 00000000000..f594d0c5cf7
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/CqueryLanguageServer.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Manish Khurana , Nathan Ridge and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.cdt.lsp.core;
+
+import java.net.URI;
+
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+
+import com.google.gson.JsonObject;
+
+public class CqueryLanguageServer implements ICPPLanguageServer {
+
+ @Override
+ public Object getLSSpecificInitializationOptions(Object defaultInitOptions, URI rootPath) {
+
+ // TODO: Allow user to specify cache directory path
+
+ IPath cacheDirectory = Path.fromOSString(rootPath.getPath()).append(".lsp4e-cpp/cquery_index"); //$NON-NLS-1$
+ JsonObject result = (defaultInitOptions instanceof JsonObject) ? (JsonObject) defaultInitOptions : new JsonObject();
+ result.addProperty("cacheDirectory", cacheDirectory.toString()); //$NON-NLS-1$
+ result.addProperty("emitInactiveRegions", CUIPlugin.getDefault().getPreferenceStore().getBoolean(CEditor.INACTIVE_CODE_ENABLE)); //$NON-NLS-1$
+ JsonObject semanticHighlights = new JsonObject();
+ semanticHighlights.addProperty("enabled", CUIPlugin.getDefault().getPreferenceStore().getBoolean(org.eclipse.cdt.ui.PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED)); //$NON-NLS-1$
+ result.add("highlight", semanticHighlights); //$NON-NLS-1$
+ return result;
+ }
+
+}
diff --git a/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/ICPPLanguageServer.java b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/ICPPLanguageServer.java
new file mode 100644
index 00000000000..82f3240d62a
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/ICPPLanguageServer.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Manish Khurana , Nathan Ridge and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.cdt.lsp.core;
+
+import java.net.URI;
+/*
+ * Encapsulates functionality specific to a particular C++ language server (e.g., CQuery)
+ */
+public interface ICPPLanguageServer {
+
+ public Object getLSSpecificInitializationOptions(Object defaultInitOptions, URI rootPath) ;
+
+}
diff --git a/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/LineBackgroundListenerCPP.java b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/LineBackgroundListenerCPP.java
new file mode 100644
index 00000000000..c474c57fb63
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/LineBackgroundListenerCPP.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Manish Khurana , Nathan Ridge and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.cdt.lsp.core;
+
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.BadPositionCategoryException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.Position;
+import org.eclipse.swt.custom.LineBackgroundEvent;
+import org.eclipse.swt.custom.LineBackgroundListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Display;
+
+public class LineBackgroundListenerCPP implements LineBackgroundListener {
+ private IDocument currentDocument;
+ private Color lineBackgroundColor;
+
+ public void setCurrentDocument(IDocument currentDocument) {
+ this.currentDocument = currentDocument;
+ }
+
+ @Override
+ public void lineGetBackground(LineBackgroundEvent event) {
+ lineBackgroundColor = new Color(Display.getCurrent(),PreferenceConverter.getColor(CUIPlugin.getDefault().getPreferenceStore(), CEditor.INACTIVE_CODE_COLOR));
+ if (currentDocument == null) {
+ return;
+ }
+
+ Position[] inactivePositions = null;
+ try {
+ inactivePositions = currentDocument.getPositions(PresentationReconcilerCPP.INACTIVE_CODE_HIGHLIGHTING_POSITION_CATEGORY);
+ } catch (BadPositionCategoryException e) {
+ Activator.log(e);
+ }
+
+ if (inactivePositions == null) {
+ return;
+ }
+
+ try {
+ for (Position eachInactivePosition : inactivePositions) {
+ int regionStartLine = currentDocument.getLineOfOffset(eachInactivePosition.getOffset());
+ int regionEndLine = currentDocument.getLineOfOffset(eachInactivePosition.getOffset() + eachInactivePosition.getLength());
+ if (event.lineOffset >= currentDocument.getLineOffset(regionStartLine)
+ && event.lineOffset <= currentDocument.getLineOffset(regionEndLine)) {
+ event.lineBackground = lineBackgroundColor;
+ break;
+ }
+ }
+ } catch (BadLocationException e) {
+ Activator.log(e);
+ }
+ }
+}
diff --git a/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/Messages.java b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/Messages.java
new file mode 100644
index 00000000000..73f13be6931
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/Messages.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Manish Khurana , Nathan Ridge and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.cdt.lsp.core;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ public static String PreferencePageDescription;
+ public static String ServerChoiceLabel;
+ public static String ServerPathLabel;
+ public static String ServerOptionsLabel;
+ public static String CqueryStateIdle;
+ public static String CqueryStateBusy;
+
+ static {
+ NLS.initializeMessages(Messages.class.getName(), Messages.class);
+ }
+}
diff --git a/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/Messages.properties b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/Messages.properties
new file mode 100644
index 00000000000..fe78024a026
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/Messages.properties
@@ -0,0 +1,14 @@
+################################################################################
+# Copyright (c) 2018 Manish Khurana , Nathan Ridge and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#################################################################################
+
+PreferencePageDescription=Preferences for the C/C++ Language Server\n\n
+ServerChoiceLabel=Please select the C/C++ Language Server you want to use in Eclipse :
+ServerPathLabel=Browse path to the server executable
+ServerOptionsLabel=Enter any command-line options for the server
+CqueryStateIdle=CQuery : Idle
+CqueryStateBusy=CQuery : Busy | {0} Jobs \ No newline at end of file
diff --git a/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/PreferenceConstants.java b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/PreferenceConstants.java
new file mode 100644
index 00000000000..0cd3a8a1a5a
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/PreferenceConstants.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Manish Khurana , Nathan Ridge and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.cdt.lsp.core;
+
+/**
+ * Constant definitions for LSP4E-CPP plug-in preferences.
+ */
+public class PreferenceConstants {
+
+ public static final String P_SERVER_PATH = "org.eclipse.cdt.lsp.serverPathPreference"; //$NON-NLS-1$
+
+ public static final String P_SERVER_CHOICE = "org.eclipse.cdt.lsp.serverChoicePreference"; //$NON-NLS-1$
+
+ public static final String P_SERVER_OPTIONS = "org.eclipse.cdt.lsp.serverOptionsPreference"; //$NON-NLS-1$
+
+}
diff --git a/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/PreferenceInitializer.java b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/PreferenceInitializer.java
new file mode 100644
index 00000000000..cb4867de4dc
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/PreferenceInitializer.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Manish Khurana , Nathan Ridge and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.cdt.lsp.core;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.jface.preference.IPreferenceStore;
+
+/**
+ * Class used to initialize default preference values for C/C++ Preference Page.
+ */
+public class PreferenceInitializer extends AbstractPreferenceInitializer {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#
+ * initializeDefaultPreferences()
+ */
+ @Override
+ public void initializeDefaultPreferences() {
+ IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+ store.setDefault(PreferenceConstants.P_SERVER_CHOICE, "clangd"); //$NON-NLS-1$
+ store.setDefault(PreferenceConstants.P_SERVER_OPTIONS, ""); //$NON-NLS-1$
+ }
+
+}
diff --git a/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/PresentationReconcilerCPP.java b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/PresentationReconcilerCPP.java
new file mode 100644
index 00000000000..d1b21daeefa
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/PresentationReconcilerCPP.java
@@ -0,0 +1,374 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2017 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * QNX Software System
+ * Anton Leherbauer (Wind River Systems)
+ * Sergey Prigogin (Google)
+ * Marc-Andre Laperle (Ericsson) - Mostly copied from CSourceViewerConfiguration
+ * Nathan Ridge
+ * Manish Khurana
+ *******************************************************************************/
+
+package org.eclipse.cdt.lsp.core;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
+import org.eclipse.cdt.core.model.ICLanguageKeywords;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.internal.ui.editor.CEditor.BracketInserter;
+import org.eclipse.cdt.internal.ui.editor.SemanticHighlightingManager.HighlightedPosition;
+import org.eclipse.cdt.internal.ui.text.CCodeScanner;
+import org.eclipse.cdt.internal.ui.text.CCommentScanner;
+import org.eclipse.cdt.internal.ui.text.CPreprocessorScanner;
+import org.eclipse.cdt.internal.ui.text.CPresentationReconciler;
+import org.eclipse.cdt.internal.ui.text.PartitionDamager;
+import org.eclipse.cdt.internal.ui.text.SingleTokenCScanner;
+import org.eclipse.cdt.internal.ui.text.TokenStore;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.ILanguageUI;
+import org.eclipse.cdt.ui.text.AbstractCScanner;
+import org.eclipse.cdt.ui.text.ICColorConstants;
+import org.eclipse.cdt.ui.text.ICPartitions;
+import org.eclipse.cdt.ui.text.ICTokenScanner;
+import org.eclipse.cdt.ui.text.ITokenStore;
+import org.eclipse.cdt.ui.text.ITokenStoreFactory;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.text.BadPositionCategoryException;
+import org.eclipse.jface.text.DefaultPositionUpdater;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextInputListener;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.TextPresentation;
+import org.eclipse.jface.text.TextViewer;
+import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
+import org.eclipse.jface.text.rules.RuleBasedScanner;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.swt.custom.StyleRange;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.editors.text.TextEditor;
+
+/**
+ * Hack-ish reconciler to get some colors in the generic editor using the C/C++
+ * Server.
+ */
+public class PresentationReconcilerCPP extends CPresentationReconciler {
+
+ private CCommentScanner fSinglelineCommentScanner;
+ private CCommentScanner fMultilineCommentScanner;
+ private SingleTokenCScanner fStringScanner;
+ private AbstractCScanner fCodeScanner;
+ private LineBackgroundListenerCPP fLineBackgroundListener = new LineBackgroundListenerCPP();
+ private ITextViewer textViewer;
+ private TextInputListenerCPP textInputListener;
+ private BracketInserter fBracketInserter;
+ private DefaultPositionUpdater semanticHighlightingPositionUpdater;
+
+ public static final String SEMANTIC_HIGHLIGHTING_POSITION_CATEGORY = "org.eclipse.lsp4e.cpp.semanticHighlight"; //$NON-NLS-1$
+ public static final String INACTIVE_CODE_HIGHLIGHTING_POSITION_CATEGORY = "org.eclipse.lsp4e.cpp.inactiveCodeHighlight"; //$NON-NLS-1$
+
+ // A set containing all active objects of PresentationReconcilerCPP.
+ public static Set<PresentationReconcilerCPP> presentationReconcilers = ConcurrentHashMap.newKeySet();
+
+ protected ITokenStoreFactory getTokenStoreFactory() {
+ return new ITokenStoreFactory() {
+ @Override
+ public ITokenStore createTokenStore(String[] propertyColorNames) {
+ return new TokenStore(CUIPlugin.getDefault().getTextTools().getColorManager(), CUIPlugin.getDefault().getCombinedPreferenceStore(), propertyColorNames);
+ }
+ };
+ }
+
+ protected ILanguage getLanguage() {
+ // fallback
+ return GPPLanguage.getDefault();
+ }
+
+ protected RuleBasedScanner getCodeScanner(ILanguage language) {
+ if (fCodeScanner != null) {
+ return fCodeScanner;
+ }
+ RuleBasedScanner scanner= null;
+
+ if (language != null) {
+ ICLanguageKeywords keywords = language.getAdapter(ICLanguageKeywords.class);
+ if (keywords != null) {
+ scanner = new CCodeScanner(getTokenStoreFactory(), keywords);
+ } else {
+ ILanguageUI languageUI = language.getAdapter(ILanguageUI.class);
+ if (languageUI != null) {
+ scanner = languageUI.getCodeScanner();
+ }
+ }
+ }
+
+ if (scanner == null) {
+ scanner = new CCodeScanner(getTokenStoreFactory(), GPPLanguage.getDefault());
+ }
+ if (scanner instanceof AbstractCScanner) {
+ fCodeScanner= (AbstractCScanner)scanner;
+ }
+ return scanner;
+ }
+
+ public PresentationReconcilerCPP() {
+ fStringScanner= new SingleTokenCScanner(getTokenStoreFactory(), ICColorConstants.C_STRING);
+ fMultilineCommentScanner= new CCommentScanner(getTokenStoreFactory(), ICColorConstants.C_MULTI_LINE_COMMENT);
+ fSinglelineCommentScanner= new CCommentScanner(getTokenStoreFactory(), ICColorConstants.C_SINGLE_LINE_COMMENT);
+
+ setDocumentPartitioning(CUIPlugin.getDefault().getTextTools().getDocumentPartitioning());
+
+ ILanguage language= getLanguage();
+ RuleBasedScanner scanner = getCodeScanner(language);
+
+ DefaultDamagerRepairer dr= new DefaultDamagerRepairer(scanner);
+
+ setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
+ setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
+
+ dr= new DefaultDamagerRepairer(fSinglelineCommentScanner);
+ setDamager(dr, ICPartitions.C_SINGLE_LINE_COMMENT);
+ setRepairer(dr, ICPartitions.C_SINGLE_LINE_COMMENT);
+
+ dr= new DefaultDamagerRepairer(fMultilineCommentScanner);
+ setDamager(dr, ICPartitions.C_MULTI_LINE_COMMENT);
+ setRepairer(dr, ICPartitions.C_MULTI_LINE_COMMENT);
+
+ ICTokenScanner docCommentSingleScanner= getSinglelineDocCommentScanner(null);
+ if (docCommentSingleScanner!=null) {
+ dr= new DefaultDamagerRepairer(docCommentSingleScanner);
+ setDamager(dr, ICPartitions.C_SINGLE_LINE_DOC_COMMENT);
+ setRepairer(dr, ICPartitions.C_SINGLE_LINE_DOC_COMMENT);
+ }
+
+ ICTokenScanner docCommentMultiScanner= getMultilineDocCommentScanner(null);
+ if (docCommentMultiScanner!=null) {
+ dr= new DefaultDamagerRepairer(docCommentMultiScanner);
+ setDamager(dr, ICPartitions.C_MULTI_LINE_DOC_COMMENT);
+ setRepairer(dr, ICPartitions.C_MULTI_LINE_DOC_COMMENT);
+ }
+
+ dr= new DefaultDamagerRepairer(fStringScanner);
+ setDamager(dr, ICPartitions.C_STRING);
+ setRepairer(dr, ICPartitions.C_STRING);
+
+ dr= new DefaultDamagerRepairer(fStringScanner);
+ setDamager(dr, ICPartitions.C_CHARACTER);
+ setRepairer(dr, ICPartitions.C_CHARACTER);
+
+ dr= new DefaultDamagerRepairer(getPreprocessorScanner(language));
+ setDamager(new PartitionDamager(), ICPartitions.C_PREPROCESSOR);
+ setRepairer(dr, ICPartitions.C_PREPROCESSOR);
+ }
+
+ @Override
+ protected TextPresentation createPresentation(IRegion damage, IDocument document) {
+ TextPresentation presentation = super.createPresentation(damage, document);
+
+ IDocument doc = textViewer.getDocument();
+ URI uri = Server2ClientProtocolExtension.getUri(doc);
+
+ if (uri == null) {
+ return presentation;
+ }
+
+ Position[] returnedPositions = null;
+ List<StyleRange> styleRanges = new ArrayList<>();
+ HighlightedPosition[] highlightedPositions;
+
+ /*
+ * Adding Semantic Highlighting Position Category to so that we don't get a
+ * BadPositionCategoryException if this method is called before setupDocument()
+ * could the add new position category.
+ */
+ addSemanticHighlightPositionCategory(doc);
+
+ try {
+ returnedPositions = doc.getPositions(SEMANTIC_HIGHLIGHTING_POSITION_CATEGORY);
+ } catch (BadPositionCategoryException e) {
+ Activator.log(e);
+ }
+
+ if (returnedPositions == null) {
+ return presentation;
+ }
+
+ highlightedPositions = Arrays.copyOf(returnedPositions, returnedPositions.length, HighlightedPosition[].class);
+ int damageStartOffset = damage.getOffset();
+ int damageEndOffset = damageStartOffset + damage.getLength();
+
+ for (HighlightedPosition eachPosition : highlightedPositions) {
+ // Find each position that resides in or overlaps the damage region and create StyleRange for it.
+ if ((eachPosition.getOffset() + eachPosition.getLength()) >= damageStartOffset
+ && eachPosition.getOffset() < damageEndOffset) {
+ StyleRange range = eachPosition.createStyleRange();
+ styleRanges.add(range);
+ }
+ }
+
+ StyleRange[] styleRangesArray = new StyleRange[styleRanges.size()];
+ styleRangesArray = styleRanges.toArray(styleRangesArray);
+ presentation.replaceStyleRanges(styleRangesArray);
+ return presentation;
+ }
+
+ /**
+ * Returns the C multi-line doc comment scanner for this configuration.
+ *
+ * @return the C multi-line doc comment scanner
+ */
+ protected ICTokenScanner getMultilineDocCommentScanner(IResource resource) {
+ if (fMultilineDocCommentScanner == null) {
+ if (resource == null) {
+ resource= ResourcesPlugin.getWorkspace().getRoot();
+ }
+ // IDocCommentViewerConfiguration owner= DocCommentOwnerManager.getInstance().getCommentOwner(resource).getMultilineConfiguration();
+ // fMultilineDocCommentScanner= owner.createCommentScanner(getTokenStoreFactory());
+ if (fMultilineDocCommentScanner == null) {
+ // fallback: normal comment highlighting
+ fMultilineDocCommentScanner= fMultilineCommentScanner;
+ }
+ }
+ return fMultilineDocCommentScanner;
+ }
+
+ protected ICTokenScanner fMultilineDocCommentScanner;
+ /**
+ * The C single-line doc comment scanner.
+ */
+ protected ICTokenScanner fSinglelineDocCommentScanner;
+
+ protected ICTokenScanner getSinglelineDocCommentScanner(IResource resource) {
+ if (fSinglelineDocCommentScanner == null) {
+ if (resource == null) {
+ resource= ResourcesPlugin.getWorkspace().getRoot();
+ }
+ // IDocCommentViewerConfiguration owner= DocCommentOwnerManager.getInstance().getCommentOwner(resource).getSinglelineConfiguration();
+ // fSinglelineDocCommentScanner= owner.createCommentScanner(getTokenStoreFactory());
+ if (fSinglelineDocCommentScanner == null) {
+ // fallback: normal comment highlighting
+ fSinglelineDocCommentScanner= fSinglelineCommentScanner;
+ }
+ }
+ return fSinglelineDocCommentScanner;
+ }
+
+ protected AbstractCScanner fPreprocessorScanner;
+
+ protected RuleBasedScanner getPreprocessorScanner(ILanguage language) {
+ if (fPreprocessorScanner != null) {
+ return fPreprocessorScanner;
+ }
+ AbstractCScanner scanner= null;
+ ICLanguageKeywords keywords = language == null ? null : (ICLanguageKeywords) language.getAdapter(ICLanguageKeywords.class);
+ if (keywords != null) {
+ scanner = new CPreprocessorScanner(getTokenStoreFactory(), keywords);
+ }
+ if (scanner == null) {
+ keywords = GPPLanguage.getDefault().getAdapter(ICLanguageKeywords.class);
+ scanner= new CPreprocessorScanner(getTokenStoreFactory(), keywords);
+ }
+ fPreprocessorScanner= scanner;
+ return fPreprocessorScanner;
+ }
+
+ public class TextInputListenerCPP implements ITextInputListener {
+
+ @Override
+ public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
+ setupDocument(newInput);
+ }
+
+ @Override
+ public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
+ }
+ }
+
+ private void addSemanticHighlightPositionCategory(IDocument document) {
+ if (!document.containsPositionCategory(SEMANTIC_HIGHLIGHTING_POSITION_CATEGORY)) {
+ document.addPositionCategory(SEMANTIC_HIGHLIGHTING_POSITION_CATEGORY);
+ semanticHighlightingPositionUpdater = new DefaultPositionUpdater(SEMANTIC_HIGHLIGHTING_POSITION_CATEGORY);
+ document.addPositionUpdater(semanticHighlightingPositionUpdater);
+ }
+ }
+
+ private void addInactiveCodeHighlightingCategory(IDocument document) {
+ if (!document.containsPositionCategory(INACTIVE_CODE_HIGHLIGHTING_POSITION_CATEGORY)) {
+ document.addPositionCategory(INACTIVE_CODE_HIGHLIGHTING_POSITION_CATEGORY);
+ DefaultPositionUpdater inactiveCodeHighlightingPositionUpdater = new DefaultPositionUpdater(INACTIVE_CODE_HIGHLIGHTING_POSITION_CATEGORY);
+ document.addPositionUpdater(inactiveCodeHighlightingPositionUpdater);
+ }
+ }
+
+ public void setupDocument(IDocument newDocument) {
+ if (newDocument != null) {
+ fLineBackgroundListener.setCurrentDocument(newDocument);
+
+ // Adding Semantic Highlighting Position Category and a DefaultPositionUpdater to the document.
+ addSemanticHighlightPositionCategory(newDocument);
+
+ // Adding Inactive Code Highlighting Position Category and a DefaultPositionUpdater to the document.
+ addInactiveCodeHighlightingCategory(newDocument);
+ }
+ }
+
+ public ITextViewer getTextViewer() {
+ return textViewer;
+ }
+
+ public DefaultPositionUpdater getSemanticHighlightingPositionUpdater() {
+ return semanticHighlightingPositionUpdater;
+ }
+
+ @Override
+ public void install(ITextViewer viewer) {
+ super.install(viewer);
+ this.textViewer = viewer;
+ textInputListener = new TextInputListenerCPP();
+ viewer.addTextInputListener(textInputListener);
+ IDocument document= viewer.getDocument();
+ if (document != null) {
+ textInputListener.inputDocumentChanged(null, document);
+ }
+ StyledText textWidget = textViewer.getTextWidget();
+ textWidget.addLineBackgroundListener(fLineBackgroundListener);
+ presentationReconcilers.add(this);
+
+ // Using asyncExec() to make sure that by the time Runnable runs,
+ // the Editor is active and we don't get a NPE.
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ // To provide bracket auto-completion support of CEditor in Generic Editor of LSP4E-CPP.
+ TextEditor editor = (TextEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ fBracketInserter = new BracketInserter(editor, true);
+ fBracketInserter.setSourceViewer((SourceViewer) textViewer);
+ ((TextViewer) textViewer).prependVerifyKeyListener(fBracketInserter);
+ }});
+ }
+
+ @Override
+ public void uninstall() {
+ super.uninstall();
+ textViewer.getTextWidget().removeLineBackgroundListener(fLineBackgroundListener);
+ textViewer.removeTextInputListener(textInputListener);
+ ((TextViewer) textViewer).removeVerifyKeyListener(fBracketInserter);
+ presentationReconcilers.remove(this);
+ }
+}
diff --git a/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/Server2ClientProtocolExtension.java b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/Server2ClientProtocolExtension.java
new file mode 100644
index 00000000000..8dd2e30e0f2
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/Server2ClientProtocolExtension.java
@@ -0,0 +1,244 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Manish Khurana , Nathan Ridge and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.cdt.lsp.core;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.internal.ui.editor.SemanticHighlightingManager.HighlightedPosition;
+import org.eclipse.cdt.internal.ui.editor.SemanticHighlightingManager.HighlightingStyle;
+import org.eclipse.cdt.lsp.core.cquery.CqueryInactiveRegions;
+import org.eclipse.cdt.lsp.core.cquery.CquerySemanticHighlights;
+import org.eclipse.cdt.lsp.core.cquery.HighlightSymbol;
+import org.eclipse.cdt.lsp.core.cquery.IndexingProgressStats;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.action.StatusLineContributionItem;
+import org.eclipse.jface.action.StatusLineManager;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.BadPositionCategoryException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.jface.text.TextPresentation;
+import org.eclipse.lsp4e.LSPEclipseUtils;
+import org.eclipse.lsp4e.LanguageClientImpl;
+import org.eclipse.lsp4j.Range;
+import org.eclipse.lsp4j.jsonrpc.services.JsonNotification;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.internal.WorkbenchWindow;
+
+@SuppressWarnings("restriction")
+public class Server2ClientProtocolExtension extends LanguageClientImpl {
+
+ @JsonNotification("$cquery/progress")
+ public final void indexingProgress(IndexingProgressStats stats) {
+
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ final String cqueryStatusFieldId = "org.eclipse.lsp4e.cpp.status"; //$NON-NLS-1$
+ final int width = 28;
+ IWorkbenchWindow[] workbenchWindows = PlatformUI.getWorkbench().getWorkbenchWindows();
+ for (IWorkbenchWindow window : workbenchWindows) {
+ StatusLineManager statusLine = ((WorkbenchWindow) window).getStatusLineManager();
+ StatusLineContributionItem cqueryStatusField = (StatusLineContributionItem) statusLine.find(cqueryStatusFieldId);
+ if (cqueryStatusField == null) {
+ cqueryStatusField = new StatusLineContributionItem(cqueryStatusFieldId, width);
+ statusLine.add(cqueryStatusField);
+ }
+ String msg = stats.getTotalJobs() > 0 ? NLS.bind(Messages.CqueryStateBusy, stats.getTotalJobs())
+ : Messages.CqueryStateIdle;
+ cqueryStatusField.setText(msg);
+ }
+ }
+ });
+ }
+
+ @JsonNotification("$cquery/setInactiveRegions")
+ public final void setInactiveRegions(CqueryInactiveRegions regions) {
+ URI uriReceived = regions.getUri();
+ List<Range> inactiveRegions = regions.getInactiveRegions();
+ IDocument doc = null;
+
+ // To get the document for the received URI.
+ for (PresentationReconcilerCPP eachReconciler: PresentationReconcilerCPP.presentationReconcilers) {
+ IDocument currentReconcilerDoc = eachReconciler.getTextViewer().getDocument();
+ URI currentReconcilerUri = getUri(currentReconcilerDoc);
+
+ if (currentReconcilerUri == null) {
+ continue;
+ }
+
+ if (uriReceived.equals(currentReconcilerUri)) {
+ doc = currentReconcilerDoc;
+ break;
+ }
+ }
+
+ if (doc == null) {
+ return;
+ }
+
+ // Removing inactive code highlighting position category and old positions from document.
+ try {
+ doc.removePositionCategory(PresentationReconcilerCPP.INACTIVE_CODE_HIGHLIGHTING_POSITION_CATEGORY);
+ } catch (BadPositionCategoryException e) {
+ Activator.log(e);
+ }
+ // Again add Inactive Code Position Category to the document.
+ doc.addPositionCategory(PresentationReconcilerCPP.INACTIVE_CODE_HIGHLIGHTING_POSITION_CATEGORY);
+
+ for (Range region : inactiveRegions) {
+ int offset = 0, length = 0;
+ try {
+ offset = doc.getLineOffset(region.getStart().getLine());
+ length = doc.getLineOffset(region.getEnd().getLine()) - offset;
+ } catch (BadLocationException e) {
+ Activator.log(e);
+ }
+
+ Position inactivePosition = new Position(offset, length);
+ try {
+ doc.addPosition(PresentationReconcilerCPP.INACTIVE_CODE_HIGHLIGHTING_POSITION_CATEGORY, inactivePosition);
+ } catch (BadLocationException | BadPositionCategoryException e) {
+ Activator.log(e);
+ }
+ }
+ }
+
+ @JsonNotification("$cquery/publishSemanticHighlighting")
+ public final void semanticHighlights(CquerySemanticHighlights highlights) {
+ URI uriReceived = highlights.getUri();
+
+ // List of PresentationReconcilerCPP objects attached with same C++ source file.
+ List<PresentationReconcilerCPP> matchingReconcilers = new ArrayList<>();
+
+ for (PresentationReconcilerCPP eachReconciler: PresentationReconcilerCPP.presentationReconcilers) {
+ IDocument currentReconcilerDoc = eachReconciler.getTextViewer().getDocument();
+ URI currentReconcilerUri = getUri(currentReconcilerDoc);
+
+ if (currentReconcilerUri == null) {
+ continue;
+ }
+
+ if (uriReceived.equals(currentReconcilerUri)) {
+ matchingReconcilers.add(eachReconciler);
+ }
+ }
+
+ if (matchingReconcilers.size() == 0) {
+ return;
+ }
+
+ // Using only first object of matchingReconcilers because all reconciler objects share same document object.
+ IDocument doc = matchingReconcilers.get(0).getTextViewer().getDocument();
+ IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
+
+ // Removing semantic highlighting position category and old positions from document.
+ try {
+ doc.removePositionCategory(PresentationReconcilerCPP.SEMANTIC_HIGHLIGHTING_POSITION_CATEGORY);
+ } catch (BadPositionCategoryException e) {
+ Activator.log(e);
+ }
+ // Again add Semantic Highlighting Position Category to the document.
+ doc.addPositionCategory(PresentationReconcilerCPP.SEMANTIC_HIGHLIGHTING_POSITION_CATEGORY);
+
+ for (HighlightSymbol highlight : highlights.getSymbols()) {
+
+ String highlightingName = HighlightSymbol.getHighlightingName(highlight.getKind(), highlight.getParentKind(), highlight.getStorage());
+ String colorKey = PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX
+ + highlightingName + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_COLOR_SUFFIX;
+
+ boolean isEnabled = store.getBoolean(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX
+ + highlightingName + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED_SUFFIX);
+ boolean isBold = store.getBoolean(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX
+ + highlightingName + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_BOLD_SUFFIX);
+ boolean isItalic = store.getBoolean(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX
+ + highlightingName + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ITALIC_SUFFIX);
+ boolean isUnderline = store.getBoolean(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX
+ + highlightingName + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_UNDERLINE_SUFFIX);
+ boolean isStrikethrough = store.getBoolean(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX
+ + highlightingName + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_STRIKETHROUGH_SUFFIX);
+
+ // TODO: Use IColorManager to cache Color objects so that only one object per color is created.
+ Color color = new Color(Display.getCurrent(),
+ PreferenceConverter.getColor(CUIPlugin.getDefault().getPreferenceStore(), colorKey));
+
+ List<Range> ranges = highlight.getRanges();
+ for (Range range : ranges) {
+
+ int offset = 0, length = 0;
+ try {
+ offset = doc.getLineOffset(range.getStart().getLine()) + range.getStart().getCharacter();
+ length = doc.getLineOffset(range.getEnd().getLine()) + range.getEnd().getCharacter() - offset;
+ } catch (BadLocationException e) {
+ Activator.log(e);
+ }
+
+ int textStyle = SWT.NORMAL;
+
+ if (isBold) {
+ textStyle = SWT.BOLD;
+ }
+ if (isItalic) {
+ textStyle |= SWT.ITALIC;
+ }
+ if (isUnderline) {
+ textStyle |= TextAttribute.UNDERLINE;
+ }
+ if (isStrikethrough) {
+ textStyle |= TextAttribute.STRIKETHROUGH;
+ }
+
+ TextAttribute textAttribute = new TextAttribute(color, null, textStyle);
+ HighlightingStyle highlightingStyle = new HighlightingStyle(textAttribute, isEnabled);
+ HighlightedPosition highlightedPosition = new HighlightedPosition(offset, length, highlightingStyle, matchingReconcilers.get(0).getSemanticHighlightingPositionUpdater());
+ try {
+ doc.addPosition(PresentationReconcilerCPP.SEMANTIC_HIGHLIGHTING_POSITION_CATEGORY, highlightedPosition);
+ } catch (BadLocationException | BadPositionCategoryException e) {
+ Activator.log(e);
+ }
+ }
+ }
+
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ for (PresentationReconcilerCPP eachReconciler : matchingReconcilers) {
+ TextPresentation presentation = eachReconciler.createPresentation(new Region(0, doc.getLength()), doc);
+ eachReconciler.getTextViewer().changeTextPresentation(presentation, false);
+ }
+ }
+ });
+ }
+
+ /*
+ * Returns the URI of the Document provided.
+ * Can return null value.
+ */
+ public static URI getUri(IDocument document) {
+ URI uri = null;
+ IFile file = LSPEclipseUtils.getFile(document);
+ if (file != null) {
+ uri = LSPEclipseUtils.toUri(file);
+ }
+ return uri;
+ }
+}
diff --git a/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/cquery/CqueryInactiveRegions.java b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/cquery/CqueryInactiveRegions.java
new file mode 100644
index 00000000000..5479350b83d
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/cquery/CqueryInactiveRegions.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Manish Khurana , Nathan Ridge and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.cdt.lsp.core.cquery;
+
+import java.net.URI;
+import java.util.List;
+
+import org.eclipse.lsp4j.Range;
+
+public class CqueryInactiveRegions {
+ private URI uri;
+ private List<Range> inactiveRegions;
+
+ public CqueryInactiveRegions(URI uri, List<Range> inactiveRegions) {
+ this.uri = uri;
+ this.inactiveRegions = inactiveRegions;
+ }
+
+ public URI getUri() {
+ return uri;
+ }
+ public List<Range> getInactiveRegions() {
+ return inactiveRegions;
+ }
+}
diff --git a/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/cquery/CquerySemanticHighlights.java b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/cquery/CquerySemanticHighlights.java
new file mode 100644
index 00000000000..7ae932885db
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/cquery/CquerySemanticHighlights.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Manish Khurana , Nathan Ridge and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.cdt.lsp.core.cquery;
+
+import java.net.URI;
+import java.util.List;
+
+public class CquerySemanticHighlights {
+ private URI uri;
+ private List<HighlightSymbol> symbols;
+
+ public URI getUri() {
+ return uri;
+ }
+
+ public List<HighlightSymbol> getSymbols() {
+ return symbols;
+ }
+
+ public CquerySemanticHighlights(URI uri, List<HighlightSymbol> symbols) {
+ this.uri = uri;
+ this.symbols = symbols;
+ }
+}
diff --git a/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/cquery/CquerySymbolKind.java b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/cquery/CquerySymbolKind.java
new file mode 100644
index 00000000000..b48ddf2a71d
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/cquery/CquerySymbolKind.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Manish Khurana , Nathan Ridge and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.cdt.lsp.core.cquery;
+
+enum CquerySymbolKind {
+ Unknown(0), TypeAlias(252), Parameter(253), StaticMethod(254), Macro(255);
+
+ private int value;
+
+ public int getValue() {
+ return value;
+ }
+
+ private CquerySymbolKind(int value) {
+ this.value = value;
+ }
+
+ public static CquerySymbolKind forValue(int value) {
+ switch (value) {
+ case 0:
+ return CquerySymbolKind.Unknown;
+ case 252:
+ return CquerySymbolKind.TypeAlias;
+ case 253:
+ return CquerySymbolKind.Parameter;
+ case 254:
+ return CquerySymbolKind.StaticMethod;
+ case 255:
+ return CquerySymbolKind.Macro;
+ default:
+ throw new IllegalArgumentException("Illegal value for cquery symbol kind"); //$NON-NLS-1$
+ }
+ }
+} \ No newline at end of file
diff --git a/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/cquery/ExtendedSymbolKindType.java b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/cquery/ExtendedSymbolKindType.java
new file mode 100644
index 00000000000..3107a7c3e18
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/cquery/ExtendedSymbolKindType.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Manish Khurana , Nathan Ridge and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.cdt.lsp.core.cquery;
+
+import java.lang.reflect.Type;
+
+import org.eclipse.lsp4j.SymbolKind;
+
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonPrimitive;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+import com.google.gson.annotations.JsonAdapter;
+
+@JsonAdapter(ExtendedSymbolKindParsers.class)
+public class ExtendedSymbolKindType {
+ int value;
+ transient boolean isProtocolSymbol;
+
+ public ExtendedSymbolKindType(int _v) {
+ try {
+ SymbolKind.forValue(_v);
+ value = _v;
+ isProtocolSymbol = true;
+ } catch (IllegalArgumentException e) {
+ try {
+ CquerySymbolKind.forValue(_v);
+ value = _v;
+ isProtocolSymbol = false;
+ } catch (IllegalArgumentException y) {
+ throw new IllegalArgumentException("Illegal value for SymbolKind"); //$NON-NLS-1$
+ }
+ }
+ }
+
+ public int getValue() {
+ return value;
+ }
+}
+
+class ExtendedSymbolKindParsers
+ implements JsonDeserializer<ExtendedSymbolKindType>, JsonSerializer<ExtendedSymbolKindType> {
+ @Override
+ public ExtendedSymbolKindType deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
+ throws JsonParseException {
+
+ int symbolKindValue = json.getAsInt();
+ return new ExtendedSymbolKindType(symbolKindValue);
+ }
+
+ @Override
+ public JsonElement serialize(ExtendedSymbolKindType src, Type typeOfSrc, JsonSerializationContext context) {
+ return new JsonPrimitive(src.getValue());
+ }
+}
+
diff --git a/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/cquery/HighlightSymbol.java b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/cquery/HighlightSymbol.java
new file mode 100644
index 00000000000..8db4131db0e
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/cquery/HighlightSymbol.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Manish Khurana , Nathan Ridge and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.cdt.lsp.core.cquery;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.internal.ui.editor.SemanticHighlightings;
+import org.eclipse.lsp4j.Range;
+import org.eclipse.lsp4j.SymbolKind;
+
+public class HighlightSymbol {
+ private int stableId;
+ private ExtendedSymbolKindType parentKind;
+ private ExtendedSymbolKindType kind;
+ private StorageClass storage;
+ private List<Range> ranges;
+ public static Map<Integer, String> semanticHighlightSymbolsMap = new HashMap<>();
+
+ static {
+ semanticHighlightSymbolsMap.put(SymbolKind.Namespace.getValue(), SemanticHighlightings.NAMESPACE);
+ semanticHighlightSymbolsMap.put(SymbolKind.Class.getValue(), SemanticHighlightings.CLASS);
+ semanticHighlightSymbolsMap.put(SymbolKind.Method.getValue(), SemanticHighlightings.METHOD);
+ semanticHighlightSymbolsMap.put(SymbolKind.Constructor.getValue(), SemanticHighlightings.METHOD);
+ semanticHighlightSymbolsMap.put(SymbolKind.Enum.getValue(), SemanticHighlightings.ENUM);
+ semanticHighlightSymbolsMap.put(SymbolKind.Function.getValue(), SemanticHighlightings.FUNCTION);
+ semanticHighlightSymbolsMap.put(SymbolKind.EnumMember.getValue(), SemanticHighlightings.ENUMERATOR);
+ semanticHighlightSymbolsMap.put(SymbolKind.Struct.getValue(), SemanticHighlightings.CLASS);
+ semanticHighlightSymbolsMap.put(SymbolKind.TypeParameter.getValue(), SemanticHighlightings.TEMPLATE_PARAMETER);
+ semanticHighlightSymbolsMap.put(CquerySymbolKind.TypeAlias.getValue(), SemanticHighlightings.TYPEDEF);
+ semanticHighlightSymbolsMap.put(CquerySymbolKind.Parameter.getValue(), SemanticHighlightings.PARAMETER_VARIABLE);
+ semanticHighlightSymbolsMap.put(CquerySymbolKind.StaticMethod.getValue(), SemanticHighlightings.STATIC_METHOD_INVOCATION);
+ semanticHighlightSymbolsMap.put(CquerySymbolKind.Macro.getValue(), SemanticHighlightings.MACRO_DEFINITION);
+ }
+
+ public static String getHighlightingName(ExtendedSymbolKindType kind, ExtendedSymbolKindType parentKind, StorageClass storage) {
+ String highlightingName = semanticHighlightSymbolsMap.get(kind.getValue());
+ if (highlightingName == null) {
+ if (kind.getValue() == SymbolKind.Variable.getValue()) {
+ if (parentKind.getValue() == SymbolKind.Function.getValue()
+ || parentKind.getValue() == SymbolKind.Method.getValue()
+ || parentKind.getValue() == SymbolKind.Constructor.getValue()) {
+
+ highlightingName = SemanticHighlightings.LOCAL_VARIABLE;
+ } else {
+ highlightingName = SemanticHighlightings.GLOBAL_VARIABLE;
+ }
+ } else if (kind.getValue() == SymbolKind.Field.getValue()) {
+ if (storage == StorageClass.Static) {
+ highlightingName = SemanticHighlightings.STATIC_FIELD;
+ } else {
+ highlightingName = SemanticHighlightings.FIELD;
+ }
+ }
+ }
+ return highlightingName;
+ }
+
+ public HighlightSymbol(int stableId, ExtendedSymbolKindType parentKind, ExtendedSymbolKindType kind,
+ StorageClass storage, List<Range> ranges) {
+ this.stableId = stableId;
+ this.parentKind = parentKind;
+ this.kind = kind;
+ this.storage = storage;
+ this.ranges = ranges;
+ }
+
+ public int getStableId() {
+ return stableId;
+ }
+
+ public ExtendedSymbolKindType getParentKind() {
+ return parentKind;
+ }
+
+ public ExtendedSymbolKindType getKind() {
+ return kind;
+ }
+
+ public StorageClass getStorage() {
+ return storage;
+ }
+
+ public List<Range> getRanges() {
+ return ranges;
+ }
+} \ No newline at end of file
diff --git a/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/cquery/IndexingProgressStats.java b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/cquery/IndexingProgressStats.java
new file mode 100644
index 00000000000..bb99e305a5a
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/cquery/IndexingProgressStats.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Manish Khurana , Nathan Ridge and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.cdt.lsp.core.cquery;
+
+public class IndexingProgressStats {
+ private int indexRequestCount;
+ private int doIdMapCount;
+ private int loadPreviousIndexCount;
+ private int onIdMappedCount;
+ private int onIndexedCount;
+ private int activeThreads;
+
+ public IndexingProgressStats(int indexRequestCount, int doIdMapCount, int loadPreviousIndexCount, int onIdMappedCount,
+ int onIndexedCount, int activeThreads) {
+ this.indexRequestCount = indexRequestCount;
+ this.doIdMapCount = doIdMapCount;
+ this.loadPreviousIndexCount = loadPreviousIndexCount;
+ this.onIdMappedCount = onIdMappedCount;
+ this.onIndexedCount = onIndexedCount;
+ this.activeThreads = activeThreads;
+ }
+
+ public int getTotalJobs() {
+ int sum = indexRequestCount + doIdMapCount + loadPreviousIndexCount + onIdMappedCount + onIndexedCount;
+ return sum;
+ }
+
+ public int getIndexRequestCount() {
+ return indexRequestCount;
+ }
+
+ public int getDoIdMapCount() {
+ return doIdMapCount;
+ }
+
+ public int getLoadPreviousIndexCount() {
+ return loadPreviousIndexCount;
+ }
+
+ public int getOnIdMappedCount() {
+ return onIdMappedCount;
+ }
+
+ public int getOnIndexedCount() {
+ return onIndexedCount;
+ }
+
+ public int getActiveThreads() {
+ return activeThreads;
+ }
+} \ No newline at end of file
diff --git a/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/cquery/StorageClass.java b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/cquery/StorageClass.java
new file mode 100644
index 00000000000..26317990823
--- /dev/null
+++ b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/cquery/StorageClass.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Manish Khurana , Nathan Ridge and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.cdt.lsp.core.cquery;
+
+public enum StorageClass {
+ Invalid(0), None(1), Extern(2), Static(3), PrivateExtern(4), Auto(5), Register(6);
+
+ private int value;
+
+ public int getValue() {
+ return value;
+ }
+
+ StorageClass(int value) {
+ this.value = value;
+ }
+
+ public static StorageClass forValue(int value) {
+ StorageClass[] allValues = StorageClass.values();
+ if (value < 1 || value > allValues.length) {
+ throw new IllegalArgumentException("Illegal enum value: " + value); //$NON-NLS-1$
+ }
+ return allValues[value - 1];
+ }
+} \ No newline at end of file
diff --git a/lsp/pom.xml b/lsp/pom.xml
new file mode 100644
index 00000000000..88b372fa89c
--- /dev/null
+++ b/lsp/pom.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.eclipse.cdt</groupId>
+ <artifactId>cdt-parent</artifactId>
+ <version>9.6.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>org.eclipse.cdt.lsp-parent</artifactId>
+ <packaging>pom</packaging>
+</project>

Back to the top