[gnome-builder/gnome-builder-3-18] vala: cleanup adding a file to the index



commit efd18f11ff4530a71d4a057221ae4eb07e5e97a9
Author: Christian Hergert <christian hergert me>
Date:   Sat Sep 26 01:28:55 2015 -0700

    vala: cleanup adding a file to the index

 plugins/vala-pack/ide-vala-index.vala |   30 +++++++++++++++++-------------
 1 files changed, 17 insertions(+), 13 deletions(-)
---
diff --git a/plugins/vala-pack/ide-vala-index.vala b/plugins/vala-pack/ide-vala-index.vala
index d03526d..899101e 100644
--- a/plugins/vala-pack/ide-vala-index.vala
+++ b/plugins/vala-pack/ide-vala-index.vala
@@ -107,26 +107,27 @@ namespace Ide
                        Vala.CodeContext.pop ();
                }
 
+               void add_file (GLib.File file)
+               {
+                       var path  =file.get_path ();
+                       if (path == null)
+                               return;
+
+                       var source_file = new Ide.ValaSourceFile (this.code_context, 
Vala.SourceFileType.SOURCE, path, null, false);
+                       this.code_context.add_source_file (source_file);
+
+                       this.source_files [file] = source_file;
+               }
+
                public async void add_files (ArrayList<GLib.File> files,
                                             GLib.Cancellable? cancellable)
                {
                        Ide.ThreadPool.push (Ide.ThreadPoolKind.COMPILER, () => {
                                lock (this.code_context) {
                                        Vala.CodeContext.push (this.code_context);
-
-                                       foreach (var file in files) {
-                                               var path = file.get_path ();
-                                               if (path == null)
-                                                       continue;
-
-                                               var source_file = new Ide.ValaSourceFile (this.code_context, 
Vala.SourceFileType.SOURCE, path, null, false);
-                                               this.code_context.add_source_file (source_file);
-
-                                               this.source_files[file] = source_file;
-                                       }
-
+                                       foreach (var file in files)
+                                               this.add_file (file);
                                        Vala.CodeContext.pop ();
-
                                        GLib.Idle.add(add_files.callback);
                                }
                        });
@@ -150,6 +151,9 @@ namespace Ide
                                        lock (this.code_context) {
                                                Vala.CodeContext.push (this.code_context);
 
+                                               if (!this.source_files.contains (file))
+                                                       this.add_file (file);
+
                                                this.apply_unsaved_files (unsaved_files_copy);
                                                this.reparse ();
                                                this.code_context.check ();


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