diff options
author | Daniel Kolesa <d.kolesa@osg.samsung.com> | 2018-04-12 15:22:33 +0200 |
---|---|---|
committer | Daniel Kolesa <d.kolesa@osg.samsung.com> | 2018-04-12 15:24:15 +0200 |
commit | 2defb322144ce7f2864b53b4b73e1a849da92089 (patch) | |
tree | 84e03168d3a7b959fac53ad45a127387945ea4fb | |
parent | 4793398759d6c3d8288924b894603d75a10e03b2 (diff) | |
download | efl-2defb322144ce7f2864b53b4b73e1a849da92089.tar.gz |
eolian: correct line/column number during doc reference validation
Eolian doc objects now bundle debug information necessary to
provide correct line/column numbers. It is not possible to get
this information cirectly from the text, as it's reformatted and
contains no extra whitespace or newlines beyond paragraph
separators.
Fixes T6701.
-rw-r--r-- | src/lib/eolian/database_validate.c | 41 | ||||
-rw-r--r-- | src/lib/eolian/eo_lexer.c | 15 | ||||
-rw-r--r-- | src/lib/eolian/eolian_database.c | 1 | ||||
-rw-r--r-- | src/lib/eolian/eolian_database.h | 1 |
4 files changed, 41 insertions, 17 deletions
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c index f065584f82..5e88a1d857 100644 --- a/src/lib/eolian/database_validate.c +++ b/src/lib/eolian/database_validate.c @@ -21,7 +21,8 @@ _validate(Eolian_Object *obj) } static Eina_Bool -_validate_docstr(const Eolian_Unit *src, Eina_Stringshare *str, const Eolian_Object *info) +_validate_docstr(const Eolian_Unit *src, Eina_Stringshare *str, + const Eolian_Object *info, Eina_List **rdbg) { if (!str || !str[0]) return EINA_TRUE; @@ -34,16 +35,28 @@ _validate_docstr(const Eolian_Unit *src, Eina_Stringshare *str, const Eolian_Obj Eolian_Doc_Token tok; eolian_doc_token_init(&tok); while (ret && (doc = eolian_documentation_tokenize(doc, &tok))) - if (eolian_doc_token_type_get(&tok) == EOLIAN_DOC_TOKEN_REF) - if (eolian_doc_token_ref_resolve(&tok, src, NULL, NULL) == EOLIAN_OBJECT_UNKNOWN) - { - char *refn = eolian_doc_token_text_get(&tok); - eolian_state_log_obj(info->unit->state, info, - "failed validating reference '%s'", refn); - free(refn); - ret = EINA_FALSE; - break; - } + { + if (eolian_doc_token_type_get(&tok) == EOLIAN_DOC_TOKEN_REF) + { + if (eolian_doc_token_ref_resolve(&tok, src, NULL, NULL) == EOLIAN_OBJECT_UNKNOWN) + { + size_t dbgn = (size_t)eina_list_data_get(*rdbg); + char *refn = eolian_doc_token_text_get(&tok); + Eolian_Object tmp; + memset(&tmp, 0, sizeof(Eolian_Object)); + tmp.unit = info->unit; + tmp.file = info->file; + tmp.line = (int)(dbgn & 0xFFFFF); + tmp.column = (int)(dbgn >> 20); + eolian_state_log_obj(info->unit->state, &tmp, + "failed validating reference '%s'", refn); + free(refn); + ret = EINA_FALSE; + break; + } + *rdbg = eina_list_next(*rdbg); + } + } free(par); } @@ -56,9 +69,11 @@ _validate_doc(Eolian_Documentation *doc) if (!doc) return EINA_TRUE; - if (!_validate_docstr(doc->base.unit, doc->summary, &doc->base)) + Eina_List *rdbg = doc->ref_dbg; + + if (!_validate_docstr(doc->base.unit, doc->summary, &doc->base, &rdbg)) return EINA_FALSE; - if (!_validate_docstr(doc->base.unit, doc->description, &doc->base)) + if (!_validate_docstr(doc->base.unit, doc->description, &doc->base, &rdbg)) return EINA_FALSE; return _validate(&doc->base); diff --git a/src/lib/eolian/eo_lexer.c b/src/lib/eolian/eo_lexer.c index 44570bd17a..ce18009950 100644 --- a/src/lib/eolian/eo_lexer.c +++ b/src/lib/eolian/eo_lexer.c @@ -287,7 +287,7 @@ doc_ref_class(Eo_Lexer *ls, const char *cname) } static void -doc_ref(Eo_Lexer *ls) +doc_ref(Eo_Lexer *ls, Eolian_Documentation *doc) { const char *st = ls->stream, *ste = ls->stream_end; size_t rlen = 0; @@ -310,6 +310,12 @@ doc_ref(Eo_Lexer *ls) /* actual full class name */ doc_ref_class(ls, buf); + /* it's definitely a reference, add debug info + * 20 bits for line and 12 bits for column, good enough + */ + doc->ref_dbg = eina_list_append(doc->ref_dbg, + (void *)(size_t)((ls->line_number & 0xFFFFF) | (((ls->column + 1) & 0xFFF) << 20))); + /* method name at the end */ char *end = strrchr(buf, '.'); if (!end) @@ -328,7 +334,7 @@ doc_ref(Eo_Lexer *ls) } static int -doc_lex(Eo_Lexer *ls, Eina_Bool *term, Eina_Bool *since) +doc_lex(Eo_Lexer *ls, Eolian_Documentation *doc, Eina_Bool *term, Eina_Bool *since) { int tokret = -1; eina_strbuf_reset(ls->buff); @@ -398,7 +404,7 @@ doc_lex(Eo_Lexer *ls, Eina_Bool *term, Eina_Bool *since) tokret = DOC_TEXT; goto exit_with_token; } - doc_ref(ls); + doc_ref(ls, doc); eina_strbuf_append_char(ls->buff, '@'); next_char(ls); /* in-class references */ @@ -453,6 +459,7 @@ void doc_error(Eo_Lexer *ls, const char *msg, Eolian_Documentation *doc, Eina_St { eina_stringshare_del(doc->summary); eina_stringshare_del(doc->description); + eina_list_free(doc->ref_dbg); free(doc); eina_strbuf_free(buf); eo_lexer_lex_error(ls, msg, -1); @@ -483,7 +490,7 @@ read_doc(Eo_Lexer *ls, Eo_Token *tok, int line, int column) term = EINA_TRUE; } else - read = doc_lex(ls, &term, &since); + read = doc_lex(ls, doc, &term, &since); switch (read) { case DOC_MANGLED: diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c index 5ae0cc83bd..307c6bc65e 100644 --- a/src/lib/eolian/eolian_database.c +++ b/src/lib/eolian/eolian_database.c @@ -125,6 +125,7 @@ void database_doc_del(Eolian_Documentation *doc) eina_stringshare_del(doc->summary); eina_stringshare_del(doc->description); eina_stringshare_del(doc->since); + eina_list_free(doc->ref_dbg); free(doc); } diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h index f4e310c9c1..2cf09810e5 100644 --- a/src/lib/eolian/eolian_database.h +++ b/src/lib/eolian/eolian_database.h @@ -168,6 +168,7 @@ struct _Eolian_Documentation Eina_Stringshare *summary; Eina_Stringshare *description; Eina_Stringshare *since; + Eina_List *ref_dbg; }; struct _Eolian_Class |