[anjuta] Update language-support-js to new IAnjutaAssist.



commit d60894ec181994cec28aa064b9a0871d3725fce9
Author: Maxim Ermilov <zaspire rambler ru>
Date:   Thu Dec 3 21:29:00 2009 +0300

    Update language-support-js to new IAnjutaAssist.

 plugins/language-support-js/js-context.c           |    2 +-
 plugins/language-support-js/js-context.h           |    2 +-
 plugins/language-support-js/js-node.c              |    2 +-
 plugins/language-support-js/js-node.h              |    2 +-
 plugins/language-support-js/jsparse.c              |    2 +-
 plugins/language-support-js/jsparse.h              |    2 +-
 plugins/language-support-js/jstypes.h              |    2 +-
 plugins/language-support-js/lex.l                  |    1 +
 plugins/language-support-js/lex.yy.c               |    2 +-
 plugins/language-support-js/lex.yy.h               |    2 +-
 plugins/language-support-js/plugin.c               |  435 +++++++-------------
 plugins/language-support-js/plugin.h               |    9 +-
 plugins/language-support-js/util.c                 |    1 -
 plugins/language-support-js/util.h                 |    5 +-
 plugins/language-support-js/y.tab.c                |    2 +-
 plugins/language-support-js/y.tab.h                |    2 +-
 plugins/symbol-db/anjuta-tags/Makefile.am          |   22 +-
 .../anjuta-tags/{parser => js_parser}/Grammar.y    |    0
 .../anjuta-tags/{parser => js_parser}/js-context.c |    0
 .../anjuta-tags/{parser => js_parser}/js-context.h |    0
 .../anjuta-tags/{parser => js_parser}/js-node.c    |    0
 .../anjuta-tags/{parser => js_parser}/js-node.h    |    0
 .../anjuta-tags/{parser => js_parser}/jsparse.c    |    0
 .../anjuta-tags/{parser => js_parser}/jsparse.h    |    0
 .../anjuta-tags/{parser => js_parser}/jstypes.h    |    0
 .../anjuta-tags/{parser => js_parser}/lex.l        |    0
 .../anjuta-tags/{parser => js_parser}/lex.yy.c     |    0
 .../anjuta-tags/{parser => js_parser}/lex.yy.h     |    0
 .../anjuta-tags/{parser => js_parser}/y.tab.c      |    0
 .../anjuta-tags/{parser => js_parser}/y.tab.h      |    0
 plugins/symbol-db/anjuta-tags/jscript.c            |    6 +-
 31 files changed, 185 insertions(+), 316 deletions(-)
