[anjuta] Adapt the parser-cxx plugin to the new interface IAnjutaLanguageProvider
- From: Johannes Schmid <jhs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] Adapt the parser-cxx plugin to the new interface IAnjutaLanguageProvider
- Date: Fri, 27 Jul 2012 10:17:27 +0000 (UTC)
commit b4da2e4eaf216224edc49636a7d0c651bf911918
Author: Moritz LÃdecke <ritze skweez net>
Date: Mon Jul 23 18:23:35 2012 +0200
Adapt the parser-cxx plugin to the new interface IAnjutaLanguageProvider
configure.ac | 3 +-
plugins/Makefile.am | 1 +
plugins/language-support-cpp-java/Makefile.am | 10 +-
.../anjuta-language-cpp-java.ui | 330 +-----
.../language-support-cpp-java/cpp-java-assist.h | 71 --
.../org.gnome.anjuta.plugins.cpp.gschema.xml.in | 15 -
plugins/language-support-cpp-java/plugin.c | 59 +-
plugins/language-support-cpp-java/plugin.h | 2 -
plugins/parser-cxx/Makefile.am | 73 ++
plugins/parser-cxx/anjuta-parser-cxx-plugin.png | Bin 0 -> 4218 bytes
plugins/parser-cxx/anjuta-parser-cxx.plugin.in | 11 +
plugins/parser-cxx/anjuta-parser-cxx.ui | 226 ++++
....gnome.anjuta.plugins.parser-cxx.gschema.xml.in | 22 +
.../parser-cxx-assist.c} | 1164 +++++++-------------
plugins/parser-cxx/parser-cxx-assist.h | 73 ++
plugins/parser-cxx/plugin.c | 297 +++++
plugins/parser-cxx/plugin.h | 59 +
17 files changed, 1218 insertions(+), 1198 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 70f1b5d..35f6862 100644
--- a/configure.ac
+++ b/configure.ac
@@ -866,7 +866,6 @@ plugins/am-project/tests/Makefile
plugins/mk-project/Makefile
plugins/dir-project/Makefile
plugins/language-support-cpp-java/Makefile
-plugins/language-support-cpp-java/cxxparser/Makefile
plugins/run-program/Makefile
plugins/starter/Makefile
plugins/indentation-c-style/Makefile
@@ -874,6 +873,8 @@ plugins/indentation-python-style/Makefile
plugins/language-support-js/Makefile
plugins/language-support-vala/Makefile
plugins/language-support-python/Makefile
+plugins/parser-cxx/Makefile
+plugins/parser-cxx/cxxparser/Makefile
plugins/python-loader/Makefile
anjuta.desktop.in
manuals/Makefile
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 299e695..5dcba6d 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -28,6 +28,7 @@ SUBDIRS = . \
message-view \
mk-project \
patch \
+ parser-cxx \
project-import \
project-manager \
project-wizard \
diff --git a/plugins/language-support-cpp-java/Makefile.am b/plugins/language-support-cpp-java/Makefile.am
index 1586d19..2b1777b 100644
--- a/plugins/language-support-cpp-java/Makefile.am
+++ b/plugins/language-support-cpp-java/Makefile.am
@@ -1,5 +1,3 @@
-SUBDIRS = cxxparser
-
# Plugin glade file
cpp_java_gladedir = $(anjuta_glade_dir)
cpp_java_glade_DATA = anjuta-language-cpp-java.ui
@@ -48,20 +46,14 @@ plugin_LTLIBRARIES = libanjuta-language-cpp-java.la
libanjuta_language_cpp_java_la_SOURCES = \
plugin.c \
plugin.h \
- cpp-java-assist.h \
- cpp-java-assist.c \
cpp-packages.c \
cpp-packages.h
libanjuta_language_cpp_java_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
-# Use C++ linking
-nodist_EXTRA_libanjuta_language_cpp_java_la_SOURCES = dummy.cxx
-
# Plugin dependencies
libanjuta_language_cpp_java_la_LIBADD = \
- $(LIBANJUTA_LIBS) \
- cxxparser/libcxxparser.la
+ $(LIBANJUTA_LIBS)
gsettings_in_file = org.gnome.anjuta.plugins.cpp.gschema.xml.in
gsettings_SCHEMAS = $(gsettings_in_file:.xml.in=.xml)
diff --git a/plugins/language-support-cpp-java/anjuta-language-cpp-java.ui b/plugins/language-support-cpp-java/anjuta-language-cpp-java.ui
index e760e3c..6123f61 100644
--- a/plugins/language-support-cpp-java/anjuta-language-cpp-java.ui
+++ b/plugins/language-support-cpp-java/anjuta-language-cpp-java.ui
@@ -29,305 +29,79 @@
<property name="can_focus">False</property>
<property name="title" translatable="yes">window1</property>
<child>
- <object class="GtkNotebook" id="preferences">
+ <object class="GtkVBox" id="preferences">
<property name="visible">True</property>
- <property name="can_focus">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">5</property>
<child>
- <object class="GtkVBox" id="vbox1">
+ <object class="GtkCheckButton" id="preferences:load-project-packages">
+ <property name="label" translatable="yes">Automatically load required libraries of the project</property>
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <child>
- <object class="GtkFrame" id="frame45">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label_xalign">0</property>
- <property name="label_yalign">0</property>
- <property name="shadow_type">none</property>
- <child>
- <object class="GtkVBox" id="vbox1118">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkCheckButton" id="preferences:completion-enable">
- <property name="label" translatable="yes">Enable code completion</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="border_width">5</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkFrame" id="frame3">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label_xalign">0</property>
- <property name="shadow_type">none</property>
- <child>
- <object class="GtkAlignment" id="alignment3">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="left_padding">12</property>
- <child>
- <object class="GtkVBox" id="vbox3">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkCheckButton" id="preferences:completion-space-after-func">
- <property name="label" translatable="yes">Add a space after function call autocompletion</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="border_width">5</property>
- <property name="use_action_appearance">False</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="preferences:completion-brace-after-func">
- <property name="label" translatable="yes">Add '(' after function call autocompletion</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="border_width">5</property>
- <property name="use_action_appearance">False</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="preferences:completion-closebrace-after-func">
- <property name="label" translatable="yes">Add ')' after function call autocompletion</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="border_width">5</property>
- <property name="use_action_appearance">False</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child type="label_item">
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="label12334">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="label" translatable="yes">Autocompletion</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkFrame" id="frame1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="border_width">5</property>
- <property name="label_xalign">0</property>
- <property name="label_yalign">0</property>
- <property name="shadow_type">none</property>
- <child>
- <object class="GtkAlignment" id="alignment1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <child>
- <object class="GtkHBox" id="hbox1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <child>
- <object class="GtkCheckButton" id="preferences:calltip-enable">
- <property name="label" translatable="yes">Show calltips</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="border_width">5</property>
- <property name="use_action_appearance">False</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="label2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="label" translatable="yes">Calltips</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
</object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
</child>
- <child type="tab">
- <object class="GtkLabel" id="label4">
+ <child>
+ <object class="GtkCheckButton" id="preferences:load-libc">
+ <property name="label" translatable="yes">Load API tags for C standard library</property>
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="label" translatable="yes">Auto-complete</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
</object>
<packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">1</property>
- <property name="tab_fill">False</property>
</packing>
</child>
<child>
- <object class="GtkVBox" id="vbox4">
+ <object class="GtkCheckButton" id="preferences:load-stdcpp">
+ <property name="label" translatable="yes">Load API tags for C++ standard template library</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow2">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">5</property>
+ <property name="can_focus">True</property>
+ <property name="shadow_type">in</property>
<child>
- <object class="GtkCheckButton" id="preferences:load-project-packages">
- <property name="label" translatable="yes">Automatically load required libraries of the project</property>
+ <object class="AnjutaPkgConfigChooser" id="pkg_config_chooser1">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
- <property name="xalign">0</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="preferences:load-libc">
- <property name="label" translatable="yes">Load API tags for C standard library</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
- <property name="xalign">0</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="preferences:load-stdcpp">
- <property name="label" translatable="yes">Load API tags for C++ standard template library</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
- <property name="xalign">0</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkScrolledWindow" id="scrolledwindow2">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="shadow_type">in</property>
- <child>
- <object class="AnjutaPkgConfigChooser" id="pkg_config_chooser1">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="headers_visible">False</property>
- <property name="headers_clickable">False</property>
- <property name="search_column">0</property>
- <child internal-child="selection">
- <object class="GtkTreeSelection" id="treeview-selection"/>
- </child>
- </object>
+ <property name="headers_visible">False</property>
+ <property name="headers_clickable">False</property>
+ <property name="search_column">0</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection" id="treeview-selection"/>
</child>
</object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">3</property>
- </packing>
</child>
</object>
<packing>
- <property name="position">2</property>
- </packing>
- </child>
- <child type="tab">
- <object class="GtkLabel" id="label1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">API Tags (C/C++)</property>
- </object>
- <packing>
- <property name="position">1</property>
- <property name="tab_fill">False</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
</packing>
</child>
</object>
diff --git a/plugins/language-support-cpp-java/org.gnome.anjuta.plugins.cpp.gschema.xml.in b/plugins/language-support-cpp-java/org.gnome.anjuta.plugins.cpp.gschema.xml.in
index 50cb1f9..8a1e5b6 100644
--- a/plugins/language-support-cpp-java/org.gnome.anjuta.plugins.cpp.gschema.xml.in
+++ b/plugins/language-support-cpp-java/org.gnome.anjuta.plugins.cpp.gschema.xml.in
@@ -3,21 +3,6 @@
<key name="user-packages" type="s">
<default>""</default>
</key>
- <key name="completion-enable" type="b">
- <default>true</default>
- </key>
- <key name="completion-space-after-func" type="b">
- <default>true</default>
- </key>
- <key name="completion-brace-after-func" type="b">
- <default>true</default>
- </key>
- <key name="completion-closebrace-after-func" type="b">
- <default>true</default>
- </key>
- <key name="calltip-enable" type="b">
- <default>true</default>
- </key>
<key name="load-project-packages" type="b">
<default>true</default>
</key>
diff --git a/plugins/language-support-cpp-java/plugin.c b/plugins/language-support-cpp-java/plugin.c
index f0ef8ca..c269a1b 100644
--- a/plugins/language-support-cpp-java/plugin.c
+++ b/plugins/language-support-cpp-java/plugin.c
@@ -33,7 +33,6 @@
#include <libanjuta/interfaces/ianjuta-editor-cell.h>
#include <libanjuta/interfaces/ianjuta-editor-language.h>
#include <libanjuta/interfaces/ianjuta-editor-selection.h>
-#include <libanjuta/interfaces/ianjuta-editor-assist.h>
#include <libanjuta/interfaces/ianjuta-editor-glade-signal.h>
#include <libanjuta/interfaces/ianjuta-editor-tip.h>
#include <libanjuta/interfaces/ianjuta-editor-search.h>
@@ -58,7 +57,6 @@
#define ICON_FILE "anjuta-language-cpp-java-plugin.png"
/* Preferences keys */
-
#define ANJUTA_PREF_SCHEMA_PREFIX "org.gnome.anjuta."
#define PREF_SCHEMA "org.gnome.anjuta.plugins.cpp"
#define PREF_USER_PACKAGES "user-packages"
@@ -746,7 +744,7 @@ install_support (CppJavaPlugin *lang_plugin)
IAnjutaLanguage* lang_manager =
anjuta_shell_get_interface (ANJUTA_PLUGIN (lang_plugin)->shell,
IAnjutaLanguage, NULL);
-
+
if (!lang_manager)
return;
@@ -770,23 +768,10 @@ install_support (CppJavaPlugin *lang_plugin)
}
init_file_type (lang_plugin);
-
-
+
if (g_str_equal (lang_plugin->current_language, "C" ) ||
g_str_equal (lang_plugin->current_language, "C++"))
{
- CppJavaAssist *assist;
-
- g_assert (lang_plugin->assist == NULL);
-
- assist = cpp_java_assist_new (IANJUTA_EDITOR (lang_plugin->current_editor),
- anjuta_shell_get_interface (ANJUTA_PLUGIN (lang_plugin)->shell,
- IAnjutaSymbolManager,
- NULL),
- lang_plugin->settings);
- lang_plugin->assist = assist;
-
-
if (IANJUTA_IS_EDITOR_GLADE_SIGNAL (lang_plugin->current_editor))
{
g_signal_connect (lang_plugin->current_editor,
@@ -820,12 +805,6 @@ uninstall_support (CppJavaPlugin *lang_plugin)
if (!lang_plugin->support_installed)
return;
- if (lang_plugin->assist)
- {
- g_object_unref (lang_plugin->assist);
- lang_plugin->assist = NULL;
- }
-
g_signal_handlers_disconnect_by_func (lang_plugin->current_editor,
on_glade_drop_possible, lang_plugin);
g_signal_handlers_disconnect_by_func (lang_plugin->current_editor,
@@ -1153,7 +1132,7 @@ cpp_java_plugin_activate_plugin (AnjutaPlugin *plugin)
lang_plugin->editor_watch_id =
anjuta_plugin_add_watch (plugin,
- IANJUTA_DOCUMENT_MANAGER_CURRENT_DOCUMENT,
+ IANJUTA_DOCUMENT_MANAGER_CURRENT_DOCUMENT,
on_value_added_current_editor,
on_value_removed_current_editor,
plugin);
@@ -1213,7 +1192,6 @@ cpp_java_plugin_instance_init (GObject *obj)
plugin->current_language = NULL;
plugin->editor_watch_id = 0;
plugin->uiid = 0;
- plugin->assist = NULL;
plugin->settings = g_settings_new (PREF_SCHEMA);
plugin->editor_settings = g_settings_new (ANJUTA_PREF_SCHEMA_PREFIX IANJUTA_EDITOR_PREF_SCHEMA);
plugin->packages = NULL;
@@ -1232,29 +1210,10 @@ cpp_java_plugin_class_init (GObjectClass *klass)
klass->dispose = cpp_java_plugin_dispose;
}
-#define PREF_WIDGET_SPACE "preferences:completion-space-after-func"
-#define PREF_WIDGET_BRACE "preferences:completion-brace-after-func"
-#define PREF_WIDGET_CLOSEBRACE "preferences:completion-closebrace-after-func"
-#define PREF_WIDGET_AUTO "preferences:completion-enable"
#define PREF_WIDGET_PACKAGES "preferences:load-project-packages"
#define PREF_WIDGET_PKG_CONFIG "pkg_config_chooser1"
static void
-on_autocompletion_toggled (GtkToggleButton* button,
- CppJavaPlugin* plugin)
-{
- GtkWidget* widget;
- gboolean sensitive = gtk_toggle_button_get_active (button);
-
- widget = GTK_WIDGET (gtk_builder_get_object (plugin->bxml, PREF_WIDGET_SPACE));
- gtk_widget_set_sensitive (widget, sensitive);
- widget = GTK_WIDGET (gtk_builder_get_object (plugin->bxml, PREF_WIDGET_BRACE));
- gtk_widget_set_sensitive (widget, sensitive);
- widget = GTK_WIDGET (gtk_builder_get_object (plugin->bxml, PREF_WIDGET_CLOSEBRACE));
- gtk_widget_set_sensitive (widget, sensitive);
-}
-
-static void
cpp_java_plugin_select_user_packages (CppJavaPlugin* plugin,
AnjutaPkgConfigChooser* chooser)
{
@@ -1364,6 +1323,7 @@ on_package_deactivated (AnjutaPkgConfigChooser *self, const gchar* package,
cpp_java_plugin_update_user_packages (plugin, self);
}
+
static void
ipreferences_merge (IAnjutaPreferences* ipref, AnjutaPreferences* prefs,
GError** e)
@@ -1382,13 +1342,8 @@ ipreferences_merge (IAnjutaPreferences* ipref, AnjutaPreferences* prefs,
}
anjuta_preferences_add_from_builder (prefs,
plugin->bxml, plugin->settings,
- "preferences", _("C/C++/Java/Vala"),
+ "preferences", _("API Tags (C/C++)"),
ICON_FILE);
- toggle = GTK_WIDGET (gtk_builder_get_object (plugin->bxml, PREF_WIDGET_AUTO));
- g_signal_connect (toggle, "toggled", G_CALLBACK (on_autocompletion_toggled),
- plugin);
- on_autocompletion_toggled (GTK_TOGGLE_BUTTON (toggle), plugin);
-
toggle = GTK_WIDGET (gtk_builder_get_object (plugin->bxml, PREF_WIDGET_PACKAGES));
g_signal_connect (toggle, "toggled", G_CALLBACK (on_project_packages_toggled),
plugin);
@@ -1407,7 +1362,7 @@ ipreferences_merge (IAnjutaPreferences* ipref, AnjutaPreferences* prefs,
if (!g_settings_get_boolean (plugin->settings,
PREF_PROJECT_PACKAGES))
cpp_java_plugin_select_user_packages (plugin, ANJUTA_PKG_CONFIG_CHOOSER (pkg_config));
-
+
gtk_widget_show (pkg_config);
}
@@ -1416,7 +1371,7 @@ ipreferences_unmerge (IAnjutaPreferences* ipref, AnjutaPreferences* prefs,
GError** e)
{
CppJavaPlugin* plugin = ANJUTA_PLUGIN_CPP_JAVA (ipref);
- anjuta_preferences_remove_page(prefs, _("C/C++/Java/Vala"));
+ anjuta_preferences_remove_page(prefs, _("API Tags (C/C++)"));
g_object_unref (plugin->bxml);
}
diff --git a/plugins/language-support-cpp-java/plugin.h b/plugins/language-support-cpp-java/plugin.h
index 01fd416..f021874 100644
--- a/plugins/language-support-cpp-java/plugin.h
+++ b/plugins/language-support-cpp-java/plugin.h
@@ -24,7 +24,6 @@
#include <libanjuta/anjuta-plugin.h>
#include <libanjuta/interfaces/ianjuta-editor.h>
#include <libanjuta/interfaces/ianjuta-symbol-manager.h>
-#include "cpp-java-assist.h"
#include "cpp-packages.h"
extern GType cpp_java_plugin_get_type (GTypeModule *module);
@@ -61,7 +60,6 @@ struct _CppJavaPlugin {
const gchar *current_language;
/* Assist */
- CppJavaAssist *assist;
CppFileType filetype;
/* Packages */
diff --git a/plugins/parser-cxx/Makefile.am b/plugins/parser-cxx/Makefile.am
new file mode 100644
index 0000000..43b40e1
--- /dev/null
+++ b/plugins/parser-cxx/Makefile.am
@@ -0,0 +1,73 @@
+SUBDIRS = cxxparser
+
+# Plugin glade file
+parser_cxx_gladedir = $(anjuta_glade_dir)
+parser_cxx_glade_DATA = anjuta-parser-cxx.ui
+
+# Plugin Icon file
+parser_cxx_pixmapsdir = $(anjuta_image_dir)
+parser_cxx_pixmaps_DATA = \
+ anjuta-parser-cxx-plugin.png
+
+# Plugin description file
+plugin_in_files = anjuta-parser-cxx.plugin.in
+%.plugin: %.plugin.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
+
+parser_cxx_plugindir = $(anjuta_plugin_dir)
+parser_cxx_plugin_DATA = $(plugin_in_files:.plugin.in=.plugin)
+
+# NOTE :
+# The naming convention is very intentional
+# We are forced to use the prefix 'lib' by automake and libtool
+# There is probably a way to avoid it but it is not worth to effort
+# to find out.
+# The 'anjuta_' prfix is a safety measure to avoid conflicts where the
+# plugin 'libpython.so' needs to link with the real 'libpython.so'
+
+# Include paths
+AM_CPPFLAGS = \
+ $(WARN_CFLAGS) \
+ $(DEPRECATED_FLAGS) \
+ $(LIBANJUTA_CFLAGS) \
+ $(EXTRA_CFLAGS) \
+ -DG_LOG_DOMAIN=\"parser-cxx\"
+
+# Where to install the plugin
+plugindir = $(anjuta_plugin_dir)
+
+# The plugin
+plugin_LTLIBRARIES = libanjuta-parser-cxx.la
+
+# Plugin sources
+libanjuta_parser_cxx_la_SOURCES = \
+ parser-cxx-assist.h \
+ parser-cxx-assist.c \
+ plugin.h \
+ plugin.c
+
+libanjuta_parser_cxx_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
+
+# Use C++ linking
+nodist_EXTRA_libanjuta_parser_cxx_la_SOURCES = dummy.cxx
+
+# Plugin dependencies
+libanjuta_parser_cxx_la_LIBADD = \
+ $(LIBANJUTA_LIBS) \
+ cxxparser/libcxxparser.la
+
+gsettings_in_file = org.gnome.anjuta.plugins.parser-cxx.gschema.xml.in
+gsettings_SCHEMAS = $(gsettings_in_file:.xml.in=.xml)
+ INTLTOOL_XML_NOMERGE_RULE@
+ GSETTINGS_RULES@
+
+EXTRA_DIST = \
+ $(plugin_in_files) \
+ $(parser_cxx_plugin_DATA) \
+ $(parser_cxx_pixmaps_DATA) \
+ $(parser_cxx_glade_DATA) \
+ $(gsettings_in_file)
+
+CLEANFILES = \
+ $(gsettings_SCHEMAS)
+
+-include $(top_srcdir)/git.mk
diff --git a/plugins/parser-cxx/anjuta-parser-cxx-plugin.png b/plugins/parser-cxx/anjuta-parser-cxx-plugin.png
new file mode 100644
index 0000000..0fe99c5
Binary files /dev/null and b/plugins/parser-cxx/anjuta-parser-cxx-plugin.png differ
diff --git a/plugins/parser-cxx/anjuta-parser-cxx.plugin.in b/plugins/parser-cxx/anjuta-parser-cxx.plugin.in
new file mode 100644
index 0000000..73b3798
--- /dev/null
+++ b/plugins/parser-cxx/anjuta-parser-cxx.plugin.in
@@ -0,0 +1,11 @@
+[Anjuta Plugin]
+Location=anjuta-parser-cxx:ParserCxxPlugin
+Icon=anjuta-parser-cxx-plugin.png
+_Name=C and C++ parser Plugin
+_Description=C and C++ parser plugin for code completion
+Interfaces=IAnjutaLanguageSupport
+UserActivatable=no
+
+[Language Support]
+Languages=C,C++
+MimeTypes=text/x-c
diff --git a/plugins/parser-cxx/anjuta-parser-cxx.ui b/plugins/parser-cxx/anjuta-parser-cxx.ui
new file mode 100644
index 0000000..98f4059
--- /dev/null
+++ b/plugins/parser-cxx/anjuta-parser-cxx.ui
@@ -0,0 +1,226 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="2.16"/>
+ <!-- interface-requires anjuta 0.0 -->
+ <object class="GtkAdjustment" id="adjustment1">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment2">
+ <property name="upper">100</property>
+ <property name="value">4</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment3">
+ <property name="upper">50</property>
+ <property name="value">10</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment4">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkListStore" id="liststore1"/>
+ <object class="GtkWindow" id="preferences_dialog">
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">window1</property>
+ <child>
+ <object class="GtkVBox" id="preferences">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <child>
+ <object class="GtkFrame" id="frame45">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="label_yalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkVBox" id="vbox1118">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkCheckButton" id="preferences:completion-enable">
+ <property name="label" translatable="yes">Enable code completion</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="border_width">5</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="frame3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkVBox" id="vbox3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkCheckButton" id="preferences:completion-space-after-func">
+ <property name="label" translatable="yes">Add a space after function call autocompletion</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="border_width">5</property>
+ <property name="use_action_appearance">False</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="preferences:completion-brace-after-func">
+ <property name="label" translatable="yes">Add '(' after function call autocompletion</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="border_width">5</property>
+ <property name="use_action_appearance">False</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="preferences:completion-closebrace-after-func">
+ <property name="label" translatable="yes">Add ')' after function call autocompletion</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="border_width">5</property>
+ <property name="use_action_appearance">False</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label_item">
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label12334">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="label" translatable="yes">Autocompletion</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="frame1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="border_width">5</property>
+ <property name="label_xalign">0</property>
+ <property name="label_yalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <child>
+ <object class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <child>
+ <object class="GtkCheckButton" id="preferences:calltip-enable">
+ <property name="label" translatable="yes">Show calltips</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="border_width">5</property>
+ <property name="use_action_appearance">False</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">Calltips</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/plugins/parser-cxx/org.gnome.anjuta.plugins.parser-cxx.gschema.xml.in b/plugins/parser-cxx/org.gnome.anjuta.plugins.parser-cxx.gschema.xml.in
new file mode 100644
index 0000000..06ed275
--- /dev/null
+++ b/plugins/parser-cxx/org.gnome.anjuta.plugins.parser-cxx.gschema.xml.in
@@ -0,0 +1,22 @@
+<schemalist>
+ <schema id="org.gnome.anjuta.plugins.parser-cxx" path="/org/gnome/anjuta/plugins/parser-cxx/">
+ <key name="user-packages" type="s">
+ <default>""</default>
+ </key>
+ <key name="completion-enable" type="b">
+ <default>true</default>
+ </key>
+ <key name="completion-space-after-func" type="b">
+ <default>true</default>
+ </key>
+ <key name="completion-brace-after-func" type="b">
+ <default>true</default>
+ </key>
+ <key name="completion-closebrace-after-func" type="b">
+ <default>true</default>
+ </key>
+ <key name="calltip-enable" type="b">
+ <default>true</default>
+ </key>
+ </schema>
+</schemalist>
diff --git a/plugins/language-support-cpp-java/cpp-java-assist.c b/plugins/parser-cxx/parser-cxx-assist.c
similarity index 55%
rename from plugins/language-support-cpp-java/cpp-java-assist.c
rename to plugins/parser-cxx/parser-cxx-assist.c
index e5d8e8f..53afe6f 100644
--- a/plugins/language-support-cpp-java/cpp-java-assist.c
+++ b/plugins/parser-cxx/parser-cxx-assist.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
- * cpp-java-assist.c
+ * parser-cxx-assist.c
* Copyright (C) 2007 Naba Kumar <naba gnome org>
* Johannes Schmid <jhs gnome org>
*
@@ -23,58 +23,48 @@
* Boston, MA 02110-1301, USA.
*/
-#include "cxxparser/engine-parser.h"
-
#include <ctype.h>
#include <string.h>
#include <libanjuta/anjuta-debug.h>
+#include <libanjuta/anjuta-language-provider.h>
#include <libanjuta/anjuta-utils.h>
#include <libanjuta/interfaces/ianjuta-file.h>
#include <libanjuta/interfaces/ianjuta-editor-cell.h>
-#include <libanjuta/interfaces/ianjuta-editor-selection.h>
#include <libanjuta/interfaces/ianjuta-editor-assist.h>
#include <libanjuta/interfaces/ianjuta-editor-tip.h>
-#include <libanjuta/interfaces/ianjuta-provider.h>
-#include <libanjuta/interfaces/ianjuta-document.h>
+#include <libanjuta/interfaces/ianjuta-language-provider.h>
#include <libanjuta/interfaces/ianjuta-symbol-manager.h>
-#include "cpp-java-assist.h"
+#include "parser-cxx-assist.h"
+#include "cxxparser/engine-parser.h"
-#define PREF_AUTOCOMPLETE_ENABLE "completion-enable"
-#define PREF_AUTOCOMPLETE_SPACE_AFTER_FUNC "completion-space-after-func"
-#define PREF_AUTOCOMPLETE_BRACE_AFTER_FUNC "completion-brace-after-func"
-#define PREF_AUTOCOMPLETE_CLOSEBRACE_AFTER_FUNC "completion-closebrace-after-func"
-#define PREF_CALLTIP_ENABLE "calltip-enable"
#define BRACE_SEARCH_LIMIT 500
+#define SCOPE_CONTEXT_CHARACTERS "_.:>-0"
+#define WORD_CHARACTER "_0"
-static void cpp_java_assist_iface_init(IAnjutaProviderIface* iface);
+static void iprovider_iface_init(IAnjutaProviderIface* iface);
+static void ilanguage_provider_iface_init(IAnjutaLanguageProviderIface* iface);
-G_DEFINE_TYPE_WITH_CODE (CppJavaAssist,
- cpp_java_assist,
- G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (IANJUTA_TYPE_PROVIDER,
- cpp_java_assist_iface_init))
+G_DEFINE_TYPE_WITH_CODE (ParserCxxAssist,
+ parser_cxx_assist,
+ G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (IANJUTA_TYPE_PROVIDER,
+ iprovider_iface_init)
+ G_IMPLEMENT_INTERFACE (IANJUTA_TYPE_LANGUAGE_PROVIDER,
+ ilanguage_provider_iface_init))
-typedef struct
-{
- gchar *name;
- gboolean is_func;
- GdkPixbuf* icon;
- IAnjutaSymbolType type;
-} CppJavaAssistTag;
-
-struct _CppJavaAssistPriv {
+struct _ParserCxxAssistPriv {
GSettings* settings;
IAnjutaEditorAssist* iassist;
IAnjutaEditorTip* itip;
-
- GCompletion *completion_cache;
+ AnjutaLanguageProvider* lang_prov;
+
+ const gchar* editor_filename;
/* Calltips */
- gboolean calltip_active;
gchar* calltip_context;
- GList* tips;
IAnjutaIterable* calltip_iter;
-
+ GList* tips;
+
gint async_calltip_file;
gint async_calltip_system;
gint async_calltip_project;
@@ -84,10 +74,10 @@ struct _CppJavaAssistPriv {
IAnjutaSymbolQuery *calltip_query_project;
/* Autocompletion */
+ GCompletion *completion_cache;
+ gchar* pre_word;
gboolean member_completion;
gboolean autocompletion;
- IAnjutaIterable* start_iter;
- gchar* pre_word;
gint async_file_id;
gint async_system_id;
@@ -95,7 +85,7 @@ struct _CppJavaAssistPriv {
IAnjutaSymbolQuery *ac_query_file;
IAnjutaSymbolQuery *ac_query_system;
- IAnjutaSymbolQuery *ac_query_project;
+ IAnjutaSymbolQuery *ac_query_project;
/* Member autocompletion */
IAnjutaSymbolQuery *query_members;
@@ -106,14 +96,8 @@ struct _CppJavaAssistPriv {
IAnjutaSymbolQuery *sync_query_project;
};
-typedef struct
-{
- gboolean is_func;
- gchar* name;
-} ProposalData;
-
/**
- * cpp_java_assist_proposal_new:
+ * parser_cxx_assist_proposal_new:
* @symbol: IAnjutaSymbol to create the proposal for
*
* Creates a new IAnjutaEditorAssistProposal for symbol
@@ -121,14 +105,14 @@ typedef struct
* Returns: a newly allocated IAnjutaEditorAssistProposal
*/
static IAnjutaEditorAssistProposal*
-cpp_java_assist_proposal_new (IAnjutaSymbol* symbol)
+parser_cxx_assist_proposal_new (IAnjutaSymbol* symbol)
{
IAnjutaEditorAssistProposal* proposal = g_new0 (IAnjutaEditorAssistProposal, 1);
- IAnjutaSymbolType type = ianjuta_symbol_get_sym_type (symbol, NULL);
- ProposalData* data = g_new0 (ProposalData, 1);
-
+ IAnjutaLanguageProviderProposalData* data = g_new0 (IAnjutaLanguageProviderProposalData, 1);
+
data->name = g_strdup (ianjuta_symbol_get_string (symbol, IANJUTA_SYMBOL_FIELD_NAME, NULL));
- switch (type)
+ data->type = ianjuta_symbol_get_sym_type (symbol, NULL);
+ switch (data->type)
{
case IANJUTA_SYMBOL_TYPE_PROTOTYPE:
case IANJUTA_SYMBOL_TYPE_FUNCTION:
@@ -141,6 +125,17 @@ cpp_java_assist_proposal_new (IAnjutaSymbol* symbol)
proposal->label = g_strdup (data->name);
data->is_func = FALSE;
}
+ data->has_para = FALSE;
+ if (data->is_func)
+ {
+ const gchar* signature = ianjuta_symbol_get_string (symbol,
+ IANJUTA_SYMBOL_FIELD_SIGNATURE,
+ NULL);
+ if (g_strcmp0 (signature, "(void)") || g_strcmp0 (signature, "()"))
+ data->has_para = TRUE;
+
+ }
+
proposal->data = data;
/* Icons are lifetime object of the symbol-db so we can cast here */
proposal->icon = (GdkPixbuf*) ianjuta_symbol_get_icon (symbol, NULL);
@@ -148,16 +143,17 @@ cpp_java_assist_proposal_new (IAnjutaSymbol* symbol)
}
/**
- * cpp_java_assist_proposal_free:
+ * parser_cxx_assist_proposal_free:
* @proposal: the proposal to free
*
* Frees the proposal
*/
static void
-cpp_java_assist_proposal_free (IAnjutaEditorAssistProposal* proposal)
+parser_cxx_assist_proposal_free (IAnjutaEditorAssistProposal* proposal)
{
- ProposalData* data = proposal->data;
+ IAnjutaLanguageProviderProposalData* data = proposal->data;
g_free (data->name);
+ g_free (data->info);
g_free (data);
g_free (proposal->label);
g_free (proposal);
@@ -173,22 +169,22 @@ static gchar*
anjuta_proposal_completion_func (gpointer data)
{
IAnjutaEditorAssistProposal* proposal = data;
- ProposalData* prop_data = proposal->data;
+ IAnjutaLanguageProviderProposalData* prop_data = proposal->data;
return prop_data->name;
}
/**
- * cpp_java_assist_create_completion_from_symbols:
+ * parser_cxx_assist_create_completion_from_symbols:
* @symbols: Symbol iteration
- *
+ *
* Create a list of IAnjutaEditorAssistProposals from a list of symbols
*
- * Returns: a newly allocated GList of newly allocated proposals. Free
+ * Returns: a newly allocated GList of newly allocated proposals. Free
* with cpp_java_assist_proposal_free()
*/
static GList*
-cpp_java_assist_create_completion_from_symbols (IAnjutaIterable* symbols)
+parser_cxx_assist_create_completion_from_symbols (IAnjutaIterable* symbols)
{
GList* list = NULL;
@@ -197,7 +193,7 @@ cpp_java_assist_create_completion_from_symbols (IAnjutaIterable* symbols)
do
{
IAnjutaSymbol* symbol = IANJUTA_SYMBOL (symbols);
- IAnjutaEditorAssistProposal* proposal = cpp_java_assist_proposal_new (symbol);
+ IAnjutaEditorAssistProposal* proposal = parser_cxx_assist_proposal_new (symbol);
list = g_list_append (list, proposal);
}
@@ -207,94 +203,24 @@ cpp_java_assist_create_completion_from_symbols (IAnjutaIterable* symbols)
}
/**
- * cpp_java_assist_is_word_character:
- * @ch: character to check
- *
- * Returns: TRUE if ch is a valid word character, FALSE otherwise
- */
-
-static gboolean
-cpp_java_assist_is_word_character (gchar ch)
-{
- if (g_ascii_isspace (ch))
- return FALSE;
- if (g_ascii_isalnum (ch))
- return TRUE;
- if (ch == '_')
- return TRUE;
-
- return FALSE;
-}
-
-/**
- * cpp_java_assist_get_pre_word:
- * @editor: Editor object
- * @iter: current cursor position
- * @start_iter: return location for the start_iter (if a preword was found)
- *
- * Search for the current typed word
- *
- * Returns: The current word (needs to be freed) or NULL if no word was found
- */
-static gchar*
-cpp_java_assist_get_pre_word (IAnjutaEditor* editor, IAnjutaIterable *iter, IAnjutaIterable** start_iter)
-{
- IAnjutaIterable *end = ianjuta_iterable_clone (iter, NULL);
- IAnjutaIterable *begin = ianjuta_iterable_clone (iter, NULL);
- gchar ch, *preword_chars = NULL;
- gboolean out_of_range = FALSE;
- gboolean preword_found = FALSE;
-
- /* Cursor points after the current characters, move back */
- ianjuta_iterable_previous (begin, NULL);
-
- ch = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (begin), 0, NULL);
-
- while (ch && cpp_java_assist_is_word_character (ch))
- {
- preword_found = TRUE;
- if (!ianjuta_iterable_previous (begin, NULL))
- {
- out_of_range = TRUE;
- break;
- }
- ch = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (begin), 0, NULL);
- }
-
- if (preword_found)
- {
- if (!out_of_range)
- ianjuta_iterable_next (begin, NULL);
- preword_chars = ianjuta_editor_get_text (editor, begin, end, NULL);
- *start_iter = begin;
- }
- else
- {
- g_object_unref (begin);
- *start_iter = NULL;
- }
-
- g_object_unref (end);
- return preword_chars;
-}
-
-/**
- * cpp_java_assist_update_pre_word:
+ * parser_cxx_assist_update_pre_word:
* @assist: self
* @pre_word: new pre_word
*
* Updates the current pre_word
*/
static void
-cpp_java_assist_update_pre_word (CppJavaAssist* assist, const gchar* pre_word)
+parser_cxx_assist_update_pre_word (ParserCxxAssist* assist,
+ const gchar* pre_word)
{
g_free (assist->priv->pre_word);
- if (pre_word == NULL) pre_word = "";
+ if (pre_word == NULL)
+ pre_word = "";
assist->priv->pre_word = g_strdup (pre_word);
}
/**
- * cpp_java_assist_is_expression_separator:
+ * parser_cxx_assist_is_expression_separator:
* @c: character to check
* @skip_braces: whether to skip closing braces
* @iter: current cursor position
@@ -305,10 +231,12 @@ cpp_java_assist_update_pre_word (CppJavaAssist* assist, const gchar* pre_word)
* Returns: TRUE if the characters seperates an expression, FALSE otherwise
*/
static gboolean
-cpp_java_assist_is_expression_separator (gchar c, gboolean skip_braces, IAnjutaIterable* iter)
+parser_cxx_assist_is_expression_separator (gchar c,
+ gboolean skip_braces,
+ IAnjutaIterable* iter)
{
- IAnjutaEditorAttribute attrib = ianjuta_editor_cell_get_attribute (IANJUTA_EDITOR_CELL(iter),
- NULL);
+ IAnjutaEditorAttribute attrib = ianjuta_editor_cell_get_attribute (
+ IANJUTA_EDITOR_CELL(iter), NULL);
int i;
const gchar separators[] = {',', ';', '\n', '\r', '\t', '(',
'{', '}', '=', '<', '\v', '!',
@@ -333,13 +261,13 @@ cpp_java_assist_is_expression_separator (gchar c, gboolean skip_braces, IAnjutaI
{
if (separators[i] == c)
return TRUE;
- }
+ }
return FALSE;
}
/**
- * cpp_java_assist_parse_expression:
+ * parser_cxx_assist_parse_expression:
* @assist: self,
* @iter: current cursor position
* @start_iter: return location for the start of the completion
@@ -347,7 +275,7 @@ cpp_java_assist_is_expression_separator (gchar c, gboolean skip_braces, IAnjutaI
* Returns: An iter of a list of IAnjutaSymbols or NULL
*/
static IAnjutaIterable*
-cpp_java_assist_parse_expression (CppJavaAssist* assist, IAnjutaIterable* iter, IAnjutaIterable** start_iter)
+parser_cxx_assist_parse_expression (ParserCxxAssist* assist, IAnjutaIterable* iter, IAnjutaIterable** start_iter)
{
IAnjutaEditor* editor = IANJUTA_EDITOR (assist->priv->iassist);
IAnjutaIterable* res = NULL;
@@ -362,22 +290,25 @@ cpp_java_assist_parse_expression (CppJavaAssist* assist, IAnjutaIterable* iter,
/* Search for a operator in the current line */
do
{
- gchar ch = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL(cur_pos), 0, NULL);
+ gchar ch = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL(cur_pos),
+ 0, NULL);
- if (cpp_java_assist_is_expression_separator(ch, FALSE, iter)) {
+ if (parser_cxx_assist_is_expression_separator(ch, FALSE, iter)) {
break;
}
if (ch == '.' || (op_start && ch == '-') || (ref_start && ch == ':'))
{
/* Found an operator, get the statement and the pre_word */
- IAnjutaIterable* pre_word_start = ianjuta_iterable_clone (cur_pos, NULL);
+ IAnjutaIterable* pre_word_start = ianjuta_iterable_clone (cur_pos,
+ NULL);
IAnjutaIterable* pre_word_end = ianjuta_iterable_clone (iter, NULL);
- IAnjutaIterable* stmt_end = ianjuta_iterable_clone (pre_word_start, NULL);
+ IAnjutaIterable* stmt_end = ianjuta_iterable_clone (pre_word_start,
+ NULL);
- /* we need to pass to the parser all the statement included the last operator,
- * being it "." or "->" or "::"
+ /* we need to pass to the parser all the statement included the last
+ * operator, being it "." or "->" or "::"
* Increase the end bound of the statement.
*/
ianjuta_iterable_next (stmt_end, NULL);
@@ -385,8 +316,8 @@ cpp_java_assist_parse_expression (CppJavaAssist* assist, IAnjutaIterable* iter,
ianjuta_iterable_next (stmt_end, NULL);
- /* Move one character forward so we have the start of the pre_word and
- * not the last operator */
+ /* Move one character forward so we have the start of the pre_word
+ * and not the last operator */
ianjuta_iterable_next (pre_word_start, NULL);
/* If this is a two character operator, skip the second character */
if (op_start)
@@ -394,16 +325,20 @@ cpp_java_assist_parse_expression (CppJavaAssist* assist, IAnjutaIterable* iter,
ianjuta_iterable_next (pre_word_start, NULL);
}
- cpp_java_assist_update_pre_word (assist,
- ianjuta_editor_get_text (editor,
- pre_word_start, pre_word_end, NULL));
+ parser_cxx_assist_update_pre_word (assist, ianjuta_editor_get_text (
+ editor,
+ pre_word_start,
+ pre_word_end,
+ NULL));
/* Try to get the name of the variable */
while (ianjuta_iterable_previous (cur_pos, NULL))
{
- gchar word_ch = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL(cur_pos), 0, NULL);
+ gchar word_ch = ianjuta_editor_cell_get_char (
+ IANJUTA_EDITOR_CELL(cur_pos), 0, NULL);
- if (cpp_java_assist_is_expression_separator(word_ch, FALSE, cur_pos))
+ if (parser_cxx_assist_is_expression_separator(word_ch, FALSE,
+ cur_pos))
break;
}
ianjuta_iterable_next (cur_pos, NULL);
@@ -429,38 +364,28 @@ cpp_java_assist_parse_expression (CppJavaAssist* assist, IAnjutaIterable* iter,
if (stmt)
{
gint lineno;
- gchar *filename = NULL;
gchar *above_text;
IAnjutaIterable* start;
-
- if (IANJUTA_IS_FILE (assist->priv->iassist))
+
+ if (!assist->priv->editor_filename)
{
- GFile *file = ianjuta_file_get_file (IANJUTA_FILE (assist->priv->iassist), NULL);
- if (file != NULL)
- {
- filename = g_file_get_path (file);
- g_object_unref (file);
- }
- else
- {
- g_free (stmt);
- return NULL;
- }
+ g_free (stmt);
+ return NULL;
}
+
start = ianjuta_editor_get_start_position (editor, NULL);
above_text = ianjuta_editor_get_text (editor, start, iter, NULL);
g_object_unref (start);
lineno = ianjuta_editor_get_lineno (editor, NULL);
- /* the parser works even for the "Gtk::" like expressions, so it shouldn't be
- * created a specific case to handle this.
+ /* the parser works even for the "Gtk::" like expressions, so it
+ * shouldn't be created a specific case to handle this.
*/
res = engine_parser_process_expression (stmt,
above_text,
- filename,
+ assist->priv->editor_filename,
lineno);
- g_free (filename);
g_free (stmt);
}
g_object_unref (cur_pos);
@@ -468,13 +393,13 @@ cpp_java_assist_parse_expression (CppJavaAssist* assist, IAnjutaIterable* iter,
}
/**
- * cpp_java_assist_create_completion_cache:
+ * parser_cxx_assist_create_completion_cache:
* @assist: self
*
* Create a new completion_cache object
*/
static void
-cpp_java_assist_create_completion_cache (CppJavaAssist* assist)
+parser_cxx_assist_create_completion_cache (ParserCxxAssist* assist)
{
g_assert (assist->priv->completion_cache == NULL);
assist->priv->completion_cache =
@@ -482,13 +407,13 @@ cpp_java_assist_create_completion_cache (CppJavaAssist* assist)
}
/**
- * cpp_java_assist_cancel_queries:
+ * parser_cxx_assist_cancel_queries:
* @assist: self
*
* Abort all async operations
*/
static void
-cpp_java_assist_cancel_queries (CppJavaAssist* assist)
+parser_cxx_assist_cancel_queries (ParserCxxAssist* assist)
{
ianjuta_symbol_query_cancel (assist->priv->ac_query_file, NULL);
ianjuta_symbol_query_cancel (assist->priv->ac_query_project, NULL);
@@ -499,18 +424,19 @@ cpp_java_assist_cancel_queries (CppJavaAssist* assist)
}
/**
- * cpp_java_assist_clear_completion_cache:
+ * parser_cxx_assist_clear_completion_cache:
* @assist: self
*
* Clear the completion cache, aborting all async operations
*/
static void
-cpp_java_assist_clear_completion_cache (CppJavaAssist* assist)
+parser_cxx_assist_clear_completion_cache (ParserCxxAssist* assist)
{
- cpp_java_assist_cancel_queries (assist);
+ parser_cxx_assist_cancel_queries (assist);
if (assist->priv->completion_cache)
{
- g_list_foreach (assist->priv->completion_cache->items, (GFunc) cpp_java_assist_proposal_free, NULL);
+ g_list_foreach (assist->priv->completion_cache->items,
+ (GFunc) parser_cxx_assist_proposal_free, NULL);
g_completion_free (assist->priv->completion_cache);
}
assist->priv->completion_cache = NULL;
@@ -519,83 +445,67 @@ cpp_java_assist_clear_completion_cache (CppJavaAssist* assist)
}
/**
- * cpp_java_assist_populate_real:
+ * parser_cxx_assist_populate_real:
* @assist: self
* @finished: TRUE if no more proposals are expected, FALSE otherwise
*
- * Really invokes the completion interfaces and adds completions. Might be called
- * from an async context
+ * Really invokes the completion interfaces and adds completions.
+ * Might be called from an async context
*/
static void
-cpp_java_assist_populate_real (CppJavaAssist* assist, gboolean finished)
+parser_cxx_assist_populate_real (ParserCxxAssist* assist, gboolean finished)
{
g_assert (assist->priv->pre_word != NULL);
- gchar* prefix;
GList* proposals = g_completion_complete (assist->priv->completion_cache,
assist->priv->pre_word,
- &prefix);
- if (g_list_length (proposals) == 1)
- {
- IAnjutaEditorAssistProposal* proposal = proposals->data;
- ProposalData* data = proposal->data;
- if (g_str_equal (assist->priv->pre_word, data->name))
- {
- ianjuta_editor_assist_proposals (assist->priv->iassist,
- IANJUTA_PROVIDER(assist),
- NULL, finished, NULL);
- return;
- }
- }
-
+ NULL);
ianjuta_editor_assist_proposals (assist->priv->iassist,
- IANJUTA_PROVIDER(assist),
- proposals, finished, NULL);
+ IANJUTA_PROVIDER(assist), proposals,
+ assist->priv->pre_word, finished, NULL);
}
/**
- * cpp_java_assist_create_member_completion_cache
+ * parser_cxx_assist_create_member_completion_cache
* @assist: self
* @cursor: Current cursor position
*
* Create the completion_cache for member completion if possible
*
- * Returns: TRUE if a completion cache was build, FALSE otherwise
+ * Returns: the iter where a completion cache was build, NULL otherwise
*/
-static gboolean
-cpp_java_assist_create_member_completion_cache (CppJavaAssist* assist, IAnjutaIterable* cursor)
+static IAnjutaIterable*
+parser_cxx_assist_create_member_completion_cache (ParserCxxAssist* assist,
+ IAnjutaIterable* cursor)
{
IAnjutaIterable* symbol = NULL;
IAnjutaIterable* start_iter = NULL;
- symbol = cpp_java_assist_parse_expression (assist, cursor, &start_iter);
+ symbol = parser_cxx_assist_parse_expression (assist, cursor, &start_iter);
if (symbol)
{
- gint retval = FALSE;
/* Query symbol children */
IAnjutaIterable *children =
ianjuta_symbol_query_search_members (assist->priv->query_members,
IANJUTA_SYMBOL(symbol),
NULL);
+
+ g_object_unref (symbol);
if (children)
{
- GList* proposals =
- cpp_java_assist_create_completion_from_symbols (children);
- cpp_java_assist_create_completion_cache (assist);
+ GList* proposals =
+ parser_cxx_assist_create_completion_from_symbols (children);
+ parser_cxx_assist_create_completion_cache (assist);
g_completion_add_items (assist->priv->completion_cache, proposals);
- assist->priv->start_iter = start_iter;
-
- cpp_java_assist_populate_real (assist, TRUE);
+ parser_cxx_assist_populate_real (assist, TRUE);
g_list_free (proposals);
g_object_unref (children);
- retval = TRUE;
+ return start_iter;
}
- g_object_unref (symbol);
- return retval;
}
else if (start_iter)
g_object_unref (start_iter);
- return FALSE;
+ return NULL;
}
/**
@@ -608,10 +518,10 @@ cpp_java_assist_create_member_completion_cache (CppJavaAssist* assist, IAnjutaIt
*/
static void
on_symbol_search_complete (IAnjutaSymbolQuery *query, IAnjutaIterable* symbols,
- CppJavaAssist* assist)
+ ParserCxxAssist* assist)
{
GList* proposals;
- proposals = cpp_java_assist_create_completion_from_symbols (symbols);
+ proposals = parser_cxx_assist_create_completion_from_symbols (symbols);
if (query == assist->priv->ac_query_file)
assist->priv->async_file_id = 0;
@@ -623,44 +533,49 @@ on_symbol_search_complete (IAnjutaSymbolQuery *query, IAnjutaIterable* symbols,
g_assert_not_reached ();
g_completion_add_items (assist->priv->completion_cache, proposals);
- gboolean running = assist->priv->async_system_id || assist->priv->async_file_id ||
- assist->priv->async_project_id;
+ gboolean running = assist->priv->async_system_id
+ || assist->priv->async_file_id
+ || assist->priv->async_project_id;
if (!running)
- cpp_java_assist_populate_real (assist, TRUE);
+ parser_cxx_assist_populate_real (assist, TRUE);
g_list_free (proposals);
}
/**
- * cpp_java_assist_create_autocompletion_cache:
+ * parser_cxx_assist_create_autocompletion_cache:
* @assist: self
* @cursor: Current cursor position
*
* Create completion cache for autocompletion. This is done async.
*
- * Returns: TRUE if a preword was detected, FALSE otherwise
+ * Returns: the iter where a preword was detected, NULL otherwise
*/
-static gboolean
-cpp_java_assist_create_autocompletion_cache (CppJavaAssist* assist, IAnjutaIterable* cursor)
+static IAnjutaIterable*
+parser_cxx_assist_create_autocompletion_cache (ParserCxxAssist* assist,
+ IAnjutaIterable* cursor)
{
IAnjutaIterable* start_iter;
- gchar* pre_word =
- cpp_java_assist_get_pre_word (IANJUTA_EDITOR (assist->priv->iassist), cursor, &start_iter);
+ gchar* pre_word = anjuta_language_provider_get_pre_word (
+ assist->priv->lang_prov,
+ IANJUTA_EDITOR (assist->priv->iassist),
+ cursor, &start_iter, WORD_CHARACTER);
if (!pre_word || strlen (pre_word) <= 3)
{
if (start_iter)
g_object_unref (start_iter);
- return FALSE;
+ return NULL;
}
else
{
gchar *pattern = g_strconcat (pre_word, "%", NULL);
- cpp_java_assist_create_completion_cache (assist);
- cpp_java_assist_update_pre_word (assist, pre_word);
+ parser_cxx_assist_create_completion_cache (assist);
+ parser_cxx_assist_update_pre_word (assist, pre_word);
if (IANJUTA_IS_FILE (assist->priv->iassist))
{
- GFile *file = ianjuta_file_get_file (IANJUTA_FILE (assist->priv->iassist), NULL);
+ GFile *file = ianjuta_file_get_file (
+ IANJUTA_FILE (assist->priv->iassist), NULL);
if (file != NULL)
{
assist->priv->async_file_id = 1;
@@ -671,21 +586,43 @@ cpp_java_assist_create_autocompletion_cache (CppJavaAssist* assist, IAnjutaItera
}
/* This will avoid duplicates of FUNCTION and PROTOTYPE */
assist->priv->async_project_id = 1;
- ianjuta_symbol_query_search (assist->priv->ac_query_project, pattern, NULL);
+ ianjuta_symbol_query_search (assist->priv->ac_query_project, pattern,
+ NULL);
assist->priv->async_system_id = 1;
- ianjuta_symbol_query_search (assist->priv->ac_query_system, pattern, NULL);
+ ianjuta_symbol_query_search (assist->priv->ac_query_system, pattern,
+ NULL);
g_free (pre_word);
g_free (pattern);
-
- assist->priv->start_iter = start_iter;
- return TRUE;
+ return start_iter;
}
}
+/**
+ * parser_cxx_assist_get_calltip_context:
+ * @self: Self
+ * @iter: current cursor position
+ * @e: Error propagation
+ *
+ * Searches for a calltip context
+ *
+ * Returns: name of the method to show a calltip for or NULL
+ */
+static gchar*
+parser_cxx_assist_get_calltip_context (IAnjutaLanguageProvider *self,
+ IAnjutaIterable *iter,
+ GError** e)
+{
+ ParserCxxAssist* assist = PARSER_CXX_ASSIST (self);
+ gchar* calltip_context;
+ calltip_context = anjuta_language_provider_get_calltip_context (
+ assist->priv->lang_prov, assist->priv->itip, iter,
+ SCOPE_CONTEXT_CHARACTERS);
+ return calltip_context;
+}
/**
- * cpp_java_assist_create_calltips:
+ * parser_cxx_assist_create_calltips:
* @iter: List of symbols
* @merge: list of calltips to merge or NULL
*
@@ -694,19 +631,26 @@ cpp_java_assist_create_autocompletion_cache (CppJavaAssist* assist, IAnjutaItera
* A newly allocated GList* with newly allocated strings
*/
static GList*
-cpp_java_assist_create_calltips (IAnjutaIterable* iter, GList* merge)
+parser_cxx_assist_create_calltips (IAnjutaIterable* iter, GList* merge)
{
GList* tips = merge;
if (iter)
{
do
{
- IAnjutaSymbol* symbol = IANJUTA_SYMBOL(iter);
- const gchar* name = ianjuta_symbol_get_string (symbol, IANJUTA_SYMBOL_FIELD_NAME, NULL);
+ IAnjutaSymbol* symbol = IANJUTA_SYMBOL (iter);
+ const gchar* name = ianjuta_symbol_get_string (
+ symbol,IANJUTA_SYMBOL_FIELD_NAME, NULL);
if (name != NULL)
{
- const gchar* args = ianjuta_symbol_get_string (symbol, IANJUTA_SYMBOL_FIELD_SIGNATURE, NULL);
- const gchar* rettype = ianjuta_symbol_get_string (symbol, IANJUTA_SYMBOL_FIELD_RETURNTYPE, NULL);
+ const gchar* args = ianjuta_symbol_get_string (
+ symbol,
+ IANJUTA_SYMBOL_FIELD_SIGNATURE,
+ NULL);
+ const gchar* rettype = ianjuta_symbol_get_string (
+ symbol,
+ IANJUTA_SYMBOL_FIELD_RETURNTYPE,
+ NULL);
gchar* print_args;
gchar* separator;
gchar* white_name;
@@ -721,15 +665,14 @@ cpp_java_assist_create_calltips (IAnjutaIterable* iter, GList* merge)
white_name = g_strnfill (white_count, ' ');
separator = g_strjoin (NULL, ", \n", white_name, NULL);
-
gchar** argv;
if (!args)
args = "()";
argv = g_strsplit (args, ",", -1);
print_args = g_strjoinv (separator, argv);
-
- gchar* tip = g_strdup_printf ("%s %s %s", rettype, name, print_args);
+ gchar* tip = g_strdup_printf ("%s %s %s", rettype, name,
+ print_args);
if (!g_list_find_custom (tips, tip, (GCompareFunc) strcmp))
tips = g_list_append (tips, tip);
@@ -757,9 +700,10 @@ cpp_java_assist_create_calltips (IAnjutaIterable* iter, GList* merge)
*/
static void
on_calltip_search_complete (IAnjutaSymbolQuery *query, IAnjutaIterable* symbols,
- CppJavaAssist* assist)
+ ParserCxxAssist* assist)
{
- assist->priv->tips = cpp_java_assist_create_calltips (symbols, assist->priv->tips);
+ assist->priv->tips = parser_cxx_assist_create_calltips (symbols,
+ assist->priv->tips);
if (query == assist->priv->calltip_query_file)
assist->priv->async_calltip_file = 0;
else if (query == assist->priv->calltip_query_project)
@@ -768,184 +712,62 @@ on_calltip_search_complete (IAnjutaSymbolQuery *query, IAnjutaIterable* symbols,
assist->priv->async_calltip_system = 0;
else
g_assert_not_reached ();
- gboolean running = assist->priv->async_calltip_system || assist->priv->async_calltip_file ||
- assist->priv->async_calltip_project;
+ gboolean running = assist->priv->async_calltip_system
+ || assist->priv->async_calltip_file
+ || assist->priv->async_calltip_project;
- DEBUG_PRINT ("Calltip search finished with %d items", g_list_length (assist->priv->tips));
+ DEBUG_PRINT ("Calltip search finished with %d items",
+ g_list_length (assist->priv->tips));
if (!running && assist->priv->tips)
{
- ianjuta_editor_tip_show (IANJUTA_EDITOR_TIP(assist->priv->itip), assist->priv->tips,
- assist->priv->calltip_iter,
+ ianjuta_editor_tip_show (IANJUTA_EDITOR_TIP(assist->priv->itip),
+ assist->priv->tips, assist->priv->calltip_iter,
NULL);
}
}
/**
- * cpp_java_assist_query_calltip:
- * @assist: self
+ * parser_cxx_assist_query_calltip:
+ * @self: Self
* @call_context: name of method/function
+ * e: Error propagation
*
* Starts an async query for the calltip
*/
static void
-cpp_java_assist_query_calltip (CppJavaAssist *assist, const gchar *call_context)
-{
- CppJavaAssistPriv* priv = assist->priv;
-
+parser_cxx_assist_query_calltip (ParserCxxAssist* assist,
+ const gchar *call_context,
+ IAnjutaIterable* calltip_iter)
+{
/* Search file */
if (IANJUTA_IS_FILE (assist->priv->itip))
{
- GFile *file = ianjuta_file_get_file (IANJUTA_FILE (priv->itip), NULL);
+ GFile *file = ianjuta_file_get_file (IANJUTA_FILE (assist->priv->itip),
+ NULL);
if (file != NULL)
{
- priv->async_calltip_file = 1;
+ assist->priv->async_calltip_file = 1;
ianjuta_symbol_query_search_file (assist->priv->calltip_query_file,
- call_context, file,
- NULL);
+ call_context, file, NULL);
g_object_unref (file);
}
}
/* Search Project */
- priv->async_calltip_project = 1;
+ assist->priv->async_calltip_project = 1;
ianjuta_symbol_query_search (assist->priv->calltip_query_project,
- call_context, NULL);
+ call_context, NULL);
/* Search system */
assist->priv->async_calltip_system = 1;
ianjuta_symbol_query_search (assist->priv->calltip_query_system,
- call_context, NULL);
-}
-
-/**
- * cpp_java_assist_is_scope_context_character:
- * @ch: character to check
- *
- * Returns: if the current character seperates a scope
- */
-static gboolean
-cpp_java_assist_is_scope_context_character (gchar ch)
-{
- if (g_ascii_isspace (ch))
- return FALSE;
- if (g_ascii_isalnum (ch))
- return TRUE;
- if (ch == '_' || ch == '.' || ch == ':' || ch == '>' || ch == '-')
- return TRUE;
-
- return FALSE;
-}
-
-#define SCOPE_BRACE_JUMP_LIMIT 50
-
-/**
- * cpp_java_assist_get_scope_context
- * @editor: current editor
- * @scope_operator: The scope operator to check for
- * @iter: Current cursor position
- *
- * Find the scope context for calltips
- */
-static gchar*
-cpp_java_assist_get_scope_context (IAnjutaEditor* editor,
- const gchar *scope_operator,
- IAnjutaIterable *iter)
-{
- IAnjutaIterable* end;
- gchar ch, *scope_chars = NULL;
- gboolean out_of_range = FALSE;
- gboolean scope_chars_found = FALSE;
-
- end = ianjuta_iterable_clone (iter, NULL);
- ianjuta_iterable_next (end, NULL);
-
- ch = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (iter), 0, NULL);
-
- while (ch)
- {
- if (cpp_java_assist_is_scope_context_character (ch))
- {
- scope_chars_found = TRUE;
- }
- else if (ch == ')')
- {
- if (!anjuta_util_jump_to_matching_brace (iter, ch, SCOPE_BRACE_JUMP_LIMIT))
- {
- out_of_range = TRUE;
- break;
- }
- }
- else
- break;
- if (!ianjuta_iterable_previous (iter, NULL))
- {
- out_of_range = TRUE;
- break;
- }
- ch = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (iter), 0, NULL);
- }
- if (scope_chars_found)
- {
- IAnjutaIterable* begin;
- begin = ianjuta_iterable_clone (iter, NULL);
- if (!out_of_range)
- ianjuta_iterable_next (begin, NULL);
- scope_chars = ianjuta_editor_get_text (editor, begin, end, NULL);
- g_object_unref (begin);
- }
- g_object_unref (end);
- return scope_chars;
-}
-
-/**
- * cpp_java_assist_create_calltip_context:
- * @assist: self
- * @iter: current cursor position
- *
- * Searches for a calltip context
- *
- * Returns: name of the method to show a calltip for or NULL
- */
-static gchar*
-cpp_java_assist_get_calltip_context (CppJavaAssist *assist,
- IAnjutaIterable *iter)
-{
- gchar ch;
- gchar *context = NULL;
-
- ch = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (iter), 0, NULL);
- if (ch == ')')
- {
- if (!anjuta_util_jump_to_matching_brace (iter, ')', -1))
- return NULL;
- if (!ianjuta_iterable_previous (iter, NULL))
- return NULL;
- }
- if (ch != '(')
- {
- if (!anjuta_util_jump_to_matching_brace (iter, ')',
- BRACE_SEARCH_LIMIT))
- return NULL;
- }
-
- /* Skip white spaces */
- while (ianjuta_iterable_previous (iter, NULL)
- && g_ascii_isspace (ianjuta_editor_cell_get_char
- (IANJUTA_EDITOR_CELL (iter), 0, NULL)));
-
- context = cpp_java_assist_get_scope_context
- (IANJUTA_EDITOR (assist->priv->itip), "(", iter);
-
- /* Point iter to the first character of the scope to align calltip correctly */
- ianjuta_iterable_next (iter, NULL);
-
- return context;
+ call_context, NULL);
}
/**
- * cpp_java_assist_create_calltip_context:
+ * parser_cxx_assist_create_calltip_context:
* @assist: self
* @call_context: The context (method/function name)
* @position: iter where to show calltips
@@ -953,22 +775,23 @@ cpp_java_assist_get_calltip_context (CppJavaAssist *assist,
* Create the calltip context
*/
static void
-cpp_java_assist_create_calltip_context (CppJavaAssist* assist,
- const gchar* call_context,
- IAnjutaIterable* position)
+parser_cxx_assist_create_calltip_context (ParserCxxAssist* assist,
+ const gchar* call_context,
+ IAnjutaIterable* position)
{
assist->priv->calltip_context = g_strdup (call_context);
assist->priv->calltip_iter = position;
}
/**
- * cpp_java_assist_clear_calltip_context:
- * @assist: self
+ * parser_cxx_assist_clear_calltip_context:
+ * @self: Self
+ * @e: Error propagation
*
* Clears the calltip context and brings it back into a save state
*/
static void
-cpp_java_assist_clear_calltip_context (CppJavaAssist* assist)
+parser_cxx_assist_clear_calltip_context (ParserCxxAssist* assist)
{
ianjuta_symbol_query_cancel (assist->priv->calltip_query_file, NULL);
ianjuta_symbol_query_cancel (assist->priv->calltip_query_project, NULL);
@@ -978,439 +801,184 @@ cpp_java_assist_clear_calltip_context (CppJavaAssist* assist)
assist->priv->async_calltip_project = 0;
assist->priv->async_calltip_system = 0;
- g_free (assist->priv->calltip_context);
- assist->priv->calltip_context = NULL;
-
g_list_foreach (assist->priv->tips, (GFunc) g_free, NULL);
g_list_free (assist->priv->tips);
assist->priv->tips = NULL;
-
+
+ g_free (assist->priv->calltip_context);
+ assist->priv->calltip_context = NULL;
+
if (assist->priv->calltip_iter)
g_object_unref (assist->priv->calltip_iter);
assist->priv->calltip_iter = NULL;
}
/**
- * cpp_java_assist_calltip:
- * @assist: self
- *
- * Creates a calltip if there is something to show a tip for
- * Calltips are queried async
+ * parser_cxx_assist_cancelled:
+ * @iassist: IAnjutaEditorAssist that emitted the signal
+ * @assist: ParserCxxAssist object
*
- * Returns: TRUE if a calltips was queried, FALSE otherwise
+ * Stop any autocompletion queries when the cancelled signal was received
*/
+static void
+parser_cxx_assist_cancelled (IAnjutaEditorAssist* iassist,
+ ParserCxxAssist* assist)
+{
+ parser_cxx_assist_cancel_queries (assist);
+}
-static gboolean
-cpp_java_assist_calltip (CppJavaAssist *assist)
+static GList*
+parser_cxx_assist_get_calltip_cache (IAnjutaLanguageProvider* self,
+ gchar* call_context,
+ GError** e)
{
- IAnjutaEditor *editor;
- IAnjutaIterable *iter;
-
- editor = IANJUTA_EDITOR (assist->priv->itip);
-
- iter = ianjuta_editor_get_position (editor, NULL);
- ianjuta_iterable_previous (iter, NULL);
- gchar *call_context =
- cpp_java_assist_get_calltip_context (assist, iter);
- if (call_context)
+ ParserCxxAssist* assist = PARSER_CXX_ASSIST (self);
+ if (!g_strcmp0 (call_context, assist->priv->calltip_context))
{
- DEBUG_PRINT ("Searching calltip for: %s", call_context);
- if (assist->priv->calltip_context &&
- g_str_equal (call_context, assist->priv->calltip_context))
- {
- /* Continue tip */
- if (assist->priv->tips)
- {
- if (!ianjuta_editor_tip_visible (IANJUTA_EDITOR_TIP (editor), NULL))
- {
- ianjuta_editor_tip_show (IANJUTA_EDITOR_TIP (editor),
- assist->priv->tips,
- assist->priv->calltip_iter, NULL);
- }
- }
- g_free (call_context);
- return TRUE;
- }
- else /* New tip */
- {
- if (ianjuta_editor_tip_visible (IANJUTA_EDITOR_TIP (editor), NULL))
- ianjuta_editor_tip_cancel (IANJUTA_EDITOR_TIP (editor), NULL);
-
- cpp_java_assist_clear_calltip_context (assist);
- cpp_java_assist_create_calltip_context (assist, call_context, iter);
- cpp_java_assist_query_calltip (assist, call_context);
- g_free (call_context);
- return TRUE;
- }
+ DEBUG_PRINT ("Calltip was found in the cache.");
+ return assist->priv->tips;
}
else
{
- if (ianjuta_editor_tip_visible (IANJUTA_EDITOR_TIP (editor), NULL))
- ianjuta_editor_tip_cancel (IANJUTA_EDITOR_TIP (editor), NULL);
- cpp_java_assist_clear_calltip_context (assist);
+ DEBUG_PRINT ("Calltip is not available in the cache!");
+ return NULL;
}
-
- g_object_unref (iter);
- return FALSE;
-}
-
-/**
- * cpp_java_assist_cancelled:
- * @iassist: IAnjutaEditorAssist that emitted the signal
- * @assist: CppJavaAssist object
- *
- * Stop any autocompletion queries when the cancelled signal was received
- */
-static void
-cpp_java_assist_cancelled (IAnjutaEditorAssist* iassist, CppJavaAssist* assist)
-{
- cpp_java_assist_cancel_queries (assist);
}
-/**
- * cpp_java_assist_none:
- * @self: IAnjutaProvider object
- * @assist: CppJavaAssist object
- *
- * Indicate that there is nothing to autocomplete
- */
static void
-cpp_java_assist_none (IAnjutaProvider* self,
- CppJavaAssist* assist)
+parser_cxx_assist_new_calltip (IAnjutaLanguageProvider* self,
+ gchar* call_context,
+ IAnjutaIterable* cursor,
+ GError** e)
{
- ianjuta_editor_assist_proposals (assist->priv->iassist,
- self,
- NULL, TRUE, NULL);
+ ParserCxxAssist* assist = PARSER_CXX_ASSIST (self);
+ parser_cxx_assist_clear_calltip_context (assist);
+ parser_cxx_assist_create_calltip_context (assist, call_context, cursor);
+ parser_cxx_assist_query_calltip (assist, call_context, cursor);
}
-
-/**
- * cpp_java_assist_populate:
- * @self: IAnjutaProvider object
- * @cursor: Iter at current cursor position (after current character)
- * @e: Error population
- */
-static void
-cpp_java_assist_populate (IAnjutaProvider* self, IAnjutaIterable* cursor, GError** e)
+static IAnjutaIterable*
+parser_cxx_assist_populate_language (IAnjutaLanguageProvider* self,
+ IAnjutaIterable* cursor,
+ GError** e)
{
- CppJavaAssist* assist = CPP_JAVA_ASSIST (self);
-
- /* Check if we actually want autocompletion at all */
- if (!g_settings_get_boolean (assist->priv->settings,
- PREF_AUTOCOMPLETE_ENABLE))
- {
- cpp_java_assist_none (self, assist);
- return;
- }
-
- /* Check if this is a valid text region for completion */
- IAnjutaEditorAttribute attrib = ianjuta_editor_cell_get_attribute (IANJUTA_EDITOR_CELL(cursor),
- NULL);
- if (attrib == IANJUTA_EDITOR_STRING ||
- attrib == IANJUTA_EDITOR_COMMENT)
- {
- cpp_java_assist_none (self, assist);
- return;
- }
-
- /* Check for calltip */
- if (assist->priv->itip &&
- g_settings_get_boolean (assist->priv->settings,
- PREF_CALLTIP_ENABLE))
- {
- assist->priv->calltip_active = cpp_java_assist_calltip (assist);
-
- }
+ ParserCxxAssist* assist = PARSER_CXX_ASSIST (self);
+ IAnjutaIterable* start_iter = NULL;
/* Check if completion was in progress */
if (assist->priv->member_completion || assist->priv->autocompletion)
{
- IAnjutaIterable* start_iter = NULL;
g_assert (assist->priv->completion_cache != NULL);
- gchar* pre_word = cpp_java_assist_get_pre_word (IANJUTA_EDITOR (assist->priv->iassist), cursor, &start_iter);
+ gchar* pre_word = anjuta_language_provider_get_pre_word (
+ assist->priv->lang_prov,
+ IANJUTA_EDITOR (assist->priv->iassist),
+ cursor, &start_iter, WORD_CHARACTER);
+ DEBUG_PRINT ("Preword: %s", pre_word);
if (pre_word && g_str_has_prefix (pre_word, assist->priv->pre_word))
{
- /* Great, we just continue the current completion */
- g_object_unref (assist->priv->start_iter);
- assist->priv->start_iter = start_iter;
-
- cpp_java_assist_update_pre_word (assist, pre_word);
- cpp_java_assist_populate_real (assist, TRUE);
+ DEBUG_PRINT ("Continue autocomplete for %s", pre_word);
+
+ /* Great, we just continue the current completion */
+ parser_cxx_assist_update_pre_word (assist, pre_word);
+ parser_cxx_assist_populate_real (assist, TRUE);
g_free (pre_word);
- return;
+ return start_iter;
}
g_free (pre_word);
}
-
- cpp_java_assist_clear_completion_cache (assist);
+
+ parser_cxx_assist_clear_completion_cache (assist);
/* Check for member completion */
- if (cpp_java_assist_create_member_completion_cache (assist, cursor))
- {
+ start_iter = parser_cxx_assist_create_member_completion_cache (assist,
+ cursor);
+ if (start_iter)
assist->priv->member_completion = TRUE;
- return;
- }
- else if (cpp_java_assist_create_autocompletion_cache (assist, cursor))
- {
- assist->priv->autocompletion = TRUE;
- return;
- }
- /* Nothing to propose */
- if (assist->priv->start_iter)
- {
- g_object_unref (assist->priv->start_iter);
- assist->priv->start_iter = NULL;
- }
- cpp_java_assist_none (self, assist);
-}
-
-/**
- * cpp_java_assist_find_next_brace:
- * @self: CppJavaAssist object
- * @iter: Iter to start searching at
- *
- * Returns: TRUE if the next non-whitespace character is a opening brace,
- * FALSE otherwise
- */
-static gboolean
-cpp_java_assist_find_next_brace (CppJavaAssist* assist,
- IAnjutaIterable* iter)
-{
- IAnjutaIterable* my_iter = ianjuta_iterable_clone (iter, NULL);
- char ch;
- do
- {
- ch = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (my_iter), 0, NULL);
- if (ch == '(')
- {
- g_object_unref (my_iter);
- return TRUE;
- }
- }
- while (g_ascii_isspace (ch) && ianjuta_iterable_next (my_iter, NULL));
-
- return FALSE;
-}
-
-/**
- * cpp_java_assist_activate:
- * @self: IAnjutaProvider object
- * @iter: cursor position when proposal was activated
- * @data: Data assigned to the completion object
- * @e: Error population
- *
- * Called from the provider when the user activated a proposal
- */
-static void
-cpp_java_assist_activate (IAnjutaProvider* self, IAnjutaIterable* iter, gpointer data, GError** e)
-{
- CppJavaAssist* assist = CPP_JAVA_ASSIST(self);
- ProposalData *prop_data = data;
- GString *assistance;
- IAnjutaEditor *te;
- gboolean add_space_after_func = FALSE;
- gboolean add_brace_after_func = FALSE;
- gboolean add_closebrace_after_func = FALSE;
-
- g_return_if_fail (prop_data != NULL);
-
- assistance = g_string_new (prop_data->name);
-
- if (prop_data->is_func)
- {
- add_space_after_func =
- g_settings_get_boolean (assist->priv->settings,
- PREF_AUTOCOMPLETE_SPACE_AFTER_FUNC);
- add_brace_after_func =
- g_settings_get_boolean (assist->priv->settings,
- PREF_AUTOCOMPLETE_BRACE_AFTER_FUNC);
- add_closebrace_after_func =
- g_settings_get_boolean (assist->priv->settings,
- PREF_AUTOCOMPLETE_CLOSEBRACE_AFTER_FUNC);
-
- if (!cpp_java_assist_find_next_brace (assist, iter))
- {
- if (add_space_after_func)
- g_string_append (assistance, " ");
- if (add_brace_after_func)
- g_string_append (assistance, "(");
- }
- }
-
- te = IANJUTA_EDITOR (assist->priv->iassist);
-
- ianjuta_document_begin_undo_action (IANJUTA_DOCUMENT (te), NULL);
-
- if (ianjuta_iterable_compare(iter, assist->priv->start_iter, NULL) != 0)
- {
- ianjuta_editor_selection_set (IANJUTA_EDITOR_SELECTION (te),
- assist->priv->start_iter, iter, FALSE, NULL);
- ianjuta_editor_selection_replace (IANJUTA_EDITOR_SELECTION (te),
- assistance->str, -1, NULL);
- }
else
{
- ianjuta_editor_insert (te, iter, assistance->str, -1, NULL);
- }
-
- if (add_brace_after_func && add_closebrace_after_func)
- {
- IAnjutaIterable *pos = ianjuta_iterable_clone (iter, NULL);
-
- ianjuta_iterable_set_position (pos,
- ianjuta_iterable_get_position (assist->priv->start_iter, NULL)
- + strlen (assistance->str),
- NULL);
- ianjuta_editor_insert (te, pos, ")", -1, NULL);
- ianjuta_editor_goto_position (te, pos, NULL);
-
- ianjuta_iterable_previous (pos, NULL);
- gchar *context = cpp_java_assist_get_calltip_context (assist, pos);
- g_object_unref (pos);
- IAnjutaIterable *symbol = NULL;
- if (IANJUTA_IS_FILE (assist->priv->iassist))
- {
- GFile *file = ianjuta_file_get_file (IANJUTA_FILE (assist->priv->iassist), NULL);
- if (file != NULL)
- {
- symbol =
- ianjuta_symbol_query_search_file (assist->priv->sync_query_file,
- context, file, NULL);
- g_object_unref (file);
- }
- }
- if (!symbol)
- {
- symbol =
- ianjuta_symbol_query_search (assist->priv->sync_query_project, context, NULL);
- }
- if (!symbol)
- {
- symbol =
- ianjuta_symbol_query_search (assist->priv->sync_query_system, context, NULL);
- }
- const gchar* signature =
- ianjuta_symbol_get_string (IANJUTA_SYMBOL(symbol),
- IANJUTA_SYMBOL_FIELD_SIGNATURE, NULL);
- if (!g_strcmp0 (signature, "(void)") || !g_strcmp0 (signature, "()"))
- {
- pos = ianjuta_editor_get_position (te, NULL);
- ianjuta_iterable_next (pos, NULL);
- ianjuta_editor_goto_position (te, pos, NULL);
- }
- g_object_unref (symbol);
- g_object_unref (pos);
- g_free (context);
- }
-
- ianjuta_document_end_undo_action (IANJUTA_DOCUMENT (te), NULL);
-
- /* Show calltip if we completed function */
- if (add_brace_after_func)
- {
- /* Check for calltip */
- if (assist->priv->itip &&
- g_settings_get_boolean (assist->priv->settings,
- PREF_CALLTIP_ENABLE))
- assist->priv->calltip_active = cpp_java_assist_calltip (assist);
-
+ start_iter = parser_cxx_assist_create_autocompletion_cache (assist,
+ cursor);
+ if (start_iter)
+ assist->priv->autocompletion = TRUE;
}
- g_string_free (assistance, TRUE);
-}
-
-/**
- * cpp_java_assist_get_start_iter:
- * @self: IAnjutaProvider object
- * @e: Error population
- *
- * Returns: the iter where the autocompletion starts
- */
-static IAnjutaIterable*
-cpp_java_assist_get_start_iter (IAnjutaProvider* provider, GError** e)
-{
- CppJavaAssist* assist = CPP_JAVA_ASSIST (provider);
- return assist->priv->start_iter;
-}
-
-/**
- * cpp_java_assist_get_name:
- * @self: IAnjutaProvider object
- * @e: Error population
- *
- * Returns: the provider name
- */
-static const gchar*
-cpp_java_assist_get_name (IAnjutaProvider* provider, GError** e)
-{
- return _("C/C++");
+
+ return start_iter;
}
/**
- * cpp_java_assist_install:
- * @self: IAnjutaProvider object
+ * 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
-cpp_java_assist_install (CppJavaAssist *assist, IAnjutaEditor *ieditor)
+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 (cpp_java_assist_cancelled), assist);
+ 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);
+ }
}
}
/**
- * cpp_java_assist_uninstall:
- * @self: IAnjutaProvider object
+ * parser_cxx_assist_uninstall:
+ * @self: ParserCxxAssist object
*
* Returns: Unregisters provider
*/
static void
-cpp_java_assist_uninstall (CppJavaAssist *assist)
+parser_cxx_assist_uninstall (ParserCxxAssist *assist)
{
g_return_if_fail (assist->priv->iassist != NULL);
g_signal_handlers_disconnect_by_func (assist->priv->iassist,
- cpp_java_assist_cancelled, assist);
+ parser_cxx_assist_cancelled, assist);
ianjuta_editor_assist_remove (assist->priv->iassist, IANJUTA_PROVIDER(assist), NULL);
assist->priv->iassist = NULL;
}
static void
-cpp_java_assist_init (CppJavaAssist *assist)
+parser_cxx_assist_init (ParserCxxAssist *assist)
{
- assist->priv = g_new0 (CppJavaAssistPriv, 1);
+ assist->priv = g_new0 (ParserCxxAssistPriv, 1);
}
static void
-cpp_java_assist_finalize (GObject *object)
+parser_cxx_assist_finalize (GObject *object)
{
- CppJavaAssist *assist = CPP_JAVA_ASSIST (object);
- CppJavaAssistPriv* priv = assist->priv;
+ ParserCxxAssist *assist = PARSER_CXX_ASSIST (object);
+ ParserCxxAssistPriv* priv = assist->priv;
- cpp_java_assist_uninstall (assist);
- cpp_java_assist_clear_completion_cache (assist);
- cpp_java_assist_clear_calltip_context (assist);
+ parser_cxx_assist_uninstall (assist);
+ parser_cxx_assist_clear_completion_cache (assist);
+ parser_cxx_assist_clear_calltip_context (assist);
if (priv->calltip_query_file)
@@ -1439,7 +1007,7 @@ cpp_java_assist_finalize (GObject *object)
if (priv->query_members)
g_object_unref (priv->query_members);
- priv->query_members = NULL;
+ priv->query_members = NULL;
if (priv->sync_query_file)
g_object_unref (priv->sync_query_file);
@@ -1456,23 +1024,23 @@ cpp_java_assist_finalize (GObject *object)
engine_parser_deinit ();
g_free (assist->priv);
- G_OBJECT_CLASS (cpp_java_assist_parent_class)->finalize (object);
+ G_OBJECT_CLASS (parser_cxx_assist_parent_class)->finalize (object);
}
static void
-cpp_java_assist_class_init (CppJavaAssistClass *klass)
+parser_cxx_assist_class_init (ParserCxxAssistClass *klass)
{
GObjectClass* object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = cpp_java_assist_finalize;
+ object_class->finalize = parser_cxx_assist_finalize;
}
-CppJavaAssist *
-cpp_java_assist_new (IAnjutaEditor *ieditor,
- IAnjutaSymbolManager *isymbol_manager,
- GSettings* settings)
+ParserCxxAssist *
+parser_cxx_assist_new (IAnjutaEditor *ieditor,
+ IAnjutaSymbolManager *isymbol_manager,
+ GSettings* settings)
{
- CppJavaAssist *assist;
+ ParserCxxAssist *assist;
static IAnjutaSymbolField calltip_fields[] = {
IANJUTA_SYMBOL_FIELD_ID,
IANJUTA_SYMBOL_FIELD_NAME,
@@ -1484,7 +1052,8 @@ cpp_java_assist_new (IAnjutaEditor *ieditor,
IANJUTA_SYMBOL_FIELD_NAME,
IANJUTA_SYMBOL_FIELD_KIND,
IANJUTA_SYMBOL_FIELD_TYPE,
- IANJUTA_SYMBOL_FIELD_ACCESS
+ IANJUTA_SYMBOL_FIELD_ACCESS,
+ IANJUTA_SYMBOL_FIELD_SIGNATURE
};
if (!IANJUTA_IS_EDITOR_ASSIST (ieditor) && !IANJUTA_IS_EDITOR_TIP (ieditor))
@@ -1492,9 +1061,9 @@ cpp_java_assist_new (IAnjutaEditor *ieditor,
/* No assistance is available with the current editor */
return NULL;
}
- assist = g_object_new (TYPE_CPP_JAVA_ASSIST, NULL);
+ assist = g_object_new (TYPE_PARSER_CXX_ASSIST, NULL);
assist->priv->settings = settings;
-
+
/* Create call tip queries */
/* Calltip in file */
assist->priv->calltip_query_file =
@@ -1512,7 +1081,8 @@ cpp_java_assist_new (IAnjutaEditor *ieditor,
IANJUTA_SYMBOL_TYPE_MACRO_WITH_ARG,
TRUE, NULL);
ianjuta_symbol_query_set_file_scope (assist->priv->calltip_query_file,
- IANJUTA_SYMBOL_QUERY_SEARCH_FS_PRIVATE, NULL);
+ IANJUTA_SYMBOL_QUERY_SEARCH_FS_PRIVATE,
+ NULL);
ianjuta_symbol_query_set_mode (assist->priv->calltip_query_file,
IANJUTA_SYMBOL_QUERY_MODE_ASYNC, NULL);
g_signal_connect (assist->priv->calltip_query_file, "async-result",
@@ -1532,7 +1102,8 @@ cpp_java_assist_new (IAnjutaEditor *ieditor,
IANJUTA_SYMBOL_TYPE_MACRO_WITH_ARG,
TRUE, NULL);
ianjuta_symbol_query_set_file_scope (assist->priv->calltip_query_project,
- IANJUTA_SYMBOL_QUERY_SEARCH_FS_PUBLIC, NULL);
+ IANJUTA_SYMBOL_QUERY_SEARCH_FS_PUBLIC,
+ NULL);
ianjuta_symbol_query_set_mode (assist->priv->calltip_query_project,
IANJUTA_SYMBOL_QUERY_MODE_ASYNC, NULL);
g_signal_connect (assist->priv->calltip_query_project, "async-result",
@@ -1552,7 +1123,8 @@ cpp_java_assist_new (IAnjutaEditor *ieditor,
IANJUTA_SYMBOL_TYPE_MACRO_WITH_ARG,
TRUE, NULL);
ianjuta_symbol_query_set_file_scope (assist->priv->calltip_query_system,
- IANJUTA_SYMBOL_QUERY_SEARCH_FS_PUBLIC, NULL);
+ IANJUTA_SYMBOL_QUERY_SEARCH_FS_PUBLIC,
+ NULL);
ianjuta_symbol_query_set_mode (assist->priv->calltip_query_system,
IANJUTA_SYMBOL_QUERY_MODE_ASYNC, NULL);
g_signal_connect (assist->priv->calltip_query_system, "async-result",
@@ -1571,7 +1143,8 @@ cpp_java_assist_new (IAnjutaEditor *ieditor,
G_N_ELEMENTS (ac_fields),
ac_fields, NULL);
ianjuta_symbol_query_set_file_scope (assist->priv->ac_query_file,
- IANJUTA_SYMBOL_QUERY_SEARCH_FS_PRIVATE, NULL);
+ IANJUTA_SYMBOL_QUERY_SEARCH_FS_PRIVATE,
+ NULL);
ianjuta_symbol_query_set_mode (assist->priv->ac_query_file,
IANJUTA_SYMBOL_QUERY_MODE_ASYNC, NULL);
g_signal_connect (assist->priv->ac_query_file, "async-result",
@@ -1588,7 +1161,8 @@ cpp_java_assist_new (IAnjutaEditor *ieditor,
G_N_ELEMENTS (ac_fields),
ac_fields, NULL);
ianjuta_symbol_query_set_file_scope (assist->priv->ac_query_project,
- IANJUTA_SYMBOL_QUERY_SEARCH_FS_PUBLIC, NULL);
+ IANJUTA_SYMBOL_QUERY_SEARCH_FS_PUBLIC,
+ NULL);
ianjuta_symbol_query_set_mode (assist->priv->ac_query_project,
IANJUTA_SYMBOL_QUERY_MODE_ASYNC, NULL);
g_signal_connect (assist->priv->ac_query_project, "async-result",
@@ -1605,7 +1179,8 @@ cpp_java_assist_new (IAnjutaEditor *ieditor,
G_N_ELEMENTS (ac_fields),
ac_fields, NULL);
ianjuta_symbol_query_set_file_scope (assist->priv->ac_query_system,
- IANJUTA_SYMBOL_QUERY_SEARCH_FS_PUBLIC, NULL);
+ IANJUTA_SYMBOL_QUERY_SEARCH_FS_PUBLIC,
+ NULL);
ianjuta_symbol_query_set_mode (assist->priv->ac_query_system,
IANJUTA_SYMBOL_QUERY_MODE_ASYNC, NULL);
g_signal_connect (assist->priv->ac_query_system, "async-result",
@@ -1638,7 +1213,8 @@ cpp_java_assist_new (IAnjutaEditor *ieditor,
IANJUTA_SYMBOL_TYPE_MACRO_WITH_ARG,
TRUE, NULL);
ianjuta_symbol_query_set_file_scope (assist->priv->sync_query_file,
- IANJUTA_SYMBOL_QUERY_SEARCH_FS_PRIVATE, NULL);
+ IANJUTA_SYMBOL_QUERY_SEARCH_FS_PRIVATE,
+ NULL);
/* Sync query in project */
assist->priv->sync_query_project =
ianjuta_symbol_manager_create_query (isymbol_manager,
@@ -1654,7 +1230,8 @@ cpp_java_assist_new (IAnjutaEditor *ieditor,
IANJUTA_SYMBOL_TYPE_MACRO_WITH_ARG,
TRUE, NULL);
ianjuta_symbol_query_set_file_scope (assist->priv->sync_query_project,
- IANJUTA_SYMBOL_QUERY_SEARCH_FS_PUBLIC, NULL);
+ IANJUTA_SYMBOL_QUERY_SEARCH_FS_PUBLIC,
+ NULL);
/* Sync query in system */
assist->priv->sync_query_system =
ianjuta_symbol_manager_create_query (isymbol_manager,
@@ -1670,20 +1247,67 @@ cpp_java_assist_new (IAnjutaEditor *ieditor,
IANJUTA_SYMBOL_TYPE_MACRO_WITH_ARG,
TRUE, NULL);
ianjuta_symbol_query_set_file_scope (assist->priv->sync_query_system,
- IANJUTA_SYMBOL_QUERY_SEARCH_FS_PUBLIC, NULL);
+ IANJUTA_SYMBOL_QUERY_SEARCH_FS_PUBLIC,
+ NULL);
/* Install support */
- cpp_java_assist_install (assist, ieditor);
-
- engine_parser_init (isymbol_manager);
+ parser_cxx_assist_install (assist, ieditor);
+ assist->priv->lang_prov = g_object_new (ANJUTA_TYPE_LANGUAGE_PROVIDER, NULL);
+ anjuta_language_provider_install (assist->priv->lang_prov, ieditor, settings);
+ engine_parser_init (isymbol_manager);
return assist;
}
-static void cpp_java_assist_iface_init(IAnjutaProviderIface* iface)
+static void
+parser_cxx_assist_activate (IAnjutaProvider* self,
+ IAnjutaIterable* iter,
+ gpointer data,
+ GError** e)
+{
+ ParserCxxAssist* assist = PARSER_CXX_ASSIST (self);
+ anjuta_language_provider_activate (assist->priv->lang_prov, self, iter,
+ data);
+}
+
+static void
+parser_cxx_assist_populate (IAnjutaProvider* self,
+ IAnjutaIterable* cursor,
+ GError** e)
+{
+ ParserCxxAssist* assist = PARSER_CXX_ASSIST (self);
+ anjuta_language_provider_populate (assist->priv->lang_prov, self, cursor);
+}
+
+static const gchar*
+parser_cxx_assist_get_name (IAnjutaProvider* self,
+ GError** e)
+{
+ return _("C/C++");
+}
+
+static IAnjutaIterable*
+parser_cxx_assist_get_start_iter (IAnjutaProvider* self,
+ GError** e)
+{
+ ParserCxxAssist* assist = PARSER_CXX_ASSIST (self);
+ return anjuta_language_provider_get_start_iter (assist->priv->lang_prov);
+}
+
+static void
+iprovider_iface_init (IAnjutaProviderIface* iface)
+{
+ iface->activate = parser_cxx_assist_activate;
+ iface->populate = parser_cxx_assist_populate;
+ iface->get_name = parser_cxx_assist_get_name;
+ iface->get_start_iter = parser_cxx_assist_get_start_iter;
+}
+
+static void
+ilanguage_provider_iface_init (IAnjutaLanguageProviderIface* iface)
{
- iface->populate = cpp_java_assist_populate;
- iface->get_start_iter = cpp_java_assist_get_start_iter;
- iface->activate = cpp_java_assist_activate;
- iface->get_name = cpp_java_assist_get_name;
+ iface->get_calltip_cache = parser_cxx_assist_get_calltip_cache;
+ iface->get_calltip_context = parser_cxx_assist_get_calltip_context;
+ iface->new_calltip = parser_cxx_assist_new_calltip;
+ iface->populate_language = parser_cxx_assist_populate_language;
}
diff --git a/plugins/parser-cxx/parser-cxx-assist.h b/plugins/parser-cxx/parser-cxx-assist.h
new file mode 100644
index 0000000..45da8a9
--- /dev/null
+++ b/plugins/parser-cxx/parser-cxx-assist.h
@@ -0,0 +1,73 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * parser-cxx-anjuta
+ * Copyright (C) 2007 Naba Kumar <naba gnome org>
+ *
+ * anjuta is free software.
+ *
+ * You may redistribute it and/or modify it under the terms of the
+ * GNU General Public License, as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * anjuta 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 anjuta. If not, write to:
+ * The Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _PARSER_CXX_ASSIST_H_
+#define _PARSER_CXX_ASSIST_H_
+
+#include <glib-object.h>
+#include <libanjuta/anjuta-preferences.h>
+#include <libanjuta/interfaces/ianjuta-editor-assist.h>
+#include <libanjuta/interfaces/ianjuta-symbol-manager.h>
+
+G_BEGIN_DECLS
+
+#define TYPE_PARSER_CXX_ASSIST (parser_cxx_assist_get_type ())
+#define PARSER_CXX_ASSIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PARSER_CXX_ASSIST, ParserCxxAssist))
+#define PARSER_CXX_ASSIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PARSER_CXX_ASSIST, ParserCxxAssistClass))
+#define IS_PARSER_CXX_ASSIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PARSER_CXX_ASSIST))
+#define IS_PARSER_CXX_ASSIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PARSER_CXX_ASSIST))
+#define PARSER_CXX_ASSIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PARSER_CXX_ASSIST, ParserCxxAssistClass))
+
+typedef struct _ParserCxxAssistClass ParserCxxAssistClass;
+typedef struct _ParserCxxAssist ParserCxxAssist;
+typedef struct _ParserCxxAssistContext ParserCxxAssistContext;
+typedef struct _ParserCxxAssistPriv ParserCxxAssistPriv;
+
+struct _ParserCxxAssistContext {
+ GCompletion* completion;
+ GList* tips;
+ gint position;
+};
+
+struct _ParserCxxAssistClass
+{
+ GObjectClass parent_class;
+};
+
+struct _ParserCxxAssist
+{
+ GObject parent_instance;
+ ParserCxxAssistPriv *priv;
+};
+
+GType parser_cxx_assist_get_type (void) G_GNUC_CONST;
+
+ParserCxxAssist*
+parser_cxx_assist_new (IAnjutaEditor *ieditor,
+ IAnjutaSymbolManager *isymbol_manager,
+ GSettings* settings);
+
+G_END_DECLS
+
+#endif /* _PARSER_CXX_ASSIST_H_ */
diff --git a/plugins/parser-cxx/plugin.c b/plugins/parser-cxx/plugin.c
new file mode 100644
index 0000000..75d46f7
--- /dev/null
+++ b/plugins/parser-cxx/plugin.c
@@ -0,0 +1,297 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ plugin.c
+ Copyright (C) 2000 Naba Kumar
+
+ 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 2 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, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#include <config.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <libanjuta/anjuta-shell.h>
+#include <libanjuta/anjuta-debug.h>
+#include <libanjuta/interfaces/ianjuta-editor-assist.h>
+#include <libanjuta/interfaces/ianjuta-document.h>
+#include <libanjuta/interfaces/ianjuta-document-manager.h>
+#include <libanjuta/interfaces/ianjuta-preferences.h>
+#include <libanjuta/interfaces/ianjuta-language.h>
+
+#include "plugin.h"
+
+#define PREFS_BUILDER PACKAGE_DATA_DIR"/glade/anjuta-parser-cxx.ui"
+#define ICON_FILE "anjuta-parser-cxx-plugin.png"
+
+/* Preferences keys */
+#define ANJUTA_PREF_SCHEMA_PREFIX "org.gnome.anjuta."
+#define PREF_SCHEMA "org.gnome.anjuta.plugins.parser-cxx"
+
+static gpointer parent_class;
+
+/* Enable/Disable language-support */
+static void
+install_support (ParserCxxPlugin *parser_plugin)
+{
+ IAnjutaLanguage* lang_manager =
+ anjuta_shell_get_interface (ANJUTA_PLUGIN (parser_plugin)->shell,
+ IAnjutaLanguage, NULL);
+
+ if (!lang_manager)
+ return;
+
+ if (parser_plugin->support_installed)
+ return;
+
+ parser_plugin->current_language =
+ ianjuta_language_get_name_from_editor (lang_manager,
+ IANJUTA_EDITOR_LANGUAGE (parser_plugin->current_editor), NULL);
+
+ DEBUG_PRINT("Parser support installed for: %s",
+ parser_plugin->current_language);
+
+ if (parser_plugin->current_language &&
+ (g_str_equal (parser_plugin->current_language, "C" )
+ || g_str_equal (parser_plugin->current_language, "C++")))
+ {
+ ParserCxxAssist *assist;
+
+ g_assert (parser_plugin->assist == NULL);
+
+ assist = parser_cxx_assist_new (IANJUTA_EDITOR (parser_plugin->current_editor),
+ anjuta_shell_get_interface (
+ anjuta_plugin_get_shell (ANJUTA_PLUGIN (parser_plugin)),
+ IAnjutaSymbolManager, NULL),
+ parser_plugin->settings);
+
+ if (!assist)
+ return;
+
+ parser_plugin->assist = assist;
+ }
+ else
+ return;
+
+ parser_plugin->support_installed = TRUE;
+}
+
+static void
+uninstall_support (ParserCxxPlugin *parser_plugin)
+{
+ if (!parser_plugin->support_installed)
+ return;
+
+ if (parser_plugin->assist)
+ {
+ g_object_unref (parser_plugin->assist);
+ parser_plugin->assist = NULL;
+ }
+
+ parser_plugin->support_installed = FALSE;
+}
+
+static void
+on_editor_language_changed (IAnjutaEditor *editor,
+ const gchar *new_language,
+ ParserCxxPlugin *plugin)
+{
+ uninstall_support (plugin);
+ install_support (plugin);
+}
+
+static void
+on_value_added_current_editor (AnjutaPlugin *plugin, const gchar *name,
+ const GValue *value, gpointer data)
+{
+ ParserCxxPlugin *parser_plugin;
+ IAnjutaDocument* doc = IANJUTA_DOCUMENT(g_value_get_object (value));
+ parser_plugin = ANJUTA_PLUGIN_PARSER_CXX (plugin);
+
+ if (IANJUTA_IS_EDITOR(doc))
+ parser_plugin->current_editor = G_OBJECT(doc);
+ else
+ {
+ parser_plugin->current_editor = NULL;
+ return;
+ }
+
+ if (IANJUTA_IS_EDITOR(parser_plugin->current_editor))
+ install_support (parser_plugin);
+
+ g_signal_connect (parser_plugin->current_editor, "language-changed",
+ G_CALLBACK (on_editor_language_changed),
+ plugin);
+}
+
+static void
+on_value_removed_current_editor (AnjutaPlugin *plugin, const gchar *name,
+ gpointer data)
+{
+ ParserCxxPlugin *parser_plugin;
+ parser_plugin = ANJUTA_PLUGIN_PARSER_CXX (plugin);
+
+ if (parser_plugin->current_editor)
+ g_signal_handlers_disconnect_by_func (parser_plugin->current_editor,
+ G_CALLBACK (on_editor_language_changed),
+ plugin);
+
+ if (IANJUTA_IS_EDITOR(parser_plugin->current_editor))
+ uninstall_support (parser_plugin);
+
+ parser_plugin->current_editor = NULL;
+}
+
+static gboolean
+parser_cxx_plugin_activate_plugin (AnjutaPlugin *plugin)
+{
+ ParserCxxPlugin *parser_plugin;
+
+ parser_plugin = ANJUTA_PLUGIN_PARSER_CXX (plugin);
+
+ DEBUG_PRINT ("%s", "AnjutaParserCxxPlugin: Activating plugin ...");
+
+ parser_plugin->editor_watch_id =
+ anjuta_plugin_add_watch (plugin,
+ IANJUTA_DOCUMENT_MANAGER_CURRENT_DOCUMENT,
+ on_value_added_current_editor,
+ on_value_removed_current_editor,
+ plugin);
+
+ return TRUE;
+}
+
+static gboolean
+parser_cxx_plugin_deactivate_plugin (AnjutaPlugin *plugin)
+{
+ ParserCxxPlugin *parser_plugin;
+ parser_plugin = ANJUTA_PLUGIN_PARSER_CXX (plugin);
+
+ anjuta_plugin_remove_watch (plugin,
+ parser_plugin->editor_watch_id,
+ TRUE);
+
+ DEBUG_PRINT ("%s", "AnjutaParserCxxPlugin: Deactivated plugin.");
+ return TRUE;
+}
+
+static void
+parser_cxx_plugin_finalize (GObject *obj)
+{
+ /* Finalization codes here */
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
+}
+
+static void
+parser_cxx_plugin_dispose (GObject *obj)
+{
+ ParserCxxPlugin* plugin = ANJUTA_PLUGIN_PARSER_CXX (obj);
+
+ /* Disposition codes */
+ g_object_unref (plugin->settings);
+ g_object_unref (plugin->editor_settings);
+
+ G_OBJECT_CLASS (parent_class)->dispose (obj);
+}
+
+static void
+parser_cxx_plugin_instance_init (GObject *obj)
+{
+ ParserCxxPlugin *plugin = ANJUTA_PLUGIN_PARSER_CXX (obj);
+ plugin->current_editor = NULL;
+ plugin->current_language = NULL;
+ plugin->editor_watch_id = 0;
+ plugin->assist = NULL;
+ plugin->settings = g_settings_new (PREF_SCHEMA);
+ plugin->editor_settings = g_settings_new (ANJUTA_PREF_SCHEMA_PREFIX IANJUTA_EDITOR_PREF_SCHEMA);
+}
+
+static void
+parser_cxx_plugin_class_init (GObjectClass *klass)
+{
+ AnjutaPluginClass *plugin_class = ANJUTA_PLUGIN_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ plugin_class->activate = parser_cxx_plugin_activate_plugin;
+ plugin_class->deactivate = parser_cxx_plugin_deactivate_plugin;
+ klass->finalize = parser_cxx_plugin_finalize;
+ klass->dispose = parser_cxx_plugin_dispose;
+}
+
+#define PREF_WIDGET_SPACE "preferences:completion-space-after-func"
+#define PREF_WIDGET_BRACE "preferences:completion-brace-after-func"
+#define PREF_WIDGET_CLOSEBRACE "preferences:completion-closebrace-after-func"
+#define PREF_WIDGET_AUTO "preferences:completion-enable"
+
+static void
+on_autocompletion_toggled (GtkToggleButton* button,
+ ParserCxxPlugin* plugin)
+{
+ GtkWidget* widget;
+ gboolean sensitive = gtk_toggle_button_get_active (button);
+
+ widget = GTK_WIDGET (gtk_builder_get_object (plugin->bxml, PREF_WIDGET_SPACE));
+ gtk_widget_set_sensitive (widget, sensitive);
+ widget = GTK_WIDGET (gtk_builder_get_object (plugin->bxml, PREF_WIDGET_BRACE));
+ gtk_widget_set_sensitive (widget, sensitive);
+ widget = GTK_WIDGET (gtk_builder_get_object (plugin->bxml, PREF_WIDGET_CLOSEBRACE));
+ gtk_widget_set_sensitive (widget, sensitive);
+}
+
+static void
+ipreferences_merge (IAnjutaPreferences* ipref, AnjutaPreferences* prefs,
+ GError** e)
+{
+ GError* error = NULL;
+ ParserCxxPlugin* plugin = ANJUTA_PLUGIN_PARSER_CXX (ipref);
+ plugin->bxml = gtk_builder_new ();
+ GtkWidget* toggle;
+
+ /* Add preferences */
+ if (!gtk_builder_add_from_file (plugin->bxml, PREFS_BUILDER, &error))
+ {
+ g_warning ("Couldn't load builder file: %s", error->message);
+ g_error_free (error);
+ }
+ anjuta_preferences_add_from_builder (prefs,
+ plugin->bxml, plugin->settings,
+ "preferences", _("Auto-complete"),
+ ICON_FILE);
+ toggle = GTK_WIDGET (gtk_builder_get_object (plugin->bxml, PREF_WIDGET_AUTO));
+ g_signal_connect (toggle, "toggled", G_CALLBACK (on_autocompletion_toggled),
+ plugin);
+ on_autocompletion_toggled (GTK_TOGGLE_BUTTON (toggle), plugin);
+}
+
+static void
+ipreferences_unmerge (IAnjutaPreferences* ipref, AnjutaPreferences* prefs,
+ GError** e)
+{
+ ParserCxxPlugin* plugin = ANJUTA_PLUGIN_PARSER_CXX (ipref);
+ anjuta_preferences_remove_page(prefs, _("Auto-complete"));
+ g_object_unref (plugin->bxml);
+}
+
+static void
+ipreferences_iface_init (IAnjutaPreferencesIface* iface)
+{
+ iface->merge = ipreferences_merge;
+ iface->unmerge = ipreferences_unmerge;
+}
+
+ANJUTA_PLUGIN_BEGIN (ParserCxxPlugin, parser_cxx_plugin);
+ANJUTA_PLUGIN_ADD_INTERFACE (ipreferences, IANJUTA_TYPE_PREFERENCES);
+ANJUTA_PLUGIN_END;
+
+ANJUTA_SIMPLE_PLUGIN (ParserCxxPlugin, parser_cxx_plugin);
diff --git a/plugins/parser-cxx/plugin.h b/plugins/parser-cxx/plugin.h
new file mode 100644
index 0000000..0e08ba3
--- /dev/null
+++ b/plugins/parser-cxx/plugin.h
@@ -0,0 +1,59 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ plugin.h
+ Copyright (C) 2000 Naba Kumar
+
+ 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 2 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, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#ifndef _PLUGIN_H_
+#define _PLUGIN_H_
+
+#include <libanjuta/anjuta-plugin.h>
+#include "parser-cxx-assist.h"
+
+extern GType parser_cxx_plugin_get_type (GTypeModule *module);
+#define ANJUTA_TYPE_PLUGIN_PARSER_CXX (parser_cxx_plugin_get_type (NULL))
+#define ANJUTA_PLUGIN_PARSER_CXX(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ANJUTA_TYPE_PLUGIN_PARSER_CXX, ParserCxxPlugin))
+#define ANJUTA_PLUGIN_PARSER_CXX_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), ANJUTA_TYPE_PLUGIN_PARSER_CXX, ParserCxxPluginClass))
+#define ANJUTA_IS_PLUGIN_PARSER_CXX(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ANJUTA_TYPE_PLUGIN_PARSER_CXX))
+#define ANJUTA_IS_PLUGIN_PARSER_CXX_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ANJUTA_TYPE_PLUGIN_PARSER_CXX))
+#define ANJUTA_PLUGIN_PARSER_CXX_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ANJUTA_TYPE_PLUGIN_PARSER_CXX, ParserCxxPluginClass))
+
+typedef struct _ParserCxxPlugin ParserCxxPlugin;
+typedef struct _ParserCxxPluginClass ParserCxxPluginClass;
+
+struct _ParserCxxPlugin {
+ AnjutaPlugin parent;
+
+ GSettings* settings;
+ GSettings* editor_settings;
+ gint editor_watch_id;
+ gboolean support_installed;
+ GObject *current_editor;
+ const gchar *current_language;
+
+ /* Assist */
+ ParserCxxAssist *assist;
+
+ /* Preferences */
+ GtkBuilder* bxml;
+};
+
+struct _ParserCxxPluginClass {
+ AnjutaPluginClass parent_class;
+};
+
+#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]