[gnome-builder] vala-pack: Improve Vala completion. Allow completion inside lambda expressions.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] vala-pack: Improve Vala completion. Allow completion inside lambda expressions.
- Date: Sun, 18 Oct 2015 16:25:14 +0000 (UTC)
commit 9ac26c912465549b18f68048293604f8f0e28087
Author: Yannick Inizan <inizan yannick gmail com>
Date: Fri Oct 16 10:31:33 2015 +0200
vala-pack: Improve Vala completion. Allow completion inside lambda expressions.
https://bugzilla.gnome.org/show_bug.cgi?id=756661
.../vala-pack/ide-vala-completion-provider.vala | 25 +++++++++---------
plugins/vala-pack/ide-vala-index.vala | 9 +-----
plugins/vala-pack/ide-vala-locator.vala | 27 ++++++++++++++++++-
3 files changed, 40 insertions(+), 21 deletions(-)
---
diff --git a/plugins/vala-pack/ide-vala-completion-provider.vala
b/plugins/vala-pack/ide-vala-completion-provider.vala
index 499d570..b4ca166 100644
--- a/plugins/vala-pack/ide-vala-completion-provider.vala
+++ b/plugins/vala-pack/ide-vala-completion-provider.vala
@@ -76,28 +76,29 @@ namespace Ide
context.cancelled.connect(() => {
cancellable.cancel ();
});
-
- index.code_complete.begin (file.file,
+
+ Ide.ThreadPool.push (Ide.ThreadPoolKind.INDEXER, () => {
+ int res_line = -1;
+ int res_column = -1;
+ this.results = index.code_complete (file.file,
iter.get_line () + 1,
iter.get_line_offset () + 1,
line,
unsaved_files,
this,
cancellable,
- (obj,res) => {
- int res_line = -1;
- int res_column = -1;
-
- this.results = index.code_complete.end (res, out res_line, out res_column);
-
- if (res_line > 0 && res_column > 0) {
+ out res_line,
+ out res_column);
+ if (res_line > 0 && res_column > 0) {
this.line = res_line - 1;
this.column = res_column - 1;
}
- if (!cancellable.is_cancelled ()) {
- this.results.present (this, context);
- }
+ Idle.add (() => {
+ if (!cancellable.is_cancelled ())
+ this.results.present (this, context);
+ return false;
+ });
});
}
diff --git a/plugins/vala-pack/ide-vala-index.vala b/plugins/vala-pack/ide-vala-index.vala
index 093b5e9..676b6f3 100644
--- a/plugins/vala-pack/ide-vala-index.vala
+++ b/plugins/vala-pack/ide-vala-index.vala
@@ -168,7 +168,7 @@ namespace Ide
return true;
}
- public async Ide.CompletionResults code_complete (GLib.File file,
+ public Ide.CompletionResults code_complete (GLib.File file,
int line,
int column,
string? line_text,
@@ -181,8 +181,7 @@ namespace Ide
var unsaved_files_copy = unsaved_files.to_array ();
var result = new Ide.CompletionResults (provider.query);
- Ide.ThreadPool.push (Ide.ThreadPoolKind.COMPILER, () => {
- if ((cancellable == null) || !cancellable.is_cancelled ()) {
+ if ((cancellable == null) || !cancellable.is_cancelled ()) {
lock (this.code_context) {
Vala.CodeContext.push (this.code_context);
@@ -203,10 +202,6 @@ namespace Ide
}
}
- GLib.Idle.add(code_complete.callback);
- });
-
- yield;
result_line = line;
result_column = column;
diff --git a/plugins/vala-pack/ide-vala-locator.vala b/plugins/vala-pack/ide-vala-locator.vala
index 92d93e6..84a84b1 100644
--- a/plugins/vala-pack/ide-vala-locator.vala
+++ b/plugins/vala-pack/ide-vala-locator.vala
@@ -151,8 +151,31 @@ namespace Ide {
public override void visit_lock_statement (Vala.LockStatement stmt) {
stmt.accept_children(this);
}
- public override void visit_lambda_expression (Vala.LambdaExpression expr) {
- expr.accept_children(this);
+ public override void visit_expression_statement (Vala.ExpressionStatement stmt) {
+ stmt.accept_children (this);
+ }
+ public override void visit_declaration_statement (Vala.DeclarationStatement stmt) {
+ stmt.accept_children (this);
+ }
+ public override void visit_local_variable (Vala.LocalVariable variable) {
+ variable.accept_children (this);
+ }
+ public override void visit_end_full_expression (Vala.Expression expr) {
+ if (expr is Vala.LambdaExpression)
+ visit_method ((expr as Vala.LambdaExpression).method);
+ if (expr is Vala.MethodCall) {
+ foreach (Vala.Expression e in (expr as Vala.MethodCall).get_argument_list()) {
+ visit_expression (e);
+ }
+ }
+ }
+ public override void visit_expression (Vala.Expression expr) {
+ if (expr is Vala.LambdaExpression)
+ visit_method ((expr as Vala.LambdaExpression).method);
+ if (expr is Vala.MethodCall) {
+ foreach (Vala.Expression e in (expr as Vala.MethodCall).get_argument_list())
+ visit_expression (e);
+ }
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]