ajwillia-ms pushed a commit to branch master.

http://git.enlightenment.org/tools/edi.git/commit/?id=e6feb19a30f7dd12623ad65b582ca5ee1493f576

commit e6feb19a30f7dd12623ad65b582ca5ee1493f576
Author: Andy Williams <[email protected]>
Date:   Wed Jan 11 14:23:15 2017 +0000

    suggest: Move documentaton lookup to suggeest provider
    
    Trying to get all the clang code out of edi_editor
    and into suggest_provider_c :)
---
 src/bin/editor/edi_editor.c                    |   9 +-
 src/bin/editor/edi_editor_documentation.c      | 292 ++-----------------------
 src/bin/editor/edi_editor_suggest_provider.c   |  16 +-
 src/bin/editor/edi_editor_suggest_provider.h   |  18 ++
 src/bin/editor/edi_editor_suggest_provider_c.c | 240 ++++++++++++++++++++
 5 files changed, 300 insertions(+), 275 deletions(-)

diff --git a/src/bin/editor/edi_editor.c b/src/bin/editor/edi_editor.c
index 351a1be..453037f 100644
--- a/src/bin/editor/edi_editor.c
+++ b/src/bin/editor/edi_editor.c
@@ -527,6 +527,13 @@ _smart_cb_key_down(void *data EINA_UNUSED, Evas *e 
EINA_UNUSED,
              _suggest_list_set(editor);
           }
      }