---
diff --git a/plugins/language-support-js/js-context.c b/plugins/language-support-js/js-context.c
index 55a2bcd..1ffdca5 120000
--- a/plugins/language-support-js/js-context.c
+++ b/plugins/language-support-js/js-context.c
@@ -1 +1 @@
-../symbol-db/anjuta-tags/parser/js-context.c
\ No newline at end of file
+../symbol-db/anjuta-tags/js_parser/js-context.c
\ No newline at end of file
diff --git a/plugins/language-support-js/js-context.h b/plugins/language-support-js/js-context.h
index 6fe3e6c..b38b133 120000
--- a/plugins/language-support-js/js-context.h
+++ b/plugins/language-support-js/js-context.h
@@ -1 +1 @@
-../symbol-db/anjuta-tags/parser/js-context.h
\ No newline at end of file
+../symbol-db/anjuta-tags/js_parser/js-context.h
\ No newline at end of file
diff --git a/plugins/language-support-js/js-node.c b/plugins/language-support-js/js-node.c
index 3727029..370f30c 120000
--- a/plugins/language-support-js/js-node.c
+++ b/plugins/language-support-js/js-node.c
@@ -1 +1 @@
-../symbol-db/anjuta-tags/parser/js-node.c
\ No newline at end of file
+../symbol-db/anjuta-tags/js_parser/js-node.c
\ No newline at end of file
diff --git a/plugins/language-support-js/js-node.h b/plugins/language-support-js/js-node.h
index feabe2e..b30b391 120000
--- a/plugins/language-support-js/js-node.h
+++ b/plugins/language-support-js/js-node.h
@@ -1 +1 @@
-../symbol-db/anjuta-tags/parser/js-node.h
\ No newline at end of file
+../symbol-db/anjuta-tags/js_parser/js-node.h
\ No newline at end of file
diff --git a/plugins/language-support-js/jsparse.c b/plugins/language-support-js/jsparse.c
index 3b55efe..1803c94 120000
--- a/plugins/language-support-js/jsparse.c
+++ b/plugins/language-support-js/jsparse.c
@@ -1 +1 @@
-../symbol-db/anjuta-tags/parser/jsparse.c
\ No newline at end of file
+../symbol-db/anjuta-tags/js_parser/jsparse.c
\ No newline at end of file
diff --git a/plugins/language-support-js/jsparse.h b/plugins/language-support-js/jsparse.h
index cddae7a..37f0ae6 120000
--- a/plugins/language-support-js/jsparse.h
+++ b/plugins/language-support-js/jsparse.h
@@ -1 +1 @@
-../symbol-db/anjuta-tags/parser/jsparse.h
\ No newline at end of file
+../symbol-db/anjuta-tags/js_parser/jsparse.h
\ No newline at end of file
diff --git a/plugins/language-support-js/jstypes.h b/plugins/language-support-js/jstypes.h
index 7e94d11..2a888dd 120000
--- a/plugins/language-support-js/jstypes.h
+++ b/plugins/language-support-js/jstypes.h
@@ -1 +1 @@
-../symbol-db/anjuta-tags/parser/jstypes.h
\ No newline at end of file
+../symbol-db/anjuta-tags/js_parser/jstypes.h
\ No newline at end of file
diff --git a/plugins/language-support-js/lex.l b/plugins/language-support-js/lex.l
new file mode 120000
index 0000000..837149a
--- /dev/null
+++ b/plugins/language-support-js/lex.l
@@ -0,0 +1 @@
+../symbol-db/anjuta-tags/js_parser/lex.l
\ No newline at end of file
diff --git a/plugins/language-support-js/lex.yy.c b/plugins/language-support-js/lex.yy.c
index 3c6c8b3..27e7c2f 120000
--- a/plugins/language-support-js/lex.yy.c
+++ b/plugins/language-support-js/lex.yy.c
@@ -1 +1 @@
-../symbol-db/anjuta-tags/parser/lex.yy.c
\ No newline at end of file
+../symbol-db/anjuta-tags/js_parser/lex.yy.c
\ No newline at end of file
diff --git a/plugins/language-support-js/lex.yy.h b/plugins/language-support-js/lex.yy.h
index 6944fe2..aa9432d 120000
--- a/plugins/language-support-js/lex.yy.h
+++ b/plugins/language-support-js/lex.yy.h
@@ -1 +1 @@
-../symbol-db/anjuta-tags/parser/lex.yy.h
\ No newline at end of file
+../symbol-db/anjuta-tags/js_parser/lex.yy.h
\ No newline at end of file
diff --git a/plugins/language-support-js/plugin.c b/plugins/language-support-js/plugin.c
index f8dad67..7d22117 100644
--- a/plugins/language-support-js/plugin.c
+++ b/plugins/language-support-js/plugin.c
@@ -24,6 +24,7 @@
 #include <libanjuta/interfaces/ianjuta-document-manager.h>
 #include <libanjuta/interfaces/ianjuta-project-manager.h>
 #include <libanjuta/interfaces/ianjuta-editor-assist.h>
+#include <libanjuta/interfaces/ianjuta-editor-tip.h>
 #include <libanjuta/interfaces/ianjuta-language.h>
 #include <libanjuta/interfaces/ianjuta-preferences.h>
 #include <ctype.h>
@@ -49,9 +50,6 @@
 static gpointer parent_class;
 
 static void
-on_code_complete (GtkAction * action, JSLang *plugin);
-
-static void
 on_value_added_current_editor (AnjutaPlugin *plugin, const gchar *name,
 							   const GValue *value, gpointer data);
 static void
@@ -64,12 +62,6 @@ on_jsdirs_rm_button_clicked (GtkButton *button, gpointer user_data);
 G_MODULE_EXPORT void
 on_jsdirs_add_button_clicked (GtkButton *button, gpointer user_data);
 
-
-static GtkActionEntry actions[] = {
-  { "CodeComplete", GTK_STOCK_DIALOG_INFO, N_("_Code Complete..."), "<control>space",
-	NULL, G_CALLBACK (on_code_complete)},
-};
-
 static gboolean
 js_support_plugin_activate (AnjutaPlugin *plugin)
 {
@@ -78,11 +70,10 @@ js_support_plugin_activate (AnjutaPlugin *plugin)
 	DEBUG_PRINT ("%s", "JSLang: Activating JSLang plugin ...");
 	js_support_plugin = (JSLang*) plugin;
 	js_support_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);
+		anjuta_plugin_add_watch (plugin, IANJUTA_DOCUMENT_MANAGER_CURRENT_DOCUMENT,
+					 on_value_added_current_editor,
+					 on_value_removed_current_editor,
+					 plugin);
 
 	return TRUE;
 }
@@ -94,9 +85,7 @@ js_support_plugin_deactivate (AnjutaPlugin *plugin)
 
 	DEBUG_PRINT ("%s", "JSLang: Dectivating JSLang plugin ...");
 	js_support_plugin = (JSLang*) plugin;
-	anjuta_plugin_remove_watch (plugin,
-								js_support_plugin->editor_watch_id,
-								TRUE);
+	anjuta_plugin_remove_watch (plugin, js_support_plugin->editor_watch_id, TRUE);
 	return TRUE;
 }
 
@@ -107,8 +96,6 @@ js_support_plugin_finalize (GObject *obj)
 
 	g_object_unref (self->symbol);
 	self->symbol = NULL;
