[anjuta] am-project: bgo #636410 - Unable to delete data target



commit d7b89849cd14e4138d2f5e8e7ffb862cd5ccd22e
Author: Sébastien Granjoux <seb sfo free fr>
Date:   Sat Mar 5 15:48:44 2011 +0100

    am-project: bgo #636410 - Unable to delete data target

 libanjuta/anjuta-token-list.c      |    6 +-
 plugins/am-project/am-parser.y     |    4 +-
 plugins/am-project/am-project.c    |   71 ++++++++++++---------
 plugins/am-project/am-scanner.h    |    4 +-
 plugins/am-project/am-scanner.l    |    4 +-
 plugins/am-project/am-writer.c     |  118 +++++++++++++++++++++++-------------
 plugins/am-project/amp-target.c    |    2 +-
 plugins/am-project/tests/target.at |   46 ++++++++++++++
 8 files changed, 171 insertions(+), 84 deletions(-)
---
diff --git a/libanjuta/anjuta-token-list.c b/libanjuta/anjuta-token-list.c
index 0b96adc..d03c238 100644
--- a/libanjuta/anjuta-token-list.c
+++ b/libanjuta/anjuta-token-list.c
@@ -649,20 +649,18 @@ anjuta_token_remove_word (AnjutaToken *token)
 
 /**
  * anjuta_token_remove_list:
- * @token: a #AnjutaToken a list element
+ * @token: a #AnjutaToken corresponding to a list
  *
  * Remove a complete list of token.
  *
  * Return value: A #AnjutaToken representing the following token
  */
 AnjutaToken *
-anjuta_token_remove_list (AnjutaToken *token)
+anjuta_token_remove_list (AnjutaToken *list)
 {
-	AnjutaToken *list;
 	AnjutaToken *next;
 	AnjutaToken *prev;
 
-	list = anjuta_token_list (token);
 	anjuta_token_set_flags (list, ANJUTA_TOKEN_REMOVED);
 
 	prev = anjuta_token_previous_item (list);
diff --git a/plugins/am-project/am-parser.y b/plugins/am-project/am-parser.y
index 4e828b0..6190efd 100644
--- a/plugins/am-project/am-parser.y
+++ b/plugins/am-project/am-parser.y
@@ -192,7 +192,7 @@ am_variable:
 		if ($3 != NULL) anjuta_token_set_type ($3, ANJUTA_TOKEN_NEXT);
 		anjuta_token_merge ($$, $4);
 		anjuta_token_merge ($$, $5);
-		amp_am_scanner_set_am_variable (scanner, amp_am_automake_variable ($2), $2, anjuta_token_last_item ($$));
+		amp_am_scanner_set_am_variable (scanner, $$);
 	}
 	| optional_space automake_token optional_space equal_token
 	{
@@ -202,7 +202,7 @@ am_variable:
 		$$ = anjuta_token_new_static (amp_am_automake_variable ($2), NULL);
 		anjuta_token_merge ($$, $2);
 		anjuta_token_merge ($$, list);
-		amp_am_scanner_set_am_variable (scanner, amp_am_automake_variable ($2), $2, anjuta_token_last_item ($$));
+		amp_am_scanner_set_am_variable (scanner, $$);
 	}
 	;
 
diff --git a/plugins/am-project/am-project.c b/plugins/am-project/am-project.c
index edf0f5d..38dc2c6 100644
--- a/plugins/am-project/am-project.c
+++ b/plugins/am-project/am-project.c
@@ -810,7 +810,7 @@ amp_project_load_config (AmpProject *project, AnjutaToken *arg_list)
 }
 
 static AnjutaToken*
