1 /* rust-analyzer-diagnostic-provider.c
2  *
3  * Copyright 2020 Günther Wagner <info@gunibert.de>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * 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 #include "rust-analyzer-diagnostic-provider.h"
22 #include "rust-analyzer-service.h"
23 
24 struct _RustAnalyzerDiagnosticProvider
25 {
26   IdeLspDiagnosticProvider parent_instance;
27 };
28 
29 static void provider_iface_init (IdeDiagnosticProviderInterface *iface);
30 
G_DEFINE_FINAL_TYPE_WITH_CODE(RustAnalyzerDiagnosticProvider,rust_analyzer_diagnostic_provider,IDE_TYPE_LSP_DIAGNOSTIC_PROVIDER,G_IMPLEMENT_INTERFACE (IDE_TYPE_DIAGNOSTIC_PROVIDER,provider_iface_init))31 G_DEFINE_FINAL_TYPE_WITH_CODE (RustAnalyzerDiagnosticProvider,
32                          rust_analyzer_diagnostic_provider,
33                          IDE_TYPE_LSP_DIAGNOSTIC_PROVIDER,
34                          G_IMPLEMENT_INTERFACE (IDE_TYPE_DIAGNOSTIC_PROVIDER, provider_iface_init))
35 
36 static void
37 rust_analyzer_diagnostic_provider_class_init (RustAnalyzerDiagnosticProviderClass *klass)
38 {
39 }
40 
41 static void
rust_analyzer_diagnostic_provider_init(RustAnalyzerDiagnosticProvider * self)42 rust_analyzer_diagnostic_provider_init (RustAnalyzerDiagnosticProvider *self)
43 {
44 }
45 
46 static void
rust_analyzer_diagnostic_provider_load(IdeDiagnosticProvider * self)47 rust_analyzer_diagnostic_provider_load (IdeDiagnosticProvider *self)
48 {
49   RustAnalyzerService *service;
50   IdeContext *context;
51 
52   g_assert (RUST_IS_ANALYZER_DIAGNOSTIC_PROVIDER (self));
53 
54   context = ide_object_get_context (IDE_OBJECT (self));
55   service = rust_analyzer_service_from_context (context);
56   g_object_bind_property (service, "client", self, "client", G_BINDING_SYNC_CREATE);
57   rust_analyzer_service_ensure_started (service);
58 }
59 
60 static void
provider_iface_init(IdeDiagnosticProviderInterface * iface)61 provider_iface_init (IdeDiagnosticProviderInterface *iface)
62 {
63   iface->load = rust_analyzer_diagnostic_provider_load;
64 }
65