+   else if ((!alt) && (ctrl) && (shift))
+     {
+        if (edi_editor_suggest_provider_has(editor) && !strcmp(ev->key, 
"space"))
+          {
+             edi_editor_doc_open(editor);
+          }
+     }
 
    if (edi_editor_suggest_provider_has(editor))
      {
@@ -919,7 +926,7 @@ _mouse_up_cb(void *data, Evas *e EINA_UNUSED, Evas_Object 
*obj EINA_UNUSED,
      evas_object_hide(editor->suggest_bg);
 
    ctrl = evas_key_modifier_is_set(event->modifiers, "Control");
-   if (event->button != 3 || !ctrl)
+   if (event->button != 3 || !ctrl || !edi_editor_suggest_provider_has(editor))
      return;
 
    elm_code_widget_position_at_coordinates_get(editor->entry, event->canvas.x, 
event->canvas.y, &row, &col);
diff --git a/src/bin/editor/edi_editor_documentation.c 
b/src/bin/editor/edi_editor_documentation.c
index 20a4347..ce6ff1f 100644
--- a/src/bin/editor/edi_editor_documentation.c
+++ b/src/bin/editor/edi_editor_documentation.c
@@ -6,196 +6,13 @@
 #include <Evas.h>
 
 #include "edi_editor.h"
-#include "edi_private.h"
-
-typedef struct
-{
-   Eina_Strbuf *title;
-   Eina_Strbuf *detail;
-   Eina_Strbuf *param;
-   Eina_Strbuf *ret;
-   Eina_Strbuf *see;
-} Edi_Document;
-
-static void
-_edi_doc_free(Edi_Document *doc)
-{
-   if (!doc) return;
-
-   eina_strbuf_free(doc->title);
-   eina_strbuf_free(doc->detail);
-   eina_strbuf_free(doc->param);
-   eina_strbuf_free(doc->ret);
-   eina_strbuf_free(doc->see);
-}
-
-#if HAVE_LIBCLANG
-static void
-_edi_doc_init(Edi_Document *doc)
-{
-   doc->title = eina_strbuf_new();
-   doc->detail = eina_strbuf_new();
-   doc->param = eina_strbuf_new();
-   doc->ret = eina_strbuf_new();
-   doc->see = eina_strbuf_new();
-}
-
-static Eina_Bool
-_edi_doc_newline_check(Eina_Strbuf *strbuf)
-{
-   const char *str;
-
-   str = eina_strbuf_string_get(strbuf);
-
-   if (strlen(str) < 4)
-     return EINA_TRUE;
-
-   str = str + strlen(str) - 4;
-
-   if (!strcmp(str, "<br>"))
-     return EINA_FALSE;
-   else
-     return EINA_TRUE;
-}
-
-static void
-_edi_doc_trim(Eina_Strbuf *strbuf)
-{
-   const char *str;
-   int cmp_strlen, ori_strlen;
-
-   str = eina_strbuf_string_get(strbuf);
-   ori_strlen = strlen(str);
-
-   if (strlen(str) < 8)
-     return;
-
-   cmp_strlen = strlen(str) - 8;
-   str += cmp_strlen;
-
-   if (!strcmp(str, "<br><br>"))
-     {
-        eina_strbuf_remove(strbuf, cmp_strlen, ori_strlen);
-        _edi_doc_trim(strbuf);
-     }
-   else
-     return;
-}
-
-static void
-_edi_doc_title_get(CXCursor cursor, Eina_Strbuf *strbuf)
-{
-   CXCompletionString str;
-   int chunk_num;
-
-   str = clang_getCursorCompletionString(cursor);
-   chunk_num = clang_getNumCompletionChunks(str);
-
-   for (int i = 0; i < chunk_num; i++)
-     {
-        enum CXCompletionChunkKind kind = clang_getCompletionChunkKind(str, i);
-        switch (kind)
-          {
-           case CXCompletionChunk_ResultType:
-             eina_strbuf_append_printf(strbuf, 
"<color=#31d12f><b>%s</b></color><br>",
-                        clang_getCString(clang_getCompletionChunkText(str, 
i)));
-             break;
-           case CXCompletionChunk_Placeholder:
-             eina_strbuf_append_printf(strbuf, 
"<color=#edd400><b>%s</b></color>",
-                        clang_getCString(clang_getCompletionChunkText(str, 
i)));
-             break;
-           default:
-             eina_strbuf_append(strbuf,
-                        clang_getCString(clang_getCompletionChunkText(str, 
i)));
-             break;
-          }
-     }
-}
 
-static void
-_edi_doc_dump(Edi_Document *doc, CXComment comment, Eina_Strbuf *strbuf)
-{
-   const char *str ,*tag;
-   enum CXCommentKind kind = clang_Comment_getKind(comment);
-
-   if (kind == CXComment_Null) return;
+#include "editor/edi_editor_suggest_provider.h"
 
-   switch (kind)
-     {
-      case CXComment_Text:
-        str = clang_getCString(clang_TextComment_getText(comment));
-
-        if (doc->see == strbuf)
-          {
-             eina_strbuf_append_printf(strbuf, "   %s", str);
-             break;
-          }
-        if (clang_Comment_isWhitespace(comment))
-          {
-             if (_edi_doc_newline_check(strbuf))
-               {
-                  if (strbuf == doc->detail)
-                    eina_strbuf_append(strbuf, "<br><br>");
-                  else
-                    eina_strbuf_append(strbuf, "<br>");
-               }
-             break;
-          }
-        eina_strbuf_append(strbuf, str);
-        break;
-      case CXComment_InlineCommand:
-        str = 
clang_getCString(clang_InlineCommandComment_getCommandName(comment));
-
-        if (str[0] == 'p')
-          eina_strbuf_append_printf(strbuf, 
"<font_style=italic>%s</font_style>",
-             clang_getCString(clang_InlineCommandComment_getArgText(comment, 
0)));
-        else if (str[0] == 'c')
-          eina_strbuf_append_printf(strbuf, "<b>%s</b>",
-             clang_getCString(clang_InlineCommandComment_getArgText(comment, 
0)));
-        else
-          eina_strbuf_append_printf(strbuf, "@%s", str);
-        break;
-      case CXComment_BlockCommand:
-        tag = 
clang_getCString(clang_BlockCommandComment_getCommandName(comment));
-
-        if (!strcmp(tag, "return"))
-          strbuf = doc->ret;
-        else if (!strcmp(tag, "see"))
-          strbuf = doc->see;
-
-        break;
-      case CXComment_ParamCommand:
-        str = 
clang_getCString(clang_ParamCommandComment_getParamName(comment));
-        strbuf = doc->param;
-
-        eina_strbuf_append_printf(strbuf, "<color=#edd400><b>   
%s</b></color>",
-                                  str);
-        break;
-      case CXComment_VerbatimBlockLine:
-        str = 
clang_getCString(clang_VerbatimBlockLineComment_getText(comment));
-
-        if (str[0] == 10)
-          {
-             eina_strbuf_append(strbuf, "<br>");
-             break;
-          }
-        eina_strbuf_append_printf(strbuf, "%s<br>", str);
-        break;
-      case CXComment_VerbatimLine:
-        str = clang_getCString(clang_VerbatimLineComment_getText(comment));
-
-        if (doc->see == strbuf)
-          eina_strbuf_append(strbuf, str);
-        break;
-      default:
-        break;
-     }
-   for (unsigned i = 0; i < clang_Comment_getNumChildren(comment); i++)
-     _edi_doc_dump(doc, clang_Comment_getChild(comment, i), strbuf);
-}
+#include "edi_private.h"
 
 static void
-_edi_doc_font_set(Edi_Document *doc, const char *font, int font_size)
+_edi_doc_font_set(Edi_Editor_Suggest_Document *doc, const char *font, int 
font_size)
 {
    char *format = "<align=left><font=\'%s\'><font_size=%d>";
    char *font_head;
@@ -240,7 +57,7 @@ _edi_doc_font_set(Edi_Document *doc, const char *font, int 
font_size)
 }
 
 static void
-_edi_doc_tag_name_set(Edi_Document *doc)
+_edi_doc_tag_name_set(Edi_Editor_Suggest_Document *doc)
 {
    if (strlen(eina_strbuf_string_get(doc->param)) > 0)
      eina_strbuf_prepend(doc->param, "<b><br><br> Parameters<br></b>");
@@ -252,87 +69,6 @@ _edi_doc_tag_name_set(Edi_Document *doc)
      eina_strbuf_prepend(doc->see, "<b><br><br> See also<br></b>");
 }
 
-static CXCursor
-_edi_doc_cursor_get(Edi_Editor *editor, CXIndex idx, CXTranslationUnit unit)
-{
-   CXFile cxfile;
-   CXSourceLocation location;
-   CXCursor cursor;
-   struct CXUnsavedFile unsaved_file;
-   Elm_Code *code;
-   const char *path, *args;
-   char **clang_argv;
-   unsigned int clang_argc, row, col, end_row, end_col;
-
-   code = elm_code_widget_code_get(editor->entry);
-   path = elm_code_file_path_get(code->file);
-   elm_code_widget_cursor_position_get(editor->entry, &row, &col);
-
-   end_row = elm_code_file_lines_get(code->file);
-   end_col = elm_code_file_line_get(code->file, end_row)->length;
-
-   unsaved_file.Filename = path;
-   unsaved_file.Contents = elm_code_widget_text_between_positions_get(
-                                         editor->entry, 1, 1, end_row, 
end_col);
-   unsaved_file.Length = strlen(unsaved_file.Contents);
-
-   //Initialize Clang
-   args = "-I/usr/inclue/ " EFL_CFLAGS " " CLANG_INCLUDES " -Wall -Wextra";
-   clang_argv = eina_str_split_full(args, " ", 0, &clang_argc);
-
-   idx = clang_createIndex(0, 0);
-
-   unit = clang_parseTranslationUnit(idx, path, (const char *const 
*)clang_argv,
-                                  (int)clang_argc, &unsaved_file, 1,
-                                  
clang_defaultEditingTranslationUnitOptions());
-
-   cxfile = clang_getFile(unit, path);
-   location = clang_getLocation(unit, cxfile, row, col);
-   cursor = clang_getCursor(unit, location);
-
-   return clang_getCursorReferenced(cursor);
-}
-#endif
-
-static Edi_Document *
-_edi_doc_get(Edi_Editor *editor)
-{
-   Edi_Document *doc = NULL;
-#if HAVE_LIBCLANG
-   CXIndex idx = NULL;
-   CXTranslationUnit unit = NULL;
-   CXCursor cursor;
-   CXComment comment;
-   const char *font;
-   int font_size;
-
-   cursor = _edi_doc_cursor_get(editor, idx, unit);
-   comment = clang_Cursor_getParsedComment(cursor);
-
-   if (clang_Comment_getKind(comment) == CXComment_Null)
-     {
-        clang_disposeTranslationUnit(unit);
-        clang_disposeIndex(idx);
-        return NULL;
-     }
-
-   doc = malloc(sizeof(Edi_Document));
-
-   _edi_doc_init(doc);
-   _edi_doc_dump(doc, comment, doc->detail);
-   _edi_doc_title_get(cursor, doc->title);
-   _edi_doc_trim(doc->detail);
-
-   _edi_doc_tag_name_set(doc);
-   elm_code_widget_font_get(editor->entry, &font, &font_size);
-   _edi_doc_font_set(doc, font, font_size);
-
-   clang_disposeTranslationUnit(unit);
-   clang_disposeIndex(idx);
-#endif
-   return doc;
-}
-
 static void
 _edi_doc_popup_cb_block_clicked(void *data EINA_UNUSED, Evas_Object *obj,
                                 void *event_info EINA_UNUSED)
@@ -361,21 +97,29 @@ static void
 _edi_doc_popup_cb_del(void *data, Evas *e EINA_UNUSED,
                      Evas_Object *obj EINA_UNUSED, void *event_info 
EINA_UNUSED)
 {
-   Edi_Document *doc = data;
+   Edi_Editor_Suggest_Document *doc = data;
 
-   _edi_doc_free(doc);
+   edi_editor_suggest_doc_free(doc);
 }
 
 void
 edi_editor_doc_open(Edi_Editor *editor)
 {
-   Edi_Document *doc;
+   Edi_Editor_Suggest_Document *doc = NULL;
    const char *detail, *param, *ret, *see;
    char *display;
    int displen;
    Evas_Coord w, h;
+   const char *font;
+   int font_size;
 
-   doc = _edi_doc_get(editor);
+   if (edi_editor_suggest_provider_has(editor))
+     {
+        unsigned int row, col;
+
+        elm_code_widget_cursor_position_get(editor->entry, &row, &col);
+        doc = edi_editor_suggest_provider_get(editor)->lookup_doc(editor, row, 
col);
+     }
 
    //Popup
    editor->doc_popup = elm_popup_add(editor->entry);
@@ -394,6 +138,10 @@ edi_editor_doc_open(Edi_Editor *editor)
         return;
      }
 
+   _edi_doc_tag_name_set(doc);
+   elm_code_widget_font_get(editor->entry, &font, &font_size);
+   _edi_doc_font_set(doc, font, font_size);
+
    detail = eina_strbuf_string_get(doc->detail);
    param = eina_strbuf_string_get(doc->param);
    ret = eina_strbuf_string_get(doc->ret);
diff --git a/src/bin/editor/edi_editor_suggest_provider.c 
b/src/bin/editor/edi_editor_suggest_provider.c
index d7982a4..35462a5 100644
--- a/src/bin/editor/edi_editor_suggest_provider.c
+++ b/src/bin/editor/edi_editor_suggest_provider.c
@@ -14,10 +14,10 @@ static Edi_Editor_Suggest_Provider 
_edi_editor_suggest_provider_registry[] =
 {
    {
       "c", _edi_editor_sugggest_c_add, _edi_editor_sugget_c_del,
-      _edi_editor_suggest_c_lookup
+      _edi_editor_suggest_c_lookup, _edi_editor_suggest_c_lookup_doc
    },
 
-   {NULL, NULL, NULL, NULL}
+   {NULL, NULL, NULL, NULL, NULL}
 };
 
 Edi_Editor_Suggest_Provider *edi_editor_suggest_provider_get(Edi_Editor 
*editor)
@@ -63,3 +63,15 @@ edi_editor_suggest_item_free(Edi_Editor_Suggest_Item *item)
    free(item);
 }
 
+void
+edi_editor_suggest_doc_free(Edi_Editor_Suggest_Document *doc)
+{
+   if (!doc) return;
+
+   eina_strbuf_free(doc->title);
+   eina_strbuf_free(doc->detail);
+   eina_strbuf_free(doc->param);
+   eina_strbuf_free(doc->ret);
+   eina_strbuf_free(doc->see);
+}
+
diff --git a/src/bin/editor/edi_editor_suggest_provider.h 
b/src/bin/editor/edi_editor_suggest_provider.h
index 9dbd4d6..a0eef08 100644
--- a/src/bin/editor/edi_editor_suggest_provider.h
+++ b/src/bin/editor/edi_editor_suggest_provider.h
@@ -23,6 +23,14 @@ typedef struct _Edi_Editor_Suggest_Item
    const char *detail;
 } Edi_Editor_Suggest_Item;
 
