summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManish Khurana2018-07-08 16:47:01 -0400
committerNathan Ridge2018-07-08 17:06:59 -0400
commit79331d755a273fbf249a765b5790c418e2132d87 (patch)
treef4c3ebd46a80da8bef020b00d4b11205160c8cae
parent52e1ccf3bc64257067a6b512052eb28f0bebc033 (diff)
downloadorg.eclipse.cdt-79331d755a273fbf249a765b5790c418e2132d87.zip
org.eclipse.cdt-79331d755a273fbf249a765b5790c418e2132d87.tar.gz
org.eclipse.cdt-79331d755a273fbf249a765b5790c418e2132d87.tar.xz
Bug 536797. Add implement for "$cquery/progress" notification message from cquery
Change-Id: I1e49023262facab821b2278c38b82076c2bf21f9 Signed-off-by: Manish Khurana <mkmanishkhurana98@gmail.com>
-rw-r--r--lsp4e-cpp/org.eclipse.lsp4e.cpp.language/META-INF/MANIFEST.MF1
-rw-r--r--lsp4e-cpp/org.eclipse.lsp4e.cpp.language/src/org/eclipse/lsp4e/cpp/language/Messages.java2
-rw-r--r--lsp4e-cpp/org.eclipse.lsp4e.cpp.language/src/org/eclipse/lsp4e/cpp/language/Messages.properties4
-rw-r--r--lsp4e-cpp/org.eclipse.lsp4e.cpp.language/src/org/eclipse/lsp4e/cpp/language/Server2ClientProtocolExtension.java30
-rw-r--r--lsp4e-cpp/org.eclipse.lsp4e.cpp.language/src/org/eclipse/lsp4e/cpp/language/cquery/IndexingProgressStats.java5
5 files changed, 39 insertions, 3 deletions
diff --git a/lsp4e-cpp/org.eclipse.lsp4e.cpp.language/META-INF/MANIFEST.MF b/lsp4e-cpp/org.eclipse.lsp4e.cpp.language/META-INF/MANIFEST.MF
index eda7dd8..b816272 100644
--- a/lsp4e-cpp/org.eclipse.lsp4e.cpp.language/META-INF/MANIFEST.MF
+++ b/lsp4e-cpp/org.eclipse.lsp4e.cpp.language/META-INF/MANIFEST.MF
@@ -24,3 +24,4 @@ Export-Package: org.eclipse.lsp4e.cpp.language,
org.eclipse.lsp4e.cpp.language.cquery
Bundle-Activator: org.eclipse.lsp4e.cpp.language.Activator
Bundle-ActivationPolicy: lazy
+Import-Package: org.eclipse.ui.texteditor
diff --git a/lsp4e-cpp/org.eclipse.lsp4e.cpp.language/src/org/eclipse/lsp4e/cpp/language/Messages.java b/lsp4e-cpp/org.eclipse.lsp4e.cpp.language/src/org/eclipse/lsp4e/cpp/language/Messages.java
index 925db4e..a7b2fb8 100644
--- a/lsp4e-cpp/org.eclipse.lsp4e.cpp.language/src/org/eclipse/lsp4e/cpp/language/Messages.java
+++ b/lsp4e-cpp/org.eclipse.lsp4e.cpp.language/src/org/eclipse/lsp4e/cpp/language/Messages.java
@@ -15,6 +15,8 @@ public class Messages extends NLS {
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/lsp4e-cpp/org.eclipse.lsp4e.cpp.language/src/org/eclipse/lsp4e/cpp/language/Messages.properties b/lsp4e-cpp/org.eclipse.lsp4e.cpp.language/src/org/eclipse/lsp4e/cpp/language/Messages.properties
index b671b98..fe78024 100644
--- a/lsp4e-cpp/org.eclipse.lsp4e.cpp.language/src/org/eclipse/lsp4e/cpp/language/Messages.properties
+++ b/lsp4e-cpp/org.eclipse.lsp4e.cpp.language/src/org/eclipse/lsp4e/cpp/language/Messages.properties
@@ -9,4 +9,6 @@
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 \ No newline at end of file
+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/lsp4e-cpp/org.eclipse.lsp4e.cpp.language/src/org/eclipse/lsp4e/cpp/language/Server2ClientProtocolExtension.java b/lsp4e-cpp/org.eclipse.lsp4e.cpp.language/src/org/eclipse/lsp4e/cpp/language/Server2ClientProtocolExtension.java
index 80550f9..239aef5 100644
--- a/lsp4e-cpp/org.eclipse.lsp4e.cpp.language/src/org/eclipse/lsp4e/cpp/language/Server2ClientProtocolExtension.java
+++ b/lsp4e-cpp/org.eclipse.lsp4e.cpp.language/src/org/eclipse/lsp4e/cpp/language/Server2ClientProtocolExtension.java
@@ -8,17 +8,44 @@
package org.eclipse.lsp4e.cpp.language;
+import org.eclipse.jface.action.StatusLineContributionItem;
+import org.eclipse.jface.action.StatusLineManager;
import org.eclipse.lsp4e.LanguageClientImpl;
import org.eclipse.lsp4e.cpp.language.cquery.CqueryInactiveRegions;
import org.eclipse.lsp4e.cpp.language.cquery.CquerySemanticHighlights;
import org.eclipse.lsp4e.cpp.language.cquery.IndexingProgressStats;
import org.eclipse.lsp4j.jsonrpc.services.JsonNotification;
+import org.eclipse.osgi.util.NLS;
+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) {
- // TODO: Implement
+
+ 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")
@@ -26,7 +53,6 @@ public class Server2ClientProtocolExtension extends LanguageClientImpl {
// TODO: Implement
}
-
@JsonNotification("$cquery/publishSemanticHighlighting")
public final void semanticHighlights(CquerySemanticHighlights highlights) {
// TODO: Implement
diff --git a/lsp4e-cpp/org.eclipse.lsp4e.cpp.language/src/org/eclipse/lsp4e/cpp/language/cquery/IndexingProgressStats.java b/lsp4e-cpp/org.eclipse.lsp4e.cpp.language/src/org/eclipse/lsp4e/cpp/language/cquery/IndexingProgressStats.java
index 6a3a9ba..6168882 100644
--- a/lsp4e-cpp/org.eclipse.lsp4e.cpp.language/src/org/eclipse/lsp4e/cpp/language/cquery/IndexingProgressStats.java
+++ b/lsp4e-cpp/org.eclipse.lsp4e.cpp.language/src/org/eclipse/lsp4e/cpp/language/cquery/IndexingProgressStats.java
@@ -26,6 +26,11 @@ public class IndexingProgressStats {
this.activeThreads = activeThreads;
}
+ public int getTotalJobs() {
+ int sum = indexRequestCount + doIdMapCount + loadPreviousIndexCount + onIdMappedCount + onIndexedCount;
+ return sum;
+ }
+
public int getIndexRequestCount() {
return indexRequestCount;
}