[gnome-builder/gnome-builder-3-18] vala: start on a simple vala symbol resolver
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/gnome-builder-3-18] vala: start on a simple vala symbol resolver
- Date: Tue, 13 Oct 2015 07:24:36 +0000 (UTC)
commit 5e118dbef54725e35ddecbb9c0341e5fca92a8a8
Author: Christian Hergert <christian hergert me>
Date: Sat Sep 26 01:29:42 2015 -0700
vala: start on a simple vala symbol resolver
plugins/vala-pack/Makefile.am | 1 +
plugins/vala-pack/ide-vala-symbol-resolver.vala | 67 +++++++++++++++++++++++
plugins/vala-pack/vala-pack.plugin | 2 +
3 files changed, 70 insertions(+), 0 deletions(-)
---
diff --git a/plugins/vala-pack/Makefile.am b/plugins/vala-pack/Makefile.am
index 439e928..f83fccc 100644
--- a/plugins/vala-pack/Makefile.am
+++ b/plugins/vala-pack/Makefile.am
@@ -17,6 +17,7 @@ libvala_pack_plugin_la_SOURCES = \
ide-vala-index.vala \
ide-vala-locator.vala \
ide-vala-source-file.vala \
+ ide-vala-symbol-resolver.vala \
vala-pack-plugin.vala \
$(NULL)
diff --git a/plugins/vala-pack/ide-vala-symbol-resolver.vala b/plugins/vala-pack/ide-vala-symbol-resolver.vala
new file mode 100644
index 0000000..8c740ef
--- /dev/null
+++ b/plugins/vala-pack/ide-vala-symbol-resolver.vala
@@ -0,0 +1,67 @@
+/* ide-vala-symbol-resolver.vala
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * 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/>.
+ */
+
+using GLib;
+using Ide;
+using Vala;
+
+namespace Ide
+{
+ public class ValaSymbolResolver: Ide.Object, Ide.SymbolResolver
+ {
+ public async Ide.SymbolTree? get_symbol_tree_async (GLib.File file,
+ GLib.Cancellable? cancellable)
+ throws GLib.Error
+ {
+ return null;
+ }
+
+ public async Ide.Symbol? lookup_symbol_async (Ide.SourceLocation location,
+ GLib.Cancellable? cancellable)
+ throws GLib.Error
+ {
+ Vala.Symbol? symbol = null;
+
+ var context = this.get_context ();
+ var service = (Ide.ValaService)context.get_service_typed (typeof (Ide.ValaService));
+ var index = service.index;
+ var file = location.get_file ();
+ var line = (int)location.get_line () + 1;
+ var column = (int)location.get_line_offset () + 1;
+
+ symbol = yield index.find_symbol_at (file.get_file (), line, column);
+
+ if (symbol != null) {
+ var kind = Ide.SymbolKind.FUNCTION;
+ var flags = Ide.SymbolFlags.SYMBOL_FLAGS_NONE;
+ var source_reference = symbol.source_reference;
+
+ if (source_reference != null) {
+ var loc = new Ide.SourceLocation (file,
+ source_reference.begin.line - 1,
+ source_reference.begin.column - 1,
+ 0);
+ return new Ide.Symbol (symbol.name, kind, flags, loc, loc, loc);
+ }
+ }
+
+ return null;
+ }
+ }
+}
+
diff --git a/plugins/vala-pack/vala-pack.plugin b/plugins/vala-pack/vala-pack.plugin
index 50f1cf6..9bb3a62 100644
--- a/plugins/vala-pack/vala-pack.plugin
+++ b/plugins/vala-pack/vala-pack.plugin
@@ -10,3 +10,5 @@ X-Completion-Provider-Languages=vala
X-Diagnostic-Provider-Languages=vala
X-Indenter-Languages=vala
X-Indenter-Languages-Priority=0
+X-Symbol-Resolver-Languages=vala
+X-Symbol-Resolver-Languages-Priority=100
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]