[anjuta] am-project: Improve layout of new target and group properties
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] am-project: Improve layout of new target and group properties
- Date: Sun, 13 Feb 2011 18:56:20 +0000 (UTC)
commit f876ff38405639eee9399790e4b7c27baabc7872
Author: Sébastien Granjoux <seb sfo free fr>
Date: Sun Feb 13 18:10:34 2011 +0100
am-project: Improve layout of new target and group properties
plugins/am-project/am-parser.y | 4 +-
plugins/am-project/am-project.c | 2 +-
plugins/am-project/am-scanner.h | 24 +-
plugins/am-project/am-writer.c | 516 ++++++++++++++++++++---------
plugins/am-project/amp-group.c | 15 +
plugins/am-project/amp-group.h | 1 +
plugins/am-project/amp-target.c | 20 ++
plugins/am-project/amp-target.h | 1 +
plugins/am-project/tests/group.at | 20 +-
plugins/am-project/tests/properties.at | 131 ++++++++
plugins/am-project/tests/target.at | 15 +-
plugins/am-project/tests/target_module.at | 4 +-
12 files changed, 567 insertions(+), 186 deletions(-)
---
diff --git a/plugins/am-project/am-parser.y b/plugins/am-project/am-parser.y
index f3ae674..4e828b0 100644
--- a/plugins/am-project/am-parser.y
+++ b/plugins/am-project/am-parser.y
@@ -186,7 +186,7 @@ statement:
am_variable:
optional_space automake_token optional_space equal_token value_list {
- $$ = anjuta_token_new_static (ANJUTA_TOKEN_LIST, NULL);
+ $$ = anjuta_token_new_static (amp_am_automake_variable ($2), NULL);
if ($1 != NULL) anjuta_token_set_type ($1, ANJUTA_TOKEN_START);
anjuta_token_merge ($$, $2);
if ($3 != NULL) anjuta_token_set_type ($3, ANJUTA_TOKEN_NEXT);
@@ -199,7 +199,7 @@ am_variable:
AnjutaToken *list;
list = anjuta_token_new_static (ANJUTA_TOKEN_LIST, NULL);
anjuta_token_insert_after ($4, list);
- $$ = anjuta_token_new_static (ANJUTA_TOKEN_LIST, NULL);
+ $$ = 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 ($$));
diff --git a/plugins/am-project/am-project.c b/plugins/am-project/am-project.c
index 7d1dad5..2926a1e 100644
--- a/plugins/am-project/am-project.c
+++ b/plugins/am-project/am-project.c
@@ -895,7 +895,7 @@ project_load_target (AmpProject *project, AnjutaToken *name, AnjutaTokenType tok
AnjutaProjectProperty *prop;
prop = (AnjutaProjectProperty *)anjuta_project_node_remove_property (ANJUTA_PROJECT_NODE (orphan), (AnjutaProjectProperty *)properties->data);
-
+
amp_node_property_add (ANJUTA_PROJECT_NODE (target), prop);
}
diff --git a/plugins/am-project/am-scanner.h b/plugins/am-project/am-scanner.h
index 1d7ec48..d7327e0 100644
--- a/plugins/am-project/am-scanner.h
+++ b/plugins/am-project/am-scanner.h
@@ -52,7 +52,9 @@ void amp_am_yyerror (YYLTYPE *loc, AmpAmScanner *scanner, char const *s);
typedef enum
{
- AM_TOKEN_SUBDIRS = ANJUTA_TOKEN_USER,
+ /* Order is important as the backend will try to follow it */
+ AM_TOKEN_FIRST_ORDERED_MACRO = ANJUTA_TOKEN_USER,
+ AM_TOKEN_SUBDIRS,
AM_TOKEN_DIST_SUBDIRS,
AM_TOKEN__DATA,
AM_TOKEN__HEADERS,
@@ -63,7 +65,6 @@ typedef enum
AM_TOKEN__PROGRAMS,
AM_TOKEN__PYTHON,
AM_TOKEN__SCRIPTS,
- AM_TOKEN__SOURCES,
AM_TOKEN__TEXINFOS,
AM_TOKEN__JAVA,
AM_TOKEN_DIR,
@@ -77,19 +78,26 @@ typedef enum
AM_TOKEN__OBJCFLAGS,
AM_TOKEN__LFLAGS,
AM_TOKEN__YFLAGS,
- AM_TOKEN_TARGET_LDFLAGS,
+
+ AM_TOKEN_FIRST_ORDERED_TARGET_MACRO,
+ AM_TOKEN__SOURCES,
AM_TOKEN_TARGET_CPPFLAGS,
AM_TOKEN_TARGET_CFLAGS,
AM_TOKEN_TARGET_CXXFLAGS,
- AM_TOKEN_TARGET_JAVACFLAGS,
- AM_TOKEN_TARGET_VALAFLAGS,
- AM_TOKEN_TARGET_FCFLAGS,
AM_TOKEN_TARGET_OBJCFLAGS,
+ AM_TOKEN_TARGET_VALAFLAGS,
+ AM_TOKEN_TARGET_JAVACFLAGS,
AM_TOKEN_TARGET_LFLAGS,
AM_TOKEN_TARGET_YFLAGS,
- AM_TOKEN_TARGET_DEPENDENCIES,
+ AM_TOKEN_TARGET_FCFLAGS,
+ AM_TOKEN_TARGET_LDFLAGS,
AM_TOKEN_TARGET_LIBADD,
- AM_TOKEN_TARGET_LDADD
+ AM_TOKEN_TARGET_LDADD,
+ AM_TOKEN_TARGET_DEPENDENCIES,
+ AM_TOKEN_LAST_ORDERED_TARGET_MACRO,
+
+ AM_TOKEN_LAST_ORDERED_MACRO,
+
} AmTokenType;
G_END_DECLS
diff --git a/plugins/am-project/am-writer.c b/plugins/am-project/am-writer.c
index 58513ab..03d9031 100644
--- a/plugins/am-project/am-writer.c
+++ b/plugins/am-project/am-writer.c
@@ -51,6 +51,317 @@
/* Private functions
*---------------------------------------------------------------------------*/
+static AnjutaToken *
+anjuta_token_find_target_property_position (AmpTargetNode *target,
+ AnjutaTokenType type)
+{
+ AnjutaToken *pos = NULL;
+ gboolean after = FALSE;
+ GList *list;
+ AmpGroupNode *group;
+ AnjutaToken *makefile;
+
+
+ group = AMP_GROUP_NODE (anjuta_project_node_parent (ANJUTA_PROJECT_NODE (target)));
+
+ /* Try to find a better position */
+
+ /* 1. With the other properties of the target */
+ list = amp_target_node_get_all_token (target);
+ if (list != NULL)
+ {
+ GList *link;
+ AnjutaTokenType best = 0;
+
+ for (link = list; link != NULL; link = g_list_next (link))
+ {
+ AnjutaToken *token = (AnjutaToken *)link->data;
+ AnjutaTokenType existing = anjuta_token_get_type (token);
+
+ if ((existing < AM_TOKEN_FIRST_ORDERED_TARGET_MACRO) || (existing > AM_TOKEN_LAST_ORDERED_TARGET_MACRO))
+ {
+ token = anjuta_token_list (token);
+ if (token != NULL) existing = anjuta_token_get_type (token);
+ }
+
+ if ((existing >= AM_TOKEN_FIRST_ORDERED_TARGET_MACRO) && (existing <= AM_TOKEN_LAST_ORDERED_TARGET_MACRO))
+ {
+ if (existing > type)
+ {
+ if ((best == 0) || ((existing - type) < best))
+ {
+ best = existing - type;
+ pos = token;
+ after = FALSE;
+ }
+ }
+ else
+ {
+ if ((best == 0) || ((type -existing) < best))
+ {
+ best = type - existing;
+ pos = token;
+ after = TRUE;
+ }
+ }
+ }
+ }
+ g_list_free (list);
+ }
+
+
+ /* 2. With properties of sibling targets */
+ if (pos == NULL)
+ {
+ AnjutaProjectNode *prev = ANJUTA_PROJECT_NODE (target);
+ AnjutaProjectNode *next = ANJUTA_PROJECT_NODE (target);
+ AnjutaTokenFile *makefile;
+ GList *link;
+
+ makefile = amp_group_node_get_make_token_file (group);
+
+ if (makefile != NULL)
+ {
+ after = TRUE;
+ while ((prev != NULL) || (next != NULL))
+ {
+ /* Find sibling */
+ if (after)
+ {
+ while (prev != NULL)
+ {
+ prev = anjuta_project_node_prev_sibling (prev);
+ if (anjuta_project_node_get_node_type (prev) == ANJUTA_PROJECT_TARGET) break;
+ }
+ list = prev == NULL ? NULL : amp_target_node_get_all_token (AMP_TARGET_NODE (prev));
+ }
+ else
+ {
+ while (next != NULL)
+ {
+ next = anjuta_project_node_next_sibling (next);
+ if (anjuta_project_node_get_node_type (next) == ANJUTA_PROJECT_TARGET) break;
+ }
+ list = next == NULL ? NULL : amp_target_node_get_all_token (AMP_TARGET_NODE (next));
+ }
+
+ if (list != NULL)
+ {
+ gsize best = 0;
+
+ for (link = list; link != NULL; link = g_list_next (link))
+ {
+ AnjutaToken *token = (AnjutaToken *)link->data;
+ AnjutaTokenType existing = anjuta_token_get_type (token);
+
+ if ((existing < AM_TOKEN_FIRST_ORDERED_TARGET_MACRO) || (existing > AM_TOKEN_LAST_ORDERED_TARGET_MACRO))
+ {
+ token = anjuta_token_list (token);
+ if (token != NULL) existing = anjuta_token_get_type (token);
+ }
+
+ if ((existing >= AM_TOKEN_FIRST_ORDERED_TARGET_MACRO) && (existing <= AM_TOKEN_LAST_ORDERED_TARGET_MACRO))
+ {
+ gsize tpos;
+
+ tpos = anjuta_token_file_get_token_position (makefile, token);
+
+ if ((best == 0) ||
+ (after && (tpos > best)) ||
+ (!after && (tpos < best)))
+ {
+ pos = token;
+ best = tpos;
+ }
+ }
+ }
+ g_list_free (list);
+ list = NULL;
+
+ if (best != 0) break;
+ }
+
+ after = after ? FALSE : TRUE;
+ }
+ }
+ }
+
+
+ /* 3. After target declaration */
+ if (pos == NULL)
+ {
+ list = amp_target_node_get_token (AMP_TARGET_NODE (target), ANJUTA_TOKEN_ARGUMENT);
+ if (list != NULL)
+ {
+ pos = (AnjutaToken *)list->data;
+ if (pos != NULL)
+ {
+ pos = anjuta_token_list (pos);
+ if (pos != NULL)
+ {
+ pos = anjuta_token_list (pos);
+ }
+ }
+ }
+ after = TRUE;
+ }
+
+ /* 4. At the end of the file */
+ if (pos == NULL)
+ {
+ makefile = amp_group_node_get_makefile_token (group);
+
+ for (pos = anjuta_token_first_item (makefile); (pos != NULL) && (anjuta_token_next_item (pos) != NULL); pos = anjuta_token_next_item (pos));
+
+ after = TRUE;
+ }
+
+ /* 5. Create new file */
+ if (pos == NULL)
+ {
+ /* Empty file */
+ pos = anjuta_token_new_string (ANJUTA_TOKEN_COMMENT | ANJUTA_TOKEN_ADDED, "## Process this file with automake to produce Makefile.in\n");
+ anjuta_token_append_child (makefile, pos);
+ amp_group_node_update_makefile (group, pos);
+ }
+
+
+ /* Find end of line */
+ if (after)
+ {
+ while (pos != NULL)
+ {
+ if (anjuta_token_get_type (pos) == ANJUTA_TOKEN_EOL) break;
+ if (anjuta_token_next (pos) == NULL)
+ {
+ pos = anjuta_token_insert_token_list (after, pos,
+ ANJUTA_TOKEN_EOL, "\n",
+ NULL);
+
+ break;
+ }
+ pos = anjuta_token_next (pos);
+ }
+ }
+
+ pos = anjuta_token_insert_token_list (after, pos,
+ ANJUTA_TOKEN_EOL, "\n",
+ NULL);
+ pos = anjuta_token_insert_token_list (after, pos,
+ ANJUTA_TOKEN_EOL, "\n",
+ NULL);
+ amp_group_node_update_makefile (group, pos);
+
+
+ return pos;
+}
+
+static AnjutaToken *
+anjuta_token_find_group_property_position (AmpGroupNode *group,
+ AnjutaTokenType type)
+{
+ AnjutaToken *pos = NULL;
+ gboolean after = FALSE;
+ GList *list;
+ AnjutaToken *makefile;
+
+
+ /* Try to find a better position */
+
+ /* 1. With the other properties of the group */
+ list = amp_group_node_get_all_token (group);
+ if (list != NULL)
+ {
+ GList *link;
+ AnjutaTokenType best = 0;
+
+ for (link = list; link != NULL; link = g_list_next (link))
+ {
+ AnjutaToken *token = (AnjutaToken *)link->data;
+ AnjutaTokenType existing = anjuta_token_get_type (token);
+
+ if ((existing < AM_TOKEN_FIRST_ORDERED_TARGET_MACRO) || (existing > AM_TOKEN_LAST_ORDERED_TARGET_MACRO))
+ {
+ token = anjuta_token_list (token);
+ if (token != NULL) existing = anjuta_token_get_type (token);
+ }
+
+ if ((existing >= AM_TOKEN_FIRST_ORDERED_TARGET_MACRO) && (existing <= AM_TOKEN_LAST_ORDERED_TARGET_MACRO))
+ {
+ if (existing > type)
+ {
+ if ((best == 0) || ((existing - type) < best))
+ {
+ best = existing - type;
+ pos = token;
+ after = FALSE;
+ }
+ }
+ else
+ {
+ if ((best == 0) || ((type -existing) < best))
+ {
+ best = type - existing;
+ pos = token;
+ after = TRUE;
+ }
+ }
+ }
+ }
+ g_list_free (list);
+ }
+
+ /* 2. At the end of the file */
+ if (pos == NULL)
+ {
+ makefile = amp_group_node_get_makefile_token (group);
+ anjuta_token_dump (makefile);
+
+ for (pos = anjuta_token_first_item (makefile); (pos != NULL) && (anjuta_token_next_item (pos) != NULL); pos = anjuta_token_next_item (pos));
+
+ after = TRUE;
+ }
+
+ /* 3. Create new file */
+ if (pos == NULL)
+ {
+ /* Empty file */
+ pos = anjuta_token_new_string (ANJUTA_TOKEN_COMMENT | ANJUTA_TOKEN_ADDED, "## Process this file with automake to produce Makefile.in\n");
+ anjuta_token_append_child (makefile, pos);
+ amp_group_node_update_makefile (group, pos);
+ }
+
+ /* Find end of line */
+ if (after)
+ {
+ while (pos != NULL)
+ {
+ if (anjuta_token_get_type (pos) == ANJUTA_TOKEN_EOL) break;
+ if (anjuta_token_next (pos) == NULL)
+ {
+ pos = anjuta_token_insert_token_list (after, pos,
+ ANJUTA_TOKEN_EOL, "\n",
+ NULL);
+
+ break;
+ }
+ pos = anjuta_token_next (pos);
+ }
+ }
+
+ pos = anjuta_token_insert_token_list (after, pos,
+ ANJUTA_TOKEN_EOL, "\n",
+ NULL);
+ pos = anjuta_token_insert_token_list (after, pos,
+ ANJUTA_TOKEN_EOL, "\n",
+ NULL);
+ amp_group_node_update_makefile (group, pos);
+
+
+ return pos;
+}
+
+
/* Public functions
*---------------------------------------------------------------------------*/
@@ -223,22 +534,9 @@ amp_group_node_create_token (AmpProject *project, AmpGroupNode *group, GError *
/* Add in Makefile.am */
if (sibling == NULL)
{
- AnjutaToken *pos;
- AnjutaToken *makefile;
- static gint eol_type[] = {ANJUTA_TOKEN_EOL, ANJUTA_TOKEN_SPACE, ANJUTA_TOKEN_COMMENT, 0};
-
- makefile = amp_group_node_get_makefile_token (parent);
- pos = anjuta_token_find_type (makefile, ANJUTA_TOKEN_SEARCH_NOT, eol_type);
- if (pos == NULL)
- {
- pos = anjuta_token_prepend_child (makefile, anjuta_token_new_static (ANJUTA_TOKEN_SPACE, "\n"));
- }
+ list = anjuta_token_find_group_property_position (parent, AM_TOKEN_SUBDIRS);
- list = anjuta_token_new_string (ANJUTA_TOKEN_EOL | ANJUTA_TOKEN_ADDED, "\n");
- anjuta_token_insert_after (pos, list);
- amp_group_node_update_makefile (parent, list);
-
- list = anjuta_token_insert_token_list (FALSE, pos,
+ list = anjuta_token_insert_token_list (FALSE, list,
AM_TOKEN_SUBDIRS, "SUBDIRS",
ANJUTA_TOKEN_SPACE, " ",
ANJUTA_TOKEN_OPERATOR, "=",
@@ -363,46 +661,10 @@ static AnjutaToken *
amp_project_write_target (AmpGroupNode *group, gint type, const gchar *name, gboolean after, AnjutaToken* sibling)
{
AnjutaToken *pos;
- AnjutaToken *token;
- AnjutaToken *makefile;
-
-
- if (sibling == NULL)
- {
- makefile = amp_group_node_get_makefile_token (group);
- pos = anjuta_token_first_item (makefile);
- if (pos == NULL)
- {
- /* Empty file */
- token = anjuta_token_new_string (ANJUTA_TOKEN_COMMENT | ANJUTA_TOKEN_ADDED, "## Process this file with automake to produce Makefile.in\n");
- anjuta_token_append_child (makefile, token);
- amp_group_node_update_makefile (group, token);
- pos = token;
- }
- else
- {
- /* Add at the end of the file */
- while (anjuta_token_next_item (pos) != NULL)
- {
- pos = anjuta_token_next_item (pos);
- }
- }
- }
- else
- {
- pos = sibling;
- }
+ pos = anjuta_token_find_group_property_position (group, type);
- pos = anjuta_token_insert_token_list (after, pos,
- ANJUTA_TOKEN_EOL, "\n",
- NULL);
- pos = anjuta_token_insert_token_list (after, pos,
- ANJUTA_TOKEN_EOL, "\n",
- NULL);
- amp_group_node_update_makefile (group, pos);
-
- token = anjuta_token_insert_token_list (FALSE, pos,
+ pos = anjuta_token_insert_token_list (FALSE, pos,
ANJUTA_TOKEN_LIST, NULL,
type, name,
ANJUTA_TOKEN_SPACE, " ",
@@ -410,10 +672,10 @@ amp_project_write_target (AmpGroupNode *group, gint type, const gchar *name, gbo
ANJUTA_TOKEN_LIST, NULL,
ANJUTA_TOKEN_SPACE, " ",
NULL);
- token = anjuta_token_last_item (token);
- amp_group_node_update_makefile (group, token);
+ pos = anjuta_token_last_item (pos);
+ amp_group_node_update_makefile (group, pos);
- return token;
+ return pos;
}
gboolean
@@ -615,59 +877,6 @@ amp_target_node_delete_token (AmpProject *project, AmpTargetNode *target, GErro
/* Source objects
*---------------------------------------------------------------------------*/
-static AnjutaToken *
-amp_project_write_source_list (AmpGroupNode *group, const gchar *name, gboolean after, AnjutaToken* sibling)
-{
- AnjutaToken *pos;
- AnjutaToken *token;
- AnjutaToken *makefile;
- static gint eol_type[] = {ANJUTA_TOKEN_EOL, 0};
-
- if (sibling == NULL)
- {
- makefile = amp_group_node_get_makefile_token (group);
- pos = anjuta_token_first_item (makefile);
-
- /* Add at the end of the file */
- while (anjuta_token_next_item (pos) != NULL)
- {
- pos = anjuta_token_next_item (pos);
- }
- }
- else
- {
- pos = sibling;
- }
-
- if (after && (pos != NULL))
- {
- token = anjuta_token_find_type (pos, 0, eol_type);
- if (token != NULL)
- {
- pos = token;
- }
- }
-
- pos = anjuta_token_insert_token_list (after, pos,
- ANJUTA_TOKEN_EOL, "\n",
- NULL);
- pos = anjuta_token_insert_token_list (after, pos,
- ANJUTA_TOKEN_EOL, "\n",
- NULL);
- amp_group_node_update_makefile (group, pos);
-
- token = anjuta_token_insert_token_list (FALSE, pos,
- ANJUTA_TOKEN_LIST, NULL,
- ANJUTA_TOKEN_NAME, name,
- ANJUTA_TOKEN_SPACE, " ",
- ANJUTA_TOKEN_OPERATOR, "=",
- ANJUTA_TOKEN_LIST, NULL,
- ANJUTA_TOKEN_SPACE, " ",
- NULL);
-
- return anjuta_token_last_item (token);
-}
-
/* Source objects
*---------------------------------------------------------------------------*/
@@ -734,28 +943,22 @@ amp_source_node_create_token (AmpProject *project, AmpSourceNode *source, GErro
gchar *target_var;
gchar *canon_name;
AnjutaToken *var;
- GList *list;
canon_name = canonicalize_automake_variable (anjuta_project_node_get_name (ANJUTA_PROJECT_NODE (target)));
target_var = g_strconcat (canon_name, "_SOURCES", NULL);
- /* Search where the target is declared */
- var = NULL;
- list = amp_target_node_get_token (target, ANJUTA_TOKEN_ARGUMENT);
- if (list != NULL)
- {
- var = (AnjutaToken *)list->data;
- if (var != NULL)
- {
- var = anjuta_token_list (var);
- if (var != NULL)
- {
- var = anjuta_token_list (var);
- }
- }
- }
-
- args = amp_project_write_source_list (group, target_var, after, var);
+ var = anjuta_token_find_target_property_position (target, AM_TOKEN__SOURCES);
+
+ args = anjuta_token_insert_token_list (FALSE, var,
+ ANJUTA_TOKEN_LIST, NULL,
+ ANJUTA_TOKEN_NAME, target_var,
+ ANJUTA_TOKEN_SPACE, " ",
+ ANJUTA_TOKEN_OPERATOR, "=",
+ ANJUTA_TOKEN_LIST, NULL,
+ ANJUTA_TOKEN_SPACE, " ",
+ NULL);
+
+ args = anjuta_token_last_item (args);
g_free (target_var);
}
@@ -852,36 +1055,43 @@ amp_property_delete_token (AmpProject *project, AnjutaToken *token)
}
static AnjutaToken *
-amp_project_write_property_list (AmpGroupNode *group, AnjutaProjectNode *node, const gchar *name)
+amp_project_write_property_list (AmpGroupNode *group, AnjutaProjectNode *node, AmpProperty *property)
{
AnjutaToken *pos;
- AnjutaToken *makefile;
- AnjutaToken *token;
+ gchar *name;
- makefile = amp_group_node_get_makefile_token (group);
- pos = anjuta_token_first_item (makefile);
-
- /* Add at the end of the file */
- while (anjuta_token_next_item (pos) != NULL)
+ if (anjuta_project_node_get_node_type (node) == ANJUTA_PROJECT_GROUP)
{
- pos = anjuta_token_next_item (pos);
- }
+ /* Group property */
+ name = g_strdup (property->suffix);
- pos = anjuta_token_insert_token_list (TRUE, pos,
- ANJUTA_TOKEN_EOL, "\n",
- NULL);
- amp_group_node_update_makefile (group, pos);
+ pos = anjuta_token_find_group_property_position (AMP_GROUP_NODE (node), property->token_type);
+ }
+ else
+ {
+ /* Target property */
+ gchar *canon_name;
+
+ canon_name = canonicalize_automake_variable (anjuta_project_node_get_name (ANJUTA_PROJECT_NODE (node)));
+ name = g_strconcat (canon_name, property->suffix, NULL);
+ g_free (canon_name);
- token = anjuta_token_insert_token_list (TRUE, pos,
- ANJUTA_TOKEN_LIST, NULL,
+ pos = anjuta_token_find_target_property_position (AMP_TARGET_NODE (node), property->token_type);
+ }
+
+ pos = anjuta_token_insert_token_list (FALSE, pos,
+ property->token_type, NULL,
ANJUTA_TOKEN_NAME, name,
ANJUTA_TOKEN_SPACE, " ",
ANJUTA_TOKEN_OPERATOR, "=",
+ ANJUTA_TOKEN_SPACE, " ",
ANJUTA_TOKEN_LIST, NULL,
ANJUTA_TOKEN_SPACE, " ",
NULL);
+
+ g_free (name);
- return anjuta_token_last_item (token);
+ return anjuta_token_last_item (pos);
}
gboolean amp_project_update_am_property (AmpProject *project, AnjutaProjectNode *node, AnjutaProjectProperty *property)
@@ -924,24 +1134,8 @@ gboolean amp_project_update_am_property (AmpProject *project, AnjutaProjectNode
if (args== NULL)
{
- gchar *prop_name;
- gchar *canon_name = NULL;
-
- if (group == node)
- {
- /* Group property */
- prop_name = g_strdup (((AmpProperty *)property->native)->suffix);
- }
- else
- {
- /* Target property */
- canon_name = canonicalize_automake_variable (anjuta_project_node_get_name (ANJUTA_PROJECT_NODE (node)));
- prop_name = g_strconcat (canon_name, ((AmpProperty *)property->native)->suffix, NULL);
- }
- args = amp_project_write_property_list (AMP_GROUP_NODE (group), node, prop_name);
+ args = amp_project_write_property_list (AMP_GROUP_NODE (group), node, (AmpProperty *)property->native);
((AmpProperty *)property)->token = args;
- g_free (canon_name);
- g_free (prop_name);
}
switch (property->native->type)
diff --git a/plugins/am-project/amp-group.c b/plugins/am-project/amp-group.c
index 3e35797..8867ef6 100644
--- a/plugins/am-project/amp-group.c
+++ b/plugins/am-project/amp-group.c
@@ -287,6 +287,20 @@ amp_group_node_get_token (AmpGroupNode *group, AmpGroupNodeTokenCategory categor
return group->tokens[category];
}
+GList *
+amp_group_node_get_all_token (AmpGroupNode *group)
+{
+ gint i;
+ GList *tokens = NULL;
+
+ for (i = 0; i < AM_GROUP_TOKEN_LAST; i++)
+ {
+ tokens = g_list_concat (tokens, g_list_copy (group->tokens[i]));
+ }
+
+ return tokens;
+}
+
AnjutaToken*
amp_group_node_get_first_token (AmpGroupNode *group, AmpGroupNodeTokenCategory category)
{
@@ -548,6 +562,7 @@ amp_group_node_new (GFile *file, gboolean dist_only, GError **error)
node = g_object_new (AMP_TYPE_GROUP_NODE, NULL);
node->base.file = g_object_ref (file);
node->dist_only = dist_only;
+ memset (node->tokens, 0, sizeof (node->tokens));
return node;
}
diff --git a/plugins/am-project/amp-group.h b/plugins/am-project/amp-group.h
index c125725..1f723d3 100644
--- a/plugins/am-project/amp-group.h
+++ b/plugins/am-project/amp-group.h
@@ -64,6 +64,7 @@ AmpVariable* amp_variable_new (gchar *name, AnjutaTokenType assign, AnjutaToken
void amp_group_node_add_token (AmpGroupNode *group, AnjutaToken *token, AmpGroupNodeTokenCategory category);
GList * amp_group_node_get_token (AmpGroupNode *group, AmpGroupNodeTokenCategory category);
+GList * amp_group_node_get_all_token (AmpGroupNode *group);
AnjutaToken* amp_group_node_get_first_token (AmpGroupNode *group, AmpGroupNodeTokenCategory category);
void amp_group_node_set_dist_only (AmpGroupNode *group, gboolean dist_only);
AnjutaTokenFile* amp_group_node_set_makefile (AmpGroupNode *group, GFile *makefile, AmpProject *project);
diff --git a/plugins/am-project/amp-target.c b/plugins/am-project/amp-target.c
index 487f663..0c1df22 100644
--- a/plugins/am-project/amp-target.c
+++ b/plugins/am-project/amp-target.c
@@ -155,6 +155,20 @@ tagged_token_list_get (GList *list, AmTokenType type)
return tokens;
}
+/* The returned list must be freed */
+static GList*
+tagged_token_list_get_all (GList *list)
+{
+ GList *tokens = NULL;
+
+ for (; list != NULL; list = g_list_next (list))
+ {
+ tokens = g_list_concat (tokens, g_list_copy (((TaggedTokenItem *)list->data)->tokens));
+ }
+
+ return tokens;
+}
+
static AnjutaTokenType
tagged_token_list_next (GList *list, AmTokenType type)
{
@@ -208,6 +222,12 @@ amp_target_node_get_token (AmpTargetNode *target, AmTokenType type)
return tagged_token_list_get (target->tokens, type);
}
+GList*
+amp_target_node_get_all_token (AmpTargetNode *target)
+{
+ return tagged_token_list_get_all (target->tokens);
+}
+
AnjutaTokenType
amp_target_node_get_first_token_type (AmpTargetNode *target)
{
diff --git a/plugins/am-project/amp-target.h b/plugins/am-project/amp-target.h
index 816fe1c..4f83414 100644
--- a/plugins/am-project/amp-target.h
+++ b/plugins/am-project/amp-target.h
@@ -63,6 +63,7 @@ void amp_target_node_register (GTypeModule *module);
void amp_target_node_add_token (AmpTargetNode *target, AmTokenType type, AnjutaToken *token);
GList * amp_target_node_get_token (AmpTargetNode *target, AmTokenType type);
+GList * amp_target_node_get_all_token (AmpTargetNode *target);
void amp_target_node_set_type (AmpTargetNode *target, AmTokenType type);
AnjutaTokenType amp_target_node_get_first_token_type (AmpTargetNode *target);
AnjutaTokenType amp_target_node_get_next_token_type (AmpTargetNode *target, AnjutaTokenType type);
diff --git a/plugins/am-project/tests/group.at b/plugins/am-project/tests/group.at
index 05313fd..510af5a 100644
--- a/plugins/am-project/tests/group.at
+++ b/plugins/am-project/tests/group.at
@@ -14,9 +14,10 @@ AT_DATA([expect],
GROUP (0:0): group1
]])
AT_DATA([reference.am],
-[[SUBDIRS = \
- group1
+[[
+SUBDIRS = \
+ group1
]])
AT_DATA([reference.ac],
[[AC_CONFIG_FILES(Makefile
@@ -43,10 +44,11 @@ AT_DATA([expect],
GROUP (0:1): group2
]])
AT_DATA([reference.am],
-[[SUBDIRS = \
+[[
+
+SUBDIRS = \
group1 \
group2
-
]])
AT_DATA([reference.ac],
[[AC_CONFIG_FILES(Makefile
@@ -72,9 +74,10 @@ AT_DATA([expect],
GROUP (0:0): group2
]])
AT_DATA([reference.am],
-[[SUBDIRS = \
- group2
+[[
+SUBDIRS = \
+ group2
]])
AT_DATA([reference.ac],
[[AC_CONFIG_FILES(Makefile
@@ -122,9 +125,10 @@ AT_DATA([expect],
GROUP (0:0): group1
]])
AT_DATA([reference.am],
-[[SUBDIRS = \
- group1
+[[
+SUBDIRS = \
+ group1
]])
AT_DATA([reference.ac],
[[AC_CONFIG_FILES(Makefile
diff --git a/plugins/am-project/tests/properties.at b/plugins/am-project/tests/properties.at
index a3f2941..7b10c10 100644
--- a/plugins/am-project/tests/properties.at
+++ b/plugins/am-project/tests/properties.at
@@ -104,4 +104,135 @@ AT_CHECK([diff output expect])
+AT_DATA([expect],
+[[ GROUP (0): empty5
+ TARGET (0:0): target1
+ PROPERTY (Installation directory): bindir
+ PROPERTY (Libraries): $(GDL_LIBS)
+ TARGET (0:1): target2
+ PROPERTY (Installation directory): bindir
+]])
+AT_DATA([reference.am],
+[[
+bin_PROGRAMS = target1 \
+ target2
+
+target1_LDADD = $(GDL_LIBS)
+]])
+AT_PARSER_CHECK([load empty4 \
+ move empty5 \
+ set 0:0 lib '$(GDL_LIBS)' \
+ add target 0 target2 prog \
+ list \
+ save])
+AT_CHECK([diff -b empty5/Makefile.am reference.am])
+AT_PARSER_CHECK([load empty5 \
+ list])
+AT_CHECK([diff output expect])
+
+
+
+AT_DATA([expect],
+[[ GROUP (0): empty6
+ TARGET (0:0): target1
+ PROPERTY (Installation directory): bindir
+ PROPERTY (Libraries): $(GDL_LIBS)
+ TARGET (0:1): target2
+ PROPERTY (Installation directory): bindir
+ SOURCE (0:1:0): source1
+]])
+AT_DATA([reference.am],
+[[
+bin_PROGRAMS = target1 \
+ target2
+
+target1_LDADD = $(GDL_LIBS)
+
+target2_SOURCES = \
+ source1
+]])
+AT_PARSER_CHECK([load empty5 \
+ move empty6 \
+ add source 0:1 source1 \
+ list \
+ save])
+AT_CHECK([diff -b empty6/Makefile.am reference.am])
+AT_PARSER_CHECK([load empty6 \
+ list])
+AT_CHECK([diff output expect])
+
+
+
+AT_DATA([expect],
+[[ GROUP (0): empty7
+ TARGET (0:0): target1
+ PROPERTY (Installation directory): bindir
+ PROPERTY (Libraries): $(GDL_LIBS)
+ TARGET (0:1): target2
+ PROPERTY (Installation directory): bindir
+ PROPERTY (Libraries): $(GDL_LIBS)
+ SOURCE (0:1:0): source1
+]])
+AT_DATA([reference.am],
+[[
+bin_PROGRAMS = target1 \
+ target2
+
+target1_LDADD = $(GDL_LIBS)
+
+target2_SOURCES = \
+ source1
+
+target2_LDADD = $(GDL_LIBS)
+]])
+AT_PARSER_CHECK([load empty6 \
+ move empty7 \
+ set 0:1 lib '$(GDL_LIBS)' \
+ list \
+ save])
+AT_CHECK([diff -b empty7/Makefile.am reference.am])
+AT_PARSER_CHECK([load empty7 \
+ list])
+AT_CHECK([diff output expect])
+
+
+
+AT_DATA([expect],
+[[ GROUP (0): empty8
+ TARGET (0:0): target1
+ PROPERTY (Installation directory): bindir
+ PROPERTY (Libraries): $(GDL_LIBS)
+ SOURCE (0:0:0): source2
+ TARGET (0:1): target2
+ PROPERTY (Installation directory): bindir
+ PROPERTY (Libraries): $(GDL_LIBS)
+ SOURCE (0:1:0): source1
+]])
+AT_DATA([reference.am],
+[[
+bin_PROGRAMS = target1 \
+ target2
+
+target1_SOURCES = \
+ source2
+
+target1_LDADD = $(GDL_LIBS)
+
+target2_SOURCES = \
+ source1
+
+target2_LDADD = $(GDL_LIBS)
+]])
+AT_PARSER_CHECK([load empty7 \
+ move empty8 \
+ add source 0:0 source2 \
+ list \
+ save])
+AT_CHECK([diff -b empty8/Makefile.am reference.am])
+AT_PARSER_CHECK([load empty8 \
+ list])
+AT_CHECK([diff output expect])
+
+
+
AT_CLEANUP
diff --git a/plugins/am-project/tests/target.at b/plugins/am-project/tests/target.at
index d6f7d82..c9b4582 100644
--- a/plugins/am-project/tests/target.at
+++ b/plugins/am-project/tests/target.at
@@ -16,6 +16,7 @@ AT_DATA([expect],
AT_DATA([reference],
[[## Process this file with automake to produce Makefile.in
+
bin_PROGRAMS = \
target1
]])
@@ -41,6 +42,7 @@ AT_DATA([expect],
AT_DATA([reference],
[[## Process this file with automake to produce Makefile.in
+
bin_PROGRAMS = \
target1 \
target2
@@ -65,6 +67,7 @@ AT_DATA([expect],
AT_DATA([reference],
[[## Process this file with automake to produce Makefile.in
+
bin_PROGRAMS = \
target2
]])
@@ -85,6 +88,7 @@ AT_DATA([expect],
]])
AT_DATA([reference],
[[## Process this file with automake to produce Makefile.in
+
]])
AT_PARSER_CHECK([load empty3 \
move empty4 \
@@ -107,6 +111,7 @@ AT_DATA([expect],
AT_DATA([reference],
[[## Process this file with automake to produce Makefile.in
+
bin_PROGRAMS = \
target1
]])
@@ -133,11 +138,12 @@ AT_DATA([expect],
AT_DATA([reference],
[[## Process this file with automake to produce Makefile.in
-bin_PROGRAMS = \
+
+bin_PROGRAMS = \
target1 \
target2
-target1_SOURCES = \
+target1_SOURCES = \
source1
]])
AT_PARSER_CHECK([load empty5 \
@@ -165,11 +171,12 @@ AT_DATA([expect],
AT_DATA([reference],
[[## Process this file with automake to produce Makefile.in
-bin_PROGRAMS = \
+
+bin_PROGRAMS = \
target1 \
target2
-target1_SOURCES = \
+target1_SOURCES = \
source1
target2_CFLAGS = -g
diff --git a/plugins/am-project/tests/target_module.at b/plugins/am-project/tests/target_module.at
index 6f7e2c5..5246292 100644
--- a/plugins/am-project/tests/target_module.at
+++ b/plugins/am-project/tests/target_module.at
@@ -45,8 +45,8 @@ AT_DATA([expect],
PROPERTY (Libraries): $(MODULE1_LIBS)
MODULE (): MODULE1
TARGET (): program
- PROPERTY (Do not install): true
PROPERTY (Libraries): $(MODULE1_LIBS)
+ PROPERTY (Do not install): true
MODULE (): MODULE1
]])
AT_PARSER_CHECK([load simple1 \
@@ -68,8 +68,8 @@ AT_DATA([expect],
TARGET (): library.la
PROPERTY (Installation directory): libdir
TARGET (): program
- PROPERTY (Do not install): true
PROPERTY (Libraries): $(MODULE1_LIBS)
+ PROPERTY (Do not install): true
MODULE (): MODULE1
]])
AT_PARSER_CHECK([load simple2 \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]