-	g_list_free (self->complition_cache);
-	self->complition_cache = NULL;
 
 	G_OBJECT_CLASS (parent_class)->finalize (obj);
 }
@@ -122,8 +109,6 @@ js_support_plugin_dispose (GObject *obj)
 
 	g_object_unref (self->symbol);
 	self->symbol = NULL;
-	g_list_free (self->complition_cache);
-	self->complition_cache = NULL;
 
 	G_OBJECT_CLASS (parent_class)->dispose (obj);
 }
@@ -132,11 +117,9 @@ static void
 js_support_plugin_instance_init (GObject *obj)
 {
 	JSLang *plugin = (JSLang*)obj;
-	plugin->complition_cache = NULL;
-	plugin->current = NULL;
+	plugin->last = NULL;
 	plugin->prefs = NULL;
 	plugin->symbol = NULL;
-	plugin->action_group = NULL;
 }
 
 static void
@@ -153,178 +136,8 @@ js_support_plugin_class_init (GObjectClass *klass)
 }
 
 static void
-on_editor_char_inserted (IAnjutaEditor *editor,
-						 IAnjutaIterable *insert_pos,
-						 gchar ch,
-						 JSLang *plugin)
-{
-	DEBUG_PRINT ("JSLang: Insert char %c \"%s\"", ch, plugin->current);
-	if (ianjuta_editor_assist_tip_shown (IANJUTA_EDITOR_ASSIST (editor), NULL))
-	{
-		plugin->current = NULL;
-		plugin->complition_cache = NULL;
-	}
-	if (ch == ')')
-		ianjuta_editor_assist_cancel_tips (IANJUTA_EDITOR_ASSIST (editor), NULL);
-
-	if (!isalnum(ch) && ch != '.')
-	{
-		plugin->current = NULL;
-		plugin->complition_cache = NULL;
-		return;
-	}
-	gchar *str = code_completion_get_str (editor, TRUE);
-	if (!str)
-		return;
-	if (plugin->current)
-	{
-		if (strncmp (plugin->current, str, strlen (plugin->current)) != 0)
-		{
-			plugin->current = NULL;
-			plugin->complition_cache = NULL;
-			DEBUG_PRINT ("JSLang: Incorrect string");
-			return;
-		}
-		GList *tmp;
-		IAnjutaIterable *position = ianjuta_editor_get_position (IANJUTA_EDITOR (editor), NULL);
-		plugin->current = g_strdup_printf ("%s%c", plugin->current, ch);
-		DEBUG_PRINT ("JSLang: Continue completion for %s ", plugin->current);
-		tmp = filter_list (plugin->complition_cache, plugin->current);
-		if (tmp)
-			ianjuta_editor_assist_suggest (IANJUTA_EDITOR_ASSIST (editor),
-											   tmp,
-											   position,
-											   /*alignment*/1 - strlen (plugin->current),
-											   NULL);
-		else
-			ianjuta_editor_assist_hide_suggestions (IANJUTA_EDITOR_ASSIST (editor), NULL);
-		return;
-	}
-	if (!plugin->prefs)
-		plugin->prefs = anjuta_shell_get_preferences (ANJUTA_PLUGIN (plugin)->shell, NULL);
-	if (!anjuta_preferences_get_bool (plugin->prefs, AUTO_CODECOMPLETE))
-	{
-		DEBUG_PRINT ("JSLang: Auto code complete off");
-		return;
-	}
-	gint depth;
-	IAnjutaIterable *position = ianjuta_editor_get_position (IANJUTA_EDITOR (editor), NULL);
-	GList *suggestions = NULL;
-	gchar *file = file_completion (editor, &depth);
-	DEBUG_PRINT ("JSLang: Auto complete for %s (TMFILE=%s)", str, file);
-	if (ch == '.')
-	{
-		suggestions = code_completion_get_list (plugin, file, str, depth);
-		plugin->complition_cache = suggestions;
-		ianjuta_editor_assist_suggest (IANJUTA_EDITOR_ASSIST (editor),
-										   suggestions,
-										   position,
-										   /*alignment*/1,
-										   NULL);
-		plugin->current = g_strdup ("");
-		DEBUG_PRINT ("JSLang: Auto complete for '%s'", plugin->current);
-	} else
-	{
-		suggestions = code_completion_get_list (plugin, file, NULL, depth);
-		if (suggestions)
-		{
-			plugin->complition_cache = suggestions;
-			suggestions = filter_list (suggestions, str);
-			ianjuta_editor_assist_suggest (IANJUTA_EDITOR_ASSIST (editor),
-										   suggestions,
-										   position,
-										   /*alignment*/1,
-										   NULL);
-			plugin->current = g_strdup (str);
-		}
-	}
-}
-
-static void
-on_assist_chosen (IAnjutaEditorAssist* iassist, gint selection,
-					JSLang *plugin)
-{
-	DEBUG_PRINT ("%s %d", "JSLang: assist_chosen", selection);
-	IAnjutaIterable *position = ianjuta_editor_get_position (IANJUTA_EDITOR (iassist), NULL);
-	GList *tmp = g_list_nth (filter_list (plugin->complition_cache, plugin->current), selection);
-	if (tmp)
-	{
-		gchar *str = tmp->data;
-
-		g_assert (strlen (str) >= strlen (plugin->current));
-
-		if (strlen (str) > strlen (plugin->current))
-		{
-			ianjuta_editor_insert (IANJUTA_EDITOR (iassist), position, str + strlen (plugin->current), -1, NULL);
-			
-			gchar *sym = code_completion_get_str (IANJUTA_EDITOR (iassist), FALSE);
-			g_assert (sym != NULL);
-
-			if (sym && code_completion_is_symbol_func (plugin, sym))
-			{
-				position = ianjuta_editor_get_position (IANJUTA_EDITOR (iassist), NULL);
-
-				if (anjuta_preferences_get_bool (plugin->prefs, ADD_BRACE_AFTER_FUNCCALL))
-				{
-					ianjuta_editor_insert (IANJUTA_EDITOR (iassist), position, " (", -1, NULL);
-				}
-				if (anjuta_preferences_get_bool (plugin->prefs, SHOW_CALLTIPS))
-				{
-
-					GList *t = NULL;
-					gchar *args = code_completion_get_func_tooltip (plugin, sym);
-					t = g_list_append (t, args);
-					if (args)
-					{
-						ianjuta_editor_assist_show_tips (iassist, t,  position,  1, NULL);
-						g_free (args);
-					}
-				}
-			}
-			g_free (sym);
-		}
-	}
-	ianjuta_editor_assist_hide_suggestions (iassist, NULL);
-	plugin->current = NULL;
-	plugin->complition_cache = NULL;
-}
-
-static void
-on_editor_backspace (IAnjutaEditor* editor, JSLang *plugin)
-{
-	DEBUG_PRINT ("%s (%s)", "JSLang: editor backspace ", plugin->current);
-
-	ianjuta_editor_assist_cancel_tips (IANJUTA_EDITOR_ASSIST (editor), NULL);
-
-	if (!plugin->current)
-		return;
-	int size = strlen (plugin->current);
-	if (size == 0)
-	{
-		ianjuta_editor_assist_hide_suggestions (IANJUTA_EDITOR_ASSIST (editor), NULL);
-		plugin->current = NULL;
-	}
-	else
-	{
-		IAnjutaIterable *position = ianjuta_editor_get_position (IANJUTA_EDITOR (editor), NULL);
-		GList *tmp;
-		plugin->current[size - 1] = '\0';
-		tmp = filter_list (plugin->complition_cache, plugin->current);
-		if (tmp)
-			ianjuta_editor_assist_suggest (IANJUTA_EDITOR_ASSIST (editor),
-											   tmp,
-											   position,
-											   /*alignment*/1 - strlen (plugin->current),
-											   NULL);
-		else
-			ianjuta_editor_assist_hide_suggestions (IANJUTA_EDITOR_ASSIST (editor), NULL);
-	}
-}
-
-static void
 install_support (JSLang *plugin)
 {
-	AnjutaUI *ui;
 	const gchar *lang;
 	IAnjutaLanguage* lang_manager;
 
@@ -340,46 +153,18 @@ install_support (JSLang *plugin)
 													   IANJUTA_EDITOR_LANGUAGE (plugin->current_editor), NULL);
 	if (!lang || !g_str_equal (lang, "JavaScript"))
 		return;
