[vala/switch-to-gir: 6/37] Support adding new source files while visiting the code tree.



commit 69a123809386b0a916b87b93196847f3adb9190b
Author: Luca Bruno <lethalman88 gmail com>
Date:   Mon Aug 23 20:51:48 2010 +0200

    Support adding new source files while visiting the code tree.

 vala/valacodecontext.vala |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/vala/valacodecontext.vala b/vala/valacodecontext.vala
index 92bf449..efcdc38 100644
--- a/vala/valacodecontext.vala
+++ b/vala/valacodecontext.vala
@@ -436,14 +436,19 @@ public class Vala.CodeContext {
 
 	/**
 	 * Visits the complete code tree file by file.
+	 * It is possible to add new source files while visiting the tree.
 	 *
 	 * @param visitor the visitor to be called when traversing
 	 */
 	public void accept (CodeVisitor visitor) {
 		root.accept (visitor);
 
-		foreach (SourceFile file in source_files) {
-			file.accept (visitor);
+		// support queueing new source files
+		int index = 0;
+		while (index < source_files.size) {
+			var source_file = source_files[index];
+			source_file.accept (visitor);
+			index++;
 		}
 	}
 



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