/* afroditetest.c generated by valac 0.12.1.1-323029-dirty, the Vala compiler
 * generated from afroditetest.vala, do not modify */

/* afroditetest.vala
 *
 * Copyright (C) 2010  Andrea Del Signore
 *
 * This library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Author:
 * 	Andrea Del Signore <sejerpz@tin.it>
 */

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <afrodite.h>
#include <glib/gi18n-lib.h>
#include <valagee.h>
#include <glib/gstdio.h>


#define AFRODITE_TEST_TYPE_APPLICATION (afrodite_test_application_get_type ())
#define AFRODITE_TEST_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AFRODITE_TEST_TYPE_APPLICATION, AfroditeTestApplication))
#define AFRODITE_TEST_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), AFRODITE_TEST_TYPE_APPLICATION, AfroditeTestApplicationClass))
#define AFRODITE_TEST_IS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AFRODITE_TEST_TYPE_APPLICATION))
#define AFRODITE_TEST_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), AFRODITE_TEST_TYPE_APPLICATION))
#define AFRODITE_TEST_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), AFRODITE_TEST_TYPE_APPLICATION, AfroditeTestApplicationClass))

typedef struct _AfroditeTestApplication AfroditeTestApplication;
typedef struct _AfroditeTestApplicationClass AfroditeTestApplicationClass;
typedef struct _AfroditeTestApplicationPrivate AfroditeTestApplicationPrivate;
#define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_option_context_free0(var) ((var == NULL) ? NULL : (var = (g_option_context_free (var), NULL)))
#define _vala_iterable_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterable_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _afrodite_source_file_unref0(var) ((var == NULL) ? NULL : (var = (afrodite_source_file_unref (var), NULL)))
#define _afrodite_query_result_unref0(var) ((var == NULL) ? NULL : (var = (afrodite_query_result_unref (var), NULL)))
#define _afrodite_data_type_unref0(var) ((var == NULL) ? NULL : (var = (afrodite_data_type_unref (var), NULL)))
#define _afrodite_result_item_unref0(var) ((var == NULL) ? NULL : (var = (afrodite_result_item_unref (var), NULL)))
#define _afrodite_query_options_unref0(var) ((var == NULL) ? NULL : (var = (afrodite_query_options_unref (var), NULL)))
#define _vala_code_visitor_unref0(var) ((var == NULL) ? NULL : (var = (vala_code_visitor_unref (var), NULL)))
#define _afrodite_source_item_unref0(var) ((var == NULL) ? NULL : (var = (afrodite_source_item_unref (var), NULL)))

struct _AfroditeTestApplication {
	GObject parent_instance;
	AfroditeTestApplicationPrivate * priv;
};

struct _AfroditeTestApplicationClass {
	GObjectClass parent_class;
};

struct _AfroditeTestApplicationPrivate {
	GMainLoop* _loop;
	AfroditeCompletionEngine* _engine;
};


extern gchar* option_symbol_name;
gchar* option_symbol_name = NULL;
extern gint option_line;
gint option_line = 0;
extern gint option_column;
gint option_column = 0;
extern gchar* option_visible_symbols;
gchar* option_visible_symbols = NULL;
extern gchar* option_filter;
gchar* option_filter = NULL;
extern gchar* option_namespace;
gchar* option_namespace = NULL;
extern gboolean option_dump_unresolved;
gboolean option_dump_unresolved = FALSE;
extern gchar** option_files;
extern gint option_files_length1;
gchar** option_files = NULL;
gint option_files_length1 = 0;
static gint _option_files_size_ = 0;
extern gint option_repeat;
gint option_repeat = 0;
extern gboolean option_live_buffers;
gboolean option_live_buffers = FALSE;
static gpointer afrodite_test_application_parent_class = NULL;

GType afrodite_test_application_get_type (void) G_GNUC_CONST;
#define AFRODITE_TEST_APPLICATION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), AFRODITE_TEST_TYPE_APPLICATION, AfroditeTestApplicationPrivate))
enum  {
	AFRODITE_TEST_APPLICATION_DUMMY_PROPERTY
};
gint afrodite_test_application_run (AfroditeTestApplication* self, gchar** args, int args_length1);
static void afrodite_test_application_parse (AfroditeTestApplication* self);
static void afrodite_test_application_on_begin_parsing (AfroditeTestApplication* self, AfroditeCompletionEngine* engine);
static void afrodite_test_application_on_end_parsing (AfroditeTestApplication* self, AfroditeCompletionEngine* engine);
static void afrodite_test_application_dump (AfroditeTestApplication* self, AfroditeCompletionEngine* engine);
static void _afrodite_test_application_on_begin_parsing_afrodite_completion_engine_begin_parsing (AfroditeCompletionEngine* _sender, AfroditeCompletionEngine* sender, gpointer self);
static void _afrodite_test_application_on_end_parsing_afrodite_completion_engine_end_parsing (AfroditeCompletionEngine* _sender, AfroditeCompletionEngine* sender, gpointer self);
static gint afrodite_test_application_main (gchar** args, int args_length1);
AfroditeTestApplication* afrodite_test_application_new (void);
AfroditeTestApplication* afrodite_test_application_construct (GType object_type);
static void afrodite_test_application_finalize (GObject* obj);

