[gnome-builder/gnome-builder-3-18] vala: add function to locate a symbol from the index
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/gnome-builder-3-18] vala: add function to locate a symbol from the index
- Date: Tue, 13 Oct 2015 07:24:31 +0000 (UTC)
commit 1f7b15f09ad82604603ca6a01e5cd6ae1b2c51ba
Author: Christian Hergert <christian hergert me>
Date: Sat Sep 26 01:29:21 2015 -0700
vala: add function to locate a symbol from the index
plugins/vala-pack/ide-vala-index.vala | 36 +++++++++++++++++++++++++++++++++
1 files changed, 36 insertions(+), 0 deletions(-)
---
diff --git a/plugins/vala-pack/ide-vala-index.vala b/plugins/vala-pack/ide-vala-index.vala
index 899101e..a90b1ad 100644
--- a/plugins/vala-pack/ide-vala-index.vala
+++ b/plugins/vala-pack/ide-vala-index.vala
@@ -291,5 +291,41 @@ namespace Ide
line = cursor.line;
column = cursor.column;
}
+
+ public async Vala.Symbol? find_symbol_at (GLib.File file, int line, int column)
+ {
+ Vala.Symbol? symbol = null;
+
+ /*
+ * TODO: This isn't quite right because the locator is finding
+ * us the nearest block instead of the symbol. We need to
+ * adjust the locator to find the exact expression.
+ */
+
+ Ide.ThreadPool.push (Ide.ThreadPoolKind.COMPILER, () => {
+ lock (this.code_context) {
+ Vala.CodeContext.push (this.code_context);
+
+ if (!this.source_files.contains (file)) {
+ this.add_file (file);
+ this.reparse ();
+ }
+
+ var source_file = this.source_files [file];
+ var locator = new Ide.ValaLocator ();
+
+ symbol = locator.locate (source_file, line, column);
+
+ Vala.CodeContext.pop ();
+ }
+
+ this.find_symbol_at.callback ();
+ });
+
+ yield;
+
+ return symbol;
+ }
}
}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]