1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-21 21:52:10 +02:00

Bug 558664 - Cquery integration should be extracted from LSP Core

Part 4:
Switch C/C++ LSP preferences to LanguageServerConfiguration and remove
constants with server identifiers. Align i18n accordingly.

Change-Id: I4dcd9ea57a2c4577bb6763bb859afbd339eb66e0
Signed-off-by: Alexander Fedorov <alexander.fedorov@arsysop.ru>
This commit is contained in:
Alexander Fedorov 2020-08-19 12:42:07 +03:00
parent 3705069ef2
commit 8abfaab458
13 changed files with 72 additions and 38 deletions

View file

@ -27,6 +27,7 @@ Export-Package: org.eclipse.cdt.cquery;x-friends:="org.eclipse.cdt.lsp.ui",
org.eclipse.cdt.internal.clangd;x-friends:="org.eclipse.cdt.lsp.ui",
org.eclipse.cdt.internal.cquery;x-friends:="org.eclipse.cdt.lsp.ui",
org.eclipse.cdt.internal.cquery.ui;x-internal:=true,
org.eclipse.cdt.lsp;x-friends:="org.eclipse.cdt.lsp.ui",
org.eclipse.cdt.lsp.core;x-friends:="org.eclipse.cdt.lsp.ui",
org.eclipse.cdt.lsp.internal.core;x-internal:=true,
org.eclipse.cdt.lsp.internal.text;x-friends:="org.eclipse.cdt.lsp.ui"

View file

