[anjuta] am-project: bgo#683728 - Project browser is not updated when files are added or removed
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] am-project: bgo#683728 - Project browser is not updated when files are added or removed
- Date: Sun, 14 Oct 2012 17:59:20 +0000 (UTC)
commit f5f2443fa1a3cfecf4bcc2cc12f64ddac69a4fd6
Author: SÃbastien Granjoux <seb sfo free fr>
Date: Sun Oct 14 19:57:46 2012 +0200
am-project: bgo#683728 - Project browser is not updated when files are added or removed
libanjuta/anjuta-token-file.c | 2 -
libanjuta/anjuta-token-list.c | 51 ++++++++++++++++--------------
libanjuta/anjuta-token.c | 4 ++-
plugins/am-project/tests/data_target.at | 2 +-
plugins/am-project/tests/source.at | 49 +++++++++++++++++++++++++++++
5 files changed, 80 insertions(+), 28 deletions(-)
---
diff --git a/libanjuta/anjuta-token-file.c b/libanjuta/anjuta-token-file.c
index 49ef23b..c39e3ed 100644
--- a/libanjuta/anjuta-token-file.c
+++ b/libanjuta/anjuta-token-file.c
@@ -238,8 +238,6 @@ anjuta_token_file_remove_token (AnjutaTokenFile *file, AnjutaToken *token)
AnjutaToken *next = NULL;
if (token != NULL) next = anjuta_token_foreach_post_order (token, remove_raw_token, file);
-
- next = anjuta_token_free (token);
file->dirty = TRUE;
return next;
diff --git a/libanjuta/anjuta-token-list.c b/libanjuta/anjuta-token-list.c
index 4b7e097..c80214b 100644
--- a/libanjuta/anjuta-token-list.c
+++ b/libanjuta/anjuta-token-list.c
@@ -354,7 +354,7 @@ anjuta_token_first_word (AnjutaToken *list)
item = NULL;
break;
default:
- if (anjuta_token_is_empty (item)) continue;
+ if (anjuta_token_is_empty (item) || (anjuta_token_get_flags(item) & ANJUTA_TOKEN_REMOVED)) continue;
break;
}
break;
@@ -384,7 +384,7 @@ anjuta_token_next_word (AnjutaToken *item)
next = NULL;
break;
default:
- if (anjuta_token_is_empty (next)) continue;
+ if (anjuta_token_is_empty (next) || (anjuta_token_get_flags(next) & ANJUTA_TOKEN_REMOVED)) continue;
break;
}
break;
@@ -662,39 +662,42 @@ anjuta_token_remove_list (AnjutaToken *list)
AnjutaToken *next;
AnjutaToken *prev;
- anjuta_token_set_flags (list, ANJUTA_TOKEN_REMOVED);
-
- prev = anjuta_token_previous_item (list);
- if (prev != NULL)
+ if (!(anjuta_token_get_flags(list) & ANJUTA_TOKEN_REMOVED))
{
- if (anjuta_token_get_type (prev) == ANJUTA_TOKEN_EOL)
- {
- /* Remove line above if empty */
- AnjutaToken *prev_prev = anjuta_token_previous_item (prev);
+ anjuta_token_set_flags (list, ANJUTA_TOKEN_REMOVED);
- if ((prev_prev == NULL) || (anjuta_token_get_type (prev_prev) == ANJUTA_TOKEN_EOL) || (anjuta_token_get_type (prev_prev) == ANJUTA_TOKEN_COMMENT))
- {
- anjuta_token_set_flags (prev, ANJUTA_TOKEN_REMOVED);
- }
- }
- else if (anjuta_token_get_type (prev) == ANJUTA_TOKEN_COMMENT)
+ prev = anjuta_token_previous_item (list);
+ if (prev != NULL)
{
- /* Remove comment above if there is an empty line after it */
- do
+ if (anjuta_token_get_type (prev) == ANJUTA_TOKEN_EOL)
{
- prev = anjuta_token_previous_item (prev);
- }
- while ((prev != NULL) && (anjuta_token_get_type (prev) == ANJUTA_TOKEN_COMMENT));
+ /* Remove line above if empty */
+ AnjutaToken *prev_prev = anjuta_token_previous_item (prev);
- if ((prev != NULL) && (anjuta_token_get_type (prev) == ANJUTA_TOKEN_EOL))
+ if ((prev_prev == NULL) || (anjuta_token_get_type (prev_prev) == ANJUTA_TOKEN_EOL) || (anjuta_token_get_type (prev_prev) == ANJUTA_TOKEN_COMMENT))
+ {
+ anjuta_token_set_flags (prev, ANJUTA_TOKEN_REMOVED);
+ }
+ }
+ else if (anjuta_token_get_type (prev) == ANJUTA_TOKEN_COMMENT)
{
- prev = list;
+ /* Remove comment above if there is an empty line after it */
do
{
- anjuta_token_set_flags (prev, ANJUTA_TOKEN_REMOVED);
prev = anjuta_token_previous_item (prev);
}
while ((prev != NULL) && (anjuta_token_get_type (prev) == ANJUTA_TOKEN_COMMENT));
+
+ if ((prev != NULL) && (anjuta_token_get_type (prev) == ANJUTA_TOKEN_EOL))
+ {
+ prev = list;
+ do
+ {
+ anjuta_token_set_flags (prev, ANJUTA_TOKEN_REMOVED);
+ prev = anjuta_token_previous_item (prev);
+ }
+ while ((prev != NULL) && (anjuta_token_get_type (prev) == ANJUTA_TOKEN_COMMENT));
+ }
}
}
}
diff --git a/libanjuta/anjuta-token.c b/libanjuta/anjuta-token.c
index fbeaf1a..4cca2af 100644
--- a/libanjuta/anjuta-token.c
+++ b/libanjuta/anjuta-token.c
@@ -161,6 +161,7 @@ anjuta_token_next_child (AnjutaToken *child, AnjutaToken **last)
break;
}
child = child->parent;
+ if (child == NULL) break;
}
}
@@ -1371,8 +1372,9 @@ anjuta_token_foreach_content (AnjutaToken *token, AnjutaTokenForeachFunc func, g
{
/* Get parent */
token = token->parent;
- if (token != NULL) last_parent = token->last;
expand = FALSE;
+ if (token == NULL) break;
+ last_parent = token->last;
}
}
}
diff --git a/plugins/am-project/tests/data_target.at b/plugins/am-project/tests/data_target.at
index 80f9c40..034bedc 100644
--- a/plugins/am-project/tests/data_target.at
+++ b/plugins/am-project/tests/data_target.at
@@ -90,7 +90,7 @@ data_DATA = data4.txt \
]])
AT_PARSER_CHECK([load data1 \
move data2 \
- add target 0 target3 data \
+ add target 0 data data \
add source 0:3 data4.txt \
add source 0:3 data5.txt \
list \
diff --git a/plugins/am-project/tests/source.at b/plugins/am-project/tests/source.at
index dec8010..d01e914 100644
--- a/plugins/am-project/tests/source.at
+++ b/plugins/am-project/tests/source.at
@@ -179,4 +179,53 @@ AT_CHECK([diff -b output expect])
+AS_MKDIR_P([empty7])
+AT_DATA([empty7/configure.ac],
+[[AC_CONFIG_FILES(Makefile)
+]])
+AT_DATA([empty7/Makefile.am],
+[[
+bin_PROGRAMS = target1
+
+target1_SOURCES = source1.c source2.c
+]])
+AT_DATA([reference],
+[[
+bin_PROGRAMS = target1
+
+target1_SOURCES = source2.c
+]])
+AT_PARSER_CHECK([load empty7 \
+ remove 0:2:0 \
+ remove 0:2:0 \
+ list \
+ save])
+AT_CHECK([diff -b empty7/Makefile.am reference])
+
+
+
+AS_MKDIR_P([empty8])
+AT_DATA([empty8/configure.ac],
+[[AC_CONFIG_FILES(Makefile)
+]])
+AT_DATA([empty8/Makefile.am],
+[[
+bin_PROGRAMS = target1
+
+target1_SOURCES = source1.c
+]])
+AT_DATA([reference],
+[[
+bin_PROGRAMS = target1
+
+target1_SOURCES =
+]])
+AT_PARSER_CHECK([load empty8 \
+ remove 0:2:0 \
+ remove 0:2:0 \
+ list \
+ save])
+
+
+
AT_CLEANUP
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]