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.
This commit is contained in:
parent
4793398759
commit
2defb32214
|
@ -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);
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -168,6 +168,7 @@ struct _Eolian_Documentation
|
|||
Eina_Stringshare *summary;
|
||||
Eina_Stringshare *description;
|
||||
Eina_Stringshare *since;
|
||||
Eina_List *ref_dbg;
|
||||
};
|
||||
|
||||
struct _Eolian_Class
|
||||
|
|
Loading…
Reference in New Issue