const GOptionEntry options[11] = {{"symbol-name", 's', 0, G_OPTION_ARG_STRING, &option_symbol_name, "Symbol to search NAME", "NAME"}, {"visible-symbols", 'd', 0, G_OPTION_ARG_FILENAME, &option_visible_symbols, "Dump visible symbols from line / column of source FILENAME", "FILENAME"}, {"filter", 'f', 0, G_OPTION_ARG_STRING, &option_filter, "Filter results showing only symbols starting with NAME", "NAME"}, {"line", 'l', 0, G_OPTION_ARG_INT, &option_line, "Line NUMBER", "NUMBER"}, {"column", 'c', 0, G_OPTION_ARG_INT, &option_column, "Column NUMBER", "NUMBER"}, {"repeat", 'r', 0, G_OPTION_ARG_INT, &option_repeat, "Repeat parsing NUMBER", "NUMBER"}, {"dump-namespace", 'n', 0, G_OPTION_ARG_STRING, &option_namespace, "Namespace to dump NAME", "NAME"}, {"dump-unresolved", 'u', 0, G_OPTION_ARG_NONE, &option_dump_unresolved, "Dump unresolved symbol", NULL}, {"queue-as-live-buffer", 'e', 0, G_OPTION_ARG_STRING, &option_live_buffers, "Parse the source files as live buffers", NULL}, {"", (gchar) 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &option_files, "Source files NAME", "NAME"}, {NULL}};

gint afrodite_test_application_run (AfroditeTestApplication* self, gchar** args, int args_length1) {
	gint result = 0;
	GOptionContext* _tmp0_ = NULL;
	GOptionContext* opt_context;
	GMainLoop* _tmp2_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = g_option_context_new ("- Afrodite Test");
	opt_context = _tmp0_;
	g_option_context_set_help_enabled (opt_context, TRUE);
	g_option_context_add_main_entries (opt_context, options, NULL);
	g_option_context_parse (opt_context, &args_length1, &args, &_inner_error_);
	if (_inner_error_ != NULL) {
		goto __catch0_g_error;
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError * err;
		const gchar* _tmp1_ = NULL;
		err = _inner_error_;
		_inner_error_ = NULL;
		_tmp1_ = _ ("parsing options");
		g_error ("afroditetest.vala:64: %s", _tmp1_);
		_g_error_free0 (err);
	}
	__finally0:
	if (_inner_error_ != NULL) {
		_g_option_context_free0 (opt_context);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return 0;
	}
	if (option_repeat == 0) {
		option_repeat = 1;
	}
	afrodite_test_application_parse (self);
	_tmp2_ = g_main_loop_new (NULL, FALSE);
	_g_main_loop_unref0 (self->priv->_loop);
	self->priv->_loop = _tmp2_;
	g_main_loop_run (self->priv->_loop);
	result = 0;
	_g_option_context_free0 (opt_context);
	return result;
}


static void afrodite_test_application_on_begin_parsing (AfroditeTestApplication* self, AfroditeCompletionEngine* engine) {
	g_return_if_fail (self != NULL);
	g_return_if_fail (engine != NULL);
	g_print ("\nAfrodite engine is parsing sources\n");
}


static void afrodite_test_application_on_end_parsing (AfroditeTestApplication* self, AfroditeCompletionEngine* engine) {
	g_return_if_fail (self != NULL);
	g_return_if_fail (engine != NULL);
	g_print ("\nAfrodite engine end parsing sources\n");
	g_main_loop_quit (self->priv->_loop);
	afrodite_test_application_dump (self, engine);
}


static gpointer _vala_iterable_ref0 (gpointer self) {
	return self ? vala_iterable_ref (self) : NULL;
}


static gpointer _g_object_ref0 (gpointer self) {
	return self ? g_object_ref (self) : NULL;
}


