[anjuta/gnome-2-32] language-support-cpp-java: bgo#621916 - check for brace
- From: Johannes Schmid <jhs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/gnome-2-32] language-support-cpp-java: bgo#621916 - check for brace
- Date: Fri, 12 Nov 2010 13:55:56 +0000 (UTC)
commit 5d15c8e20b2c2e6f9cfc7144955c39e7e3010ba8
Author: Johannes Schmid <jhs gnome org>
Date: Fri Oct 22 16:07:33 2010 +0200
language-support-cpp-java: bgo#621916 - check for brace
Function autocompletion should check for already present " (" string
.../language-support-cpp-java/cpp-java-assist.c | 42 +++++++++++++++++---
1 files changed, 36 insertions(+), 6 deletions(-)
---
diff --git a/plugins/language-support-cpp-java/cpp-java-assist.c b/plugins/language-support-cpp-java/cpp-java-assist.c
index 15f204b..8b5bded 100644
--- a/plugins/language-support-cpp-java/cpp-java-assist.c
+++ b/plugins/language-support-cpp-java/cpp-java-assist.c
@@ -1161,6 +1161,34 @@ cpp_java_assist_populate (IAnjutaProvider* self, IAnjutaIterable* cursor, GError
}
/**
+ * 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
@@ -1193,11 +1221,13 @@ cpp_java_assist_activate (IAnjutaProvider* self, IAnjutaIterable* iter, gpointer
anjuta_preferences_get_bool_with_default (assist->priv->preferences,
PREF_AUTOCOMPLETE_BRACE_AFTER_FUNC,
TRUE);
- if (add_space_after_func)
- g_string_append (assistance, " ");
-
- if (add_brace_after_func)
- g_string_append (assistance, "(");
+ 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);
@@ -1227,7 +1257,7 @@ cpp_java_assist_activate (IAnjutaProvider* self, IAnjutaIterable* iter, gpointer
TRUE))
assist->priv->calltip_active = cpp_java_assist_calltip (assist);
- }
+ }
g_string_free (assistance, TRUE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]