mirror of
https://github.com/vim/vim.git
synced 2025-07-04 23:07:33 -04:00
patch 9.0.1758: vim9 no class identifiers in stack dumps
Problem: vim9 no class identifiers in stack dumps Solution: Prefix class members in stack traces with the class name followed by a dot. closes: #12866 closes: #12078 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: LemonBoy <thatlemon@gmail.com>
This commit is contained in:
parent
4b1cc7906f
commit
0ffc17aa47
@ -129,7 +129,6 @@ estack_sfile(estack_arg_T which UNUSED)
|
|||||||
size_t len;
|
size_t len;
|
||||||
int idx;
|
int idx;
|
||||||
etype_T last_type = ETYPE_SCRIPT;
|
etype_T last_type = ETYPE_SCRIPT;
|
||||||
char *type_name;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
entry = ((estack_T *)exestack.ga_data) + exestack.ga_len - 1;
|
entry = ((estack_T *)exestack.ga_data) + exestack.ga_len - 1;
|
||||||
@ -190,41 +189,47 @@ estack_sfile(estack_arg_T which UNUSED)
|
|||||||
if (entry->es_name != NULL)
|
if (entry->es_name != NULL)
|
||||||
{
|
{
|
||||||
long lnum = 0;
|
long lnum = 0;
|
||||||
char *dots;
|
char_u *type_name = (char_u *)"";
|
||||||
|
char_u *class_name = (char_u *)"";
|
||||||
|
|
||||||
len = STRLEN(entry->es_name) + 15;
|
|
||||||
type_name = "";
|
|
||||||
if (entry->es_type != last_type)
|
if (entry->es_type != last_type)
|
||||||
{
|
{
|
||||||
switch (entry->es_type)
|
switch (entry->es_type)
|
||||||
{
|
{
|
||||||
case ETYPE_SCRIPT: type_name = "script "; break;
|
case ETYPE_SCRIPT: type_name = (char_u *)"script "; break;
|
||||||
case ETYPE_UFUNC: type_name = "function "; break;
|
case ETYPE_UFUNC: type_name = (char_u *)"function "; break;
|
||||||
default: type_name = ""; break;
|
default: type_name = (char_u *)""; break;
|
||||||
}
|
}
|
||||||
last_type = entry->es_type;
|
last_type = entry->es_type;
|
||||||
}
|
}
|
||||||
len += STRLEN(type_name);
|
if (entry->es_type == ETYPE_UFUNC && entry->es_info.ufunc->uf_class != NULL)
|
||||||
if (ga_grow(&ga, (int)len) == FAIL)
|
class_name = entry->es_info.ufunc->uf_class->class_name;
|
||||||
break;
|
|
||||||
if (idx == exestack.ga_len - 1)
|
if (idx == exestack.ga_len - 1)
|
||||||
lnum = which == ESTACK_STACK ? SOURCING_LNUM : 0;
|
lnum = which == ESTACK_STACK ? SOURCING_LNUM : 0;
|
||||||
else
|
else
|
||||||
lnum = entry->es_lnum;
|
lnum = entry->es_lnum;
|
||||||
dots = idx == exestack.ga_len - 1 ? "" : "..";
|
len = STRLEN(entry->es_name) + STRLEN(type_name) + STRLEN(class_name) + 26;
|
||||||
if (lnum == 0)
|
if (ga_grow(&ga, (int)len) == FAIL)
|
||||||
// For the bottom entry of <sfile>: do not add the line number,
|
break;
|
||||||
// it is used in <slnum>. Also leave it out when the number is
|
ga_concat(&ga, type_name);
|
||||||
// not set.
|
if (*class_name != NUL)
|
||||||
vim_snprintf((char *)ga.ga_data + ga.ga_len, len, "%s%s%s",
|
{
|
||||||
type_name, entry->es_name, dots);
|
// For class methods prepend "<class name>." to the function name.
|
||||||
else
|
ga_concat(&ga, class_name);
|
||||||
vim_snprintf((char *)ga.ga_data + ga.ga_len, len, "%s%s[%ld]%s",
|
ga_append(&ga, '.');
|
||||||
type_name, entry->es_name, lnum, dots);
|
}
|
||||||
ga.ga_len += (int)STRLEN((char *)ga.ga_data + ga.ga_len);
|
ga_concat(&ga, entry->es_name);
|
||||||
|
// For the bottom entry of <sfile>: do not add the line number, it is used in
|
||||||
|
// <slnum>. Also leave it out when the number is not set.
|
||||||
|
if (lnum != 0)
|
||||||
|
ga.ga_len += vim_snprintf((char *)ga.ga_data + ga.ga_len, 23, "[%ld]",
|
||||||
|
lnum);
|
||||||
|
if (idx != exestack.ga_len - 1)
|
||||||
|
ga_concat(&ga, (char_u *)"..");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ga_append(&ga, '\0');
|
||||||
return (char_u *)ga.ga_data;
|
return (char_u *)ga.ga_data;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -2492,4 +2492,27 @@ def Test_multi_level_member_access()
|
|||||||
v9.CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
" Test expansion of <stack> with class methods.
|
||||||
|
def Test_stack_expansion_with_methods()
|
||||||
|
var lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
|
||||||
|
class C
|
||||||
|
def M1()
|
||||||
|
F0()
|
||||||
|
enddef
|
||||||
|
endclass
|
||||||
|
|
||||||
|
def F0()
|
||||||
|
assert_match('<SNR>\d\+_F\[1\]\.\.C\.M1\[1\]\.\.<SNR>\d\+_F0\[1\]$', expand('<stack>'))
|
||||||
|
enddef
|
||||||
|
|
||||||
|
def F()
|
||||||
|
C.new().M1()
|
||||||
|
enddef
|
||||||
|
|
||||||
|
F()
|
||||||
|
END
|
||||||
|
v9.CheckScriptSuccess(lines)
|
||||||
|
enddef
|
||||||
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
|
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
|
||||||
|
@ -695,6 +695,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1758,
|
||||||
/**/
|
/**/
|
||||||
1757,
|
1757,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user