-project_load_target (AmpProject *project, AnjutaToken *name, AnjutaTokenType token_type, AnjutaToken *list, AnjutaProjectNode *parent, GHashTable *orphan_properties)
+project_load_target (AmpProject *project, AnjutaProjectNode *parent, AnjutaToken *variable, GHashTable *orphan_properties)
 {
 	AnjutaToken *arg;
 	gchar *install = NULL;
@@ -820,19 +820,19 @@ project_load_target (AmpProject *project, AnjutaToken *name, AnjutaTokenType tok
 
 	while (info->base.type != 0)
 	{
-		if (token_type == info->token)
+		if (anjuta_token_get_type (variable) == info->token)
 		{
 			break;
 		}
 		info++;
 	}
 
-	value = anjuta_token_evaluate (name);
+	value = anjuta_token_evaluate (anjuta_token_first_word (variable));
 	split_automake_variable (value, &flags, &install, NULL);
 
-	amp_group_node_add_token (AMP_GROUP_NODE (parent), name, AM_GROUP_TARGET);
+	amp_group_node_add_token (AMP_GROUP_NODE (parent), variable, AM_GROUP_TARGET);
 
-	for (arg = anjuta_token_first_word (list); arg != NULL; arg = anjuta_token_next_word (arg))
+	for (arg = anjuta_token_first_word (anjuta_token_last_item (variable)); arg != NULL; arg = anjuta_token_next_word (arg))
 	{
 		gchar *value;
 		gchar *canon_id;
@@ -950,13 +950,13 @@ project_load_target (AmpProject *project, AnjutaToken *name, AnjutaTokenType tok
 }
 
 static AnjutaToken*
-project_load_sources (AmpProject *project, AnjutaToken *name, AnjutaToken *list, AnjutaProjectNode *parent, GHashTable *orphan_properties)
+project_load_sources (AmpProject *project, AnjutaProjectNode *parent, AnjutaToken *variable, GHashTable *orphan_properties)
 {
 	AnjutaToken *arg;
 	GFile *parent_file = g_object_ref (anjuta_project_node_get_file (ANJUTA_PROJECT_NODE (parent)));
 	gchar *target_id = NULL;
 
-	target_id = anjuta_token_evaluate (name);
+	target_id = anjuta_token_evaluate (anjuta_token_first_word (variable));
 	if (target_id)
 	{
 		gchar *end = strrchr (target_id, '_');
@@ -996,9 +996,9 @@ project_load_sources (AmpProject *project, AnjutaToken *name, AnjutaToken *list,
 		{
 			g_free (target_id);
 		}
-		amp_target_node_add_token (AMP_TARGET_NODE (target), AM_TOKEN__SOURCES, name);
+		amp_target_node_add_token (AMP_TARGET_NODE (target), AM_TOKEN__SOURCES, variable);
 		
-		for (arg = anjuta_token_first_word (list); arg != NULL; arg = anjuta_token_next_word (arg))
+		for (arg = anjuta_token_first_word (anjuta_token_last_item (variable)); arg != NULL; arg = anjuta_token_next_word (arg))
 		{
 			gchar *value;
 			AnjutaProjectNode *source;
@@ -1030,7 +1030,7 @@ project_load_sources (AmpProject *project, AnjutaToken *name, AnjutaToken *list,
 }
 
 static AnjutaToken*
-project_load_data (AmpProject *project, AnjutaToken *name, AnjutaTokenType token_type, AnjutaToken *list, AnjutaProjectNode *parent, GHashTable *orphan_properties)
+project_load_data (AmpProject *project, AnjutaProjectNode *parent, AnjutaToken *variable, GHashTable *orphan_properties)
 {
 	gchar *install = NULL;
 	AmpTargetNode *target;
@@ -1039,20 +1039,21 @@ project_load_data (AmpProject *project, AnjutaToken *name, AnjutaTokenType token
 	gint flags = 0;
 	AmpNodeInfo *info = AmpNodeInformations; 
 	AnjutaToken *arg;
+	AnjutaToken *list;
 
 	while (info->base.name != NULL)
 	{
-		if (anjuta_token_get_type (name) == info->token)
+		if (anjuta_token_get_type (variable) == info->token)
 		{
 			break;
 		}
 		info++;
 	}
 
-	target_id = anjuta_token_evaluate (name);
+	target_id = anjuta_token_evaluate (anjuta_token_first_word (variable));
 	split_automake_variable (target_id, &flags, &install, NULL);
 	
-	amp_group_node_add_token (AMP_GROUP_NODE (parent), name, AM_GROUP_TARGET);
+	amp_group_node_add_token (AMP_GROUP_NODE (parent), variable, AM_GROUP_TARGET);
 
 	/* Check if target already exists */
 	find = target_id;
@@ -1075,10 +1076,10 @@ project_load_data (AmpProject *project, AnjutaToken *name, AnjutaTokenType token
 	if (target != NULL)
 	{
 		GFile *parent_file = g_object_ref (anjuta_project_node_get_file (parent));
-		
-		amp_target_node_add_token (AMP_TARGET_NODE (target), AM_TOKEN__DATA, name);
-		amp_target_node_add_token (AMP_TARGET_NODE (target), AM_TOKEN__SOURCES, name);
-		
+
+		amp_target_node_add_token (AMP_TARGET_NODE (target), AM_TOKEN__DATA, variable);
+
+		list = anjuta_token_last_item (variable);
 		for (arg = anjuta_token_first_word (list); arg != NULL; arg = anjuta_token_next_word (arg))
 		{
 			gchar *value;
@@ -1131,11 +1132,11 @@ project_load_data (AmpProject *project, AnjutaToken *name, AnjutaTokenType token
 }
 
 static AnjutaToken*
-project_load_target_properties (AmpProject *project, AnjutaToken *name, AnjutaTokenType type, AnjutaToken *list, AnjutaProjectNode *parent, GHashTable *orphan_properties)
+project_load_target_properties (AmpProject *project, AnjutaProjectNode *parent, AnjutaToken *variable, GHashTable *orphan_properties)
 {
 	gchar *target_id = NULL;
 	
-	target_id = anjuta_token_evaluate (name);
+	target_id = anjuta_token_evaluate (anjuta_token_first_word (variable));
 	if (target_id)
 	{
 		gchar *end = strrchr (target_id, '_');
@@ -1150,6 +1151,8 @@ project_load_target_properties (AmpProject *project, AnjutaToken *name, AnjutaTo
 		gpointer find;
 		gchar *value;
 		AnjutaProjectProperty *prop;
+		AnjutaToken *list;
+		AnjutaTokenType type;
 		
 		find = target_id;
 		DEBUG_PRINT ("search for canonical %s", target_id);
@@ -1157,6 +1160,8 @@ project_load_target_properties (AmpProject *project, AnjutaToken *name, AnjutaTo
 		parent = (gchar *)find != target_id ? (AnjutaProjectNode *)find : NULL;
 
 		/* Create property */
+		list = anjuta_token_last_item (variable);
+		type = anjuta_token_get_type (variable);
 		value = anjuta_token_evaluate (list);
 		prop = amp_property_new (NULL, type, 0, value, list);
 
@@ -1186,24 +1191,26 @@ project_load_target_properties (AmpProject *project, AnjutaToken *name, AnjutaTo
 
 		/* Add property to target */
 		amp_node_property_add (parent, prop);
-		amp_target_node_add_token (AMP_TARGET_NODE (parent), type, name);
+		amp_target_node_add_token (AMP_TARGET_NODE (parent), type, variable);
 	}
 
 	return NULL;
 }
 
 static AnjutaToken*
-project_load_group_properties (AmpProject *project, AnjutaToken *token, AnjutaTokenType type, AnjutaToken *list, AnjutaProjectNode *parent)
+project_load_group_properties (AmpProject *project, AnjutaProjectNode *parent, AnjutaToken *variable)
 {
 	gchar *value;
 	gchar *name;
 	AnjutaProjectProperty *prop;
+	AnjutaToken *list;
 		
 	/* Create property */
-	name = anjuta_token_evaluate (token);
+	list = anjuta_token_last_item (variable);
+	name = anjuta_token_evaluate (anjuta_token_first_word (variable));
 	value = anjuta_token_evaluate (list);
 
-	prop = amp_property_new (name, type, 0, value, list);
+	prop = amp_property_new (name, anjuta_token_get_type (variable), 0, value, list);
 
 	amp_node_property_add (parent, prop);
 	g_free (value);
@@ -1277,14 +1284,18 @@ project_load_subdirs (AmpProject *project, AnjutaToken *list, AnjutaProjectNode
 }
 
 void
-amp_project_set_am_variable (AmpProject* project, AmpGroupNode* group, AnjutaTokenType variable, AnjutaToken *name, AnjutaToken *list, GHashTable *orphan_properties)
+amp_project_set_am_variable (AmpProject* project, AmpGroupNode* group, AnjutaToken *variable, GHashTable *orphan_properties)
 {
-	switch (variable)
+	AnjutaToken *list;
+	
+	switch (anjuta_token_get_type (variable))
 	{
 	case AM_TOKEN_SUBDIRS:
+		list = anjuta_token_last_item (variable);
 		project_load_subdirs (project, list, ANJUTA_PROJECT_NODE (group), FALSE);
 		break;
 	case AM_TOKEN_DIST_SUBDIRS:
+		list = anjuta_token_last_item (variable);
 		project_load_subdirs (project, list, ANJUTA_PROJECT_NODE (group), TRUE);
 		break;
 	case AM_TOKEN__DATA:
@@ -1295,15 +1306,15 @@ amp_project_set_am_variable (AmpProject* project, AmpGroupNode* group, AnjutaTok
 	case AM_TOKEN__JAVA:
 	case AM_TOKEN__SCRIPTS:
 	case AM_TOKEN__TEXINFOS:
-		project_load_data (project, name, variable, list, ANJUTA_PROJECT_NODE (group), orphan_properties);
+		project_load_data (project, ANJUTA_PROJECT_NODE (group), variable, orphan_properties);
 		break;
 	case AM_TOKEN__LIBRARIES:
 	case AM_TOKEN__LTLIBRARIES:
 	case AM_TOKEN__PROGRAMS:
-		project_load_target (project, name, variable, list, ANJUTA_PROJECT_NODE (group), orphan_properties);
+		project_load_target (project, ANJUTA_PROJECT_NODE (group), variable, orphan_properties);
 		break;
 	case AM_TOKEN__SOURCES:
-		project_load_sources (project, name, list, ANJUTA_PROJECT_NODE (group), orphan_properties);
+		project_load_sources (project, ANJUTA_PROJECT_NODE (group), variable, orphan_properties);
 		break;
 	case AM_TOKEN_DIR:
 	case AM_TOKEN__LDFLAGS:
@@ -1316,7 +1327,7 @@ amp_project_set_am_variable (AmpProject* project, AmpGroupNode* group, AnjutaTok
 	case AM_TOKEN__OBJCFLAGS:
 	case AM_TOKEN__LFLAGS:
 	case AM_TOKEN__YFLAGS:
-		project_load_group_properties (project, name, variable, list, ANJUTA_PROJECT_NODE (group));
+		project_load_group_properties (project, ANJUTA_PROJECT_NODE (group), variable);
 		break;
 	case AM_TOKEN_TARGET_LDFLAGS:
 	case AM_TOKEN_TARGET_CPPFLAGS:
@@ -1331,7 +1342,7 @@ amp_project_set_am_variable (AmpProject* project, AmpGroupNode* group, AnjutaTok
 	case AM_TOKEN_TARGET_DEPENDENCIES:
 	case AM_TOKEN_TARGET_LIBADD:
 	case AM_TOKEN_TARGET_LDADD:
-		project_load_target_properties (project, name, variable, list, ANJUTA_PROJECT_NODE (group), orphan_properties);
+		project_load_target_properties (project, ANJUTA_PROJECT_NODE (group), variable, orphan_properties);
 		break;
 	default:
 		break;
diff --git a/plugins/am-project/am-scanner.h b/plugins/am-project/am-scanner.h
index d7327e0..870e254 100644
--- a/plugins/am-project/am-scanner.h
+++ b/plugins/am-project/am-scanner.h
@@ -41,11 +41,11 @@ void amp_am_scanner_free (AmpAmScanner *scanner);
 
 AnjutaToken *amp_am_scanner_parse_token (AmpAmScanner *scanner, AnjutaToken *root, AnjutaToken *content, GFile *filename, GError **error);
 
-void amp_am_scanner_set_am_variable (AmpAmScanner *scanner, AnjutaTokenType variable, AnjutaToken *name, AnjutaToken *list);
+void amp_am_scanner_set_am_variable (AmpAmScanner *scanner, AnjutaToken *variable);
 void amp_am_scanner_include (AmpAmScanner *scanner, AnjutaToken *name);
 void amp_am_scanner_update_variable (AmpAmScanner *scanner, AnjutaToken *variable);
 
-void amp_project_set_am_variable (AmpProject* project, AmpGroupNode* group, AnjutaTokenType variable, AnjutaToken *name, AnjutaToken *list, GHashTable *orphan_properties);
+void amp_project_set_am_variable (AmpProject* project, AmpGroupNode* group, AnjutaToken *variable, GHashTable *orphan_properties);
 
 
 void amp_am_yyerror (YYLTYPE *loc, AmpAmScanner *scanner, char const *s);
diff --git a/plugins/am-project/am-scanner.l b/plugins/am-project/am-scanner.l
index 678bba7..c5dad7f 100644
--- a/plugins/am-project/am-scanner.l
+++ b/plugins/am-project/am-scanner.l
@@ -260,9 +260,9 @@ amp_am_yyerror (YYLTYPE *loc, AmpAmScanner *scanner, char const *s)
 }
 
 void
-amp_am_scanner_set_am_variable (AmpAmScanner *scanner, AnjutaTokenType variable, AnjutaToken *name, AnjutaToken *list)
+amp_am_scanner_set_am_variable (AmpAmScanner *scanner, AnjutaToken *variable)
 {
-    amp_project_set_am_variable (scanner->project, scanner->group, variable, name, list, scanner->orphan_properties);
+    amp_project_set_am_variable (scanner->project, scanner->group, variable, scanner->orphan_properties);
 }
 
 void
diff --git a/plugins/am-project/am-writer.c b/plugins/am-project/am-writer.c
index 9d8a5be..389f5fa 100644
--- a/plugins/am-project/am-writer.c
+++ b/plugins/am-project/am-writer.c
@@ -639,28 +639,26 @@ amp_group_node_delete_token (AmpProject  *project, AmpGroupNode *group, GError *
 	for (item = amp_group_node_get_token (group, AM_GROUP_TOKEN_SUBDIRS); item != NULL; item = g_list_next (item))
 	{
 		AnjutaToken *token = (AnjutaToken *)item->data;
-		AnjutaToken *args;
 		AnjutaTokenStyle *style;
 		AnjutaToken *list;
 
-		args = anjuta_token_list (token);
+		list = anjuta_token_list (token);
 
 		/* Try to use the same style than the current target list */
 		style = anjuta_token_style_new_from_base (project->am_space_list);
-		anjuta_token_style_update (style, args);
+		anjuta_token_style_update (style, list);
 		
 		anjuta_token_remove_word (token);
-		anjuta_token_style_format (style, args);
+		anjuta_token_style_format (style, list);
 		anjuta_token_style_free (style);
 
 		/* Remove whole variable if empty */
-		list = anjuta_token_list (token);
 		if (anjuta_token_first_word (list) == NULL)
 		{
-			anjuta_token_remove_list (list);
+			anjuta_token_remove_list (anjuta_token_list (list));
 		}
 		
-		amp_group_node_update_makefile (AMP_GROUP_NODE (parent), args);
+		amp_group_node_update_makefile (AMP_GROUP_NODE (parent), list);
 	}
 
 	/* Remove from configure file */
@@ -797,7 +795,7 @@ amp_target_node_create_token (AmpProject  *project, AmpTargetNode *target, GErro
 	{
 		for (last = amp_group_node_get_token (parent, AM_GROUP_TARGET); last != NULL; last = g_list_next (last))
 		{
-			gchar *value = anjuta_token_evaluate ((AnjutaToken *)last->data);
+			gchar *value = anjuta_token_evaluate (anjuta_token_first_word ((AnjutaToken *)last->data));
 
 			if ((value != NULL) && (strcmp (targetname, value) == 0))
 			{
@@ -861,48 +859,73 @@ amp_target_node_create_token (AmpProject  *project, AmpTargetNode *target, GErro
 gboolean 
 amp_target_node_delete_token (AmpProject  *project, AmpTargetNode *target, GError **error)
 {
+	GList *list;
 	GList *item;
 	AmpGroupNode *parent;
 
 	/* Get parent target */
 	parent = AMP_GROUP_NODE (anjuta_project_node_parent (ANJUTA_PROJECT_NODE (target)));
 
-	/* Remove list for data target */
-	for (item = amp_target_node_get_token (target, AM_TOKEN__DATA); item != NULL; item = g_list_next (item))
-	{
-		AnjutaToken *token = (AnjutaToken *)item->data;
-		
-		anjuta_token_remove_list (token);
-		amp_group_node_update_makefile (parent, token);
-	}
-
-	for (item = amp_target_node_get_token (target, ANJUTA_TOKEN_ARGUMENT); item != NULL; item = g_list_next (item))
+	/* Remove all associated token */
+	list = amp_target_node_get_all_token (target); 
+	for (item = list; item != NULL; item = g_list_next (item))
 	{
 		AnjutaToken *token = (AnjutaToken *)item->data;
-		AnjutaToken *args;
-		AnjutaToken *list;
 		AnjutaTokenStyle *style;
+		AnjutaToken *list;
 
-		args = anjuta_token_list (token);
+		switch (anjuta_token_get_type (token))
+		{
+		case ANJUTA_TOKEN_ARGUMENT:
 
-		/* Try to use the same style than the current target list */
-		style = anjuta_token_style_new_from_base (project->am_space_list);
-		anjuta_token_style_update (style, args);
+			list = anjuta_token_list (token);
+
+			/* Try to use the same style than the current target list */
+			style = anjuta_token_style_new_from_base (project->am_space_list);
+			anjuta_token_style_update (style, list);
 		
-		anjuta_token_remove_word (token);
-		anjuta_token_style_format (style, args);
-		anjuta_token_style_free (style);
+			anjuta_token_remove_word (token);
+			anjuta_token_style_format (style, list);
+			anjuta_token_style_free (style);
 
-		/* Remove whole variable if empty */
-		list = anjuta_token_list (token);
-		if (anjuta_token_first_word (list) == NULL)
-		{
-			anjuta_token_remove_list (list);
-		}
+			/* Remove whole variable if empty */
+			if (anjuta_token_first_word (list) == NULL)
+			{
+				anjuta_token_remove_list (anjuta_token_list (list));
+			}
 
-		amp_group_node_update_makefile (parent, args);
+			amp_group_node_update_makefile (parent, list);
+				
+			break;
+		case AM_TOKEN__SOURCES:
+		case AM_TOKEN__DATA:
+		case AM_TOKEN__HEADERS:
+		case AM_TOKEN__LISP:
+		case AM_TOKEN__MANS:
+		case AM_TOKEN__PYTHON:
+		case AM_TOKEN__JAVA:
+		case AM_TOKEN__SCRIPTS:
+		case AM_TOKEN__TEXINFOS:
+        case AM_TOKEN_TARGET_LDFLAGS:
+        case AM_TOKEN_TARGET_CPPFLAGS:
+        case AM_TOKEN_TARGET_CFLAGS:
+        case AM_TOKEN_TARGET_CXXFLAGS:
+        case AM_TOKEN_TARGET_JAVACFLAGS:
+        case AM_TOKEN_TARGET_VALAFLAGS:
+        case AM_TOKEN_TARGET_FCFLAGS:
+        case AM_TOKEN_TARGET_OBJCFLAGS:
+        case AM_TOKEN_TARGET_LFLAGS:
+        case AM_TOKEN_TARGET_YFLAGS:
+        case AM_TOKEN_TARGET_DEPENDENCIES:
+        case AM_TOKEN_TARGET_LIBADD:
+        case AM_TOKEN_TARGET_LDADD:
+			anjuta_token_remove_list (token);
+			amp_group_node_update_makefile (parent, token);
+			break;	
+		};
 	}
-
+	g_list_free (list);
+	
 	return TRUE;
 }
 
@@ -970,6 +993,15 @@ amp_source_node_create_token (AmpProject  *project, AmpSourceNode *source, GErro
 			args = anjuta_token_last_item (anjuta_token_list ((AnjutaToken *)last->data));
 			break;
 		}
+		if (last == NULL)
+		{
+			for (last = amp_target_node_get_token (target, AM_TOKEN__DATA); last != NULL; last = g_list_next (last))
+			{
+				args = anjuta_token_last_item (anjuta_token_list ((AnjutaToken *)last->data));
+				break;
+			}
+		}
+		
 	}
 	
 	if (args == NULL)
@@ -982,6 +1014,8 @@ amp_source_node_create_token (AmpProject  *project, AmpSourceNode *source, GErro
 		target_var = g_strconcat (canon_name,  "_SOURCES", NULL);
 
 		var = anjuta_token_find_target_property_position (target, AM_TOKEN__SOURCES);
+		if (var == NULL)
+			var = anjuta_token_find_target_property_position (target, AM_TOKEN__DATA);
 
 		args = anjuta_token_insert_token_list (FALSE, var,
 					ANJUTA_TOKEN_LIST, NULL,
@@ -1042,28 +1076,26 @@ amp_source_node_delete_token (AmpProject  *project, AmpSourceNode *source, GErro
 	token = amp_source_node_get_token (source);
 	if (token != NULL)
 	{
-		AnjutaToken *args;
 		AnjutaTokenStyle *style;
 		AnjutaToken *list;
 
-		args = anjuta_token_list (token);
+		list = anjuta_token_list (token);
 
 		/* Try to use the same style than the current target list */
 		style = anjuta_token_style_new_from_base (project->am_space_list);
-		anjuta_token_style_update (style, args);
+		anjuta_token_style_update (style, list);
 
 		anjuta_token_remove_word (token);
-		anjuta_token_style_format (style, args);
+		anjuta_token_style_format (style, list);
 		anjuta_token_style_free (style);
 
 		/* Remove whole variable if empty */
-		list = anjuta_token_list (token);
 		if (anjuta_token_first_word (list) == NULL)
 		{
-			anjuta_token_remove_list (list);
+			anjuta_token_remove_list (anjuta_token_list (list));
 		}
 		
-		amp_group_node_update_makefile (AMP_GROUP_NODE (group), args);
+		amp_group_node_update_makefile (AMP_GROUP_NODE (group), list);
 	}
 
 	return TRUE;
@@ -1080,7 +1112,7 @@ amp_property_delete_token (AmpProject  *project, AnjutaToken *token)
 
 	if (token != NULL)
 	{
-		anjuta_token_remove_list (token);
+		anjuta_token_remove_list (anjuta_token_list (token));
 		
 		updated = TRUE;
 	}
diff --git a/plugins/am-project/amp-target.c b/plugins/am-project/amp-target.c
index 0c1df22..8788266 100644
--- a/plugins/am-project/amp-target.c
+++ b/plugins/am-project/amp-target.c
@@ -383,7 +383,7 @@ amp_target_node_erase (AmpNode *target, AmpNode *parent, AmpProject *project, GE
 				if ((prop->token_type == AM_TOKEN_DIR) && (g_strcmp0 (prop->base.name, installdir) == 0))
 				{
 					/* Remove directory variable */
-					anjuta_token_remove_list (prop->token);
+					anjuta_token_remove_list (anjuta_token_list (prop->token));
 					amp_group_node_update_makefile (AMP_GROUP_NODE (parent), prop->token);
 					break;
 				}
diff --git a/plugins/am-project/tests/target.at b/plugins/am-project/tests/target.at
index 17b24b5..a10fe34 100644
--- a/plugins/am-project/tests/target.at
+++ b/plugins/am-project/tests/target.at
@@ -193,4 +193,50 @@ AT_CHECK([diff -b output expect])
 
 
 
+AT_DATA([expect],
+[[    GROUP (): empty8
+        TARGET (): target2
+            PROPERTY (Installation directory): bindir
+            PROPERTY (C compiler flags): -g
+]])
+AT_DATA([reference],
+[[## Process this file with automake to produce Makefile.in
+
+
+bin_PROGRAMS =  \
+	target2
+
+target2_CFLAGS = -g
+]])
+AT_PARSER_CHECK([load empty7 \
+		 move empty8 \
+		 remove 0:0 \
+		 list \
+		 save])
+AT_CHECK([diff -b empty8/Makefile.am reference])
+AT_PARSER_CHECK([load empty8 \
+		 list])
+AT_CHECK([diff -b output expect])
+
+
+
+AT_DATA([expect],
+[[    GROUP (): empty9
+]])
+AT_DATA([reference],
+[[## Process this file with automake to produce Makefile.in
+
+]])
+AT_PARSER_CHECK([load empty8 \
+		 move empty9 \
+		 remove 0:0 \
+		 list \
+		 save])
+AT_CHECK([diff -b empty9/Makefile.am reference])
+AT_PARSER_CHECK([load empty9 \
+		 list])
+AT_CHECK([diff -b output expect])
+
+
+
 AT_CLEANUP



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