/* ide-vala-diagnostic-provider.c generated by valac 0.30.0, the Vala compiler
 * generated from ide-vala-diagnostic-provider.vala, do not modify */

/* ide-vala-diagnostic-provider.vala
 *
 * Copyright (C) 2015 Christian Hergert <christian@hergert.me>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <glib.h>
#include <glib-object.h>
#include <ide.h>
#include <gio/gio.h>


#define IDE_TYPE_VALA_DIAGNOSTIC_PROVIDER (ide_vala_diagnostic_provider_get_type ())
#define IDE_VALA_DIAGNOSTIC_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IDE_TYPE_VALA_DIAGNOSTIC_PROVIDER, IdeValaDiagnosticProvider))
#define IDE_VALA_DIAGNOSTIC_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), IDE_TYPE_VALA_DIAGNOSTIC_PROVIDER, IdeValaDiagnosticProviderClass))
#define IDE_IS_VALA_DIAGNOSTIC_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IDE_TYPE_VALA_DIAGNOSTIC_PROVIDER))
#define IDE_IS_VALA_DIAGNOSTIC_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), IDE_TYPE_VALA_DIAGNOSTIC_PROVIDER))
#define IDE_VALA_DIAGNOSTIC_PROVIDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IDE_TYPE_VALA_DIAGNOSTIC_PROVIDER, IdeValaDiagnosticProviderClass))

typedef struct _IdeValaDiagnosticProvider IdeValaDiagnosticProvider;
typedef struct _IdeValaDiagnosticProviderClass IdeValaDiagnosticProviderClass;
typedef struct _IdeValaDiagnosticProviderPrivate IdeValaDiagnosticProviderPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _ide_diagnostics_unref0(var) ((var == NULL) ? NULL : (var = (ide_diagnostics_unref (var), NULL)))

#define IDE_TYPE_VALA_SERVICE (ide_vala_service_get_type ())
#define IDE_VALA_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IDE_TYPE_VALA_SERVICE, IdeValaService))
#define IDE_VALA_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), IDE_TYPE_VALA_SERVICE, IdeValaServiceClass))
#define IDE_IS_VALA_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IDE_TYPE_VALA_SERVICE))
#define IDE_IS_VALA_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), IDE_TYPE_VALA_SERVICE))
#define IDE_VALA_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IDE_TYPE_VALA_SERVICE, IdeValaServiceClass))

typedef struct _IdeValaService IdeValaService;
typedef struct _IdeValaServiceClass IdeValaServiceClass;

#define IDE_TYPE_VALA_INDEX (ide_vala_index_get_type ())
#define IDE_VALA_INDEX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IDE_TYPE_VALA_INDEX, IdeValaIndex))
#define IDE_VALA_INDEX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), IDE_TYPE_VALA_INDEX, IdeValaIndexClass))
#define IDE_IS_VALA_INDEX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IDE_TYPE_VALA_INDEX))
#define IDE_IS_VALA_INDEX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), IDE_TYPE_VALA_INDEX))
#define IDE_VALA_INDEX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IDE_TYPE_VALA_INDEX, IdeValaIndexClass))

typedef struct _IdeValaIndex IdeValaIndex;
typedef struct _IdeValaIndexClass IdeValaIndexClass;
typedef struct _IdeValaDiagnosticProviderDiagnoseAsyncData IdeValaDiagnosticProviderDiagnoseAsyncData;

struct _IdeValaDiagnosticProvider {
	IdeObject parent_instance;
	IdeValaDiagnosticProviderPrivate * priv;
};

struct _IdeValaDiagnosticProviderClass {
	IdeObjectClass parent_class;
};

struct _IdeValaDiagnosticProviderDiagnoseAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	IdeValaDiagnosticProvider* self;
	IdeFile* file;
	GCancellable* cancellable;
	IdeDiagnostics* result;
	IdeContext* context;
	IdeContext* _tmp0_;
	IdeContext* _tmp1_;
	IdeValaService* service;
	void* _tmp2_;
	IdeValaService* _tmp3_;
	IdeValaIndex* _tmp4_;
	IdeValaIndex* _tmp5_;
	IdeFile* _tmp6_;
	GFile* _tmp7_;
	GFile* _tmp8_;
	IdeUnsavedFiles* _tmp9_;
	IdeUnsavedFiles* _tmp10_;
	GCancellable* _tmp11_;
	IdeDiagnostics* results;
	IdeValaIndex* _tmp12_;
	IdeValaIndex* _tmp13_;
	IdeFile* _tmp14_;
	GFile* _tmp15_;
	GFile* _tmp16_;
	GCancellable* _tmp17_;
	IdeDiagnostics* _tmp18_;
	GError * _inner_error_;
};


static gpointer ide_vala_diagnostic_provider_parent_class = NULL;
static IdeDiagnosticProviderInterface* ide_vala_diagnostic_provider_ide_diagnostic_provider_parent_iface = NULL;
static GType ide_vala_diagnostic_provider_type_id = 0;

GType ide_vala_diagnostic_provider_get_type (void) G_GNUC_CONST;
GType ide_vala_diagnostic_provider_register_type (GTypeModule * module);
enum  {
	IDE_VALA_DIAGNOSTIC_PROVIDER_DUMMY_PROPERTY
};
static void ide_vala_diagnostic_provider_real_diagnose_async_data_free (gpointer _data);
static void ide_vala_diagnostic_provider_real_diagnose_async (IdeDiagnosticProvider* base, IdeFile* file, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean ide_vala_diagnostic_provider_real_diagnose_async_co (IdeValaDiagnosticProviderDiagnoseAsyncData* _data_);
GType ide_vala_service_get_type (void) G_GNUC_CONST;
GType ide_vala_service_register_type (GTypeModule * module);
GType ide_vala_index_get_type (void) G_GNUC_CONST;
GType ide_vala_index_register_type (GTypeModule * module);
IdeValaIndex* ide_vala_service_get_index (IdeValaService* self);
void ide_vala_index_parse_file (IdeValaIndex* self, GFile* file, IdeUnsavedFiles* unsaved_files, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
gboolean ide_vala_index_parse_file_finish (IdeValaIndex* self, GAsyncResult* _res_, GError** error);
static void ide_vala_diagnostic_provider_diagnose_async_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
void ide_vala_index_get_diagnostics (IdeValaIndex* self, GFile* file, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
IdeDiagnostics* ide_vala_index_get_diagnostics_finish (IdeValaIndex* self, GAsyncResult* _res_);
IdeValaDiagnosticProvider* ide_vala_diagnostic_provider_new (void);
IdeValaDiagnosticProvider* ide_vala_diagnostic_provider_construct (GType object_type);


static void ide_vala_diagnostic_provider_real_diagnose_async_data_free (gpointer _data) {
	IdeValaDiagnosticProviderDiagnoseAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->file);
	_g_object_unref0 (_data_->cancellable);
	_ide_diagnostics_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (IdeValaDiagnosticProviderDiagnoseAsyncData, _data_);
}


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


static void ide_vala_diagnostic_provider_real_diagnose_async (IdeDiagnosticProvider* base, IdeFile* file, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	IdeValaDiagnosticProvider * self;
	IdeValaDiagnosticProviderDiagnoseAsyncData* _data_;
	IdeValaDiagnosticProvider* _tmp0_ = NULL;
	IdeFile* _tmp1_ = NULL;
	IdeFile* _tmp2_ = NULL;
	GCancellable* _tmp3_ = NULL;
	GCancellable* _tmp4_ = NULL;
	self = (IdeValaDiagnosticProvider*) base;
	_data_ = g_slice_new0 (IdeValaDiagnosticProviderDiagnoseAsyncData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, ide_vala_diagnostic_provider_real_diagnose_async);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, ide_vala_diagnostic_provider_real_diagnose_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = file;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	_g_object_unref0 (_data_->file);
	_data_->file = _tmp2_;
	_tmp3_ = cancellable;
	_tmp4_ = _g_object_ref0 (_tmp3_);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp4_;
	ide_vala_diagnostic_provider_real_diagnose_async_co (_data_);
}


static IdeDiagnostics* ide_vala_diagnostic_provider_real_diagnose_finish (IdeDiagnosticProvider* base, GAsyncResult* _res_, GError** error) {
	IdeDiagnostics* result;
	IdeValaDiagnosticProviderDiagnoseAsyncData* _data_;
	if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
		return NULL;
	}
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
	result = _data_->result;
	_data_->result = NULL;
	return result;
}


static void ide_vala_diagnostic_provider_diagnose_async_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	IdeValaDiagnosticProviderDiagnoseAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	ide_vala_diagnostic_provider_real_diagnose_async_co (_data_);
}


static gboolean ide_vala_diagnostic_provider_real_diagnose_async_co (IdeValaDiagnosticProviderDiagnoseAsyncData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = NULL;
	_data_->_tmp0_ = ide_object_get_context ((IdeObject*) _data_->self);
	_data_->_tmp1_ = NULL;
	_data_->_tmp1_ = _g_object_ref0 (_data_->_tmp0_);
	_data_->context = _data_->_tmp1_;
	_data_->_tmp2_ = NULL;
	_data_->_tmp2_ = ide_context_get_service_typed (_data_->context, IDE_TYPE_VALA_SERVICE);
	_data_->_tmp3_ = NULL;
	_data_->_tmp3_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp2_, IDE_TYPE_VALA_SERVICE, IdeValaService));
	_data_->service = _data_->_tmp3_;
	_data_->_tmp4_ = NULL;
	_data_->_tmp4_ = ide_vala_service_get_index (_data_->service);
	_data_->_tmp5_ = NULL;
	_data_->_tmp5_ = _data_->_tmp4_;
	_data_->_tmp6_ = NULL;
	_data_->_tmp6_ = _data_->file;
	_data_->_tmp7_ = NULL;
	_data_->_tmp7_ = ide_file_get_file (_data_->_tmp6_);
	_data_->_tmp8_ = NULL;
	_data_->_tmp8_ = _data_->_tmp7_;
	_data_->_tmp9_ = NULL;
	_data_->_tmp9_ = ide_context_get_unsaved_files (_data_->context);
	_data_->_tmp10_ = NULL;
	_data_->_tmp10_ = _data_->_tmp9_;
	_data_->_tmp11_ = NULL;
	_data_->_tmp11_ = _data_->cancellable;
	_data_->_state_ = 1;
	ide_vala_index_parse_file (_data_->_tmp5_, _data_->_tmp8_, _data_->_tmp10_, _data_->_tmp11_, ide_vala_diagnostic_provider_diagnose_async_ready, _data_);
	return FALSE;
	_state_1:
	ide_vala_index_parse_file_finish (_data_->_tmp5_, _data_->_res_, &_data_->_inner_error_);
	if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
		g_simple_async_result_set_from_error (_data_->_async_result, _data_->_inner_error_);
		g_error_free (_data_->_inner_error_);
		_g_object_unref0 (_data_->service);
		_g_object_unref0 (_data_->context);
		if (_data_->_state_ == 0) {
			g_simple_async_result_complete_in_idle (_data_->_async_result);
		} else {
			g_simple_async_result_complete (_data_->_async_result);
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp12_ = NULL;
	_data_->_tmp12_ = ide_vala_service_get_index (_data_->service);
	_data_->_tmp13_ = NULL;
	_data_->_tmp13_ = _data_->_tmp12_;
	_data_->_tmp14_ = NULL;
	_data_->_tmp14_ = _data_->file;
	_data_->_tmp15_ = NULL;
	_data_->_tmp15_ = ide_file_get_file (_data_->_tmp14_);
	_data_->_tmp16_ = NULL;
	_data_->_tmp16_ = _data_->_tmp15_;
	_data_->_tmp17_ = NULL;
	_data_->_tmp17_ = _data_->cancellable;
	_data_->_state_ = 2;
	ide_vala_index_get_diagnostics (_data_->_tmp13_, _data_->_tmp16_, _data_->_tmp17_, ide_vala_diagnostic_provider_diagnose_async_ready, _data_);
	return FALSE;
	_state_2:
	_data_->_tmp18_ = NULL;
	_data_->_tmp18_ = ide_vala_index_get_diagnostics_finish (_data_->_tmp13_, _data_->_res_);
	_data_->results = _data_->_tmp18_;
	_data_->result = _data_->results;
	_g_object_unref0 (_data_->service);
	_g_object_unref0 (_data_->context);
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
	_ide_diagnostics_unref0 (_data_->results);
	_g_object_unref0 (_data_->service);
	_g_object_unref0 (_data_->context);
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


IdeValaDiagnosticProvider* ide_vala_diagnostic_provider_construct (GType object_type) {
	IdeValaDiagnosticProvider * self = NULL;
	self = (IdeValaDiagnosticProvider*) g_object_new (object_type, NULL);
	return self;
}


IdeValaDiagnosticProvider* ide_vala_diagnostic_provider_new (void) {
	return ide_vala_diagnostic_provider_construct (IDE_TYPE_VALA_DIAGNOSTIC_PROVIDER);
}


static void ide_vala_diagnostic_provider_class_init (IdeValaDiagnosticProviderClass * klass) {
	ide_vala_diagnostic_provider_parent_class = g_type_class_peek_parent (klass);
}


static void ide_vala_diagnostic_provider_ide_diagnostic_provider_interface_init (IdeDiagnosticProviderInterface * iface) {
	ide_vala_diagnostic_provider_ide_diagnostic_provider_parent_iface = g_type_interface_peek_parent (iface);
	iface->diagnose_async = (IdeDiagnostics* (*)(IdeDiagnosticProvider*, IdeFile*, GCancellable*, GError**)) ide_vala_diagnostic_provider_real_diagnose_async;
	iface->diagnose_finish = ide_vala_diagnostic_provider_real_diagnose_finish;
	iface->set_context = (void (*)(IdeDiagnosticProvider*, IdeContext*)) ide_object_set_context;
	iface->set_context = (void (*) (IdeDiagnosticProvider *, IdeContext*)) ide_object_set_context;
}


static void ide_vala_diagnostic_provider_instance_init (IdeValaDiagnosticProvider * self) {
}


GType ide_vala_diagnostic_provider_get_type (void) {
	return ide_vala_diagnostic_provider_type_id;
}


GType ide_vala_diagnostic_provider_register_type (GTypeModule * module) {
	static const GTypeInfo g_define_type_info = { sizeof (IdeValaDiagnosticProviderClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ide_vala_diagnostic_provider_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (IdeValaDiagnosticProvider), 0, (GInstanceInitFunc) ide_vala_diagnostic_provider_instance_init, NULL };
	static const GInterfaceInfo ide_diagnostic_provider_info = { (GInterfaceInitFunc) ide_vala_diagnostic_provider_ide_diagnostic_provider_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	ide_vala_diagnostic_provider_type_id = g_type_module_register_type (module, ide_object_get_type (), "IdeValaDiagnosticProvider", &g_define_type_info, 0);
	g_type_module_add_interface (module, ide_vala_diagnostic_provider_type_id, ide_diagnostic_provider_get_type (), &ide_diagnostic_provider_info);
	return ide_vala_diagnostic_provider_type_id;
}



