mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 14:55:41 +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:
parent
52e1ccf3bc
commit
79331d755a
5 changed files with 39 additions and 3 deletions
|
@ -24,3 +24,4 @@ Export-Package: org.eclipse.lsp4e.cpp.language,
|
||||||
org.eclipse.lsp4e.cpp.language.cquery
|
org.eclipse.lsp4e.cpp.language.cquery
|
||||||
Bundle-Activator: org.eclipse.lsp4e.cpp.language.Activator
|
Bundle-Activator: org.eclipse.lsp4e.cpp.language.Activator
|
||||||
Bundle-ActivationPolicy: lazy
|
Bundle-ActivationPolicy: lazy
|
||||||
|
Import-Package: org.eclipse.ui.texteditor
|
||||||
|
|
|
@ -15,6 +15,8 @@ public class Messages extends NLS {
|
||||||
public static String ServerChoiceLabel;
|
public static String ServerChoiceLabel;
|
||||||
public static String ServerPathLabel;
|
public static String ServerPathLabel;
|
||||||
public static String ServerOptionsLabel;
|
public static String ServerOptionsLabel;
|
||||||
|
public static String CqueryStateIdle;
|
||||||
|
public static String CqueryStateBusy;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
NLS.initializeMessages(Messages.class.getName(), Messages.class);
|
NLS.initializeMessages(Messages.class.getName(), Messages.class);
|
||||||
|
|
|
@ -10,3 +10,5 @@ PreferencePageDescription=Preferences for the C/C++ Language Server\n\n
|
||||||
ServerChoiceLabel=Please select the C/C++ Language Server you want to use in Eclipse :
|
ServerChoiceLabel=Please select the C/C++ Language Server you want to use in Eclipse :
|
||||||
ServerPathLabel=Browse path to the server executable
|
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
|
|
@ -8,17 +8,44 @@
|
||||||
|
|
||||||
package org.eclipse.lsp4e.cpp.language;
|
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.LanguageClientImpl;
|
||||||
import org.eclipse.lsp4e.cpp.language.cquery.CqueryInactiveRegions;
|
import org.eclipse.lsp4e.cpp.language.cquery.CqueryInactiveRegions;
|
||||||
import org.eclipse.lsp4e.cpp.language.cquery.CquerySemanticHighlights;
|
import org.eclipse.lsp4e.cpp.language.cquery.CquerySemanticHighlights;
|
||||||
import org.eclipse.lsp4e.cpp.language.cquery.IndexingProgressStats;
|
import org.eclipse.lsp4e.cpp.language.cquery.IndexingProgressStats;
|
||||||
import org.eclipse.lsp4j.jsonrpc.services.JsonNotification;
|
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 {
|
public class Server2ClientProtocolExtension extends LanguageClientImpl {
|
||||||
|
|
||||||
@JsonNotification("$cquery/progress")
|
@JsonNotification("$cquery/progress")
|
||||||
public final void indexingProgress(IndexingProgressStats stats) {
|
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")
|
@JsonNotification("$cquery/setInactiveRegions")
|
||||||
|
@ -26,7 +53,6 @@ public class Server2ClientProtocolExtension extends LanguageClientImpl {
|
||||||
// TODO: Implement
|
// TODO: Implement
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@JsonNotification("$cquery/publishSemanticHighlighting")
|
@JsonNotification("$cquery/publishSemanticHighlighting")
|
||||||
public final void semanticHighlights(CquerySemanticHighlights highlights) {
|
public final void semanticHighlights(CquerySemanticHighlights highlights) {
|
||||||
// TODO: Implement
|
// TODO: Implement
|
||||||
|
|
|
@ -26,6 +26,11 @@ public class IndexingProgressStats {
|
||||||
this.activeThreads = activeThreads;
|
this.activeThreads = activeThreads;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getTotalJobs() {
|
||||||
|
int sum = indexRequestCount + doIdMapCount + loadPreviousIndexCount + onIdMappedCount + onIndexedCount;
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
|
||||||
public int getIndexRequestCount() {
|
public int getIndexRequestCount() {
|
||||||
return indexRequestCount;
|
return indexRequestCount;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue