[vala] Support adding new source files while visiting the code tree



commit e7f9337490a0a272ef5905655748bf6ad5d9b871
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 8525fff..988a864 100644
--- a/vala/valacodecontext.vala
+++ b/vala/valacodecontext.vala
@@ -428,14 +428,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]