static void afrodite_test_application_dump (AfroditeTestApplication* self, AfroditeCompletionEngine* engine) {
	g_return_if_fail (self != NULL);
	g_return_if_fail (engine != NULL);
	g_print (": done\n\n");
	g_print ("Looking for '%s' %d,%d\n\nDump follows:\n", option_symbol_name, option_line, option_column);
	while (TRUE) {
		AfroditeAstDumper* _tmp0_ = NULL;
		AfroditeAstDumper* dumper;
		AfroditeCodeDom* _tmp1_ = NULL;
		_tmp0_ = afrodite_ast_dumper_new ();
		dumper = _tmp0_;
		_tmp1_ = afrodite_completion_engine_get_codedom (engine);
		afrodite_ast_dumper_dump (dumper, _tmp1_, option_namespace);
		g_print ("\n");
		if (option_visible_symbols != NULL) {
			AfroditeCodeDom* _tmp2_ = NULL;
			AfroditeSourceFile* _tmp3_ = NULL;
			AfroditeSourceFile* source;
			_tmp2_ = afrodite_completion_engine_get_codedom (engine);
			_tmp3_ = afrodite_code_dom_lookup_source_file (_tmp2_, option_visible_symbols);
			source = _tmp3_;
			if (source != NULL) {
				AfroditeCodeDom* _tmp4_ = NULL;
				AfroditeSymbol* _tmp5_ = NULL;
				AfroditeSymbol* s;
				_tmp4_ = afrodite_completion_engine_get_codedom (engine);
				_tmp5_ = afrodite_code_dom_get_symbol_for_source_and_position (_tmp4_, source, option_line, option_column);
				s = _tmp5_;
				if (s != NULL) {
					ValaList* syms;
					AfroditeCodeDom* _tmp6_ = NULL;
					ValaList* _tmp7_ = NULL;
					gint _tmp8_;
					syms = NULL;
					_tmp6_ = afrodite_completion_engine_get_codedom (engine);
					_tmp7_ = afrodite_code_dom_lookup_visible_symbols_from_symbol (_tmp6_, s, option_filter, AFRODITE_COMPARE_MODE_START_WITH, AFRODITE_CASE_SENSITIVENESS_CASE_SENSITIVE);
					_vala_iterable_unref0 (syms);
					syms = _tmp7_;
					_tmp8_ = vala_collection_get_size ((ValaCollection*) syms);
					g_print ("Symbols found: %d\n", _tmp8_);
					{
						ValaList* _tmp9_;
						ValaList* _sym_list;
						gint _tmp10_;
						gint _sym_size;
						gint _sym_index;
						_tmp9_ = _vala_iterable_ref0 (syms);
						_sym_list = _tmp9_;
						_tmp10_ = vala_collection_get_size ((ValaCollection*) _sym_list);
						_sym_size = _tmp10_;
						_sym_index = -1;
						while (TRUE) {
							gpointer _tmp11_ = NULL;
							AfroditeSymbol* sym;
							gchar* _tmp12_ = NULL;
							AfroditeSymbol* _tmp13_ = NULL;
							gchar* _tmp17_ = NULL;
							gchar* _tmp18_;
							gchar* _tmp19_ = NULL;
							gchar* _tmp20_;
							_sym_index = _sym_index + 1;
							if (!(_sym_index < _sym_size)) {
								break;
							}
							_tmp11_ = vala_list_get (_sym_list, _sym_index);
							sym = (AfroditeSymbol*) _tmp11_;
							_tmp13_ = afrodite_symbol_get_parent (sym);
							if (_tmp13_ == NULL) {
								gchar* _tmp14_;
								_tmp14_ = g_strdup ("<root>");
								_g_free0 (_tmp12_);
								_tmp12_ = _tmp14_;
							} else {
								AfroditeSymbol* _tmp15_ = NULL;
								gchar* _tmp16_ = NULL;
								_tmp15_ = afrodite_symbol_get_parent (sym);
								_tmp16_ = afrodite_symbol_get_fully_qualified_name (_tmp15_);
								_g_free0 (_tmp12_);
								_tmp12_ = _tmp16_;
							}
							_tmp17_ = afrodite_symbol_get_description (sym);
							_tmp18_ = _tmp17_;
							_tmp19_ = afrodite_utils_unescape_xml_string (_tmp18_);
							_tmp20_ = _tmp19_;
							g_print ("          from %s: %s\n", _tmp12_, _tmp20_);
							_g_free0 (_tmp20_);
							_g_free0 (_tmp18_);
							_g_free0 (_tmp12_);
							_g_object_unref0 (sym);
						}
						_vala_iterable_unref0 (_sym_list);
					}
					_vala_iterable_unref0 (syms);
				} else {
					g_print ("no symbol found for position: %d-%d\n", option_line, option_column);
				}
				_g_object_unref0 (s);
			} else {
				g_print ("source file not found: %s\n", option_visible_symbols);
			}
			_afrodite_source_file_unref0 (source);
		} else {
			if (option_symbol_name != NULL) {
				AfroditeQueryOptions* _tmp21_ = NULL;
				AfroditeQueryOptions* options;
				AfroditeQueryResult* sym;
				AfroditeCodeDom* _tmp22_ = NULL;
				AfroditeQueryResult* _tmp23_ = NULL;
				gboolean _tmp24_;
				_tmp21_ = afrodite_query_options_standard ();
				options = _tmp21_;
				options->auto_member_binding_mode = TRUE;
				options->compare_mode = AFRODITE_COMPARE_MODE_EXACT;
				options->access = AFRODITE_SYMBOL_ACCESSIBILITY_ANY;
				options->binding = AFRODITE_MEMBER_BINDING_ANY;
				sym = NULL;
				_tmp22_ = afrodite_completion_engine_get_codedom (engine);
				_tmp23_ = afrodite_code_dom_get_symbol_type_for_name_and_path (_tmp22_, options, option_symbol_name, option_files[0], option_line, option_column);
				_afrodite_query_result_unref0 (sym);
				sym = _tmp23_;
				g_print ("The type for '%s' is: ", option_symbol_name);
				_tmp24_ = afrodite_query_result_get_is_empty (sym);
				if (!_tmp24_) {
					{
						ValaList* _tmp25_ = NULL;
						ValaList* _tmp26_;
						ValaList* _item_list;
						gint _tmp27_;
						gint _item_size;
						gint _item_index;
						_tmp25_ = afrodite_query_result_get_children (sym);
						_tmp26_ = _vala_iterable_ref0 (_tmp25_);
						_item_list = _tmp26_;
						_tmp27_ = vala_collection_get_size ((ValaCollection*) _item_list);
						_item_size = _tmp27_;
						_item_index = -1;
						while (TRUE) {
							gpointer _tmp28_ = NULL;
							AfroditeResultItem* item;
							AfroditeSymbol* _tmp29_ = NULL;
							gchar* _tmp30_ = NULL;
							gchar* _tmp31_;
							gchar* _tmp32_ = NULL;
							gchar* _tmp33_;
							AfroditeSymbol* _tmp34_ = NULL;
							gboolean _tmp35_;
							_item_index = _item_index + 1;
							if (!(_item_index < _item_size)) {
								break;
							}
							_tmp28_ = vala_list_get (_item_list, _item_index);
							item = (AfroditeResultItem*) _tmp28_;
							_tmp29_ = afrodite_result_item_get_symbol (item);
							_tmp30_ = afrodite_symbol_get_description (_tmp29_);
							_tmp31_ = _tmp30_;
							_tmp32_ = afrodite_utils_unescape_xml_string (_tmp31_);
							_tmp33_ = _tmp32_;
							g_print ("%s\n     Childs:\n", _tmp33_);
							_g_free0 (_tmp33_);
							_g_free0 (_tmp31_);
							_tmp34_ = afrodite_result_item_get_symbol (item);
							_tmp35_ = afrodite_symbol_get_has_children (_tmp34_);
							if (_tmp35_) {
								gint count;
								gboolean _tmp45_ = FALSE;
								count = 0;
								{
									AfroditeSymbol* _tmp36_ = NULL;
									ValaList* _tmp37_ = NULL;
									ValaList* _tmp38_;
									ValaList* _child_list;
									gint _tmp39_;
									gint _child_size;
									gint _child_index;
									_tmp36_ = afrodite_result_item_get_symbol (item);
									_tmp37_ = afrodite_symbol_get_children (_tmp36_);
									_tmp38_ = _vala_iterable_ref0 (_tmp37_);
									_child_list = _tmp38_;
									_tmp39_ = vala_collection_get_size ((ValaCollection*) _child_list);
									_child_size = _tmp39_;
									_child_index = -1;
									while (TRUE) {
										gpointer _tmp40_ = NULL;
										AfroditeSymbol* child;
										gchar* _tmp41_ = NULL;
										gchar* _tmp42_;
										gchar* _tmp43_ = NULL;
										gchar* _tmp44_;
										_child_index = _child_index + 1;
										if (!(_child_index < _child_size)) {
											break;
										}
										_tmp40_ = vala_list_get (_child_list, _child_index);
										child = (AfroditeSymbol*) _tmp40_;
										_tmp41_ = afrodite_symbol_get_description (child);
										_tmp42_ = _tmp41_;
										_tmp43_ = afrodite_utils_unescape_xml_string (_tmp42_);
										_tmp44_ = _tmp43_;
										g_print ("          %s\n", _tmp44_);
										_g_free0 (_tmp44_);
										_g_free0 (_tmp42_);
										count++;
										if (count == 6) {
											g_print ("          ......\n");
											_g_object_unref0 (child);
											break;
										}
										_g_object_unref0 (child);
									}
									_vala_iterable_unref0 (_child_list);
								}
								if (count < 6) {
									AfroditeSymbol* _tmp46_ = NULL;
									gboolean _tmp47_;
									_tmp46_ = afrodite_result_item_get_symbol (item);
									_tmp47_ = afrodite_symbol_get_has_base_types (_tmp46_);
									_tmp45_ = _tmp47_;
								} else {
									_tmp45_ = FALSE;
								}
								if (_tmp45_) {
									{
										AfroditeSymbol* _tmp48_ = NULL;
										ValaList* _tmp49_ = NULL;
										ValaList* _tmp50_;
										ValaList* _base_item_list;
										gint _tmp51_;
										gint _base_item_size;
										gint _base_item_index;
										_tmp48_ = afrodite_result_item_get_symbol (item);
										_tmp49_ = afrodite_symbol_get_base_types (_tmp48_);
										_tmp50_ = _vala_iterable_ref0 (_tmp49_);
										_base_item_list = _tmp50_;
										_tmp51_ = vala_collection_get_size ((ValaCollection*) _base_item_list);
										_base_item_size = _tmp51_;
										_base_item_index = -1;
										while (TRUE) {
											gpointer _tmp52_ = NULL;
											AfroditeDataType* base_item;
											gboolean _tmp53_ = FALSE;
											gboolean _tmp54_;
											_base_item_index = _base_item_index + 1;
											if (!(_base_item_index < _base_item_size)) {
												break;
											}
											_tmp52_ = vala_list_get (_base_item_list, _base_item_index);
											base_item = (AfroditeDataType*) _tmp52_;
											_tmp54_ = afrodite_data_type_get_unresolved (base_item);
											if (_tmp54_) {
												_tmp53_ = TRUE;
											} else {
												AfroditeSymbol* _tmp55_ = NULL;
												gboolean _tmp56_;
												_tmp55_ = afrodite_data_type_get_symbol (base_item);
												_tmp56_ = afrodite_symbol_get_has_children (_tmp55_);
												_tmp53_ = !_tmp56_;
											}
											if (_tmp53_) {
												_afrodite_data_type_unref0 (base_item);
												continue;
											}
											{
												AfroditeSymbol* _tmp57_ = NULL;
												ValaList* _tmp58_ = NULL;
												ValaList* _tmp59_;
												ValaList* _child_list;
												gint _tmp60_;
												gint _child_size;
												gint _child_index;
												_tmp57_ = afrodite_data_type_get_symbol (base_item);
												_tmp58_ = afrodite_symbol_get_children (_tmp57_);
												_tmp59_ = _vala_iterable_ref0 (_tmp58_);
												_child_list = _tmp59_;
												_tmp60_ = vala_collection_get_size ((ValaCollection*) _child_list);
												_child_size = _tmp60_;
												_child_index = -1;
												while (TRUE) {
													gpointer _tmp61_ = NULL;
													AfroditeSymbol* child;
													gchar* _tmp62_ = NULL;
													gchar* _tmp63_;
													gchar* _tmp64_ = NULL;
													gchar* _tmp65_;
													_child_index = _child_index + 1;
													if (!(_child_index < _child_size)) {
														break;
													}
													_tmp61_ = vala_list_get (_child_list, _child_index);
													child = (AfroditeSymbol*) _tmp61_;
													_tmp62_ = afrodite_symbol_get_description (child);
													_tmp63_ = _tmp62_;
													_tmp64_ = afrodite_utils_unescape_xml_string (_tmp63_);
													_tmp65_ = _tmp64_;
													g_print ("          %s\n", _tmp65_);
													_g_free0 (_tmp65_);
													_g_free0 (_tmp63_);
													count++;
													if (count == 6) {
														_g_object_unref0 (child);
														break;
													}
													_g_object_unref0 (child);
												}
												_vala_iterable_unref0 (_child_list);
											}
											if (count == 6) {
												g_print ("          ......\n");
												_afrodite_data_type_unref0 (base_item);
												break;
											}
											_afrodite_data_type_unref0 (base_item);
										}
										_vala_iterable_unref0 (_base_item_list);
									}
								}
							}
							_afrodite_result_item_unref0 (item);
						}
						_vala_iterable_unref0 (_item_list);
					}
				} else {
					g_print ("unresolved :(\n");
				}
				_afrodite_query_result_unref0 (sym);
				_afrodite_query_options_unref0 (options);
			}
		}
		_vala_code_visitor_unref0 (dumper);
		break;
	}
	if (option_dump_unresolved) {
		gboolean _tmp66_ = FALSE;
		AfroditeCodeDom* _tmp67_ = NULL;
		g_print ("Unresolved symbols:");
		_tmp67_ = afrodite_completion_engine_get_codedom (engine);
		if (_tmp67_->unresolved_symbols != NULL) {
			AfroditeCodeDom* _tmp68_ = NULL;
			gint _tmp69_;
			_tmp68_ = afrodite_completion_engine_get_codedom (engine);
			_tmp69_ = vala_collection_get_size ((ValaCollection*) _tmp68_->unresolved_symbols);
			_tmp66_ = _tmp69_ > 0;
		} else {
			_tmp66_ = FALSE;
		}
		if (_tmp66_) {
			AfroditeCodeDom* _tmp70_ = NULL;
			gint _tmp71_;
			_tmp70_ = afrodite_completion_engine_get_codedom (engine);
			_tmp71_ = vala_collection_get_size ((ValaCollection*) _tmp70_->unresolved_symbols);
			g_print (" %d\n", _tmp71_);
			{
				AfroditeCodeDom* _tmp72_ = NULL;
				ValaList* _tmp73_;
				ValaList* _symbol_list;
				gint _tmp74_;
				gint _symbol_size;
				gint _symbol_index;
				_tmp72_ = afrodite_completion_engine_get_codedom (engine);
				_tmp73_ = _vala_iterable_ref0 (_tmp72_->unresolved_symbols);
				_symbol_list = _tmp73_;
				_tmp74_ = vala_collection_get_size ((ValaCollection*) _symbol_list);
				_symbol_size = _tmp74_;
				_symbol_index = -1;
				while (TRUE) {
					gpointer _tmp75_ = NULL;
					AfroditeSymbol* _tmp76_;
					AfroditeSymbol* symbol;
					AfroditeMemberType _tmp77_;
					gchar* _tmp78_ = NULL;
					gchar* _tmp79_;
					gchar* _tmp80_ = NULL;
					gchar* _tmp81_;
					gchar* _tmp82_ = NULL;
					gchar* _tmp83_;
					gboolean _tmp84_;
					gboolean _tmp92_;
					_symbol_index = _symbol_index + 1;
					if (!(_symbol_index < _symbol_size)) {
						break;
					}
					_tmp75_ = vala_list_get (_symbol_list, _symbol_index);
					_tmp76_ = _g_object_ref0 ((AfroditeSymbol*) _tmp75_);
					symbol = _tmp76_;
					_tmp77_ = afrodite_symbol_get_member_type (symbol);
					_tmp78_ = afrodite_utils_symbols_get_symbol_type_description (_tmp77_);
					_tmp79_ = _tmp78_;
					_tmp80_ = afrodite_symbol_get_fully_qualified_name (symbol);
					_tmp81_ = _tmp80_;
					_tmp82_ = afrodite_symbol_get_description (symbol);
					_tmp83_ = _tmp82_;
					g_print ("\t%s: %s - '%s'\n", _tmp79_, _tmp81_, _tmp83_);
					_g_free0 (_tmp83_);
					_g_free0 (_tmp81_);
					_g_free0 (_tmp79_);
					_tmp84_ = afrodite_symbol_get_has_local_variables (symbol);
					if (_tmp84_) {
						g_print ("\t  unresolved local variables:");
						{
							ValaList* _tmp85_ = NULL;
							ValaList* _tmp86_;
							ValaList* _p_list;
							gint _tmp87_;
							gint _p_size;
							gint _p_index;
							_tmp85_ = afrodite_symbol_get_local_variables (symbol);
							_tmp86_ = _vala_iterable_ref0 (_tmp85_);
							_p_list = _tmp86_;
							_tmp87_ = vala_collection_get_size ((ValaCollection*) _p_list);
							_p_size = _tmp87_;
							_p_index = -1;
							while (TRUE) {
								gpointer _tmp88_ = NULL;
								AfroditeDataType* p;
								gboolean _tmp89_;
								_p_index = _p_index + 1;
								if (!(_p_index < _p_size)) {
									break;
								}
								_tmp88_ = vala_list_get (_p_list, _p_index);
								p = (AfroditeDataType*) _tmp88_;
								_tmp89_ = afrodite_data_type_get_unresolved (p);
								if (_tmp89_) {
									const gchar* _tmp90_ = NULL;
									const gchar* _tmp91_ = NULL;
									_tmp90_ = afrodite_data_type_get_name (p);
									_tmp91_ = afrodite_data_type_get_type_name (p);
									g_print ("\n\t\t%s - '%s'", _tmp90_, _tmp91_);
								}
								_afrodite_data_type_unref0 (p);
							}
							_vala_iterable_unref0 (_p_list);
						}
						g_print ("\n");
					}
					_tmp92_ = afrodite_symbol_get_has_parameters (symbol);
					if (_tmp92_) {
						g_print ("\t  unresolved parameters:");
						{
							ValaList* _tmp93_ = NULL;
							ValaList* _tmp94_;
							ValaList* _p_list;
							gint _tmp95_;
							gint _p_size;
							gint _p_index;
							_tmp93_ = afrodite_symbol_get_parameters (symbol);
							_tmp94_ = _vala_iterable_ref0 (_tmp93_);
							_p_list = _tmp94_;
							_tmp95_ = vala_collection_get_size ((ValaCollection*) _p_list);
							_p_size = _tmp95_;
							_p_index = -1;
							while (TRUE) {
								gpointer _tmp96_ = NULL;
								AfroditeDataType* p;
								gboolean _tmp97_;
								_p_index = _p_index + 1;
								if (!(_p_index < _p_size)) {
									break;
								}
								_tmp96_ = vala_list_get (_p_list, _p_index);
								p = (AfroditeDataType*) _tmp96_;
								_tmp97_ = afrodite_data_type_get_unresolved (p);
								if (_tmp97_) {
									const gchar* _tmp98_ = NULL;
									const gchar* _tmp99_ = NULL;
									_tmp98_ = afrodite_data_type_get_name (p);
									_tmp99_ = afrodite_data_type_get_type_name (p);
									g_print ("\n\t\t%s - '%s'", _tmp98_, _tmp99_);
								}
								_afrodite_data_type_unref0 (p);
							}
							_vala_iterable_unref0 (_p_list);
						}
						g_print ("\n");
					}
					_g_object_unref0 (symbol);
				}
				_vala_iterable_unref0 (_symbol_list);
			}
			g_print ("\n");
		} else {
			g_print (" none\n");
		}
	}
	g_print ("done\n");
}


