diff --git a/CodeCompletion/SymTable.cs b/CodeCompletion/SymTable.cs index 9da706673..090b959e0 100644 --- a/CodeCompletion/SymTable.cs +++ b/CodeCompletion/SymTable.cs @@ -441,13 +441,12 @@ namespace CodeCompletion else tmp_ts = tmp_ts.baseScope; } - if (ts.implemented_interfaces != null && !(ts is ArrayScope && (!(ts as ArrayScope).is_dynamic_arr || (ts as ArrayScope).Rank > 1))) + + var implementedInterfaces = ts.GetAllImplementedInterfaces(); + + if (implementedInterfaces != null) { - List implemented_interfaces = new List(); - implemented_interfaces.AddRange(ts.implemented_interfaces); - if (ts is ArrayScope) - implemented_interfaces.Add((ts as ArrayScope).ilist); - foreach (TypeScope int_ts in implemented_interfaces) + foreach (TypeScope int_ts in implementedInterfaces) { TypeScope int_ts2 = int_ts; if (int_ts is CompiledScope && (int_ts as CompiledScope).CompiledType.IsGenericType && !(int_ts as CompiledScope).CompiledType.IsGenericTypeDefinition) @@ -467,7 +466,7 @@ namespace CodeCompletion if (t.GenericTypeDefinition == int_ts2.GenericTypeDefinition || t.IsEqual(int_ts2) || (t is ArrayScope && int_ts2.IsArray && t.Rank == int_ts2.Rank) || (int_ts2 is ArrayScope && t.IsArray && int_ts2.Rank == t.Rank) || - t is FileScope && int_ts2 is FileScope && + t is FileScope && int_ts2 is FileScope && ((t as FileScope).elementType == null) == ((int_ts2 as FileScope).elementType == null)) { var meth_list = extension_methods[t]; @@ -479,11 +478,9 @@ namespace CodeCompletion //break; } } - } } } - } if (this.used_units != null) for (int i = 0; i < this.used_units.Count; i++) @@ -3338,6 +3335,11 @@ namespace CodeCompletion return actType.GetNamesAsInObject(); } + public override List GetAllImplementedInterfaces() + { + return actType.GetAllImplementedInterfaces(); + } + public override TypeScope[] GetIndexers() { return actType.GetIndexers(); @@ -3530,6 +3532,11 @@ namespace CodeCompletion return actType.GetNamesAsInObject(); } + public override List GetAllImplementedInterfaces() + { + return actType.GetAllImplementedInterfaces(); + } + public override TypeScope[] GetIndexers() { return actType.GetIndexers(); @@ -3775,6 +3782,14 @@ namespace CodeCompletion return new SymInfo[0]; } + public override List GetAllImplementedInterfaces() + { + if (!is_dynamic_arr && !IsMultiDynArray) + return new List(); + + return base.GetAllImplementedInterfaces(); + } + public override List FindOverloadNamesOnlyInType(string name) { if (!is_dynamic_arr && !IsMultiDynArray) @@ -4569,6 +4584,45 @@ namespace CodeCompletion return procs; } + /// + /// Возвращает все реализуемые интерфейсы (включая интерфейсы, реализуемые классами предками и базовые интерфейсы для реализуемых интерфейсов). + /// Если реализуемых интерфейсов нет, то возвращается пустой список + /// + public virtual List GetAllImplementedInterfaces() + { + var implementedInterfaces = new List(); + + if (implemented_interfaces != null) + implementedInterfaces.AddRange(implemented_interfaces); + + if (baseScope != null) + { + var recursiveInterfaces = baseScope.GetAllImplementedInterfaces(); + + foreach (var _interface in recursiveInterfaces) + { + if (!implementedInterfaces.Contains(_interface)) + implementedInterfaces.Add(_interface); + } + } + + if (implemented_interfaces != null) + { + foreach (var _interface in implemented_interfaces) + { + var recursiveInterfaces = _interface.GetAllImplementedInterfaces(); + + foreach (var interface2 in recursiveInterfaces) + { + if (!implementedInterfaces.Contains(interface2)) + implementedInterfaces.Add(interface2); + } + } + } + + return implementedInterfaces; + } + public virtual List GetMethods() { List procs = new List(); @@ -6209,6 +6263,15 @@ namespace CodeCompletion return syms; } + public override List GetAllImplementedInterfaces() + { + // Здесь все сразу записаны в поле, поскольку так работает GetInterfaces() из .NET + if (implemented_interfaces != null) + return implemented_interfaces.ToList(); + + return new List(); + } + private void AddIndexers() { List indexers = new List();