+
 	DEBUG_PRINT ("%s", "JSLang: Install support");
 
-	g_signal_connect (plugin->current_editor,
-					  "char-added",
-					  G_CALLBACK (on_editor_char_inserted),
-					  plugin);
-	g_signal_connect (plugin->current_editor, "assist-chosen",
-					  G_CALLBACK(on_assist_chosen), plugin);
-	g_signal_connect (plugin->current_editor, "backspace",
-					  G_CALLBACK (on_editor_backspace), plugin);
-	ui = anjuta_shell_get_ui (ANJUTA_PLUGIN (plugin)->shell, NULL);
-	plugin->action_group = anjuta_ui_add_action_group_entries (ui, "ActionGroupCodeComplete",
-					_("Code Complete"),
-					actions,
-					G_N_ELEMENTS (actions),
-					GETTEXT_PACKAGE, TRUE, plugin);
-	plugin->uiid = anjuta_ui_merge (ui, UI_FILE);
+	ianjuta_editor_assist_add (IANJUTA_EDITOR_ASSIST(plugin->current_editor), IANJUTA_PROVIDER(plugin), NULL);
 }
 
 static void
 uninstall_support (JSLang *plugin)
 {
-	AnjutaUI *ui;
 	DEBUG_PRINT ("%s", "JSLang: Uninstall support");
-	if (IANJUTA_IS_EDITOR(plugin->current_editor))
-	{
-		g_signal_handlers_disconnect_by_func (plugin->current_editor,
-									G_CALLBACK (on_editor_char_inserted),
-									plugin);
-		g_signal_handlers_disconnect_by_func (plugin->current_editor,
-									G_CALLBACK (on_assist_chosen),
-									plugin);
-		g_signal_handlers_disconnect_by_func (plugin->current_editor,
-									G_CALLBACK (on_editor_backspace),
-									plugin);
-	}
-	ui = anjuta_shell_get_ui (ANJUTA_PLUGIN (plugin)->shell, NULL);
-	if (plugin->action_group)
-		anjuta_ui_remove_action_group (ui, plugin->action_group);
-	anjuta_ui_unmerge (ui, plugin->uiid);
+
+	ianjuta_editor_assist_remove (IANJUTA_EDITOR_ASSIST(plugin->current_editor), IANJUTA_PROVIDER(plugin), NULL);
 }
 
 static void
