[gnome-builder] vala: add function to locate a symbol from the index



commit 32ab04c3383fc01d4af0ff01869f524a61cdd81b
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]