This commit is contained in:
Бондарев Иван 2020-01-26 18:24:07 +01:00
parent 54570290bd
commit c742d0bf3e
4 changed files with 52 additions and 11 deletions

View file

@ -436,8 +436,11 @@ namespace CodeCompletion
}
if (returned_scope is ElementScope)
{
cnst_val.prim_val = (returned_scope as ElementScope).cnst_val;
returned_scope = (returned_scope as ElementScope).sc;
ElementScope es = returned_scope as ElementScope;
cnst_val.prim_val = es.cnst_val;
returned_scope = es.sc;
if (es.IsIndexedProperty)
returned_scope = new IndexedPropertyType(es.sc as TypeScope);
return;
}
else
@ -699,7 +702,9 @@ namespace CodeCompletion
if (returned_scope != null && returned_scope is TypeScope)
{
TypeScope ts = returned_scope as TypeScope;
if (ts.GetFullName() != null && (ts.GetFullName().IndexOf("System.Tuple") == 0 || ts.original_type != null && ts.original_type.GetFullName() != null && ts.original_type.GetFullName().IndexOf("(T1,") == 0))
if (ts is IndexedPropertyType)
returned_scope = (ts as IndexedPropertyType).propertyType;
else if (ts.GetFullName() != null && (ts.GetFullName().IndexOf("System.Tuple") == 0 || ts.original_type != null && ts.original_type.GetFullName() != null && ts.original_type.GetFullName().IndexOf("(T1,") == 0))
{
if (_indexer.indexes.expressions[0] is int32_const)
{
@ -1220,6 +1225,8 @@ namespace CodeCompletion
pr.already_defined = true;
pr.loc = cur_loc;
pr.head_loc = loc;
if (topScope.ElemKind == SymbolKind.Interface)
pr.si.not_include = true;
is_realization = true;
entry_scope.AddName("$method", pr);
}
@ -2867,7 +2874,7 @@ namespace CodeCompletion
if (_method_name.meth_name is operator_name_ident)
_method_name.meth_name.visit(this);
else
meth_name = _method_name.meth_name.name;
meth_name = _method_name.meth_name.name;
}
public override void visit(dot_node _dot_node)
@ -2921,8 +2928,11 @@ namespace CodeCompletion
}
else if (returned_scope is ElementScope)
{
this.cnst_val.prim_val = (returned_scope as ElementScope).cnst_val;
returned_scope = (returned_scope as ElementScope).sc;
ElementScope es = returned_scope as ElementScope;
this.cnst_val.prim_val = es.cnst_val;
returned_scope = es.sc;
if (es.IsIndexedProperty)
returned_scope = new IndexedPropertyType(es.sc as TypeScope);
return;
}
else if (returned_scope is TypeScope)

View file

@ -507,15 +507,18 @@ namespace CodeCompletion
_indexer.dereferencing_value.visit(this);
if (returned_scope != null)
{
ElementScope es = returned_scope as ElementScope;
if (returned_scope != null)
if (returned_scope is ElementScope && (returned_scope as ElementScope).sc is ProcScope && ((returned_scope as ElementScope).sc as ProcScope).return_type != null)
returned_scope = new ElementScope(((returned_scope as ElementScope).sc as ProcScope).return_type.GetElementType());
if (es != null && es.sc is ProcScope && (es.sc as ProcScope).return_type != null)
returned_scope = new ElementScope((es.sc as ProcScope).return_type.GetElementType());
else if (returned_scope is ProcScope && (returned_scope as ProcScope).is_constructor)
returned_scope = new ElementScope((returned_scope as ProcScope).declaringType.GetElementType());
else if (returned_scope is ElementScope && (returned_scope as ElementScope).sc is TypeScope)
else if (es != null && es.sc is TypeScope)
{
TypeScope ts = (returned_scope as ElementScope).sc as TypeScope;
if (ts.GetFullName() != null && (ts.GetFullName().IndexOf("System.Tuple") == 0 || ts.original_type != null && ts.original_type.GetFullName() != null && ts.original_type.GetFullName().IndexOf("(T1,") == 0))
TypeScope ts = es.sc as TypeScope;
if (es.IsIndexedProperty)
returned_scope = new ElementScope(ts);
else if (ts.GetFullName() != null && (ts.GetFullName().IndexOf("System.Tuple") == 0 || ts.original_type != null && ts.original_type.GetFullName() != null && ts.original_type.GetFullName().IndexOf("(T1,") == 0))
{
if (_indexer.indexes.expressions[0] is int32_const)
{

View file

@ -1446,6 +1446,15 @@ namespace CodeCompletion
}
}
public bool IsIndexedProperty
{
get
{
return this.ElemKind == SymbolKind.Property && indexers != null && indexers.Count > 0;
}
}
public PascalABCCompiler.SyntaxTree.parametr_kind ParamKind
{
get
@ -1854,6 +1863,16 @@ namespace CodeCompletion
}
}
public class IndexedPropertyType : TypeScope
{
public TypeScope propertyType;
public IndexedPropertyType(TypeScope propertyType)
{
this.propertyType = propertyType;
}
}
public class ProcType : TypeScope, IProcType
{
public ProcScope target;

View file

@ -0,0 +1,9 @@
type
t1 = class
static property p1[i: integer]: sequence of integer read Arr(0);
end;
begin
var x{@var x: sequence of integer;@} := t1.p1[0];
t1.p1[0].Average{@(расширение sequence of T) function Average(): real;@}();
end.