@ -19,17 +19,14 @@ import org.osgi.service.component.annotations.Component;
@Component
public class ClangdLanguageServer implements LanguageServerConfiguration {
//FIXME: remove this constant, it is not needed outside the class
public static final String CLANGD_ID = "clangd"; //$NON-NLS-1$
@Override
public String identifier() {
return ClangdLanguageServer.CLANGD_ID;
return "clangd"; //$NON-NLS-1$
}
@Override
public String label() {
return "ClangD";
return ClangdMessages.ClangdLanguageServer_label;
}
@Override

View file

@ -0,0 +1,28 @@
/*******************************************************************************
* Copyright (c) 2020 ArSysOp and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Alexander Fedorov (ArSysOp) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.clangd;
import org.eclipse.osgi.util.NLS;
public class ClangdMessages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.clangd.ClangdMessages"; //$NON-NLS-1$
public static String ClangdLanguageServer_label;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, ClangdMessages.class);
}
private ClangdMessages() {
}
}

View file

@ -0,0 +1,14 @@
###############################################################################
# Copyright (c) 2020 ArSysOp and others.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# https://www.eclipse.org/legal/epl-2.0/.
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Alexander Fedorov (ArSysOp) - initial API and implementation
###############################################################################
ClangdLanguageServer_label=ClangD

View file

@ -25,17 +25,14 @@ import com.google.gson.JsonObject;
@Component
public class CqueryLanguageServer implements LanguageServerConfiguration {
//FIXME: remove this constant, it is not needed outside the class
public static final String CQUERY_ID = "cquery"; //$NON-NLS-1$
@Override
public String identifier() {
return CqueryLanguageServer.CQUERY_ID;
return "cquery"; //$NON-NLS-1$
}
@Override
public String label() {
return "CQuery";
return CqueryMessages.CqueryLanguageServer_label;
}
@Override

View file

@ -1,14 +1,11 @@
/*******************************************************************************
* Copyright (c) 2019 Eclipse Foundation and others.
* Copyright (c) 2019, 2020 Eclipse contributors and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0/.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Alexander Fedorov <alexander.fedorov@arsysop.ru> - initial API and implementatin
*******************************************************************************/
package org.eclipse.cdt.internal.cquery;
@ -23,6 +20,7 @@ public class CqueryMessages extends NLS {
NLS.initializeMessages(BUNDLE_NAME, CqueryMessages.class);
}
public static String CqueryLanguageServer_label;
public static String CquerySymbolKind_e_illegal_value;
public static String Server2ClientProtocolExtension_cquery_name;
public static String StorageClass_e_illegal_value;

View file

@ -1,17 +1,13 @@
###############################################################################
# Copyright (c) 2019 Eclipse Foundation and others
# Copyright (c) 2019, 2020 Eclipse contributors and others.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# https://www.eclipse.org/legal/epl-2.0/.
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Eclipse Foundation - initial API and implementation
# Alexander Fedorov <alexander.fedorov@arsysop.ru> - Bug 558484
###############################################################################
CqueryLanguageServer_label=CQuery
CquerySymbolKind_e_illegal_value=Illegal value {0} for cquery symbol kind
Server2ClientProtocolExtension_cquery_name=CQuery
StorageClass_e_illegal_value=Illegal enum value: {0}

View file

@ -23,6 +23,7 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
@Override
public void initializeDefaultPreferences() {
IEclipsePreferences node = DefaultScope.INSTANCE.getNode(Activator.PLUGIN_ID);
//FIXME: how to determine the preferred LS implementation?
node.put(PreferenceConstants.P_SERVER_CHOICE, "clangd"); //$NON-NLS-1$
node.put(PreferenceConstants.P_SERVER_OPTIONS, ""); //$NON-NLS-1$
}

View file

@ -58,8 +58,7 @@ public class Server2ClientProtocolExtension extends LanguageClientImpl {
public Server2ClientProtocolExtension() {
this.uri = new ResolveDocumentUri();
this.progress = new ShowStatus(() -> CqueryMessages.Server2ClientProtocolExtension_cquery_name,
new StatusLineMessage());
this.progress = new ShowStatus(() -> CqueryMessages.CqueryLanguageServer_label, new StatusLineMessage());
}
@JsonNotification("$cquery/progress")

View file

@ -7,6 +7,7 @@ Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.osgi;bundle-version="[3.15.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="3.19.0",
org.eclipse.equinox.preferences;bundle-version="[3.7.0,4.0.0)",
org.eclipse.jface.text;bundle-version="3.16.0",
org.eclipse.ui;bundle-version="[3.115.0,4.0.0)",

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Eclipse Foundation and others.
* Copyright (c) 2019, 2020 Eclipse Foundation and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
@ -24,9 +24,6 @@ public class LspUiMessages extends NLS {
NLS.initializeMessages(BUNDLE_NAME, LspUiMessages.class);
}
public static String CPPLanguageServerPreferencePage_clangd;
public static String CPPLanguageServerPreferencePage_cquery;
public static String CPPLanguageServerPreferencePage_description;
public static String CPPLanguageServerPreferencePage_server_options;
public static String CPPLanguageServerPreferencePage_server_path;

View file

@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2019-2020 Eclipse Foundation and others
# Copyright (c) 2019, 2020 Eclipse Foundation and others
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
@ -13,10 +13,6 @@
# Philip Langer <planger@eclipsesource.com> - Bug 563280
###############################################################################
CPPLanguageServerPreferencePage_clangd=ClangD
CPPLanguageServerPreferencePage_cquery=CQuery
CPPLanguageServerPreferencePage_description=Preferences for the C/C++ Language Server\n\n
CPPLanguageServerPreferencePage_server_options=Command-line options for the server
CPPLanguageServerPreferencePage_server_path=Path to the server executable

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018-2020 Manish Khurana, Nathan Ridge and others.
* Copyright (c) 2018, 2020 Manish Khurana, Nathan Ridge and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
@ -17,14 +17,18 @@
package org.eclipse.cdt.lsp.internal.ui.preferences;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import org.eclipse.cdt.internal.clangd.ClangdLanguageServer;
import org.eclipse.cdt.internal.cquery.CqueryLanguageServer;
import org.eclipse.cdt.lsp.LanguageServerConfiguration;
import org.eclipse.cdt.lsp.SupportedLanguageServers;
import org.eclipse.cdt.lsp.core.CPPStreamConnectionProvider;
import org.eclipse.cdt.lsp.core.PreferenceConstants;
import org.eclipse.cdt.lsp.internal.ui.LspUiActivator;
import org.eclipse.cdt.lsp.internal.ui.LspUiMessages;
import org.eclipse.cdt.ui.newui.MultiLineTextFieldEditor;
import org.eclipse.core.runtime.ServiceCaller;
import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.FileFieldEditor;
@ -52,10 +56,7 @@ public class CPPLanguageServerPreferencePage extends FieldEditorPreferencePage i
@Override
public void createFieldEditors() {
serverChoice = new RadioGroupFieldEditor(PreferenceConstants.P_SERVER_CHOICE,
LspUiMessages.CPPLanguageServerPreferencePage_server_selector, 1,
new String[][] {
{ LspUiMessages.CPPLanguageServerPreferencePage_clangd, ClangdLanguageServer.CLANGD_ID },
{ LspUiMessages.CPPLanguageServerPreferencePage_cquery, CqueryLanguageServer.CQUERY_ID } },
LspUiMessages.CPPLanguageServerPreferencePage_server_selector, 1, contributedServers(),
getFieldEditorParent());
addField(serverChoice);
@ -82,4 +83,12 @@ public class CPPLanguageServerPreferencePage extends FieldEditorPreferencePage i
@Override
public void init(IWorkbench workbench) {
}
private String[][] contributedServers() {
List<LanguageServerConfiguration> servers = new ArrayList<>();
ServiceCaller.callOnce(getClass(), SupportedLanguageServers.class, x -> servers.addAll(x.all()));
return servers.stream()//
.map(x -> new String[] { x.label(), x.identifier() })//
.collect(Collectors.toList()).toArray(new String[0][]);
}
}