Ejemplo n.º 1
0
static AnjutaToken *
amp_project_write_module_list (AmpProject *project, const gchar *name, gboolean after, AnjutaToken* sibling)
{
	AnjutaToken *pos;
	AnjutaToken *token;
	AnjutaToken *configure;

	configure = amp_project_get_configure_token (project);

	pos = anjuta_token_find_position (configure, after, AC_TOKEN_PKG_CHECK_MODULES, sibling);

	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_project_update_configure (project, pos);

	token = anjuta_token_insert_token_list (FALSE, pos,
	    		AC_TOKEN_AC_CONFIG_FILES, "PKG_CHECK_MODULES(",
	    		ANJUTA_TOKEN_LIST, NULL,
	    		ANJUTA_TOKEN_NAME, name,
	    		ANJUTA_TOKEN_COMMA, ",",
	    		ANJUTA_TOKEN_LAST, NULL,
	    		RIGHT_PAREN, ")",
	    		NULL);

	return token;
}
Ejemplo n.º 2
0
static AnjutaToken *
amp_project_write_config_list (AmpProject *project)
{
	AnjutaToken *pos;
	AnjutaToken *token;
	static gint output_type[] = {AC_TOKEN_AC_OUTPUT, 0};
	static gint eol_type[] = {ANJUTA_TOKEN_EOL, ANJUTA_TOKEN_SPACE, ANJUTA_TOKEN_COMMENT, 0};
	AnjutaToken *configure;

	configure = amp_project_get_configure_token (project);
	pos = anjuta_token_find_type (configure, 0, output_type);
	if (pos == NULL)
	{
		gint other_type[] = {AC_TOKEN_AC_INIT,
			AC_TOKEN_PKG_CHECK_MODULES,
			AC_TOKEN_AC_CONFIG_FILES,
			AC_TOKEN_OBSOLETE_AC_OUTPUT,
			AC_TOKEN_AC_PREREQ,
			0};

		pos = anjuta_token_find_type (configure, ANJUTA_TOKEN_SEARCH_LAST, other_type);
		if (pos == NULL)
		{
			pos = anjuta_token_skip_comment (configure);
		}
		else
		{
			AnjutaToken* next;

			next = anjuta_token_find_type (pos, ANJUTA_TOKEN_SEARCH_NOT, eol_type);
		}

	}

	token = anjuta_token_insert_token_list (FALSE, pos,
	    		AC_TOKEN_AC_CONFIG_FILES, "AC_CONFIG_FILES(",
	    		ANJUTA_TOKEN_LIST, NULL,
	    		ANJUTA_TOKEN_LAST, NULL,
	    		RIGHT_PAREN, ")",
				ANJUTA_TOKEN_EOL, "\n",
	    		NULL);

	return token;
}
Ejemplo n.º 3
0
gboolean
amp_project_update_ac_property (AmpProject *project, AnjutaProjectProperty *property)
{
	AnjutaToken *token;
	AnjutaToken *arg;
	AnjutaToken *args;
	AmpProperty *prop;
	AmpPropertyInfo *info;

	if (g_strcmp0 (((AmpPropertyInfo *)property->info)->value, property->value) == 0)
	{
		/* Remove property */
		info = (AmpPropertyInfo *)property->info;
		prop = (AmpProperty *)property;

		if (info->position == -1)
		{
			token = prop->token;

			anjuta_token_remove_list (anjuta_token_list (token));
		}

		anjuta_project_node_remove_property (ANJUTA_PROJECT_NODE (project), property);
	}
	else
	{
		info = (AmpPropertyInfo *)property->info;
		prop = find_similar_property (ANJUTA_PROJECT_NODE (project), (AmpProperty *)property);
		args = prop != NULL ? prop->token : NULL;

		prop = (AmpProperty *)property;

		if (args == NULL)
		{
			AnjutaToken *group;
			AnjutaToken *configure;
			const char *suffix;

			configure = amp_project_get_configure_token (project);
			token = anjuta_token_find_position (configure, TRUE, info->token_type, NULL);
			if (token == NULL)
			{
				token = skip_comment (configure);
				if (token == NULL)
				{
					token = anjuta_token_append_child (configure, anjuta_token_new_string (COMMENT | ANJUTA_TOKEN_ADDED, "#"));
					token = anjuta_token_insert_after (token, anjuta_token_new_string (SPACE | ANJUTA_TOKEN_ADDED, " Created by Anjuta project manager"));
					token = anjuta_token_insert_after (token, anjuta_token_new_string (END_OF_LINE | ANJUTA_TOKEN_ADDED, "\n"));
					token = anjuta_token_insert_after (token, anjuta_token_new_string (END_OF_LINE | ANJUTA_TOKEN_ADDED, "\n"));
				}
			}

			suffix = info->suffix;
			token = anjuta_token_insert_after (token, anjuta_token_new_string (AC_TOKEN_AC_INIT | ANJUTA_TOKEN_ADDED, suffix));
			if (suffix[strlen(suffix) - 1] == '(')
			{
				group = anjuta_token_insert_after (token, anjuta_token_new_static (ANJUTA_TOKEN_LIST | ANJUTA_TOKEN_ADDED, NULL));
				args = group;
				token = anjuta_token_insert_after (group, anjuta_token_new_static (ANJUTA_TOKEN_LAST | ANJUTA_TOKEN_ADDED, NULL));
				anjuta_token_merge (group, token);
			}
			anjuta_token_insert_after (token, anjuta_token_new_string (END_OF_LINE | ANJUTA_TOKEN_ADDED, "\n"));
		}
		if (args != NULL)
		{
			guint pos;

			token = anjuta_token_new_string (ANJUTA_TOKEN_NAME | ANJUTA_TOKEN_ADDED, prop->base.value);
			arg = anjuta_token_insert_before (token, anjuta_token_new_static (ANJUTA_TOKEN_ITEM | ANJUTA_TOKEN_ADDED, NULL));
			anjuta_token_merge (arg, token);

			pos = info->position;
			if (pos == -1) pos = 0;
			anjuta_token_replace_nth_word (args, pos, arg);
			anjuta_token_style_format (project->arg_list, args);
		}
	}

	amp_project_update_configure (project, token);

	return TRUE;
}