+typedef struct _Edi_Editor_Suggest_Document
+{
+   Eina_Strbuf *title;
+   Eina_Strbuf *detail;
+   Eina_Strbuf *param;
+   Eina_Strbuf *ret;
+   Eina_Strbuf *see;
+} Edi_Editor_Suggest_Document;
 /**
  * @struct Edi_Editor_Suggest_Provider
  * A description of the requirements for a suggestion provider.
@@ -36,6 +44,7 @@ typedef struct _Edi_Editor_Suggest_Provider
    void (*add)(Edi_Editor *editor);
    void (*del)(Edi_Editor *editor);
    Eina_List *(*lookup)(Edi_Editor *editor, unsigned int row, unsigned int 
col);
+   Edi_Editor_Suggest_Document *(*lookup_doc)(Edi_Editor *editor, unsigned int 
row, unsigned int col);
 } Edi_Editor_Suggest_Provider;
 
 /**
@@ -73,6 +82,15 @@ Eina_Bool edi_editor_suggest_provider_has(Edi_Editor 
*editor);
 void edi_editor_suggest_item_free(Edi_Editor_Suggest_Item *item);
 
 /**
+ * Free a suggest document.
+ *
+ * @param doc the suggest document to free
+ *
+ * @ingroup Lookup
+ */
+void edi_editor_suggest_doc_free(Edi_Editor_Suggest_Document *doc);
+
+/**
  * @}
  */
 
