[gnome-builder: 86/139] gjs-symbols: port to libide-code
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder: 86/139] gjs-symbols: port to libide-code
- Date: Thu, 10 Jan 2019 04:24:33 +0000 (UTC)
commit a72f6e706abd87b13ad0c2b213db8196b05ae03e
Author: Christian Hergert <chergert redhat com>
Date: Wed Jan 9 17:23:38 2019 -0800
gjs-symbols: port to libide-code
src/plugins/gjs-symbols/gjs_symbols.plugin | 17 +++++++++--------
src/plugins/gjs-symbols/gjs_symbols.py | 28 ++++++++++++++--------------
src/plugins/gjs-symbols/meson.build | 4 ++--
3 files changed, 25 insertions(+), 24 deletions(-)
---
diff --git a/src/plugins/gjs-symbols/gjs_symbols.plugin b/src/plugins/gjs-symbols/gjs_symbols.plugin
index 7384d57ed..c715af17c 100644
--- a/src/plugins/gjs-symbols/gjs_symbols.plugin
+++ b/src/plugins/gjs-symbols/gjs_symbols.plugin
@@ -1,12 +1,13 @@
[Plugin]
-Module=gjs_symbols
-Loader=python3
-Name=GJS Symbol Resolver
-Description=Provides a symbol resolver for JavaScript using GJS.
Authors=Patrick Griffis <tingping tingping se>
-Copyright=Copyright © 2017 Patrick Griffis
Builtin=true
-X-Symbol-Resolver-Languages=js
-X-Symbol-Resolver-Languages-Priority=0
-X-Code-Indexer-Languages=js
+Copyright=Copyright © 2017 Patrick Griffis
+Description=Provides a symbol resolver for JavaScript using GJS.
+Loader=python3
+Module=gjs_symbols
+Name=GJS Symbol Resolver
X-Code-Indexer-Languages-Priority=0
+X-Code-Indexer-Languages=js
+X-Symbol-Resolver-Languages-Priority=0
+X-Symbol-Resolver-Languages=js
+X-Builder-ABI=@PACKAGE_ABI@
diff --git a/src/plugins/gjs-symbols/gjs_symbols.py b/src/plugins/gjs-symbols/gjs_symbols.py
index 98d0bad51..345df5ddd 100644
--- a/src/plugins/gjs-symbols/gjs_symbols.py
+++ b/src/plugins/gjs-symbols/gjs_symbols.py
@@ -4,7 +4,7 @@
#
# Copyright 2017 Patrick Griffi <tingping tingping se>
# Copyright 2017 Giovanni Campagna <gcampagn cs stanford edu>
-# Copyright 2018-2019 Christian Hergert <chergert redhat com>
+# Copyright 2018 Christian Hergert <chergert redhat com>
#
# 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
@@ -24,10 +24,6 @@ import gi
import json
import threading
-gi.require_versions({
- 'Ide': '1.0',
-})
-
from gi.repository import GLib
from gi.repository import GObject
from gi.repository import Gio
@@ -37,7 +33,7 @@ SYMBOL_PARAM_FLAGS=flags = GObject.ParamFlags.CONSTRUCT_ONLY | GObject.ParamFlag
class JsSymbolNode(Ide.SymbolNode):
- file = GObject.Property(type=Ide.File, flags=SYMBOL_PARAM_FLAGS)
+ file = GObject.Property(type=Gio.File, flags=SYMBOL_PARAM_FLAGS)
line = GObject.Property(type=int, flags=SYMBOL_PARAM_FLAGS)
col = GObject.Property(type=int, flags=SYMBOL_PARAM_FLAGS)
@@ -52,7 +48,7 @@ class JsSymbolNode(Ide.SymbolNode):
def do_get_location_finish(self, result):
if result.propagate_boolean():
- return Ide.SourceLocation.new(self.file, self.line, self.col, 0)
+ return Ide.Location.new(self.file, self.line, self.col)
def __len__(self):
return len(self.children)
@@ -264,16 +260,22 @@ class GjsSymbolProvider(Ide.Object, Ide.SymbolResolver):
def _get_launcher(context, file_):
file_path = file_.get_path()
script = JS_SCRIPT % file_path
- unsaved_file = context.get_unsaved_files().get_unsaved_file(file_)
+ unsaved_file = Ide.UnsavedFiles.from_context(context).get_unsaved_file(file_)
+
+ if context.has_project():
+ runtime = Ide.ConfigurationManager.from_context(context).get_current().get_runtime()
+ launcher = runtime.create_launcher()
+ else:
+ launcher = Ide.SubprocessLauncher.new(0)
- runtime = context.get_configuration_manager().get_current().get_runtime()
- launcher = runtime.create_launcher()
launcher.set_flags(Gio.SubprocessFlags.STDOUT_PIPE | Gio.SubprocessFlags.STDERR_SILENCE)
launcher.push_args(('gjs', '-c', script))
+
if unsaved_file is not None:
launcher.push_argv(unsaved_file.get_content().get_data().decode('utf-8'))
else:
launcher.push_args(('--file', file_path))
+
return launcher
def do_lookup_symbol_async(self, location, cancellable, callback, user_data=None):
@@ -300,8 +302,7 @@ class GjsSymbolProvider(Ide.Object, Ide.SymbolResolver):
task.return_error(GLib.Error('Failed to run gjs'))
return
- ide_file = Ide.File(file=file_, context=self.get_context())
- task.symbol_tree = JsSymbolTree(json.loads(stdout), ide_file)
+ task.symbol_tree = JsSymbolTree(json.loads(stdout), file_)
except GLib.Error as err:
task.return_error(err)
except (json.JSONDecodeError, UnicodeDecodeError) as e:
@@ -382,9 +383,8 @@ class GjsCodeIndexer(Ide.Object, Ide.CodeIndexer):
try:
_, stdout, stderr = subprocess.communicate_utf8_finish(result)
- ide_file = Ide.File(file=task.file, context=self.get_context())
try:
- root_node = JsSymbolTree._node_from_dict(json.loads(stdout), ide_file)
+ root_node = JsSymbolTree._node_from_dict(json.loads(stdout), task.file)
except (json.JSONDecodeError, UnicodeDecodeError) as e:
raise GLib.Error('Failed to decode gjs json: {}'.format(e))
except (IndexError, KeyError) as e:
diff --git a/src/plugins/gjs-symbols/meson.build b/src/plugins/gjs-symbols/meson.build
index 189da66cf..43ccc9724 100644
--- a/src/plugins/gjs-symbols/meson.build
+++ b/src/plugins/gjs-symbols/meson.build
@@ -1,11 +1,11 @@
-if get_option('with_gjs_symbols')
+if get_option('plugin_gjs_symbols')
install_data('gjs_symbols.py', install_dir: plugindir)
configure_file(
input: 'gjs_symbols.plugin',
output: 'gjs_symbols.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]