@@ -399,11 +184,7 @@ on_value_added_current_editor (AnjutaPlugin *plugin, const gchar *name,
 		js_support_plugin->current_editor = NULL;
 		return;
 	}
-	if (IANJUTA_IS_EDITOR(js_support_plugin->current_editor))
-		install_support (js_support_plugin);
-/*	g_signal_connect (lang_plugin->current_editor, "language-changed",
-					  G_CALLBACK (on_editor_language_changed),
-					  plugin);*/
+	install_support (js_support_plugin);
 }
 
 static void
@@ -415,63 +196,12 @@ on_value_removed_current_editor (AnjutaPlugin *plugin, const gchar *name,
 	DEBUG_PRINT ("%s", "JSLang: Remove editor");
 
 	js_support_plugin = (JSLang*) plugin;
-/*	if (js_support_plugin->current_editor)
-		g_signal_handlers_disconnect_by_func (lang_plugin->current_editor,
-										  G_CALLBACK (on_editor_language_changed),
-										  plugin);*/
 	if (IANJUTA_IS_EDITOR(js_support_plugin->current_editor))
 		uninstall_support (js_support_plugin);
 	js_support_plugin->current_editor = NULL;
 }
 
 static void
-on_code_complete (GtkAction * action, JSLang *plugin)
-{
-	DEBUG_PRINT ("JSLang: Short cut");
-	if (ianjuta_editor_assist_tip_shown (IANJUTA_EDITOR_ASSIST (plugin->current_editor), NULL))
-	{
-		plugin->current = NULL;
-		plugin->complition_cache = NULL;
-	}
-	if (plugin->current || !plugin->current_editor)
-		return;
-	gint depth;
-	IAnjutaIterable *position = ianjuta_editor_get_position (IANJUTA_EDITOR (plugin->current_editor), NULL);
-	GList *suggestions = NULL;
-	gchar *str = code_completion_get_str (IANJUTA_EDITOR (plugin->current_editor), FALSE);
-	if (!str)
-		return;
-	gchar *file = file_completion (IANJUTA_EDITOR (plugin->current_editor), &depth);
-	gint i;
-	DEBUG_PRINT ("JSLang: Auto complete for %s (TMFILE=%s)", str, file);
-	for (i = strlen (str) - 1; i; i--)
-	{
-		if (str[i] == '.')
-			break;
-	}
-	if (i > 0)
-	{
-		suggestions = code_completion_get_list (plugin, file, g_strndup (str, i), depth);
-	}
-	else
-		suggestions = code_completion_get_list (plugin, file, NULL, depth);
-	if (suggestions)
-	{
-		plugin->complition_cache = suggestions;
-		if (i > 0)
-			plugin->current = g_strdup (str + i + 1);
-		else
-			plugin->current = g_strdup (str);
-		suggestions = filter_list (suggestions, plugin->current);
-		ianjuta_editor_assist_suggest (IANJUTA_EDITOR_ASSIST (plugin->current_editor),
-									   suggestions,
-									   position,
-									   /*alignment*/1,
-									   NULL);
-	}
-}
-
-static void
 jsdirs_save (GtkTreeModel *list_store)
 {
 	GtkTreeIter iter;
@@ -617,9 +347,150 @@ ipreferences_iface_init (IAnjutaPreferencesIface* iface)
 	iface->unmerge = ipreferences_unmerge;
 }
 
