/* gcp-document.c generated by valac 0.19.0, the Vala compiler
 * generated from gcp-document.vala, do not modify */

/*
 * This file is part of gedit-code-assistant.
 *
 * Copyright (C) 2011 - Jesse van den Kieboom
 *
 * gedit-code-assistant 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.
 *
 * gedit-code-assistant 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 gedit-code-assistant.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <glib.h>
#include <glib-object.h>
#include <gedit/gedit-document.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <gtk/gtk.h>
#include <gtksourceview/gtksourceview.h>


#define GCP_TYPE_DOCUMENT (gcp_document_get_type ())
#define GCP_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCP_TYPE_DOCUMENT, GcpDocument))
#define GCP_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GCP_TYPE_DOCUMENT, GcpDocumentClass))
#define GCP_IS_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCP_TYPE_DOCUMENT))
#define GCP_IS_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GCP_TYPE_DOCUMENT))
#define GCP_DOCUMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GCP_TYPE_DOCUMENT, GcpDocumentClass))

typedef struct _GcpDocument GcpDocument;
typedef struct _GcpDocumentClass GcpDocumentClass;
typedef struct _GcpDocumentPrivate GcpDocumentPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

#define GCP_TYPE_DIAGNOSTIC_SUPPORT (gcp_diagnostic_support_get_type ())
#define GCP_DIAGNOSTIC_SUPPORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCP_TYPE_DIAGNOSTIC_SUPPORT, GcpDiagnosticSupport))
#define GCP_IS_DIAGNOSTIC_SUPPORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCP_TYPE_DIAGNOSTIC_SUPPORT))
#define GCP_DIAGNOSTIC_SUPPORT_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GCP_TYPE_DIAGNOSTIC_SUPPORT, GcpDiagnosticSupportIface))

typedef struct _GcpDiagnosticSupport GcpDiagnosticSupport;
typedef struct _GcpDiagnosticSupportIface GcpDiagnosticSupportIface;

#define GCP_TYPE_SOURCE_INDEX (gcp_source_index_get_type ())
#define GCP_SOURCE_INDEX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCP_TYPE_SOURCE_INDEX, GcpSourceIndex))
#define GCP_SOURCE_INDEX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GCP_TYPE_SOURCE_INDEX, GcpSourceIndexClass))
#define GCP_IS_SOURCE_INDEX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCP_TYPE_SOURCE_INDEX))
#define GCP_IS_SOURCE_INDEX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GCP_TYPE_SOURCE_INDEX))
#define GCP_SOURCE_INDEX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GCP_TYPE_SOURCE_INDEX, GcpSourceIndexClass))

typedef struct _GcpSourceIndex GcpSourceIndex;
typedef struct _GcpSourceIndexClass GcpSourceIndexClass;

#define GCP_TYPE_DIAGNOSTIC_TAGS (gcp_diagnostic_tags_get_type ())
#define GCP_DIAGNOSTIC_TAGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCP_TYPE_DIAGNOSTIC_TAGS, GcpDiagnosticTags))
#define GCP_DIAGNOSTIC_TAGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GCP_TYPE_DIAGNOSTIC_TAGS, GcpDiagnosticTagsClass))
#define GCP_IS_DIAGNOSTIC_TAGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCP_TYPE_DIAGNOSTIC_TAGS))
#define GCP_IS_DIAGNOSTIC_TAGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GCP_TYPE_DIAGNOSTIC_TAGS))
#define GCP_DIAGNOSTIC_TAGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GCP_TYPE_DIAGNOSTIC_TAGS, GcpDiagnosticTagsClass))

typedef struct _GcpDiagnosticTags GcpDiagnosticTags;
typedef struct _GcpDiagnosticTagsClass GcpDiagnosticTagsClass;

#define GCP_TYPE_SOURCE_LOCATION (gcp_source_location_get_type ())
#define GCP_SOURCE_LOCATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCP_TYPE_SOURCE_LOCATION, GcpSourceLocation))
#define GCP_SOURCE_LOCATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GCP_TYPE_SOURCE_LOCATION, GcpSourceLocationClass))
#define GCP_IS_SOURCE_LOCATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCP_TYPE_SOURCE_LOCATION))
#define GCP_IS_SOURCE_LOCATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GCP_TYPE_SOURCE_LOCATION))
#define GCP_SOURCE_LOCATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GCP_TYPE_SOURCE_LOCATION, GcpSourceLocationClass))

typedef struct _GcpSourceLocation GcpSourceLocation;
typedef struct _GcpSourceLocationClass GcpSourceLocationClass;

#define GCP_TYPE_SOURCE_RANGE (gcp_source_range_get_type ())
#define GCP_SOURCE_RANGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCP_TYPE_SOURCE_RANGE, GcpSourceRange))
#define GCP_SOURCE_RANGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GCP_TYPE_SOURCE_RANGE, GcpSourceRangeClass))
#define GCP_IS_SOURCE_RANGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCP_TYPE_SOURCE_RANGE))
#define GCP_IS_SOURCE_RANGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GCP_TYPE_SOURCE_RANGE))
#define GCP_SOURCE_RANGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GCP_TYPE_SOURCE_RANGE, GcpSourceRangeClass))

typedef struct _GcpSourceRange GcpSourceRange;
typedef struct _GcpSourceRangeClass GcpSourceRangeClass;

#define GCP_DIAGNOSTIC_TYPE_SEVERITY (gcp_diagnostic_severity_get_type ())

#define GCP_TYPE_DIAGNOSTIC (gcp_diagnostic_get_type ())
#define GCP_DIAGNOSTIC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCP_TYPE_DIAGNOSTIC, GcpDiagnostic))
#define GCP_DIAGNOSTIC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GCP_TYPE_DIAGNOSTIC, GcpDiagnosticClass))
#define GCP_IS_DIAGNOSTIC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCP_TYPE_DIAGNOSTIC))
#define GCP_IS_DIAGNOSTIC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GCP_TYPE_DIAGNOSTIC))
#define GCP_DIAGNOSTIC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GCP_TYPE_DIAGNOSTIC, GcpDiagnosticClass))

typedef struct _GcpDiagnostic GcpDiagnostic;
typedef struct _GcpDiagnosticClass GcpDiagnosticClass;
#define _g_slist_free0(var) ((var == NULL) ? NULL : (var = (g_slist_free (var), NULL)))

#define GCP_TYPE_SOURCE_RANGE_SUPPORT (gcp_source_range_support_get_type ())
#define GCP_SOURCE_RANGE_SUPPORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCP_TYPE_SOURCE_RANGE_SUPPORT, GcpSourceRangeSupport))
#define GCP_IS_SOURCE_RANGE_SUPPORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCP_TYPE_SOURCE_RANGE_SUPPORT))
#define GCP_SOURCE_RANGE_SUPPORT_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GCP_TYPE_SOURCE_RANGE_SUPPORT, GcpSourceRangeSupportIface))

typedef struct _GcpSourceRangeSupport GcpSourceRangeSupport;
typedef struct _GcpSourceRangeSupportIface GcpSourceRangeSupportIface;

#define GCP_DIAGNOSTIC_TYPE_FIXIT (gcp_diagnostic_fixit_get_type ())
typedef struct _GcpDiagnosticFixit GcpDiagnosticFixit;

#define GCP_SOURCE_INDEX_TYPE_ITERATOR (gcp_source_index_iterator_get_type ())
#define GCP_SOURCE_INDEX_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCP_SOURCE_INDEX_TYPE_ITERATOR, GcpSourceIndexIterator))
#define GCP_SOURCE_INDEX_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GCP_SOURCE_INDEX_TYPE_ITERATOR, GcpSourceIndexIteratorClass))
#define GCP_SOURCE_INDEX_IS_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCP_SOURCE_INDEX_TYPE_ITERATOR))
#define GCP_SOURCE_INDEX_IS_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GCP_SOURCE_INDEX_TYPE_ITERATOR))
#define GCP_SOURCE_INDEX_ITERATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GCP_SOURCE_INDEX_TYPE_ITERATOR, GcpSourceIndexIteratorClass))

typedef struct _GcpSourceIndexIterator GcpSourceIndexIterator;
typedef struct _GcpSourceIndexIteratorClass GcpSourceIndexIteratorClass;

struct _GcpDocument {
	GObject parent_instance;
	GcpDocumentPrivate * priv;
};

struct _GcpDocumentClass {
	GObjectClass parent_class;
	gboolean (*get_tainted) (GcpDocument* self);
	void (*set_tainted) (GcpDocument* self, gboolean value);
};

struct _GcpDocumentPrivate {
	GeditDocument* d_document;
	gboolean d_untitled;
	gboolean d_modified;
	gchar* d_text;
	GFile* d_location;
	gboolean d_tainted;
	gboolean d_dispose_ran;
};

struct _GcpDiagnosticSupportIface {
	GTypeInterface parent_iface;
	GcpSourceIndex* (*begin_diagnostics) (GcpDiagnosticSupport* self);
	void (*end_diagnostics) (GcpDiagnosticSupport* self);
	void (*set_diagnostic_tags) (GcpDiagnosticSupport* self, GcpDiagnosticTags* tags);
	GcpDiagnosticTags* (*get_diagnostic_tags) (GcpDiagnosticSupport* self);
};

typedef enum  {
	GCP_DIAGNOSTIC_SEVERITY_NONE,
	GCP_DIAGNOSTIC_SEVERITY_INFO,
	GCP_DIAGNOSTIC_SEVERITY_WARNING,
	GCP_DIAGNOSTIC_SEVERITY_ERROR,
	GCP_DIAGNOSTIC_SEVERITY_FATAL,
	GCP_DIAGNOSTIC_SEVERITY_NUM
} GcpDiagnosticSeverity;

struct _GcpSourceRangeSupportIface {
	GTypeInterface parent_iface;
	GcpSourceRange* (*get_range) (GcpSourceRangeSupport* self);
	GcpSourceRange** (*get_ranges) (GcpSourceRangeSupport* self, int* result_length1);
};

struct _GcpDiagnosticFixit {
	GcpSourceRange* range;
	gchar* replacement;
};

typedef void (*GcpWithDiagnosticsCallback) (GcpSourceIndex* diagnostics, void* user_data);

static gpointer gcp_document_parent_class = NULL;

GType gcp_document_get_type (void) G_GNUC_CONST;
#define GCP_DOCUMENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GCP_TYPE_DOCUMENT, GcpDocumentPrivate))
enum  {
	GCP_DOCUMENT_DUMMY_PROPERTY,
	GCP_DOCUMENT_DOCUMENT,
	GCP_DOCUMENT_TAINTED,
	GCP_DOCUMENT_LOCATION,
	GCP_DOCUMENT_TEXT,
	GCP_DOCUMENT_IS_MODIFIED
};
static void gcp_document_remove_marks (GcpDocument* self);
const gchar* gcp_document_get_info_mark_category (void);
const gchar* gcp_document_get_warning_mark_category (void);
const gchar* gcp_document_get_error_mark_category (void);
static void gcp_document_real_dispose (GObject* base);
static void gcp_document_on_document_modified_changed (GcpDocument* self);
static void _gcp_document_on_document_modified_changed_gtk_text_buffer_modified_changed (GtkTextBuffer* _sender, gpointer self);
static void gcp_document_on_location_changed (GcpDocument* self);
static void _gcp_document_on_location_changed_g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self);
static void gcp_document_on_document_end_user_action (GcpDocument* self);
static void _gcp_document_on_document_end_user_action_gtk_text_buffer_end_user_action (GtkTextBuffer* _sender, gpointer self);
static void gcp_document_on_document_saved (GcpDocument* self);
static void _gcp_document_on_document_saved_gedit_document_saved (GeditDocument* _sender, void* _error_, gpointer self);
GType gcp_source_index_get_type (void) G_GNUC_CONST;
GType gcp_diagnostic_tags_get_type (void) G_GNUC_CONST;
GType gcp_diagnostic_support_get_type (void) G_GNUC_CONST;
static void gcp_document_on_diagnostic_updated (GcpDocument* self, GcpDiagnosticSupport* diagnostic);
static void _gcp_document_on_diagnostic_updated_gcp_diagnostic_support_diagnostics_updated (GcpDiagnosticSupport* _sender, gpointer self);
GType gcp_source_location_get_type (void) G_GNUC_CONST;
static gboolean gcp_document_source_location (GcpDocument* self, GcpSourceLocation* location, GtkTextIter* iter);
gboolean gcp_source_location_get_iter (GcpSourceLocation* self, GtkTextBuffer* buffer, GtkTextIter* iter);
GType gcp_source_range_get_type (void) G_GNUC_CONST;
gboolean gcp_document_source_range (GcpDocument* self, GcpSourceRange* range, GtkTextIter* start, GtkTextIter* end);
gboolean gcp_source_range_get_iters (GcpSourceRange* self, GtkTextBuffer* buffer, GtkTextIter* start, GtkTextIter* end);
GType gcp_diagnostic_severity_get_type (void) G_GNUC_CONST;
gchar* gcp_document_mark_category_for_severity (GcpDiagnosticSeverity severity);
GType gcp_diagnostic_get_type (void) G_GNUC_CONST;
static void gcp_document_mark_diagnostic_range (GcpDocument* self, GcpDiagnostic* diagnostic, GtkTextIter* start, GtkTextIter* end);
GcpDiagnosticTags* gcp_diagnostic_support_get_diagnostic_tags (GcpDiagnosticSupport* self);
GtkTextTag* gcp_diagnostic_tags_get (GcpDiagnosticTags* self, GcpDiagnosticSeverity severity);
GcpDiagnosticSeverity gcp_diagnostic_get_severity (GcpDiagnostic* self);
static void gcp_document_mark_diagnostic (GcpDocument* self, GcpDiagnostic* diagnostic);
GType gcp_source_range_support_get_type (void) G_GNUC_CONST;
GcpSourceRange** gcp_source_range_support_get_ranges (GcpSourceRangeSupport* self, int* result_length1);
GcpSourceLocation* gcp_diagnostic_get_location (GcpDiagnostic* self);
GtkTextTag* gcp_diagnostic_tags_get_location_tag (GcpDiagnosticTags* self);
GType gcp_diagnostic_fixit_get_type (void) G_GNUC_CONST;
GcpDiagnosticFixit* gcp_diagnostic_fixit_dup (const GcpDiagnosticFixit* self);
void gcp_diagnostic_fixit_free (GcpDiagnosticFixit* self);
void gcp_diagnostic_fixit_copy (const GcpDiagnosticFixit* self, GcpDiagnosticFixit* dest);
void gcp_diagnostic_fixit_destroy (GcpDiagnosticFixit* self);
GcpDiagnosticFixit* gcp_diagnostic_get_fixits (GcpDiagnostic* self, int* result_length1);
GtkTextTag* gcp_diagnostic_tags_get_fixit_tag (GcpDiagnosticTags* self);
GtkTextTag* gcp_diagnostic_tags_get_error_tag (GcpDiagnosticTags* self);
GtkTextTag* gcp_diagnostic_tags_get_warning_tag (GcpDiagnosticTags* self);
GtkTextTag* gcp_diagnostic_tags_get_info_tag (GcpDiagnosticTags* self);
void gcp_diagnostic_support_with_diagnostics (GcpDiagnosticSupport* self, GcpWithDiagnosticsCallback callback, void* callback_target);
static void __lambda5_ (GcpDocument* self, GcpSourceIndex* diagnostics);
GType gcp_source_index_iterator_get_type (void) G_GNUC_CONST;
GcpSourceIndexIterator* gcp_source_index_iterator (GcpSourceIndex* self);
gboolean gcp_source_index_iterator_next (GcpSourceIndexIterator* self);
GObject* gcp_source_index_iterator_get (GcpSourceIndexIterator* self);
static void ___lambda5__gcp_with_diagnostics_callback (GcpSourceIndex* diagnostics, gpointer self);
static void gcp_document_set_location (GcpDocument* self, GFile* location);
static void gcp_document_update_location (GcpDocument* self);
GeditDocument* gcp_document_get_document (GcpDocument* self);
static void gcp_document_update_modified (GcpDocument* self);
static void gcp_document_update_text (GcpDocument* self);
void gcp_document_emit_changed (GcpDocument* self);
GcpDocument* gcp_document_new (void);
GcpDocument* gcp_document_construct (GType object_type);
static void gcp_document_set_document (GcpDocument* self, GeditDocument* value);
gboolean gcp_document_get_tainted (GcpDocument* self);
void gcp_document_set_tainted (GcpDocument* self, gboolean value);
GFile* gcp_document_get_location (GcpDocument* self);
const gchar* gcp_document_get_text (GcpDocument* self);
gboolean gcp_document_get_is_modified (GcpDocument* self);
static GObject * gcp_document_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void gcp_document_finalize (GObject* obj);
static void _vala_gcp_document_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_gcp_document_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);


static void gcp_document_remove_marks (GcpDocument* self) {
	GtkTextIter start = {0};
	GtkTextIter end = {0};
	GeditDocument* _tmp0_;
	GtkTextIter _tmp1_ = {0};
	GtkTextIter _tmp2_ = {0};
	GeditDocument* _tmp3_;
	GtkTextIter _tmp4_;
	GtkTextIter _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	GeditDocument* _tmp8_;
	GtkTextIter _tmp9_ = {0};
	GtkTextIter _tmp10_ = {0};
	GeditDocument* _tmp11_;
	GtkTextIter _tmp12_;
	GtkTextIter _tmp13_;
	const gchar* _tmp14_;
	const gchar* _tmp15_;
	GeditDocument* _tmp16_;
	GtkTextIter _tmp17_ = {0};
	GtkTextIter _tmp18_ = {0};
	GeditDocument* _tmp19_;
	GtkTextIter _tmp20_;
	GtkTextIter _tmp21_;
	const gchar* _tmp22_;
	const gchar* _tmp23_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->d_document;
	gtk_text_buffer_get_bounds ((GtkTextBuffer*) _tmp0_, &_tmp1_, &_tmp2_);
	start = _tmp1_;
	end = _tmp2_;
	_tmp3_ = self->priv->d_document;
	_tmp4_ = start;
	_tmp5_ = end;
	_tmp6_ = gcp_document_get_info_mark_category ();
	_tmp7_ = _tmp6_;
	gtk_source_buffer_remove_source_marks ((GtkSourceBuffer*) _tmp3_, &_tmp4_, &_tmp5_, _tmp7_);
	_tmp8_ = self->priv->d_document;
	gtk_text_buffer_get_bounds ((GtkTextBuffer*) _tmp8_, &_tmp9_, &_tmp10_);
	start = _tmp9_;
	end = _tmp10_;
	_tmp11_ = self->priv->d_document;
	_tmp12_ = start;
	_tmp13_ = end;
	_tmp14_ = gcp_document_get_warning_mark_category ();
	_tmp15_ = _tmp14_;
	gtk_source_buffer_remove_source_marks ((GtkSourceBuffer*) _tmp11_, &_tmp12_, &_tmp13_, _tmp15_);
	_tmp16_ = self->priv->d_document;
	gtk_text_buffer_get_bounds ((GtkTextBuffer*) _tmp16_, &_tmp17_, &_tmp18_);
	start = _tmp17_;
	end = _tmp18_;
	_tmp19_ = self->priv->d_document;
	_tmp20_ = start;
	_tmp21_ = end;
	_tmp22_ = gcp_document_get_error_mark_category ();
	_tmp23_ = _tmp22_;
	gtk_source_buffer_remove_source_marks ((GtkSourceBuffer*) _tmp19_, &_tmp20_, &_tmp21_, _tmp23_);
}


static void _gcp_document_on_document_modified_changed_gtk_text_buffer_modified_changed (GtkTextBuffer* _sender, gpointer self) {
	gcp_document_on_document_modified_changed (self);
}


static void _gcp_document_on_location_changed_g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) {
	gcp_document_on_location_changed (self);
}


static void _gcp_document_on_document_end_user_action_gtk_text_buffer_end_user_action (GtkTextBuffer* _sender, gpointer self) {
	gcp_document_on_document_end_user_action (self);
}


static void _gcp_document_on_document_saved_gedit_document_saved (GeditDocument* _sender, void* _error_, gpointer self) {
	gcp_document_on_document_saved (self);
}


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


static void _gcp_document_on_diagnostic_updated_gcp_diagnostic_support_diagnostics_updated (GcpDiagnosticSupport* _sender, gpointer self) {
	gcp_document_on_diagnostic_updated (self, _sender);
}


static void gcp_document_real_dispose (GObject* base) {
	GcpDocument * self;
	gboolean _tmp0_;
	self = (GcpDocument*) base;
	_tmp0_ = self->priv->d_dispose_ran;
	if (!_tmp0_) {
		GeditDocument* _tmp1_;
		guint _tmp2_ = 0U;
		GeditDocument* _tmp3_;
		guint _tmp4_ = 0U;
		GQuark _tmp5_ = 0U;
		GeditDocument* _tmp6_;
		guint _tmp7_ = 0U;
		GeditDocument* _tmp8_;
		guint _tmp9_ = 0U;
		GcpDiagnosticSupport* _tmp10_;
		GcpDiagnosticSupport* diag;
		GcpDiagnosticSupport* _tmp11_;
		self->priv->d_dispose_ran = TRUE;
		_tmp1_ = self->priv->d_document;
		g_signal_parse_name ("modified-changed", GTK_TYPE_TEXT_BUFFER, &_tmp2_, NULL, FALSE);
		g_signal_handlers_disconnect_matched ((GtkTextBuffer*) _tmp1_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp2_, 0, NULL, (GCallback) _gcp_document_on_document_modified_changed_gtk_text_buffer_modified_changed, self);
		_tmp3_ = self->priv->d_document;
		g_signal_parse_name ("notify::location", G_TYPE_OBJECT, &_tmp4_, &_tmp5_, TRUE);
		g_signal_handlers_disconnect_matched ((GObject*) _tmp3_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DETAIL | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp4_, _tmp5_, NULL, (GCallback) _gcp_document_on_location_changed_g_object_notify, self);
		_tmp6_ = self->priv->d_document;
		g_signal_parse_name ("end-user-action", GTK_TYPE_TEXT_BUFFER, &_tmp7_, NULL, FALSE);
		g_signal_handlers_disconnect_matched ((GtkTextBuffer*) _tmp6_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp7_, 0, NULL, (GCallback) _gcp_document_on_document_end_user_action_gtk_text_buffer_end_user_action, self);
		_tmp8_ = self->priv->d_document;
		g_signal_parse_name ("saved", gedit_document_get_type (), &_tmp9_, NULL, FALSE);
		g_signal_handlers_disconnect_matched (_tmp8_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp9_, 0, NULL, (GCallback) _gcp_document_on_document_saved_gedit_document_saved, self);
		_tmp10_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (self, GCP_TYPE_DIAGNOSTIC_SUPPORT) ? ((GcpDiagnosticSupport*) self) : NULL);
		diag = _tmp10_;
		_tmp11_ = diag;
		if (_tmp11_ != NULL) {
			GcpDiagnosticSupport* _tmp12_;
			guint _tmp13_ = 0U;
			_tmp12_ = diag;
			g_signal_parse_name ("diagnostics-updated", GCP_TYPE_DIAGNOSTIC_SUPPORT, &_tmp13_, NULL, FALSE);
			g_signal_handlers_disconnect_matched (_tmp12_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp13_, 0, NULL, (GCallback) _gcp_document_on_diagnostic_updated_gcp_diagnostic_support_diagnostics_updated, self);
			gcp_document_remove_marks (self);
		}
		_g_object_unref0 (diag);
	}
	G_OBJECT_CLASS (gcp_document_parent_class)->dispose (G_TYPE_CHECK_INSTANCE_CAST (self, G_TYPE_OBJECT, GObject));
}


static gboolean gcp_document_source_location (GcpDocument* self, GcpSourceLocation* location, GtkTextIter* iter) {
	GtkTextIter _vala_iter = {0};
	gboolean result = FALSE;
	GcpSourceLocation* _tmp0_;
	GeditDocument* _tmp1_;
	GtkTextIter _tmp2_ = {0};
	gboolean _tmp3_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (location != NULL, FALSE);
	_tmp0_ = location;
	_tmp1_ = self->priv->d_document;
	_tmp3_ = gcp_source_location_get_iter (_tmp0_, (GtkTextBuffer*) _tmp1_, &_tmp2_);
	_vala_iter = _tmp2_;
	result = _tmp3_;
	if (iter) {
		*iter = _vala_iter;
	}
	return result;
}


gboolean gcp_document_source_range (GcpDocument* self, GcpSourceRange* range, GtkTextIter* start, GtkTextIter* end) {
	GtkTextIter _vala_start = {0};
	GtkTextIter _vala_end = {0};
	gboolean result = FALSE;
	GcpSourceRange* _tmp0_;
	GeditDocument* _tmp1_;
	GtkTextIter _tmp2_ = {0};
	GtkTextIter _tmp3_ = {0};
	gboolean _tmp4_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (range != NULL, FALSE);
	_tmp0_ = range;
	_tmp1_ = self->priv->d_document;
	_tmp4_ = gcp_source_range_get_iters (_tmp0_, (GtkTextBuffer*) _tmp1_, &_tmp2_, &_tmp3_);
	_vala_start = _tmp2_;
	_vala_end = _tmp3_;
	result = _tmp4_;
	if (start) {
		*start = _vala_start;
	}
	if (end) {
		*end = _vala_end;
	}
	return result;
}


gchar* gcp_document_mark_category_for_severity (GcpDiagnosticSeverity severity) {
	gchar* result = NULL;
	GcpDiagnosticSeverity _tmp0_;
	_tmp0_ = severity;
	switch (_tmp0_) {
		case GCP_DIAGNOSTIC_SEVERITY_WARNING:
		{
			const gchar* _tmp1_;
			const gchar* _tmp2_;
			gchar* _tmp3_;
			_tmp1_ = gcp_document_get_warning_mark_category ();
			_tmp2_ = _tmp1_;
			_tmp3_ = g_strdup (_tmp2_);
			result = _tmp3_;
			return result;
		}
		case GCP_DIAGNOSTIC_SEVERITY_ERROR:
		case GCP_DIAGNOSTIC_SEVERITY_FATAL:
		{
			const gchar* _tmp4_;
			const gchar* _tmp5_;
			gchar* _tmp6_;
			_tmp4_ = gcp_document_get_error_mark_category ();
			_tmp5_ = _tmp4_;
			_tmp6_ = g_strdup (_tmp5_);
			result = _tmp6_;
			return result;
		}
		case GCP_DIAGNOSTIC_SEVERITY_INFO:
		{
			const gchar* _tmp7_;
			const gchar* _tmp8_;
			gchar* _tmp9_;
			_tmp7_ = gcp_document_get_info_mark_category ();
			_tmp8_ = _tmp7_;
			_tmp9_ = g_strdup (_tmp8_);
			result = _tmp9_;
			return result;
		}
		default:
		{
			result = NULL;
			return result;
		}
	}
}


static void gcp_document_mark_diagnostic_range (GcpDocument* self, GcpDiagnostic* diagnostic, GtkTextIter* start, GtkTextIter* end) {
	GcpDiagnosticSupport* _tmp0_;
	GcpDiagnosticSupport* sup;
	GcpDiagnosticSupport* _tmp1_;
	GcpDiagnosticTags* _tmp2_ = NULL;
	GcpDiagnosticTags* _tmp3_;
	GcpDiagnostic* _tmp4_;
	GcpDiagnosticSeverity _tmp5_;
	GcpDiagnosticSeverity _tmp6_;
	GtkTextTag* _tmp7_ = NULL;
	GtkTextTag* _tmp8_;
	GtkTextTag* tag;
	GcpDiagnostic* _tmp9_;
	GcpDiagnosticSeverity _tmp10_;
	GcpDiagnosticSeverity _tmp11_;
	gchar* _tmp12_ = NULL;
	gchar* category;
	GeditDocument* _tmp13_;
	GtkTextTag* _tmp14_;
	GtkTextIter _tmp15_;
	GtkTextIter _tmp16_;
	GtkTextIter _tmp17_;
	GtkTextIter m;
	gboolean _tmp18_ = FALSE;
	g_return_if_fail (self != NULL);
	g_return_if_fail (diagnostic != NULL);
	g_return_if_fail (start != NULL);
	g_return_if_fail (end != NULL);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (self, GCP_TYPE_DIAGNOSTIC_SUPPORT) ? ((GcpDiagnosticSupport*) self) : NULL);
	sup = _tmp0_;
	_tmp1_ = sup;
	_tmp2_ = gcp_diagnostic_support_get_diagnostic_tags (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = diagnostic;
	_tmp5_ = gcp_diagnostic_get_severity (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = gcp_diagnostic_tags_get (_tmp3_, _tmp6_);
	_tmp8_ = _tmp7_;
	_g_object_unref0 (_tmp3_);
	tag = _tmp8_;
	_tmp9_ = diagnostic;
	_tmp10_ = gcp_diagnostic_get_severity (_tmp9_);
	_tmp11_ = _tmp10_;
	_tmp12_ = gcp_document_mark_category_for_severity (_tmp11_);
	category = _tmp12_;
	_tmp13_ = self->priv->d_document;
	_tmp14_ = tag;
	_tmp15_ = *start;
	_tmp16_ = *end;
	gtk_text_buffer_apply_tag ((GtkTextBuffer*) _tmp13_, _tmp14_, &_tmp15_, &_tmp16_);
	_tmp17_ = *start;
	m = _tmp17_;
	_tmp18_ = gtk_text_iter_starts_line (&m);
	if (!_tmp18_) {
		gtk_text_iter_set_line_offset (&m, 0);
	}
	while (TRUE) {
		gboolean _tmp19_ = FALSE;
		const gchar* _tmp20_;
		gboolean _tmp23_;
		gboolean alreadyhas;
		GeditDocument* _tmp24_;
		GtkTextIter _tmp25_;
		const gchar* _tmp26_;
		GSList* _tmp27_ = NULL;
		gboolean _tmp32_;
		gboolean _tmp41_ = FALSE;
		_tmp20_ = category;
		if (_tmp20_ != NULL) {
			GtkTextIter _tmp21_;
			gint _tmp22_ = 0;
			_tmp21_ = *end;
			_tmp22_ = gtk_text_iter_compare (&m, &_tmp21_);
			_tmp19_ = _tmp22_ <= 0;
		} else {
			_tmp19_ = FALSE;
		}
		_tmp23_ = _tmp19_;
		if (!_tmp23_) {
			break;
		}
		alreadyhas = FALSE;
		_tmp24_ = self->priv->d_document;
		_tmp25_ = m;
		_tmp26_ = category;
		_tmp27_ = gtk_source_buffer_get_source_marks_at_iter ((GtkSourceBuffer*) _tmp24_, &_tmp25_, _tmp26_);
		{
			GSList* mark_collection = NULL;
			GSList* mark_it = NULL;
			mark_collection = _tmp27_;
			for (mark_it = mark_collection; mark_it != NULL; mark_it = mark_it->next) {
				GtkSourceMark* _tmp28_;
				GtkSourceMark* mark = NULL;
				_tmp28_ = _g_object_ref0 ((GtkSourceMark*) mark_it->data);
				mark = _tmp28_;
				{
					GtkSourceMark* _tmp29_;
					gconstpointer _tmp30_ = NULL;
					GcpDiagnostic* _tmp31_;
					_tmp29_ = mark;
					_tmp30_ = g_object_get_data ((GObject*) _tmp29_, "Gcp.Document.MarkDiagnostic");
					_tmp31_ = diagnostic;
					if (((GcpDiagnostic*) _tmp30_) == _tmp31_) {
						alreadyhas = TRUE;
						_g_object_unref0 (mark);
						break;
					}
					_g_object_unref0 (mark);
				}
			}
			_g_slist_free0 (mark_collection);
		}
		_tmp32_ = alreadyhas;
		if (!_tmp32_) {
			GeditDocument* _tmp33_;
			const gchar* _tmp34_;
			GtkTextIter _tmp35_;
			GtkSourceMark* _tmp36_ = NULL;
			GtkSourceMark* _tmp37_;
			GtkSourceMark* mark;
			GtkSourceMark* _tmp38_;
			GcpDiagnostic* _tmp39_;
			GcpDiagnostic* _tmp40_;
			_tmp33_ = self->priv->d_document;
			_tmp34_ = category;
			_tmp35_ = m;
			_tmp36_ = gtk_source_buffer_create_source_mark ((GtkSourceBuffer*) _tmp33_, NULL, _tmp34_, &_tmp35_);
			_tmp37_ = _g_object_ref0 (_tmp36_);
			mark = _tmp37_;
			_tmp38_ = mark;
			_tmp39_ = diagnostic;
			_tmp40_ = _g_object_ref0 (_tmp39_);
			g_object_set_data_full ((GObject*) _tmp38_, "Gcp.Document.MarkDiagnostic", _tmp40_, g_object_unref);
			_g_object_unref0 (mark);
		}
		_tmp41_ = gtk_text_iter_forward_line (&m);
		if (!_tmp41_) {
			break;
		}
	}
	_g_free0 (category);
	_g_object_unref0 (tag);
	_g_object_unref0 (sup);
}


static void gcp_document_mark_diagnostic (GcpDocument* self, GcpDiagnostic* diagnostic) {
	GtkTextIter start = {0};
	GtkTextIter end = {0};
	GcpDiagnosticSupport* _tmp0_;
	GcpDiagnosticSupport* sup;
	GcpDiagnostic* _tmp23_;
	GcpSourceLocation* _tmp24_;
	GcpSourceLocation* _tmp25_;
	GtkTextIter _tmp26_ = {0};
	gboolean _tmp27_ = FALSE;
	g_return_if_fail (self != NULL);
	g_return_if_fail (diagnostic != NULL);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (self, GCP_TYPE_DIAGNOSTIC_SUPPORT) ? ((GcpDiagnosticSupport*) self) : NULL);
	sup = _tmp0_;
	{
		guint i;
		i = (guint) 0;
		{
			gboolean _tmp1_;
			_tmp1_ = TRUE;
			while (TRUE) {
				gboolean _tmp2_;
				guint _tmp4_;
				GcpDiagnostic* _tmp5_;
				GcpSourceRange** _tmp6_;
				gint _tmp6__length1;
				GcpSourceRange** _tmp7_;
				gint _tmp7__length1;
				GcpSourceRange** _tmp8_;
				gint _tmp8__length1;
				gboolean _tmp9_;
				GcpDiagnostic* _tmp10_;
				GcpSourceRange** _tmp11_;
				gint _tmp11__length1;
				GcpSourceRange** _tmp12_;
				gint _tmp12__length1;
				GcpSourceRange** _tmp13_;
				gint _tmp13__length1;
				guint _tmp14_;
				GcpSourceRange* _tmp15_;
				GtkTextIter _tmp16_ = {0};
				GtkTextIter _tmp17_ = {0};
				gboolean _tmp18_ = FALSE;
				gboolean _tmp19_;
				GcpDiagnostic* _tmp20_;
				GtkTextIter _tmp21_;
				GtkTextIter _tmp22_;
				_tmp2_ = _tmp1_;
				if (!_tmp2_) {
					guint _tmp3_;
					_tmp3_ = i;
					i = _tmp3_ + 1;
				}
				_tmp1_ = FALSE;
				_tmp4_ = i;
				_tmp5_ = diagnostic;
				_tmp6_ = gcp_source_range_support_get_ranges ((GcpSourceRangeSupport*) _tmp5_, &_tmp6__length1);
				_tmp7_ = _tmp6_;
				_tmp7__length1 = _tmp6__length1;
				_tmp8_ = _tmp7_;
				_tmp8__length1 = _tmp7__length1;
				_tmp9_ = !(_tmp4_ < ((guint) _tmp7__length1));
				_tmp8_ = (_vala_array_free (_tmp8_, _tmp8__length1, (GDestroyNotify) g_object_unref), NULL);
				if (_tmp9_) {
					break;
				}
				_tmp10_ = diagnostic;
				_tmp11_ = gcp_source_range_support_get_ranges ((GcpSourceRangeSupport*) _tmp10_, &_tmp11__length1);
				_tmp12_ = _tmp11_;
				_tmp12__length1 = _tmp11__length1;
				_tmp13_ = _tmp12_;
				_tmp13__length1 = _tmp12__length1;
				_tmp14_ = i;
				_tmp15_ = _tmp13_[_tmp14_];
				_tmp18_ = gcp_document_source_range (self, _tmp15_, &_tmp16_, &_tmp17_);
				start = _tmp16_;
				end = _tmp17_;
				_tmp19_ = !_tmp18_;
				_tmp13_ = (_vala_array_free (_tmp13_, _tmp13__length1, (GDestroyNotify) g_object_unref), NULL);
				if (_tmp19_) {
					continue;
				}
				_tmp20_ = diagnostic;
				_tmp21_ = start;
				_tmp22_ = end;
				gcp_document_mark_diagnostic_range (self, _tmp20_, &_tmp21_, &_tmp22_);
			}
		}
	}
	_tmp23_ = diagnostic;
	_tmp24_ = gcp_diagnostic_get_location (_tmp23_);
	_tmp25_ = _tmp24_;
	_tmp27_ = gcp_document_source_location (self, _tmp25_, &_tmp26_);
	start = _tmp26_;
	if (_tmp27_) {
		GtkTextIter _tmp28_;
		gboolean _tmp29_ = FALSE;
		GcpDiagnostic* _tmp30_;
		GtkTextIter _tmp31_;
		GtkTextIter _tmp32_;
		GeditDocument* _tmp33_;
		GcpDiagnosticSupport* _tmp34_;
		GcpDiagnosticTags* _tmp35_ = NULL;
		GcpDiagnosticTags* _tmp36_;
		GtkTextTag* _tmp37_;
		GtkTextTag* _tmp38_;
		GtkTextIter _tmp39_;
		GtkTextIter _tmp40_;
		_tmp28_ = start;
		end = _tmp28_;
		_tmp29_ = gtk_text_iter_ends_line (&start);
		if (!_tmp29_) {
			gtk_text_iter_forward_char (&end);
		}
		_tmp30_ = diagnostic;
		_tmp31_ = start;
		_tmp32_ = end;
		gcp_document_mark_diagnostic_range (self, _tmp30_, &_tmp31_, &_tmp32_);
		_tmp33_ = self->priv->d_document;
		_tmp34_ = sup;
		_tmp35_ = gcp_diagnostic_support_get_diagnostic_tags (_tmp34_);
		_tmp36_ = _tmp35_;
		_tmp37_ = gcp_diagnostic_tags_get_location_tag (_tmp36_);
		_tmp38_ = _tmp37_;
		_tmp39_ = start;
		_tmp40_ = end;
		gtk_text_buffer_apply_tag ((GtkTextBuffer*) _tmp33_, _tmp38_, &_tmp39_, &_tmp40_);
		_g_object_unref0 (_tmp36_);
	}
	{
		guint i;
		i = (guint) 0;
		{
			gboolean _tmp41_;
			_tmp41_ = TRUE;
			while (TRUE) {
				gboolean _tmp42_;
				guint _tmp44_;
				GcpDiagnostic* _tmp45_;
				GcpDiagnosticFixit* _tmp46_;
				gint _tmp46__length1;
				GcpDiagnosticFixit* _tmp47_;
				gint _tmp47__length1;
				GcpDiagnostic* _tmp48_;
				GcpDiagnosticFixit* _tmp49_;
				gint _tmp49__length1;
				GcpDiagnosticFixit* _tmp50_;
				gint _tmp50__length1;
				guint _tmp51_;
				GcpDiagnosticFixit _tmp52_;
				GcpSourceRange* _tmp53_;
				GcpSourceRange* _tmp54_;
				GcpSourceRange* r;
				GcpSourceRange* _tmp55_;
				GtkTextIter _tmp56_ = {0};
				GtkTextIter _tmp57_ = {0};
				gboolean _tmp58_ = FALSE;
				_tmp42_ = _tmp41_;
				if (!_tmp42_) {
					guint _tmp43_;
					_tmp43_ = i;
					i = _tmp43_ + 1;
				}
				_tmp41_ = FALSE;
				_tmp44_ = i;
				_tmp45_ = diagnostic;
				_tmp46_ = gcp_diagnostic_get_fixits (_tmp45_, &_tmp46__length1);
				_tmp47_ = _tmp46_;
				_tmp47__length1 = _tmp46__length1;
				if (!(_tmp44_ < ((guint) _tmp47__length1))) {
					break;
				}
				_tmp48_ = diagnostic;
				_tmp49_ = gcp_diagnostic_get_fixits (_tmp48_, &_tmp49__length1);
				_tmp50_ = _tmp49_;
				_tmp50__length1 = _tmp49__length1;
				_tmp51_ = i;
				_tmp52_ = _tmp50_[_tmp51_];
				_tmp53_ = _tmp52_.range;
				_tmp54_ = _g_object_ref0 (_tmp53_);
				r = _tmp54_;
				_tmp55_ = r;
				_tmp58_ = gcp_document_source_range (self, _tmp55_, &_tmp56_, &_tmp57_);
				start = _tmp56_;
				end = _tmp57_;
				if (_tmp58_) {
					GeditDocument* _tmp59_;
					GcpDiagnosticSupport* _tmp60_;
					GcpDiagnosticTags* _tmp61_ = NULL;
					GcpDiagnosticTags* _tmp62_;
					GtkTextTag* _tmp63_;
					GtkTextTag* _tmp64_;
					GtkTextIter _tmp65_;
					GtkTextIter _tmp66_;
					_tmp59_ = self->priv->d_document;
					_tmp60_ = sup;
					_tmp61_ = gcp_diagnostic_support_get_diagnostic_tags (_tmp60_);
					_tmp62_ = _tmp61_;
					_tmp63_ = gcp_diagnostic_tags_get_fixit_tag (_tmp62_);
					_tmp64_ = _tmp63_;
					_tmp65_ = start;
					_tmp66_ = end;
					gtk_text_buffer_apply_tag ((GtkTextBuffer*) _tmp59_, _tmp64_, &_tmp65_, &_tmp66_);
					_g_object_unref0 (_tmp62_);
				}
				_g_object_unref0 (r);
			}
		}
	}
	_g_object_unref0 (sup);
}


static void __lambda5_ (GcpDocument* self, GcpSourceIndex* diagnostics) {
	g_return_if_fail (diagnostics != NULL);
	{
		GcpSourceIndex* _tmp0_;
		GcpSourceIndexIterator* _tmp1_ = NULL;
		GcpSourceIndexIterator* _diag_it;
		_tmp0_ = diagnostics;
		_tmp1_ = gcp_source_index_iterator (_tmp0_);
		_diag_it = _tmp1_;
		while (TRUE) {
			GcpSourceIndexIterator* _tmp2_;
			gboolean _tmp3_ = FALSE;
			GcpSourceIndexIterator* _tmp4_;
			GObject* _tmp5_ = NULL;
			GObject* diag;
			GObject* _tmp6_;
			_tmp2_ = _diag_it;
			_tmp3_ = gcp_source_index_iterator_next (_tmp2_);
			if (!_tmp3_) {
				break;
			}
			_tmp4_ = _diag_it;
			_tmp5_ = gcp_source_index_iterator_get (_tmp4_);
			diag = _tmp5_;
			_tmp6_ = diag;
			gcp_document_mark_diagnostic (self, G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, GCP_TYPE_DIAGNOSTIC, GcpDiagnostic));
			_g_object_unref0 (diag);
		}
		_g_object_unref0 (_diag_it);
	}
}


static void ___lambda5__gcp_with_diagnostics_callback (GcpSourceIndex* diagnostics, gpointer self) {
	__lambda5_ (self, diagnostics);
}


static void gcp_document_on_diagnostic_updated (GcpDocument* self, GcpDiagnosticSupport* diagnostic) {
	GtkTextIter start = {0};
	GtkTextIter end = {0};
	GeditDocument* _tmp0_;
	GtkTextIter _tmp1_ = {0};
	GtkTextIter _tmp2_ = {0};
	GcpDiagnosticSupport* _tmp3_;
	GcpDiagnosticTags* _tmp4_ = NULL;
	GcpDiagnosticTags* tags;
	GeditDocument* _tmp5_;
	GtkTextTag* _tmp6_;
	GtkTextTag* _tmp7_;
	GtkTextIter _tmp8_;
	GtkTextIter _tmp9_;
	GeditDocument* _tmp10_;
	GtkTextTag* _tmp11_;
	GtkTextTag* _tmp12_;
	GtkTextIter _tmp13_;
	GtkTextIter _tmp14_;
	GeditDocument* _tmp15_;
	GtkTextTag* _tmp16_;
	GtkTextTag* _tmp17_;
	GtkTextIter _tmp18_;
	GtkTextIter _tmp19_;
	GeditDocument* _tmp20_;
	GtkTextTag* _tmp21_;
	GtkTextTag* _tmp22_;
	GtkTextIter _tmp23_;
	GtkTextIter _tmp24_;
	GeditDocument* _tmp25_;
	GtkTextTag* _tmp26_;
	GtkTextTag* _tmp27_;
	GtkTextIter _tmp28_;
	GtkTextIter _tmp29_;
	GcpDiagnosticSupport* _tmp30_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (diagnostic != NULL);
	_tmp0_ = self->priv->d_document;
	gtk_text_buffer_get_bounds ((GtkTextBuffer*) _tmp0_, &_tmp1_, &_tmp2_);
	start = _tmp1_;
	end = _tmp2_;
	_tmp3_ = diagnostic;
	_tmp4_ = gcp_diagnostic_support_get_diagnostic_tags (_tmp3_);
	tags = _tmp4_;
	_tmp5_ = self->priv->d_document;
	_tmp6_ = gcp_diagnostic_tags_get_error_tag (tags);
	_tmp7_ = _tmp6_;
	_tmp8_ = start;
	_tmp9_ = end;
	gtk_text_buffer_remove_tag ((GtkTextBuffer*) _tmp5_, _tmp7_, &_tmp8_, &_tmp9_);
	_tmp10_ = self->priv->d_document;
	_tmp11_ = gcp_diagnostic_tags_get_warning_tag (tags);
	_tmp12_ = _tmp11_;
	_tmp13_ = start;
	_tmp14_ = end;
	gtk_text_buffer_remove_tag ((GtkTextBuffer*) _tmp10_, _tmp12_, &_tmp13_, &_tmp14_);
	_tmp15_ = self->priv->d_document;
	_tmp16_ = gcp_diagnostic_tags_get_info_tag (tags);
	_tmp17_ = _tmp16_;
	_tmp18_ = start;
	_tmp19_ = end;
	gtk_text_buffer_remove_tag ((GtkTextBuffer*) _tmp15_, _tmp17_, &_tmp18_, &_tmp19_);
	_tmp20_ = self->priv->d_document;
	_tmp21_ = gcp_diagnostic_tags_get_location_tag (tags);
	_tmp22_ = _tmp21_;
	_tmp23_ = start;
	_tmp24_ = end;
	gtk_text_buffer_remove_tag ((GtkTextBuffer*) _tmp20_, _tmp22_, &_tmp23_, &_tmp24_);
	_tmp25_ = self->priv->d_document;
	_tmp26_ = gcp_diagnostic_tags_get_fixit_tag (tags);
	_tmp27_ = _tmp26_;
	_tmp28_ = start;
	_tmp29_ = end;
	gtk_text_buffer_remove_tag ((GtkTextBuffer*) _tmp25_, _tmp27_, &_tmp28_, &_tmp29_);
	gcp_document_remove_marks (self);
	_tmp30_ = diagnostic;
	gcp_diagnostic_support_with_diagnostics (_tmp30_, ___lambda5__gcp_with_diagnostics_callback, self);
	_g_object_unref0 (tags);
}


static void gcp_document_set_location (GcpDocument* self, GFile* location) {
	GFile* _tmp0_;
	GFile* _tmp1_;
	GFile* _tmp2_;
	GFile* _tmp3_;
	GFile* prev;
	GFile* _tmp4_;
	GFile* _tmp5_;
	GFile* _tmp6_;
	GFile* _tmp7_;
	g_return_if_fail (self != NULL);
	_tmp0_ = location;
	_tmp1_ = self->priv->d_location;
	if (_tmp0_ == _tmp1_) {
		return;
	}
	_tmp2_ = self->priv->d_location;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	prev = _tmp3_;
	_tmp4_ = location;
	_tmp5_ = _g_object_ref0 (_tmp4_);
	_g_object_unref0 (self->priv->d_location);
	self->priv->d_location = _tmp5_;
	_tmp6_ = prev;
	_tmp7_ = self->priv->d_location;
	if ((_tmp6_ == NULL) != (_tmp7_ == NULL)) {
		GFile* _tmp8_;
		_tmp8_ = prev;
		g_signal_emit_by_name (self, "location-changed", _tmp8_);
	} else {
		gboolean _tmp9_ = FALSE;
		GFile* _tmp10_;
		gboolean _tmp14_;
		_tmp10_ = prev;
		if (_tmp10_ != NULL) {
			GFile* _tmp11_;
			GFile* _tmp12_;
			gboolean _tmp13_ = FALSE;
			_tmp11_ = prev;
			_tmp12_ = self->priv->d_location;
			_tmp13_ = g_file_equal (_tmp11_, _tmp12_);
			_tmp9_ = !_tmp13_;
		} else {
			_tmp9_ = FALSE;
		}
		_tmp14_ = _tmp9_;
		if (_tmp14_) {
			GFile* _tmp15_;
			_tmp15_ = prev;
			g_signal_emit_by_name (self, "location-changed", _tmp15_);
		}
	}
	_g_object_unref0 (prev);
}


static void gcp_document_update_location (GcpDocument* self) {
	GeditDocument* _tmp0_;
	GeditDocument* _tmp1_;
	gboolean _tmp2_ = FALSE;
	GeditDocument* _tmp3_;
	GeditDocument* _tmp4_;
	gboolean _tmp5_ = FALSE;
	GeditDocument* _tmp6_;
	GeditDocument* _tmp7_;
	GFile* _tmp8_;
	GFile* _tmp9_;
	GFile* _tmp10_;
	g_return_if_fail (self != NULL);
	_tmp0_ = gcp_document_get_document (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = gedit_document_is_untitled (_tmp1_);
	if (_tmp2_) {
		gcp_document_set_location (self, NULL);
		return;
	}
	_tmp3_ = gcp_document_get_document (self);
	_tmp4_ = _tmp3_;
	_tmp5_ = gedit_document_is_local (_tmp4_);
	if (!_tmp5_) {
		gcp_document_set_location (self, NULL);
		return;
	}
	_tmp6_ = gcp_document_get_document (self);
	_tmp7_ = _tmp6_;
	_tmp8_ = gedit_document_get_location (_tmp7_);
	_tmp9_ = _tmp8_;
	_tmp10_ = _tmp9_;
	gcp_document_set_location (self, _tmp10_);
	_g_object_unref0 (_tmp10_);
}


static void gcp_document_update_modified (GcpDocument* self) {
	gboolean _tmp0_;
	GeditDocument* _tmp1_;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_;
	gboolean _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->d_modified;
	_tmp1_ = self->priv->d_document;
	_tmp2_ = gtk_text_buffer_get_modified ((GtkTextBuffer*) _tmp1_);
	if (_tmp0_ == _tmp2_) {
		return;
	}
	_g_free0 (self->priv->d_text);
	self->priv->d_text = NULL;
	_tmp3_ = self->priv->d_modified;
	self->priv->d_modified = !_tmp3_;
	_tmp4_ = self->priv->d_modified;
	if (_tmp4_) {
		gcp_document_update_text (self);
	} else {
		gcp_document_emit_changed (self);
	}
}


void gcp_document_emit_changed (GcpDocument* self) {
	g_return_if_fail (self != NULL);
	self->priv->d_tainted = TRUE;
	g_signal_emit_by_name (self, "changed");
}


static void gcp_document_update_text (GcpDocument* self) {
	GtkTextIter start = {0};
	GtkTextIter end = {0};
	GeditDocument* _tmp0_;
	GtkTextIter _tmp1_ = {0};
	GtkTextIter _tmp2_ = {0};
	GeditDocument* _tmp3_;
	GtkTextIter _tmp4_;
	GtkTextIter _tmp5_;
	gchar* _tmp6_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->d_document;
	gtk_text_buffer_get_bounds ((GtkTextBuffer*) _tmp0_, &_tmp1_, &_tmp2_);
	start = _tmp1_;
	end = _tmp2_;
	_tmp3_ = self->priv->d_document;
	_tmp4_ = start;
	_tmp5_ = end;
	_tmp6_ = gtk_text_buffer_get_text ((GtkTextBuffer*) _tmp3_, &_tmp4_, &_tmp5_, TRUE);
	_g_free0 (self->priv->d_text);
	self->priv->d_text = _tmp6_;
	gcp_document_emit_changed (self);
}


static void gcp_document_on_document_end_user_action (GcpDocument* self) {
	gboolean _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->d_modified;
	if (_tmp0_) {
		gcp_document_update_text (self);
	}
}


static void gcp_document_on_document_modified_changed (GcpDocument* self) {
	g_return_if_fail (self != NULL);
	gcp_document_update_modified (self);
}


static void gcp_document_on_location_changed (GcpDocument* self) {
	g_return_if_fail (self != NULL);
	gcp_document_update_location (self);
}


static void gcp_document_on_document_saved (GcpDocument* self) {
	g_return_if_fail (self != NULL);
	gcp_document_emit_changed (self);
}


GcpDocument* gcp_document_construct (GType object_type) {
	GcpDocument * self = NULL;
	self = (GcpDocument*) g_object_new (object_type, NULL);
	return self;
}


GcpDocument* gcp_document_new (void) {
	return gcp_document_construct (GCP_TYPE_DOCUMENT);
}


GeditDocument* gcp_document_get_document (GcpDocument* self) {
	GeditDocument* result;
	GeditDocument* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->d_document;
	result = _tmp0_;
	return result;
}


static void gcp_document_set_document (GcpDocument* self, GeditDocument* value) {
	GeditDocument* _tmp0_;
	GeditDocument* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->d_document);
	self->priv->d_document = _tmp1_;
	g_object_notify ((GObject *) self, "document");
}


const gchar* gcp_document_get_error_mark_category (void) {
	const gchar* result;
	result = "Gcp.Document.ErrorCategory";
	return result;
}


const gchar* gcp_document_get_warning_mark_category (void) {
	const gchar* result;
	result = "Gcp.Document.WarningCategory";
	return result;
}


const gchar* gcp_document_get_info_mark_category (void) {
	const gchar* result;
	result = "Gcp.Document.InfoCategory";
	return result;
}


gboolean gcp_document_get_tainted (GcpDocument* self) {
	g_return_val_if_fail (self != NULL, FALSE);
	return GCP_DOCUMENT_GET_CLASS (self)->get_tainted (self);
}


static gboolean gcp_document_real_get_tainted (GcpDocument* base) {
	gboolean result;
	GcpDocument* self;
	gboolean _tmp0_;
	self = base;
	_tmp0_ = self->priv->d_tainted;
	result = _tmp0_;
	return result;
}


void gcp_document_set_tainted (GcpDocument* self, gboolean value) {
	g_return_if_fail (self != NULL);
	GCP_DOCUMENT_GET_CLASS (self)->set_tainted (self, value);
}


static void gcp_document_real_set_tainted (GcpDocument* base, gboolean value) {
	GcpDocument* self;
	self = base;
	self->priv->d_tainted = FALSE;
	g_object_notify ((GObject *) self, "tainted");
}


GFile* gcp_document_get_location (GcpDocument* self) {
	GFile* result;
	GFile* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->d_location;
	result = _tmp0_;
	return result;
}


const gchar* gcp_document_get_text (GcpDocument* self) {
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->d_text;
	result = _tmp0_;
	return result;
}


gboolean gcp_document_get_is_modified (GcpDocument* self) {
	gboolean result;
	gboolean _tmp0_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->d_modified;
	result = _tmp0_;
	return result;
}


static GObject * gcp_document_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	GcpDocument * self;
	GeditDocument* _tmp0_;
	gboolean _tmp1_ = FALSE;
	GeditDocument* _tmp2_;
	GeditDocument* _tmp3_;
	GeditDocument* _tmp4_;
	GeditDocument* _tmp5_;
	GcpDiagnosticSupport* _tmp6_;
	GcpDiagnosticSupport* diag;
	GcpDiagnosticSupport* _tmp7_;
	parent_class = G_OBJECT_CLASS (gcp_document_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GCP_TYPE_DOCUMENT, GcpDocument);
	_tmp0_ = self->priv->d_document;
	_tmp1_ = gedit_document_is_untitled (_tmp0_);
	self->priv->d_untitled = _tmp1_;
	self->priv->d_modified = FALSE;
	_g_free0 (self->priv->d_text);
	self->priv->d_text = NULL;
	gcp_document_update_modified (self);
	_tmp2_ = self->priv->d_document;
	g_signal_connect_object ((GtkTextBuffer*) _tmp2_, "modified-changed", (GCallback) _gcp_document_on_document_modified_changed_gtk_text_buffer_modified_changed, self, 0);
	_tmp3_ = self->priv->d_document;
	g_signal_connect_object ((GtkTextBuffer*) _tmp3_, "end-user-action", (GCallback) _gcp_document_on_document_end_user_action_gtk_text_buffer_end_user_action, self, 0);
	_tmp4_ = self->priv->d_document;
	g_signal_connect_object ((GObject*) _tmp4_, "notify::location", (GCallback) _gcp_document_on_location_changed_g_object_notify, self, 0);
	_tmp5_ = self->priv->d_document;
	g_signal_connect_object (_tmp5_, "saved", (GCallback) _gcp_document_on_document_saved_gedit_document_saved, self, 0);
	_g_object_unref0 (self->priv->d_location);
	self->priv->d_location = NULL;
	gcp_document_update_location (self);
	_tmp6_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (self, GCP_TYPE_DIAGNOSTIC_SUPPORT) ? ((GcpDiagnosticSupport*) self) : NULL);
	diag = _tmp6_;
	_tmp7_ = diag;
	if (_tmp7_ != NULL) {
		GcpDiagnosticSupport* _tmp8_;
		_tmp8_ = diag;
		g_signal_connect_object (_tmp8_, "diagnostics-updated", (GCallback) _gcp_document_on_diagnostic_updated_gcp_diagnostic_support_diagnostics_updated, self, 0);
	}
	_g_object_unref0 (diag);
	return obj;
}


static void gcp_document_class_init (GcpDocumentClass * klass) {
	gcp_document_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GcpDocumentPrivate));
	G_OBJECT_CLASS (klass)->dispose = gcp_document_real_dispose;
	GCP_DOCUMENT_CLASS (klass)->get_tainted = gcp_document_real_get_tainted;
	GCP_DOCUMENT_CLASS (klass)->set_tainted = gcp_document_real_set_tainted;
	G_OBJECT_CLASS (klass)->get_property = _vala_gcp_document_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gcp_document_set_property;
	G_OBJECT_CLASS (klass)->constructor = gcp_document_constructor;
	G_OBJECT_CLASS (klass)->finalize = gcp_document_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GCP_DOCUMENT_DOCUMENT, g_param_spec_object ("document", "document", "document", gedit_document_get_type (), G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GCP_DOCUMENT_TAINTED, g_param_spec_boolean ("tainted", "tainted", "tainted", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GCP_DOCUMENT_LOCATION, g_param_spec_object ("location", "location", "location", G_TYPE_FILE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GCP_DOCUMENT_TEXT, g_param_spec_string ("text", "text", "text", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GCP_DOCUMENT_IS_MODIFIED, g_param_spec_boolean ("is-modified", "is-modified", "is-modified", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	g_signal_new ("location_changed", GCP_TYPE_DOCUMENT, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, G_TYPE_FILE);
	g_signal_new ("changed", GCP_TYPE_DOCUMENT, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}


static void gcp_document_instance_init (GcpDocument * self) {
	self->priv = GCP_DOCUMENT_GET_PRIVATE (self);
}


static void gcp_document_finalize (GObject* obj) {
	GcpDocument * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GCP_TYPE_DOCUMENT, GcpDocument);
	_g_object_unref0 (self->priv->d_document);
	_g_free0 (self->priv->d_text);
	_g_object_unref0 (self->priv->d_location);
	G_OBJECT_CLASS (gcp_document_parent_class)->finalize (obj);
}


GType gcp_document_get_type (void) {
	static volatile gsize gcp_document_type_id__volatile = 0;
	if (g_once_init_enter (&gcp_document_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (GcpDocumentClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gcp_document_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GcpDocument), 0, (GInstanceInitFunc) gcp_document_instance_init, NULL };
		GType gcp_document_type_id;
		gcp_document_type_id = g_type_register_static (G_TYPE_OBJECT, "GcpDocument", &g_define_type_info, 0);
		g_once_init_leave (&gcp_document_type_id__volatile, gcp_document_type_id);
	}
	return gcp_document_type_id__volatile;
}


static void _vala_gcp_document_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	GcpDocument * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GCP_TYPE_DOCUMENT, GcpDocument);
	switch (property_id) {
		case GCP_DOCUMENT_DOCUMENT:
		g_value_set_object (value, gcp_document_get_document (self));
		break;
		case GCP_DOCUMENT_TAINTED:
		g_value_set_boolean (value, gcp_document_get_tainted (self));
		break;
		case GCP_DOCUMENT_LOCATION:
		g_value_set_object (value, gcp_document_get_location (self));
		break;
		case GCP_DOCUMENT_TEXT:
		g_value_set_string (value, gcp_document_get_text (self));
		break;
		case GCP_DOCUMENT_IS_MODIFIED:
		g_value_set_boolean (value, gcp_document_get_is_modified (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_gcp_document_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	GcpDocument * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GCP_TYPE_DOCUMENT, GcpDocument);
	switch (property_id) {
		case GCP_DOCUMENT_DOCUMENT:
		gcp_document_set_document (self, g_value_get_object (value));
		break;
		case GCP_DOCUMENT_TAINTED:
		gcp_document_set_tainted (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}


static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}



