Beispiel #1
0
/**
 * parser_cxx_assist_install:
 * @assist: ParserCxxAssist object
 * @ieditor: Editor to install support for
 * @iparser: Parser to install support for
 *
 * Returns: Registers provider for editor
 */
static void
parser_cxx_assist_install (ParserCxxAssist *assist,
                           IAnjutaEditor *ieditor)
{
	g_return_if_fail (assist->priv->iassist == NULL);

	if (IANJUTA_IS_EDITOR_ASSIST (ieditor))
	{
		assist->priv->iassist = IANJUTA_EDITOR_ASSIST (ieditor);
		ianjuta_editor_assist_add (IANJUTA_EDITOR_ASSIST (ieditor),
		                           IANJUTA_PROVIDER(assist), NULL);
		g_signal_connect (ieditor, "cancelled",
		                  G_CALLBACK (parser_cxx_assist_cancelled), assist);
	}
	else
		assist->priv->iassist = NULL;

	if (IANJUTA_IS_EDITOR_TIP (ieditor))
		assist->priv->itip = IANJUTA_EDITOR_TIP (ieditor);
	else
		assist->priv->itip = NULL;
		
	if (IANJUTA_IS_FILE (assist->priv->iassist))
	{
		GFile *file = ianjuta_file_get_file (
		                          IANJUTA_FILE (assist->priv->iassist), NULL);
		if (file != NULL)
		{
			assist->priv->editor_filename = g_file_get_path (file);
			g_object_unref (file);
		}
	}
}
static void
on_added_current_document (AnjutaPlugin *plugin,
                           const gchar *name,
                           const GValue *value,
                           gpointer data)
{
    GObject *cur_editor = NULL;
    SnippetsManagerPlugin *snippets_manager_plugin = NULL;

    /* Assertions */
    g_return_if_fail (ANJUTA_IS_PLUGIN_SNIPPETS_MANAGER (plugin));
    snippets_manager_plugin = ANJUTA_PLUGIN_SNIPPETS_MANAGER (plugin);

    /* Get the current document and test if it's an IAnjutaEditor */
    cur_editor = g_value_get_object (value);
    if (IANJUTA_IS_EDITOR (cur_editor))
        snippets_interaction_set_editor (snippets_manager_plugin->snippets_interaction,
                                         IANJUTA_EDITOR (cur_editor));
    else
        snippets_interaction_set_editor (snippets_manager_plugin->snippets_interaction,
                                         NULL);

    /* Refilter the snippets shown in the browser */
    snippets_browser_refilter_snippets_view (snippets_manager_plugin->snippets_browser);

    /* Load the provider if needed */
    if (IANJUTA_IS_EDITOR_ASSIST (cur_editor))
        snippets_provider_load (snippets_manager_plugin->snippets_provider,
                                IANJUTA_EDITOR_ASSIST (cur_editor));

}
Beispiel #3
0
static void
uninstall_support (JSLang *plugin)
{
	DEBUG_PRINT ("%s", "JSLang: Uninstall support");

	ianjuta_editor_assist_remove (IANJUTA_EDITOR_ASSIST(plugin->current_editor), IANJUTA_PROVIDER(plugin), NULL);
}
Beispiel #4
0
static void
install_support (JSLang *plugin)
{
	const gchar *lang;
	IAnjutaLanguage* lang_manager;

	setPlugin (plugin);

	if (!IANJUTA_IS_EDITOR (plugin->current_editor))
		return;
	lang_manager = anjuta_shell_get_interface (ANJUTA_PLUGIN (plugin)->shell,
							IAnjutaLanguage, NULL);
	if (!lang_manager)
		return;
	lang = ianjuta_language_get_name_from_editor (lang_manager,
													   IANJUTA_EDITOR_LANGUAGE (plugin->current_editor), NULL);
	if (!lang || !g_str_equal (lang, "JavaScript"))
		return;

	DEBUG_PRINT ("%s", "JSLang: Install support");

	ianjuta_editor_assist_add (IANJUTA_EDITOR_ASSIST(plugin->current_editor), IANJUTA_PROVIDER(plugin), NULL);
}
Beispiel #5
0
static void
install_support (PythonPlugin *lang_plugin)
{	
	IAnjutaLanguage* lang_manager =
		anjuta_shell_get_interface (ANJUTA_PLUGIN (lang_plugin)->shell,
									IAnjutaLanguage, NULL);
	IAnjutaSymbolManager* sym_manager = 
		anjuta_shell_get_interface (ANJUTA_PLUGIN (lang_plugin)->shell,
		                            IAnjutaSymbolManager,
		                            NULL);
	IAnjutaDocumentManager* docman = 
		anjuta_shell_get_interface (ANJUTA_PLUGIN (lang_plugin)->shell,
		                            IAnjutaDocumentManager,
		                            NULL);
		
	if (!lang_manager || !sym_manager || !docman)
		return;
	
	if (lang_plugin->support_installed)
		return;
	
	lang_plugin->current_language = 
		ianjuta_language_get_name_from_editor (lang_manager, 
											   IANJUTA_EDITOR_LANGUAGE (lang_plugin->current_editor), NULL);
	
	if (lang_plugin->current_language &&
		(g_str_equal (lang_plugin->current_language, "Python")))
	{
		g_signal_connect (lang_plugin->current_editor,
						  "char-added",
						  G_CALLBACK (on_editor_char_inserted_python),
						  lang_plugin);
	}
	else
	{
		return;
	}
	
	python_indent_init (lang_plugin);
	/* Disable editor intern auto-indent */
	ianjuta_editor_set_auto_indent (IANJUTA_EDITOR(lang_plugin->current_editor),
								    FALSE, NULL);
	
	if (IANJUTA_IS_EDITOR_ASSIST (lang_plugin->current_editor) )
	{
		AnjutaPlugin *plugin;		
		AnjutaUI *ui;
		IAnjutaEditorAssist* iassist;

		const gchar *project_root;
		gchar *editor_filename;		

		check_support (lang_plugin);
		
		plugin = ANJUTA_PLUGIN (lang_plugin);
		ui = anjuta_shell_get_ui (plugin->shell, NULL);
		iassist = IANJUTA_EDITOR_ASSIST (lang_plugin->current_editor);
		
		g_assert (lang_plugin->assist == NULL);

		project_root = ANJUTA_PLUGIN_PYTHON(plugin)->project_root_directory;
		editor_filename = ANJUTA_PLUGIN_PYTHON(plugin)->current_editor_filename;

		lang_plugin->assist = python_assist_new (iassist,
		                                         sym_manager,
		                                         docman,
		                                         lang_plugin->settings,
		                                         editor_filename,
		                                         project_root);
	}	

	if (IANJUTA_IS_EDITOR_GLADE_SIGNAL (lang_plugin->current_editor))
	{
		g_signal_connect (lang_plugin->current_editor,
		                  "drop-possible", G_CALLBACK (gtk_true), NULL);
		g_signal_connect (lang_plugin->current_editor,
		                  "drop", G_CALLBACK (on_glade_drop),
		                  lang_plugin);
	}

	lang_plugin->support_installed = TRUE;
}
Beispiel #6
0
static void 
iprovider_populate (IAnjutaProvider *obj, IAnjutaIterable* iter, GError **err)
{
	static GList *trash = NULL;
	JSLang *plugin = (JSLang*)obj;

	if (plugin->last) {
		g_object_unref (plugin->last);
	}

        plugin->last = ianjuta_iterable_clone(iter, NULL);

	if (!plugin->current_editor)
		return;
	gint depth;
	GList *suggestions = NULL;
	gchar *str = code_completion_get_str (IANJUTA_EDITOR (plugin->current_editor), FALSE);

	if (trash)
	{
		g_list_foreach (trash, (GFunc)g_free, NULL);
		g_list_free (trash);
		trash = NULL;
	}

	if (!str)
		return;

	g_assert (plugin->prefs);

	if (strlen (str) < g_settings_get_int (plugin->prefs, MIN_CODECOMPLETE))
	{
		ianjuta_editor_assist_proposals ( IANJUTA_EDITOR_ASSIST (plugin->current_editor), obj,  NULL,  TRUE, NULL);
		return;
	}

	gchar *file = file_completion (IANJUTA_EDITOR (plugin->current_editor), &depth);
	gint i;
	DEBUG_PRINT ("JSLang: Auto complete for %s (TMFILE=%s)", str, file);
	for (i = strlen (str) - 1; i; i--)
	{
		if (str[i] == '.')
			break;
	}
	if (i > 0)
	{
		suggestions = code_completion_get_list (plugin, file, g_strndup (str, i), depth);
	}
	else
		suggestions = code_completion_get_list (plugin, file, NULL, depth);
	if (suggestions)
	{
		GList *nsuggest = NULL;
                gint k;
		if (i > 0)
		{
			suggestions = filter_list (suggestions, str + i + 1);
			k = strlen (str + i + 1);
		} else
		{
			suggestions = filter_list (suggestions, str);
			k = strlen (str);
		}
		GList *i;
		for (; k > 0; k--)
			ianjuta_iterable_previous (plugin->last, NULL);

		for (i = suggestions; i; i = g_list_next(i)) {
			IAnjutaEditorAssistProposal* proposal = g_new0(IAnjutaEditorAssistProposal, 1);

			if (!i->data)
				continue;
	
			proposal->label = i->data;
			proposal->data = i->data;
			nsuggest = g_list_prepend (nsuggest, proposal);
		}
		ianjuta_editor_assist_proposals ( IANJUTA_EDITOR_ASSIST (plugin->current_editor), obj,  nsuggest,  TRUE, NULL);
		g_list_free (nsuggest);
                trash = suggestions;
		return;
	}
	ianjuta_editor_assist_proposals ( IANJUTA_EDITOR_ASSIST (plugin->current_editor), obj,  NULL,  TRUE, NULL);
}