+static void
+iprovider_activate (IAnjutaProvider *obj, IAnjutaIterable* iter,  gpointer data, GError **err)
+{
+	DEBUG_PRINT("activate");
+
+	JSLang *plugin = (JSLang*)obj;
+	gchar *str = (gchar*)data;
+
+	g_assert (plugin->current_editor);
+	g_assert (str);
+
+	gint a = ianjuta_iterable_diff (plugin->last, iter, NULL);
+
+	ianjuta_editor_insert (IANJUTA_EDITOR (plugin->current_editor), iter, str + a, -1, NULL);
+			
+	gchar *sym = code_completion_get_str (IANJUTA_EDITOR (plugin->current_editor), FALSE);
+	g_assert (sym != NULL);
+
+	if (sym && code_completion_is_symbol_func (plugin, sym))
+	{
+		IAnjutaIterable *position = ianjuta_editor_get_position (IANJUTA_EDITOR (plugin->current_editor), NULL);
+
+		if (anjuta_preferences_get_bool (plugin->prefs, ADD_BRACE_AFTER_FUNCCALL))
+		{
+			ianjuta_editor_insert (IANJUTA_EDITOR (plugin->current_editor), position, " (", -1, NULL);
+		}
+		if (anjuta_preferences_get_bool (plugin->prefs, SHOW_CALLTIPS))
+		{
+/*			GList *t = NULL;
+			gchar *args = code_completion_get_func_tooltip (plugin, sym);
+			t = g_list_append (t, args);
+			if (args)
+			{
+				ianjuta_editor_tip_show (IANJUTA_EDITOR_TIP(plugin->current_editor), t,
+							 position, 1, NULL);
+
+				g_free (args);
+			}*/
+		}
+	}
+	g_free (sym);
+}
+
+static const gchar* 
+iprovider_get_name (IAnjutaProvider *obj, GError **err)
+{
+	return _("JS");
+}
+
+static IAnjutaIterable* 
+iprovider_get_start_iter (IAnjutaProvider *obj, GError **err)
+{
+	JSLang *plugin = (JSLang*)obj;
+
+	return plugin->last;
+}
+
+static void 
+iprovider_populate (IAnjutaProvider *obj, IAnjutaIterable* iter, GError **err)
+{
+	static GList *trash = NULL;
+	JSLang *plugin = (JSLang*)obj;
+
+	if (plugin->last) {
+		g_object_unref (plugin->last);
+	}
+
+        plugin->last = ianjuta_iterable_clone(iter, NULL);
+
+	if (!plugin->current_editor)
+		return;
+	gint depth;
+	GList *suggestions = NULL;
+	gchar *str = code_completion_get_str (IANJUTA_EDITOR (plugin->current_editor), FALSE);
+
+	if (trash)
+	{
+		g_list_foreach (trash, (GFunc)g_free, NULL);
+		g_list_free (trash);
+		trash = NULL;
+	}
+
+	if (!str)
+		return;
+	gchar *file = file_completion (IANJUTA_EDITOR (plugin->current_editor), &depth);
+	gint i;
+	DEBUG_PRINT ("JSLang: Auto complete for %s (TMFILE=%s)", str, file);
+	for (i = strlen (str) - 1; i; i--)
+	{
+		if (str[i] == '.')
+			break;
+	}
+	if (i > 0)
+	{
+		suggestions = code_completion_get_list (plugin, file, g_strndup (str, i), depth);
+	}
+	else
+		suggestions = code_completion_get_list (plugin, file, NULL, depth);
+	if (suggestions)
+	{
+		GList *nsuggest = NULL;
+                gint k;
+		if (i > 0)
+		{
+			suggestions = filter_list (suggestions, str + i + 1);
+			k = strlen (str + i + 1);
+		} else
+		{
+			suggestions = filter_list (suggestions, str);
+			k = strlen (str);
+		}
+		GList *i;
+		for (; k > 0; k--)
+			ianjuta_iterable_previous (plugin->last, NULL);
+
+		for (i = suggestions; i; i = g_list_next(i)) {
+			IAnjutaEditorAssistProposal* proposal = g_new0(IAnjutaEditorAssistProposal, 1);
+
+			if (!i->data)
+				continue;
+	
+			proposal->label = i->data;
+			proposal->data = i->data;
+			nsuggest = g_list_prepend (nsuggest, proposal);
+		}
+		ianjuta_editor_assist_proposals ( IANJUTA_EDITOR_ASSIST (plugin->current_editor), obj,  nsuggest,  TRUE, NULL);
+		g_list_free (nsuggest);
+                trash = suggestions;
+	}
+	ianjuta_editor_assist_proposals ( IANJUTA_EDITOR_ASSIST (plugin->current_editor), obj,  NULL,  TRUE, NULL);
+}
+
+static void
+iprovider_iface_init (IAnjutaProviderIface* iface)
+{
+	iface->activate	= iprovider_activate;
+	iface->get_name	= iprovider_get_name;
+	iface->get_start_iter = iprovider_get_start_iter;
+	iface->populate= iprovider_populate;
+}
 
 ANJUTA_PLUGIN_BEGIN (JSLang, js_support_plugin);
 ANJUTA_PLUGIN_ADD_INTERFACE(ipreferences, IANJUTA_TYPE_PREFERENCES);
+ANJUTA_PLUGIN_ADD_INTERFACE(iprovider, IANJUTA_TYPE_PROVIDER);
 ANJUTA_PLUGIN_END;
 
 ANJUTA_SIMPLE_PLUGIN (JSLang, js_support_plugin);
