From 8cc15986218b3981544065a949ad1eb046d9bad2 Mon Sep 17 00:00:00 2001 From: azerr Date: Tue, 12 Dec 2023 18:00:47 +0100 Subject: [PATCH] feat: use server factory Signed-off-by: azerr --- .../lsp/QuarkusLanguageServerFactory.java | 39 +++++++++++++++++++ .../qute/lsp/QuteLanguageServerFactory.java | 39 +++++++++++++++++++ .../resources/META-INF/lsp4ij-quarkus.xml | 5 +-- src/main/resources/META-INF/lsp4ij-qute.xml | 5 +-- 4 files changed, 80 insertions(+), 8 deletions(-) create mode 100644 src/main/java/com/redhat/devtools/intellij/quarkus/lsp/QuarkusLanguageServerFactory.java create mode 100644 src/main/java/com/redhat/devtools/intellij/qute/lsp/QuteLanguageServerFactory.java diff --git a/src/main/java/com/redhat/devtools/intellij/quarkus/lsp/QuarkusLanguageServerFactory.java b/src/main/java/com/redhat/devtools/intellij/quarkus/lsp/QuarkusLanguageServerFactory.java new file mode 100644 index 000000000..10bb9d75b --- /dev/null +++ b/src/main/java/com/redhat/devtools/intellij/quarkus/lsp/QuarkusLanguageServerFactory.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2023 Red Hat, Inc. + * Distributed under license by Red Hat, Inc. All rights reserved. + * This program is made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-v20.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + ******************************************************************************/ +package com.redhat.devtools.intellij.quarkus.lsp; + +import com.intellij.openapi.project.Project; +import com.redhat.devtools.lsp4ij.LanguageServerFactory; +import com.redhat.devtools.lsp4ij.client.LanguageClientImpl; +import com.redhat.devtools.lsp4ij.server.StreamConnectionProvider; +import org.eclipse.lsp4j.services.LanguageServer; +import org.eclipse.lsp4mp.ls.api.MicroProfileLanguageServerAPI; + +/** + * Quarkus language server factory. + */ +public class QuarkusLanguageServerFactory implements LanguageServerFactory { + + @Override + public StreamConnectionProvider createConnectionProvider(Project project) { + return new QuarkusServer(project); + } + + @Override + public LanguageClientImpl createLanguageClient(Project project) { + return new QuarkusLanguageClient(project); + } + + @Override + public Class getServerInterface() { + return MicroProfileLanguageServerAPI.class; + } +} diff --git a/src/main/java/com/redhat/devtools/intellij/qute/lsp/QuteLanguageServerFactory.java b/src/main/java/com/redhat/devtools/intellij/qute/lsp/QuteLanguageServerFactory.java new file mode 100644 index 000000000..0f6ae37b8 --- /dev/null +++ b/src/main/java/com/redhat/devtools/intellij/qute/lsp/QuteLanguageServerFactory.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2023 Red Hat, Inc. + * Distributed under license by Red Hat, Inc. All rights reserved. + * This program is made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-v20.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + ******************************************************************************/ +package com.redhat.devtools.intellij.qute.lsp; + +import com.intellij.openapi.project.Project; +import com.redhat.devtools.lsp4ij.LanguageServerFactory; +import com.redhat.devtools.lsp4ij.client.LanguageClientImpl; +import com.redhat.devtools.lsp4ij.server.StreamConnectionProvider; +import com.redhat.qute.ls.api.QuteLanguageServerAPI; +import org.eclipse.lsp4j.services.LanguageServer; + +/** + * Qute language server factory. + */ +public class QuteLanguageServerFactory implements LanguageServerFactory { + + @Override + public StreamConnectionProvider createConnectionProvider(Project project) { + return new QuteServer(project); + } + + @Override + public LanguageClientImpl createLanguageClient(Project project) { + return new QuteLanguageClient(project); + } + + @Override + public Class getServerInterface() { + return QuteLanguageServerAPI.class; + } +} diff --git a/src/main/resources/META-INF/lsp4ij-quarkus.xml b/src/main/resources/META-INF/lsp4ij-quarkus.xml index 6784893da..01018d06c 100644 --- a/src/main/resources/META-INF/lsp4ij-quarkus.xml +++ b/src/main/resources/META-INF/lsp4ij-quarkus.xml @@ -4,10 +4,7 @@ + factoryClass="com.redhat.devtools.intellij.quarkus.lsp.QuarkusLanguageServerFactory"> MicroProfile language server provides MicroProfile support in:
    diff --git a/src/main/resources/META-INF/lsp4ij-qute.xml b/src/main/resources/META-INF/lsp4ij-qute.xml index ea8496778..8e87e228a 100644 --- a/src/main/resources/META-INF/lsp4ij-qute.xml +++ b/src/main/resources/META-INF/lsp4ij-qute.xml @@ -5,10 +5,7 @@ + factoryClass="com.redhat.devtools.intellij.qute.lsp.QuteLanguageServerFactory" > Qute language server provides Qute support in: