ide-lsp-client.h 5.37 KB
Newer Older
1
/* ide-lsp-client.h
2
 *
3
 * Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
4 5 6 7 8 9 10 11 12 13 14 15 16
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 18
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
19 20
 */

21
#pragma once
22

23 24 25
#if !defined (IDE_LSP_INSIDE) && !defined (IDE_LSP_COMPILATION)
# error "Only <libide-lsp.h> can be included directly."
#endif
26

27
#include <libide-code.h>
28 29 30

G_BEGIN_DECLS

31
#define IDE_TYPE_LSP_CLIENT (ide_lsp_client_get_type())
32

Christian Hergert's avatar
Christian Hergert committed
33
IDE_AVAILABLE_IN_3_32
34
G_DECLARE_DERIVABLE_TYPE (IdeLspClient, ide_lsp_client, IDE, LSP_CLIENT, IdeObject)
35

36 37 38 39 40 41 42
typedef enum
{
  IDE_LSP_TRACE_OFF,
  IDE_LSP_TRACE_MESSAGES,
  IDE_LSP_TRACE_VERBOSE,
} IdeLspTrace;

43
struct _IdeLspClientClass
44 45 46
{
  IdeObjectClass parent_class;

Daniel Buch Hansen's avatar
Daniel Buch Hansen committed
47 48 49 50 51 52 53 54
  void     (*notification)          (IdeLspClient   *self,
                                     const gchar    *method,
                                     GVariant       *params);
  gboolean (*supports_language)     (IdeLspClient   *self,
                                     const gchar    *language_id);
  void     (*published_diagnostics) (IdeLspClient   *self,
                                     GFile           *file,
                                     IdeDiagnostics  *diagnostics);
55

56
  /*< private >*/
57
  gpointer _reserved[16];
58 59
};

Christian Hergert's avatar
Christian Hergert committed
60
IDE_AVAILABLE_IN_3_32
61
IdeLspClient *ide_lsp_client_new                      (GIOStream            *io_stream);
62 63 64 65 66
IDE_AVAILABLE_IN_3_36
IdeLspTrace   ide_lsp_client_get_trace                (IdeLspClient         *self);
IDE_AVAILABLE_IN_3_36
void          ide_lsp_client_set_trace                (IdeLspClient         *self,
                                                       IdeLspTrace           trace);
67 68
IDE_AVAILABLE_IN_3_36
GVariant     *ide_lsp_client_get_server_capabilities  (IdeLspClient         *self);
Christian Hergert's avatar
Christian Hergert committed
69
IDE_AVAILABLE_IN_3_32
70 71
void          ide_lsp_client_add_language             (IdeLspClient         *self,
                                                       const gchar          *language_id);
Christian Hergert's avatar
Christian Hergert committed
72
IDE_AVAILABLE_IN_3_32
73
void          ide_lsp_client_start                    (IdeLspClient         *self);
Christian Hergert's avatar
Christian Hergert committed
74
IDE_AVAILABLE_IN_3_32
75
void          ide_lsp_client_stop                     (IdeLspClient         *self);
Christian Hergert's avatar
Christian Hergert committed
76
IDE_AVAILABLE_IN_3_32
77 78 79 80 81 82
void          ide_lsp_client_call_async               (IdeLspClient         *self,
                                                       const gchar          *method,
                                                       GVariant             *params,
                                                       GCancellable         *cancellable,
                                                       GAsyncReadyCallback   callback,
                                                       gpointer              user_data);
Christian Hergert's avatar
Christian Hergert committed
83
IDE_AVAILABLE_IN_3_32
84 85 86 87
gboolean      ide_lsp_client_call_finish              (IdeLspClient         *self,
                                                       GAsyncResult         *result,
                                                       GVariant            **return_value,
                                                       GError              **error);
Christian Hergert's avatar
Christian Hergert committed
88
IDE_AVAILABLE_IN_3_32
89 90 91 92 93 94
void          ide_lsp_client_send_notification_async  (IdeLspClient         *self,
                                                       const gchar          *method,
                                                       GVariant             *params,
                                                       GCancellable         *cancellable,
                                                       GAsyncReadyCallback   notificationback,
                                                       gpointer              user_data);
Christian Hergert's avatar
Christian Hergert committed
95
IDE_AVAILABLE_IN_3_32
96 97 98
gboolean      ide_lsp_client_send_notification_finish (IdeLspClient         *self,
                                                       GAsyncResult         *result,
                                                       GError              **error);
Christian Hergert's avatar
Christian Hergert committed
99
IDE_AVAILABLE_IN_3_32
100 101 102 103 104 105 106
void          ide_lsp_client_get_diagnostics_async    (IdeLspClient         *self,
                                                       GFile                *file,
                                                       GBytes               *content,
                                                       const gchar          *lang_id,
                                                       GCancellable         *cancellable,
                                                       GAsyncReadyCallback   callback,
                                                       gpointer              user_data);
Christian Hergert's avatar
Christian Hergert committed
107
IDE_AVAILABLE_IN_3_32
108 109 110 111
gboolean      ide_lsp_client_get_diagnostics_finish   (IdeLspClient         *self,
                                                       GAsyncResult         *result,
                                                       IdeDiagnostics      **diagnostics,
                                                       GError              **error);
112 113

G_END_DECLS