mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 9.0.1157: "implements" only handles one interface name
Problem: "implements" only handles one interface name. Solution: Handle a comma separated list of names. Check for duplicate names.
This commit is contained in:
parent
0cb3ca9f7a
commit
df8f947359
@ -3422,4 +3422,8 @@ EXTERN char e_member_str_of_interface_str_not_implemented[]
|
|||||||
INIT(= N_("E1348: Member \"%s\" of interface \"%s\" not implemented"));
|
INIT(= N_("E1348: Member \"%s\" of interface \"%s\" not implemented"));
|
||||||
EXTERN char e_function_str_of_interface_str_not_implemented[]
|
EXTERN char e_function_str_of_interface_str_not_implemented[]
|
||||||
INIT(= N_("E1349: Function \"%s\" of interface \"%s\" not implemented"));
|
INIT(= N_("E1349: Function \"%s\" of interface \"%s\" not implemented"));
|
||||||
|
EXTERN char e_duplicate_implements[]
|
||||||
|
INIT(= N_("E1350: Duplicate \"implements\""));
|
||||||
|
EXTERN char e_duplicate_interface_after_implements_str[]
|
||||||
|
INIT(= N_("E1351: Duplicate interface after \"implements\": %s"));
|
||||||
#endif
|
#endif
|
||||||
|
@ -627,9 +627,48 @@ def Test_class_implements_interface()
|
|||||||
echo nr
|
echo nr
|
||||||
enddef
|
enddef
|
||||||
endclass
|
endclass
|
||||||
|
|
||||||
|
interface Another
|
||||||
|
this.member: string
|
||||||
|
endinterface
|
||||||
|
|
||||||
|
class SomeImpl implements Some, Another
|
||||||
|
this.member = 'abc'
|
||||||
|
static count: number
|
||||||
|
def Method(nr: number)
|
||||||
|
echo nr
|
||||||
|
enddef
|
||||||
|
endclass
|
||||||
|
|
||||||
END
|
END
|
||||||
v9.CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
|
||||||
|
interface Some
|
||||||
|
static counter: number
|
||||||
|
endinterface
|
||||||
|
|
||||||
|
class SomeImpl implements Some implements Some
|
||||||
|
static count: number
|
||||||
|
endclass
|
||||||
|
END
|
||||||
|
v9.CheckScriptFailure(lines, 'E1350:')
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
|
||||||
|
interface Some
|
||||||
|
static counter: number
|
||||||
|
endinterface
|
||||||
|
|
||||||
|
class SomeImpl implements Some, Some
|
||||||
|
static count: number
|
||||||
|
endclass
|
||||||
|
END
|
||||||
|
v9.CheckScriptFailure(lines, 'E1351: Duplicate interface after "implements": Some')
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
|
|
||||||
|
@ -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 */
|
||||||
|
/**/
|
||||||
|
1157,
|
||||||
/**/
|
/**/
|
||||||
1156,
|
1156,
|
||||||
/**/
|
/**/
|
||||||
|
@ -245,9 +245,18 @@ ex_class(exarg_T *eap)
|
|||||||
// specifies SomeInterface
|
// specifies SomeInterface
|
||||||
if (STRNCMP(arg, "implements", 10) == 0 && IS_WHITE_OR_NUL(arg[10]))
|
if (STRNCMP(arg, "implements", 10) == 0 && IS_WHITE_OR_NUL(arg[10]))
|
||||||
{
|
{
|
||||||
|
if (ga_impl.ga_len > 0)
|
||||||
|
{
|
||||||
|
emsg(_(e_duplicate_implements));
|
||||||
|
goto early_ret;
|
||||||
|
}
|
||||||
arg = skipwhite(arg + 10);
|
arg = skipwhite(arg + 10);
|
||||||
char_u *impl_end = find_name_end(arg, NULL, NULL, FNE_CHECK_START);
|
|
||||||
if (!IS_WHITE_OR_NUL(*impl_end))
|
for (;;)
|
||||||
|
{
|
||||||
|
char_u *impl_end = find_name_end(arg, NULL, NULL,
|
||||||
|
FNE_CHECK_START);
|
||||||
|
if (!IS_WHITE_OR_NUL(*impl_end) && *impl_end != ',')
|
||||||
{
|
{
|
||||||
semsg(_(e_white_space_required_after_name_str), arg);
|
semsg(_(e_white_space_required_after_name_str), arg);
|
||||||
goto early_ret;
|
goto early_ret;
|
||||||
@ -255,12 +264,26 @@ ex_class(exarg_T *eap)
|
|||||||
char_u *iname = vim_strnsave(arg, impl_end - arg);
|
char_u *iname = vim_strnsave(arg, impl_end - arg);
|
||||||
if (iname == NULL)
|
if (iname == NULL)
|
||||||
goto early_ret;
|
goto early_ret;
|
||||||
|
for (int i = 0; i < ga_impl.ga_len; ++i)
|
||||||
|
if (STRCMP(((char_u **)ga_impl.ga_data)[i], iname) == 0)
|
||||||
|
{
|
||||||
|
semsg(_(e_duplicate_interface_after_implements_str),
|
||||||
|
iname);
|
||||||
|
vim_free(iname);
|
||||||
|
goto early_ret;
|
||||||
|
}
|
||||||
if (ga_add_string(&ga_impl, iname) == FAIL)
|
if (ga_add_string(&ga_impl, iname) == FAIL)
|
||||||
{
|
{
|
||||||
vim_free(iname);
|
vim_free(iname);
|
||||||
goto early_ret;
|
goto early_ret;
|
||||||
}
|
}
|
||||||
|
if (*impl_end != ',')
|
||||||
|
{
|
||||||
arg = skipwhite(impl_end);
|
arg = skipwhite(impl_end);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
arg = skipwhite(impl_end + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user