diff --git a/plugins/language-support-js/plugin.h b/plugins/language-support-js/plugin.h
index fd5e76a..b09f350 100644
--- a/plugins/language-support-js/plugin.h
+++ b/plugins/language-support-js/plugin.h
@@ -31,12 +31,13 @@ struct _JSLang{
 	AnjutaPlugin parent;
 	gint editor_watch_id;
 	GObject *current_editor;
-	gchar *current;
-	GList *complition_cache;
-	gint uiid;
+//	gchar *current;
+	gpointer last;
+//	GList *complition_cache;
+//	gint uiid;
 	AnjutaPreferences *prefs;
 	DatabaseSymbol* symbol;
-	GtkActionGroup *action_group;
+//	GtkActionGroup *action_group;
 };
 
 struct _JSLangClass{
diff --git a/plugins/language-support-js/util.c b/plugins/language-support-js/util.c
index 12fefcb..2dc611b 100644
--- a/plugins/language-support-js/util.c
+++ b/plugins/language-support-js/util.c
@@ -116,7 +116,6 @@ highlight_lines (GList *lines)
 
 	if (!anjuta_preferences_get_bool (plugin->prefs, HIGHLIGHT_MISSEDSEMICOLON))
 	{
-		DEBUG_PRINT ("JSLang: Highlight missed semicolon off");
 		return;
 	}
 
diff --git a/plugins/language-support-js/util.h b/plugins/language-support-js/util.h
index fd59720..44f8064 100644
--- a/plugins/language-support-js/util.h
+++ b/plugins/language-support-js/util.h
@@ -21,12 +21,9 @@
 #define _UTIL_H_
 
 #include <glib.h>
-
+#include <libanjuta/anjuta-debug.h>
 #include "ijs-symbol.h"
 
-#undef DEBUG_PRINT
-#define DEBUG_PRINT g_warning
-
 enum BaseType
 {
 	BASE_CLASS,
diff --git a/plugins/language-support-js/y.tab.c b/plugins/language-support-js/y.tab.c
index b6b3122..fe89d1f 120000
--- a/plugins/language-support-js/y.tab.c
+++ b/plugins/language-support-js/y.tab.c
@@ -1 +1 @@
-../symbol-db/anjuta-tags/parser/y.tab.c
\ No newline at end of file
+../symbol-db/anjuta-tags/js_parser/y.tab.c
\ No newline at end of file
diff --git a/plugins/language-support-js/y.tab.h b/plugins/language-support-js/y.tab.h
index 1376507..f01469b 120000
--- a/plugins/language-support-js/y.tab.h
+++ b/plugins/language-support-js/y.tab.h
@@ -1 +1 @@
-../symbol-db/anjuta-tags/parser/y.tab.h
\ No newline at end of file
+../symbol-db/anjuta-tags/js_parser/y.tab.h
\ No newline at end of file
diff --git a/plugins/symbol-db/anjuta-tags/Makefile.am b/plugins/symbol-db/anjuta-tags/Makefile.am
index 7ca73e3..bef0750 100644
--- a/plugins/symbol-db/anjuta-tags/Makefile.am
+++ b/plugins/symbol-db/anjuta-tags/Makefile.am
@@ -14,18 +14,18 @@ AM_CFLAGS =\
 
 bin_PROGRAMS = anjuta-tags
 
-YACCFLAGS = -d -o ./parser/y.tab.c
-YACCFILE = ./parser/Grammar.y
+YACCFLAGS = -d -o ./js_parser/y.tab.c
+YACCFILE = ./js_parser/Grammar.y
 PARSER = bison
 
-parser/y.tab.c : ${YACCFILE}
+js_parser/y.tab.c : ${YACCFILE}
 	${PARSER} ${YACCFLAGS} ${YACCFILE}
 
 LEXER = flex
-LEXFILE = ./parser/lex.l
-LEXCCFLAGS = -Cr -o parser/lex.yy.c --yylineno --bison-bridge
+LEXFILE = ./js_parser/lex.l
+LEXCCFLAGS = -Cr -o js_parser/lex.yy.c --yylineno --bison-bridge
 
-parser/lex.yy.c : ${LEXFILE}
+js_parser/lex.yy.c : ${LEXFILE}
 	${LEXER} ${LEXCCFLAGS} ${LEXFILE}
 
 anjuta_tags_SOURCES = \
@@ -108,11 +108,11 @@ anjuta_tags_SOURCES = \
 	vstring.c        \
 	vstring.h        \
 	yacc.c	\
-parser/y.tab.c	\
-parser/lex.yy.c   \
-parser/jsparse.c   \
-parser/js-context.c   \
-parser/js-node.c
+js_parser/y.tab.c	\
+js_parser/lex.yy.c   \
+js_parser/jsparse.c   \
+js_parser/js-context.c   \
+js_parser/js-node.c
 
 
 anjuta_tags_LDFLAGS = \
diff --git a/plugins/symbol-db/anjuta-tags/parser/Grammar.y b/plugins/symbol-db/anjuta-tags/js_parser/Grammar.y
similarity index 100%
rename from plugins/symbol-db/anjuta-tags/parser/Grammar.y
rename to plugins/symbol-db/anjuta-tags/js_parser/Grammar.y
diff --git a/plugins/symbol-db/anjuta-tags/parser/js-context.c b/plugins/symbol-db/anjuta-tags/js_parser/js-context.c
similarity index 100%
rename from plugins/symbol-db/anjuta-tags/parser/js-context.c
rename to plugins/symbol-db/anjuta-tags/js_parser/js-context.c
diff --git a/plugins/symbol-db/anjuta-tags/parser/js-context.h b/plugins/symbol-db/anjuta-tags/js_parser/js-context.h
similarity index 100%
rename from plugins/symbol-db/anjuta-tags/parser/js-context.h
rename to plugins/symbol-db/anjuta-tags/js_parser/js-context.h
diff --git a/plugins/symbol-db/anjuta-tags/parser/js-node.c b/plugins/symbol-db/anjuta-tags/js_parser/js-node.c
similarity index 100%
rename from plugins/symbol-db/anjuta-tags/parser/js-node.c
rename to plugins/symbol-db/anjuta-tags/js_parser/js-node.c
diff --git a/plugins/symbol-db/anjuta-tags/parser/js-node.h b/plugins/symbol-db/anjuta-tags/js_parser/js-node.h
similarity index 100%
rename from plugins/symbol-db/anjuta-tags/parser/js-node.h
rename to plugins/symbol-db/anjuta-tags/js_parser/js-node.h
diff --git a/plugins/symbol-db/anjuta-tags/parser/jsparse.c b/plugins/symbol-db/anjuta-tags/js_parser/jsparse.c
similarity index 100%
rename from plugins/symbol-db/anjuta-tags/parser/jsparse.c
rename to plugins/symbol-db/anjuta-tags/js_parser/jsparse.c
diff --git a/plugins/symbol-db/anjuta-tags/parser/jsparse.h b/plugins/symbol-db/anjuta-tags/js_parser/jsparse.h
similarity index 100%
rename from plugins/symbol-db/anjuta-tags/parser/jsparse.h
rename to plugins/symbol-db/anjuta-tags/js_parser/jsparse.h
diff --git a/plugins/symbol-db/anjuta-tags/parser/jstypes.h b/plugins/symbol-db/anjuta-tags/js_parser/jstypes.h
similarity index 100%
rename from plugins/symbol-db/anjuta-tags/parser/jstypes.h
rename to plugins/symbol-db/anjuta-tags/js_parser/jstypes.h
diff --git a/plugins/symbol-db/anjuta-tags/parser/lex.l b/plugins/symbol-db/anjuta-tags/js_parser/lex.l
similarity index 100%
rename from plugins/symbol-db/anjuta-tags/parser/lex.l
rename to plugins/symbol-db/anjuta-tags/js_parser/lex.l
diff --git a/plugins/symbol-db/anjuta-tags/parser/lex.yy.c b/plugins/symbol-db/anjuta-tags/js_parser/lex.yy.c
similarity index 100%
rename from plugins/symbol-db/anjuta-tags/parser/lex.yy.c
rename to plugins/symbol-db/anjuta-tags/js_parser/lex.yy.c
diff --git a/plugins/symbol-db/anjuta-tags/parser/lex.yy.h b/plugins/symbol-db/anjuta-tags/js_parser/lex.yy.h
similarity index 100%
rename from plugins/symbol-db/anjuta-tags/parser/lex.yy.h
rename to plugins/symbol-db/anjuta-tags/js_parser/lex.yy.h
diff --git a/plugins/symbol-db/anjuta-tags/parser/y.tab.c b/plugins/symbol-db/anjuta-tags/js_parser/y.tab.c
similarity index 100%
rename from plugins/symbol-db/anjuta-tags/parser/y.tab.c
rename to plugins/symbol-db/anjuta-tags/js_parser/y.tab.c
diff --git a/plugins/symbol-db/anjuta-tags/parser/y.tab.h b/plugins/symbol-db/anjuta-tags/js_parser/y.tab.h
similarity index 100%
rename from plugins/symbol-db/anjuta-tags/parser/y.tab.h
rename to plugins/symbol-db/anjuta-tags/js_parser/y.tab.h
diff --git a/plugins/symbol-db/anjuta-tags/jscript.c b/plugins/symbol-db/anjuta-tags/jscript.c
index 4304cf3..55ef5ae 100755
--- a/plugins/symbol-db/anjuta-tags/jscript.c
+++ b/plugins/symbol-db/anjuta-tags/jscript.c
@@ -25,10 +25,10 @@
 #include "routines.h"
 #include "vstring.h"
 #include <assert.h>
-#include "parser/jstypes.h"
+#include "js_parser/jstypes.h"
 #include <glib.h>
-#include "parser/jsparse.h"
-#include "parser/js-context.h"
+#include "js_parser/jsparse.h"
+#include "js_parser/js-context.h"
 
 #include <string.h>
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]