[anjuta] language-support-vala: interrupt parsing if user switches to another file



commit 7fda205e240e1aef38c12ff6a62d61323fe757ed
Author: Abderrahim Kitouni <a kitouni gmail com>
Date:   Wed Aug 25 14:03:22 2010 +0100

    language-support-vala: interrupt parsing if user switches to another file

 plugins/language-support-vala/plugin.vala |   32 +++++++++++++++++++++-------
 1 files changed, 24 insertions(+), 8 deletions(-)
---
diff --git a/plugins/language-support-vala/plugin.vala b/plugins/language-support-vala/plugin.vala
index fe2166b..6eab46f 100644
--- a/plugins/language-support-vala/plugin.vala
+++ b/plugins/language-support-vala/plugin.vala
@@ -24,6 +24,7 @@ public class ValaPlugin : Plugin {
 	uint editor_watch_id;
 
 	Vala.CodeContext context;
+	Cancellable cancel;
 	Vala.Map<string,Vala.SourceFile> source_files;
 	BlockLocator locator = new BlockLocator ();
 
@@ -46,6 +47,17 @@ public class ValaPlugin : Plugin {
 		context.report = report;
 		context.profile = Vala.Profile.GOBJECT;
 
+		cancel = new Cancellable ();
+		parser = new Vala.Parser ();
+		genie_parser = new Vala.Genie.Parser ();
+		resolver = new Vala.SymbolResolver ();
+		analyzer = new Vala.SemanticAnalyzer ();
+
+		/* This doesn't actually parse anything as there are no files yet,
+		   it's just to set the context in the parsers */
+		parser.parse (context);
+		genie_parser.parse (context);
+
 		var project = (IAnjuta.ProjectManager) shell.get_object("IAnjutaProjectManager");
 		weak List<string> packages = project.get_packages();
 		context.add_package("glib-2.0");
@@ -79,20 +91,23 @@ public class ValaPlugin : Plugin {
 				Vala.CodeContext.push(context);
 				var report = context.report as AnjutaReport;
 
-				parser = new Vala.Parser ();
-				genie_parser = new Vala.Genie.Parser ();
-				resolver = new Vala.SymbolResolver ();
-				analyzer = new Vala.SemanticAnalyzer ();
+				foreach (var src in context.get_source_files ()) {
+					parser.visit_source_file (src);
+					genie_parser.visit_source_file (src);
+
+					if (cancel.is_cancelled ()) {
+						Vala.CodeContext.pop();
+						return null;
+					}
+				}
 
-				parser.parse (context);
-				genie_parser.parse (context);
-				if (report.errors_found ()) {
+				if (report.errors_found () || cancel.is_cancelled ()) {
 					Vala.CodeContext.pop();
 					return null;
 				}
 
 				resolver.resolve (context);
-				if (report.errors_found ()) {
+				if (report.errors_found () || cancel.is_cancelled ()) {
 					Vala.CodeContext.pop();
 					/* TODO: there may be missing packages */
 					return null;
@@ -123,6 +138,7 @@ public class ValaPlugin : Plugin {
 		//debug("Deactivating ValaPlugin");
 		remove_watch(editor_watch_id, true);
 
+		cancel.cancel ();
 		lock (context) {
 			context = null;
 			source_files = null;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]