static void _afrodite_test_application_on_begin_parsing_afrodite_completion_engine_begin_parsing (AfroditeCompletionEngine* _sender, AfroditeCompletionEngine* sender, gpointer self) {
	afrodite_test_application_on_begin_parsing (self, sender);
}


static void _afrodite_test_application_on_end_parsing_afrodite_completion_engine_end_parsing (AfroditeCompletionEngine* _sender, AfroditeCompletionEngine* sender, gpointer self) {
	afrodite_test_application_on_end_parsing (self, sender);
}


static void afrodite_test_application_parse (AfroditeTestApplication* self) {
	gint i;
	AfroditeCompletionEngine* _tmp0_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	i = 0;
	_tmp0_ = afrodite_completion_engine_new ("afrodite-test-engine");
	_g_object_unref0 (self->priv->_engine);
	self->priv->_engine = _tmp0_;
	g_signal_connect_object (self->priv->_engine, "begin-parsing", (GCallback) _afrodite_test_application_on_begin_parsing_afrodite_completion_engine_begin_parsing, self, 0);
	g_signal_connect_object (self->priv->_engine, "end-parsing", (GCallback) _afrodite_test_application_on_end_parsing_afrodite_completion_engine_end_parsing, self, 0);
	{
		gint repeat;
		repeat = 0;
		{
			gboolean _tmp1_;
			_tmp1_ = TRUE;
			while (TRUE) {
				if (!_tmp1_) {
					repeat++;
				}
				_tmp1_ = FALSE;
				if (!(repeat < option_repeat)) {
					break;
				}
				g_print ("Adding sources (%d):\n", repeat);
				i = 0;
				while (TRUE) {
					gchar* _tmp2_;
					gchar* filename;
					const gchar* _tmp3_ = NULL;
					if (!(option_files[i] != NULL)) {
						break;
					}
					_tmp2_ = g_strdup (option_files[i]);
					filename = _tmp2_;
					if (option_live_buffers) {
						_tmp3_ = " (live buffer)";
					} else {
						_tmp3_ = "";
					}
					g_print ("   %s%s\n", filename, _tmp3_);
					if (option_live_buffers) {
						AfroditeSourceItem* _tmp4_ = NULL;
						AfroditeSourceItem* source;
						gchar* buffer = NULL;
						gchar* _tmp5_ = NULL;
						gchar* _tmp7_;
						_tmp4_ = afrodite_source_item_new ("live-buffer.vala", AFRODITE_SOURCE_TYPE_VALA);
						source = _tmp4_;
						g_file_get_contents (filename, &_tmp5_, NULL, &_inner_error_);
						_g_free0 (buffer);
						buffer = _tmp5_;
						if (_inner_error_ != NULL) {
							goto __catch1_g_error;
						}
						goto __finally1;
						__catch1_g_error:
						{
							GError * err;
							const gchar* _tmp6_ = NULL;
							err = _inner_error_;
							_inner_error_ = NULL;
							_tmp6_ = _ ("parsing options");
							g_error ("afroditetest.vala:230: %s", _tmp6_);
							_g_error_free0 (err);
						}
						__finally1:
						if (_inner_error_ != NULL) {
							_g_free0 (buffer);
							_afrodite_source_item_unref0 (source);
							_g_free0 (filename);
							g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
							g_clear_error (&_inner_error_);
							return;
						}
						_tmp7_ = g_strdup (buffer);
						_g_free0 (source->content);
						source->content = _tmp7_;
						afrodite_completion_engine_queue_source (self->priv->_engine, source);
						_g_free0 (buffer);
						_afrodite_source_item_unref0 (source);
					} else {
						afrodite_completion_engine_queue_sourcefile (self->priv->_engine, filename, NULL, FALSE, FALSE);
					}
					i++;
					_g_free0 (filename);
				}
			}
		}
	}
}


