[valencia] Manually wipe Valencia's loaded symbols
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [valencia] Manually wipe Valencia's loaded symbols
- Date: Tue, 19 Aug 2014 20:01:11 +0000 (UTC)
commit f78860508edbe8147d1743aa668c76019c365092
Author: Jim Nelson <jim yorba org>
Date: Tue Aug 19 12:49:36 2014 -0700
Manually wipe Valencia's loaded symbols
Because Valencia can't detect when a file has been changed outside of
gedit or renamed, it's possible for its symbol table to get out of
sync with the actual file contents. A better solution would be to
detect these changes and reload, but until that occurs, this menu item
allows for all symbols to be wiped from memory. The next time the
user does a symbol lookup, Valencia will reload all symbols (much as
if the user had quit and restart gedit).
program.vala | 29 ++++++++++++++++++++++++++---
valencia.vala | 10 +++++++++-
2 files changed, 35 insertions(+), 4 deletions(-)
---
diff --git a/program.vala b/program.vala
index 6251619..35c795c 100644
--- a/program.vala
+++ b/program.vala
@@ -1094,6 +1094,8 @@ public class Program : Object {
public ConfigurationFile config_file;
bool recursive_project;
+ uint local_parse_source_id = 0;
+ uint system_parse_source_id = 0;
signal void local_parse_complete();
public signal void system_parse_complete();
@@ -1118,11 +1120,24 @@ public class Program : Object {
recursive_project = false;
}
- Idle.add(parse_local_vala_files_idle_callback);
+ local_parse_source_id = Idle.add(parse_local_vala_files_idle_callback);
programs.add(this);
}
-
+
+ ~Program() {
+ if (local_parse_source_id != 0)
+ Source.remove(local_parse_source_id);
+
+ if (system_parse_source_id != 0)
+ Source.remove(system_parse_source_id);
+ }
+
+ public static void wipe() {
+ programs.clear();
+ system_sources.clear();
+ }
+
// Returns true if a BUILD_ROOT or configure.ac was found: files should be found recursively
// False if only the local directory will be used
bool get_build_root_directory(GLib.File makefile_dir) {
@@ -1212,6 +1227,8 @@ public class Program : Object {
}
bool parse_local_vala_files_idle_callback() {
+ local_parse_source_id = 0;
+
if (sourcefile_paths.is_empty) {
// Don't parse system files locally!
foreach (string system_directory in get_system_vapi_directories()) {
@@ -1237,6 +1254,8 @@ public class Program : Object {
}
bool parse_system_vala_files_idle_callback() {
+ system_parse_source_id = 0;
+
if (sourcefile_paths.size == 0) {
foreach (string system_directory in get_system_vapi_directories()) {
cache_source_paths_in_directory(system_directory, true);
@@ -1346,7 +1365,11 @@ public class Program : Object {
parsing = true;
parse_list_index = 0;
sourcefile_paths.clear();
- Idle.add(this.parse_system_vala_files_idle_callback);
+
+ if (system_parse_source_id != 0)
+ Source.remove(system_parse_source_id);
+
+ system_parse_source_id = Idle.add(this.parse_system_vala_files_idle_callback);
}
}
diff --git a/valencia.vala b/valencia.vala
index cf5d0b7..500d863 100644
--- a/valencia.vala
+++ b/valencia.vala
@@ -197,7 +197,9 @@ public class Instance : Peas.ExtensionBase, Gedit.WindowActivatable {
{ "ProjectRun", Gtk.Stock.EXECUTE, "_Run", "<ctrl><alt>r",
"Run the program", on_run },
{ "ProjectSettings", Gtk.Stock.PROPERTIES, "_Settings", "<ctrl><alt>t",
- "Customize the build and clean commands", on_project_settings }
+ "Customize the build and clean commands", on_project_settings },
+ { "ProjectWipeValencia", null, "Wipe _Valencia Symbols", null,
+ "Wipe Valencia's discovered symbols and rebuild", on_wipe_valencia }
};
const string ui = """
@@ -223,6 +225,8 @@ public class Instance : Peas.ExtensionBase, Gedit.WindowActivatable {
<menuitem name="ProjectCleanMenu" action="ProjectClean"/>
<menuitem name="ProjectRunMenu" action="ProjectRun"/>
<menuitem name="ProjectSettingsMenu" action="ProjectSettings"/>
+ <separator/>
+ <menuitem name="ProjectWipeValenciaMenu" action="ProjectWipeValencia"/>
</menu>
</placeholder>
</menubar>
@@ -1484,6 +1488,10 @@ public class Instance : Peas.ExtensionBase, Gedit.WindowActivatable {
settings_dialog.show(filename);
}
+ void on_wipe_valencia() {
+ Program.wipe();
+ }
+
void on_settings_changed(string new_build_command, string new_clean_command, string new_pkg_blacklist) {
Program program = get_active_document_program();
program.config_file.update(new_build_command, new_clean_command, new_pkg_blacklist);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]