Бондарев Иван 2019-09-09 21:00:01 +02:00
parent db897d3021
commit fe6196c6bb
4 changed files with 51 additions and 14 deletions

View file

@ -3699,16 +3699,20 @@ namespace CodeCompletion
ss.loc = get_location(_class_definition);
cur_scope = ss;
if (_class_definition.template_args != null)
if (!parse_only_method_bodies)
{
foreach (ident id in _class_definition.template_args.idents)
ss.AddGenericParameter(id.name);
}
else if (template_args != null)
{
foreach (ident id in template_args.idents)
ss.AddGenericParameter(id.name);
if (_class_definition.template_args != null)
{
foreach (ident id in _class_definition.template_args.idents)
ss.AddGenericParameter(id.name);
}
else if (template_args != null)
{
foreach (ident id in template_args.idents)
ss.AddGenericParameter(id.name);
}
}
string tmp_name = cur_type_name;
cur_type_name = null;
if (_class_definition.body != null)
@ -5297,9 +5301,9 @@ namespace CodeCompletion
if ((awaitedProcType as ProcType).target.parameters.Count > 0)
param_type = (awaitedProcType as ProcType).target.parameters[i].sc as TypeScope;
}
else if (awaitedProcType.IsDelegate && awaitedProcType.instances != null && awaitedProcType.instances.Count > i)
else if (awaitedProcType.IsDelegate && awaitedProcType.instances != null && awaitedProcType.instances.Count > 0)
{
param_type = awaitedProcType.instances[i];
param_type = awaitedProcType.instances[Math.Min(i, awaitedProcType.instances.Count - 1)];
}
else if (awaitedProcType.IsDelegate)
{

View file

@ -2227,8 +2227,25 @@ namespace CodeCompletion
public ProcScope GetInstance(List<TypeScope> gen_args)
{
if (this.template_parameters == null || this.template_parameters.Count == 0)
return this;
List<string> template_parameters = this.template_parameters;
if ((this.template_parameters == null || this.template_parameters.Count == 0))
{
bool has_instance = false;
if (this.topScope is TypeScope)
{
TypeScope ts = this.topScope as TypeScope;
if (ts.instances != null && ts.instances.Count > 0 && gen_args.Count > 0)
{
has_instance = true;
gen_args = ts.instances;
template_parameters = new List<string>(ts.TemplateArguments);
}
}
if (!has_instance)
return this;
}
ProcScope instance = new ProcScope(this.name, this.topScope, this.is_constructor);
instance.is_extension = this.is_extension;
instance.original_function = this;
@ -2241,7 +2258,7 @@ namespace CodeCompletion
i++;
if (parameter.sc is UnknownScope || (parameter.sc is TypeScope) && (parameter.sc as TypeScope).IsGenericParameter)
{
int ind = this.template_parameters.IndexOf((parameter.sc as TypeScope).Name);
int ind = template_parameters.IndexOf((parameter.sc as TypeScope).Name);
ElementScope inst_param = null;
if (gen_args.Count > ind && ind != -1)
inst_param = new ElementScope(new SymInfo(parameter.si.name, parameter.si.kind, parameter.si.description), gen_args[ind], parameter.topScope);
@ -2267,7 +2284,7 @@ namespace CodeCompletion
if (this.return_type != null)
{
bool exact = true;
if (this.template_parameters != null && this.template_parameters.Count > 0)
if (template_parameters != null && template_parameters.Count > 0)
{
foreach (ElementScope parameter in this.parameters)
{
@ -3956,6 +3973,13 @@ namespace CodeCompletion
}
}
public override void Clear()
{
base.Clear();
if (generic_params != null)
generic_params.Clear();
}
public virtual List<TypeScope> GetInstances()
{
return this.instances;

View file

@ -14,4 +14,5 @@ begin
a1.c{@var t1<>.c: byte;@} := 3;
var a2 := t1&<byte>.Create;
a2.b{@var t1<>.b: byte;@} := 4;
end.

View file

@ -0,0 +1,8 @@
begin
System.Collections.Generic.Comparer&<byte>.Create(
(b1{@parameter b1: byte;@},b2)->
begin
Result := b2{@parameter b2: byte;@}-b1;
end
)
end.