[gnome-builder: 90/139] go-langserv: port to libide-code



commit c7f85dad98106e5789b555d00a10b2f6417ff986
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jan 9 17:25:52 2019 -0800

    go-langserv: port to libide-code

 src/plugins/go-langserv/go-langserv.plugin      | 10 ++++++----
 src/plugins/go-langserv/go_langserver_plugin.py | 24 ++++++++++++++----------
 src/plugins/go-langserv/meson.build             |  4 ++--
 3 files changed, 22 insertions(+), 16 deletions(-)
---
diff --git a/src/plugins/go-langserv/go-langserv.plugin b/src/plugins/go-langserv/go-langserv.plugin
index e41ce2e7a..941174cde 100644
--- a/src/plugins/go-langserv/go-langserv.plugin
+++ b/src/plugins/go-langserv/go-langserv.plugin
@@ -1,8 +1,10 @@
 [Plugin]
-Module=go_langserver_plugin
+Builtin=true
+Copyright=Copyright © 2018 Henry Finucane
+Description=Provides LSP integration for Go
+Hidden=true
 Loader=python3
+Module=go_langserver_plugin
 Name=Go Language Server Plugin
-Description=Provides LSP integration for Go
-Copyright=Copyright © 2018 Henry Finucane
-Builtin=true
+X-Builder-ABI=@PACKAGE_ABI@
 X-Symbol-Resolver-Languages=go
diff --git a/src/plugins/go-langserv/go_langserver_plugin.py b/src/plugins/go-langserv/go_langserver_plugin.py
index ad31384e0..912b211fb 100644
--- a/src/plugins/go-langserv/go_langserver_plugin.py
+++ b/src/plugins/go-langserv/go_langserver_plugin.py
@@ -4,8 +4,6 @@ import os
 import json
 import gi
 
-gi.require_version('Ide', '1.0')
-
 from gi.repository import GLib
 from gi.repository import Gio
 from gi.repository import GObject
@@ -13,12 +11,16 @@ from gi.repository import Ide
 
 DEV_MODE = os.getenv('DEV_MODE') and True or False
 
-class GoService(Ide.Object, Ide.Service):
+class GoService(Ide.Object):
     _client = None
     _has_started = False
     _supervisor = None
 
-    @GObject.Property(type=Ide.LangservClient)
+    @classmethod
+    def from_context(klass, context):
+        return context.ensure_child_typed(GoService)
+
+    @GObject.Property(type=Ide.LspClient)
     def client(self):
         return self._client
 
@@ -49,7 +51,7 @@ class GoService(Ide.Object, Ide.Service):
             launcher.set_clear_env(False)
 
             # Locate the directory of the project and run go-langserver from there
-            workdir = self.get_context().get_vcs().get_working_directory()
+            workdir = self.get_context().ref_workdir()
             launcher.set_cwd(workdir.get_path())
 
             # Bash will load the host $PATH and $GOPATH (and optionally $GOROOT) for us.
@@ -78,8 +80,10 @@ class GoService(Ide.Object, Ide.Service):
 
         if self._client:
             self._client.stop()
+            self._client.destroy()
 
-        self._client = Ide.LangservClient.new(self.get_context(), io_stream)
+        self._client = Ide.LspClient.new(io_stream)
+        self.append(self._client)
         self._client.add_language('go')
         self._client.start()
         self.notify('client')
@@ -97,26 +101,26 @@ class GoService(Ide.Object, Ide.Service):
     @classmethod
     def bind_client(klass, provider):
         context = provider.get_context()
-        self = context.get_service_typed(GoService)
+        self = GoService.from_context(context)
         self._ensure_started()
         self.bind_property('client', provider, 'client', GObject.BindingFlags.SYNC_CREATE)
 
 # This is the only up-to-date looking list of supported things lsp things:
 # https://github.com/sourcegraph/go-langserver/blob/master/langserver/handler.go#L226
 
-class GoSymbolResolver(Ide.LangservSymbolResolver, Ide.SymbolResolver):
+class GoSymbolResolver(Ide.LspSymbolResolver, Ide.SymbolResolver):
     def do_load(self):
         GoService.bind_client(self)
 
 ## This is supported as of a few weeks ago, but at least for me, it seems
 ## awfully crashy, so I'm going to leave it disabled by default so as to
 ## not give a bad impression
-#class GoCompletionProvider(Ide.LangservCompletionProvider, Ide.CompletionProvider):
+#class GoCompletionProvider(Ide.LspCompletionProvider, Ide.CompletionProvider):
 #    def do_load(self, context):
 #        GoService.bind_client(self)
 
 ## Could not validate that this works, though `go-langserver` says it does.
 ## Calling out to `gofmt` is probably the more canonical route
-#class GoFormatter(Ide.LangservFormatter, Ide.Formatter):
+#class GoFormatter(Ide.LspFormatter, Ide.Formatter):
 #    def do_load(self):
 #        GoService.bind_client(self)
diff --git a/src/plugins/go-langserv/meson.build b/src/plugins/go-langserv/meson.build
index 33f28b3b7..2f8530fe6 100644
--- a/src/plugins/go-langserv/meson.build
+++ b/src/plugins/go-langserv/meson.build
@@ -1,11 +1,11 @@
-if get_option('with_go_langserv')
+if get_option('plugin_go_langserv')
 
 install_data('go_langserver_plugin.py', install_dir: plugindir)
 
 configure_file(
           input: 'go-langserv.plugin',
          output: 'go-langserv.plugin',
-           copy: true,
+  configuration: config_h,
         install: true,
     install_dir: plugindir,
 )


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]