static gint afrodite_test_application_main (gchar** args, int args_length1) {
	gint result = 0;
	AfroditeTestApplication* _tmp0_ = NULL;
	AfroditeTestApplication* application;
	gint _tmp1_;
	_tmp0_ = afrodite_test_application_new ();
	application = _tmp0_;
	_tmp1_ = afrodite_test_application_run (application, args, args_length1);
	result = _tmp1_;
	_g_object_unref0 (application);
	return result;
}


int main (int argc, char ** argv) {
	g_type_init ();
	return afrodite_test_application_main (argv, argc);
}


AfroditeTestApplication* afrodite_test_application_construct (GType object_type) {
	AfroditeTestApplication * self = NULL;
	self = (AfroditeTestApplication*) g_object_new (object_type, NULL);
	return self;
}


AfroditeTestApplication* afrodite_test_application_new (void) {
	return afrodite_test_application_construct (AFRODITE_TEST_TYPE_APPLICATION);
}


static void afrodite_test_application_class_init (AfroditeTestApplicationClass * klass) {
	afrodite_test_application_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (AfroditeTestApplicationPrivate));
	G_OBJECT_CLASS (klass)->finalize = afrodite_test_application_finalize;
}


static void afrodite_test_application_instance_init (AfroditeTestApplication * self) {
	self->priv = AFRODITE_TEST_APPLICATION_GET_PRIVATE (self);
}


static void afrodite_test_application_finalize (GObject* obj) {
	AfroditeTestApplication * self;
	self = AFRODITE_TEST_APPLICATION (obj);
	_g_main_loop_unref0 (self->priv->_loop);
	_g_object_unref0 (self->priv->_engine);
	G_OBJECT_CLASS (afrodite_test_application_parent_class)->finalize (obj);
}


GType afrodite_test_application_get_type (void) {
	static volatile gsize afrodite_test_application_type_id__volatile = 0;
	if (g_once_init_enter (&afrodite_test_application_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (AfroditeTestApplicationClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) afrodite_test_application_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (AfroditeTestApplication), 0, (GInstanceInitFunc) afrodite_test_application_instance_init, NULL };
		GType afrodite_test_application_type_id;
		afrodite_test_application_type_id = g_type_register_static (G_TYPE_OBJECT, "AfroditeTestApplication", &g_define_type_info, 0);
		g_once_init_leave (&afrodite_test_application_type_id__volatile, afrodite_test_application_type_id);
	}
	return afrodite_test_application_type_id__volatile;
}