diff --git a/src/bin/editor/edi_editor_suggest_provider_c.c 
b/src/bin/editor/edi_editor_suggest_provider_c.c
index 2cb0a66..94d7a33 100644
--- a/src/bin/editor/edi_editor_suggest_provider_c.c
+++ b/src/bin/editor/edi_editor_suggest_provider_c.c
@@ -180,3 +180,243 @@ _edi_editor_suggest_c_lookup(Edi_Editor *editor, unsigned 
int row, unsigned int
    return list;
 }
 
+#if HAVE_LIBCLANG
+static void
+_edi_doc_init(Edi_Editor_Suggest_Document *doc)
+{
+   doc->title = eina_strbuf_new();
+   doc->detail = eina_strbuf_new();
+   doc->param = eina_strbuf_new();
+   doc->ret = eina_strbuf_new();
+   doc->see = eina_strbuf_new();
+}
+
+static Eina_Bool
+_edi_doc_newline_check(Eina_Strbuf *strbuf)
+{
+   const char *str;
+
+   str = eina_strbuf_string_get(strbuf);
+
+   if (strlen(str) < 4)
+     return EINA_TRUE;
+
+   str = str + strlen(str) - 4;
+
+   if (!strcmp(str, "<br>"))
+     return EINA_FALSE;
+   else
+     return EINA_TRUE;
+}
+
+static void
+_edi_doc_trim(Eina_Strbuf *strbuf)
+{
+   const char *str;
+   int cmp_strlen, ori_strlen;
+
+   str = eina_strbuf_string_get(strbuf);
+   ori_strlen = strlen(str);
+
+   if (strlen(str) < 8)
+     return;
+
+   cmp_strlen = strlen(str) - 8;
+   str += cmp_strlen;
+
+   if (!strcmp(str, "<br><br>"))
+     {
+        eina_strbuf_remove(strbuf, cmp_strlen, ori_strlen);
+        _edi_doc_trim(strbuf);
+     }
+   else
+     return;
+}
+
+static void
+_edi_doc_title_get(CXCursor cursor, Eina_Strbuf *strbuf)
+{
+   CXCompletionString str;
+   int chunk_num;
+
+   str = clang_getCursorCompletionString(cursor);
+   chunk_num = clang_getNumCompletionChunks(str);
+
+   for (int i = 0; i < chunk_num; i++)
+     {
+        enum CXCompletionChunkKind kind = clang_getCompletionChunkKind(str, i);
+        switch (kind)
+          {
+           case CXCompletionChunk_ResultType:
+             eina_strbuf_append_printf(strbuf, 
"<color=#31d12f><b>%s</b></color><br>",
+                        clang_getCString(clang_getCompletionChunkText(str, 
i)));
+             break;
+           case CXCompletionChunk_Placeholder:
+             eina_strbuf_append_printf(strbuf, 
"<color=#edd400><b>%s</b></color>",
+                        clang_getCString(clang_getCompletionChunkText(str, 
i)));
+             break;
+           default:
+             eina_strbuf_append(strbuf,
+                        clang_getCString(clang_getCompletionChunkText(str, 
i)));
+             break;
+          }
+     }
+}
+
+static void
+_edi_doc_dump(Edi_Editor_Suggest_Document *doc, CXComment comment, Eina_Strbuf 
*strbuf)
+{
+   const char *str ,*tag;
+   enum CXCommentKind kind = clang_Comment_getKind(comment);
+
+   if (kind == CXComment_Null) return;
+
+   switch (kind)
+     {
+      case CXComment_Text:
+        str = clang_getCString(clang_TextComment_getText(comment));
+
+        if (doc->see == strbuf)
+          {
+             eina_strbuf_append_printf(strbuf, "   %s", str);
+             break;
+          }
+        if (clang_Comment_isWhitespace(comment))
+          {
+             if (_edi_doc_newline_check(strbuf))
+               {
+                  if (strbuf == doc->detail)
+                    eina_strbuf_append(strbuf, "<br><br>");
+                  else
+                    eina_strbuf_append(strbuf, "<br>");
+               }
+             break;
+          }
+        eina_strbuf_append(strbuf, str);
+        break;
+      case CXComment_InlineCommand:
+        str = 
clang_getCString(clang_InlineCommandComment_getCommandName(comment));
+
+        if (str[0] == 'p')
+          eina_strbuf_append_printf(strbuf, 
"<font_style=italic>%s</font_style>",
+             clang_getCString(clang_InlineCommandComment_getArgText(comment, 
0)));
+        else if (str[0] == 'c')
+          eina_strbuf_append_printf(strbuf, "<b>%s</b>",
+             clang_getCString(clang_InlineCommandComment_getArgText(comment, 
0)));
+        else
+          eina_strbuf_append_printf(strbuf, "@%s", str);
+        break;
+      case CXComment_BlockCommand:
+        tag = 
clang_getCString(clang_BlockCommandComment_getCommandName(comment));
+
+        if (!strcmp(tag, "return"))
+          strbuf = doc->ret;
+        else if (!strcmp(tag, "see"))
+          strbuf = doc->see;
+
+        break;
+      case CXComment_ParamCommand:
+        str = 
clang_getCString(clang_ParamCommandComment_getParamName(comment));
+        strbuf = doc->param;
+
+        eina_strbuf_append_printf(strbuf, "<color=#edd400><b>   
%s</b></color>",
+                                  str);
+        break;
+      case CXComment_VerbatimBlockLine:
+        str = 
clang_getCString(clang_VerbatimBlockLineComment_getText(comment));
+
+        if (str[0] == 10)
+          {
+             eina_strbuf_append(strbuf, "<br>");
+             break;
+          }
+        eina_strbuf_append_printf(strbuf, "%s<br>", str);
+        break;
+      case CXComment_VerbatimLine:
+        str = clang_getCString(clang_VerbatimLineComment_getText(comment));
+
+        if (doc->see == strbuf)
+          eina_strbuf_append(strbuf, str);
+        break;
+      default:
+        break;
+     }
+   for (unsigned i = 0; i < clang_Comment_getNumChildren(comment); i++)
+     _edi_doc_dump(doc, clang_Comment_getChild(comment, i), strbuf);
+}
+
+static CXCursor
+_edi_doc_cursor_get(Edi_Editor *editor, CXIndex idx, CXTranslationUnit unit,
+                    unsigned int row, unsigned int col)
+{
+   CXFile cxfile;
+   CXSourceLocation location;
+   CXCursor cursor;
+   struct CXUnsavedFile unsaved_file;
+   Elm_Code *code;
+   const char *path, *args;
+   char **clang_argv;
+   unsigned int clang_argc, end_row, end_col;
+
+   code = elm_code_widget_code_get(editor->entry);
+   path = elm_code_file_path_get(code->file);
+
+   end_row = elm_code_file_lines_get(code->file);
+   end_col = elm_code_file_line_get(code->file, end_row)->length;
+
+   unsaved_file.Filename = path;
+   unsaved_file.Contents = elm_code_widget_text_between_positions_get(
+                                         editor->entry, 1, 1, end_row, 
end_col);
+   unsaved_file.Length = strlen(unsaved_file.Contents);
+
+   //Initialize Clang
+   args = "-I/usr/inclue/ " EFL_CFLAGS " " CLANG_INCLUDES " -Wall -Wextra";
+   clang_argv = eina_str_split_full(args, " ", 0, &clang_argc);
+
+   idx = clang_createIndex(0, 0);
+
+   unit = clang_parseTranslationUnit(idx, path, (const char *const 
*)clang_argv,
+                                  (int)clang_argc, &unsaved_file, 1,
+                                  
clang_defaultEditingTranslationUnitOptions());
+
+   cxfile = clang_getFile(unit, path);
+   location = clang_getLocation(unit, cxfile, row, col);
+   cursor = clang_getCursor(unit, location);
+
+   return clang_getCursorReferenced(cursor);
+}
+#endif
+
+static Edi_Editor_Suggest_Document *
+_edi_editor_suggest_c_lookup_doc(Edi_Editor *editor, unsigned int row, 
unsigned int col)
+{
+   Edi_Editor_Suggest_Document *doc = NULL;
+#if HAVE_LIBCLANG
+   CXIndex idx = NULL;
+   CXTranslationUnit unit = NULL;
+   CXCursor cursor;
+   CXComment comment;
+
+   cursor = _edi_doc_cursor_get(editor, idx, unit, row, col);
+   comment = clang_Cursor_getParsedComment(cursor);
+
+   if (clang_Comment_getKind(comment) == CXComment_Null)
+     {
+        clang_disposeTranslationUnit(unit);
+        clang_disposeIndex(idx);
+        return NULL;
+     }
+
+   doc = malloc(sizeof(Edi_Editor_Suggest_Document));
+
+   _edi_doc_init(doc);
+   _edi_doc_dump(doc, comment, doc->detail);
+   _edi_doc_title_get(cursor, doc->title);
+   _edi_doc_trim(doc->detail);
+
+   clang_disposeTranslationUnit(unit);
+   clang_disposeIndex(idx);
+#endif
+   return doc;
+}
+

-- 


Reply via email to