1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-25 09:55:29 +02:00

Bug 536797. Add implement for "$cquery/progress" notification message from cquery

Change-Id: I1e49023262facab821b2278c38b82076c2bf21f9
Signed-off-by: Manish Khurana <mkmanishkhurana98@gmail.com>
This commit is contained in:
Manish Khurana 2018-07-09 02:17:01 +05:30 committed by Nathan Ridge
parent 52e1ccf3bc
commit 79331d755a
5 changed files with 39 additions and 3 deletions

View file

@ -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

View file

@ -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);

View file

@ -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
ServerOptionsLabel=Enter any command-line options for the server
CqueryStateIdle=CQuery : Idle
CqueryStateBusy=CQuery : Busy | {0} Jobs

View file

@ -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

View file

@ -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;
}