Fix cyclic dependency crash in GetRealUsedUnitsTransitive (#3419)
This commit is contained in:
parent
f61cd7770c
commit
0ffe331599
|
|
@ -542,47 +542,41 @@ namespace CodeCompletion
|
|||
/// </summary>
|
||||
public SymScope[] GetRealUsedUnitsTransitive(bool includeImplementationDependenciesForUnit = true)
|
||||
{
|
||||
var usedUnits = new List<SymScope>();
|
||||
var unitsList = new List<SymScope>();
|
||||
|
||||
if (used_units != null)
|
||||
HashSet<SymScope> visited = new HashSet<SymScope>();
|
||||
|
||||
void CollectUnitsHelper(SymScope currentScope)
|
||||
{
|
||||
usedUnits.AddRange(used_units.Where(unit => unit.file_name != null));
|
||||
IEnumerable<SymScope> usedUnitsLocal = currentScope.used_units?.Where(unit => unit.file_name != null);
|
||||
|
||||
foreach (var unit in usedUnitsLocal)
|
||||
{
|
||||
if (unitsList.Find(u => u.file_name == unit.file_name) == null)
|
||||
unitsList.Add(unit);
|
||||
}
|
||||
|
||||
if (this is InterfaceUnitScope interfaceScope && includeImplementationDependenciesForUnit && interfaceScope.impl_scope != null)
|
||||
if (currentScope is InterfaceUnitScope interfaceScope && includeImplementationDependenciesForUnit && interfaceScope.impl_scope != null)
|
||||
{
|
||||
foreach (var recursiveUsedUnit in interfaceScope.impl_scope.GetRealUsedUnitsTransitive(true))
|
||||
{
|
||||
if (recursiveUsedUnit == this)
|
||||
continue;
|
||||
CollectUnitsHelper(interfaceScope.impl_scope);
|
||||
}
|
||||
|
||||
if (usedUnits.FirstOrDefault(unit => unit.file_name == recursiveUsedUnit.file_name) == null)
|
||||
foreach (var unit in usedUnitsLocal)
|
||||
{
|
||||
usedUnits.Add(recursiveUsedUnit);
|
||||
if (!visited.Contains(unit))
|
||||
{
|
||||
visited.Add(unit);
|
||||
CollectUnitsHelper(unit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (used_units != null)
|
||||
{
|
||||
foreach (var usedUnit in used_units)
|
||||
{
|
||||
var recursiveUsedUnits = usedUnit.GetRealUsedUnitsTransitive(includeImplementationDependenciesForUnit);
|
||||
visited.Add(this);
|
||||
CollectUnitsHelper(this);
|
||||
|
||||
foreach (var recursiveUsedUnit in recursiveUsedUnits)
|
||||
{
|
||||
if (recursiveUsedUnit == this)
|
||||
continue;
|
||||
unitsList.Remove(this);
|
||||
|
||||
if (usedUnits.FirstOrDefault(unit => unit.file_name == recursiveUsedUnit.file_name) == null)
|
||||
{
|
||||
usedUnits.Add(recursiveUsedUnit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return usedUnits.ToArray();
|
||||
return unitsList.ToArray();
|
||||
}
|
||||
|
||||
public virtual string GetFullName()
|
||||
|
|
|
|||
|
|
@ -165,6 +165,8 @@ namespace VisualPascalABC
|
|||
}
|
||||
}
|
||||
}
|
||||
if (recomp_files.Count > 0)
|
||||
{
|
||||
foreach (string FileName in filesToParse.Keys.ToArray()) // копирование ключей обязательно, иначе будет InvalidOperationException EVA
|
||||
{
|
||||
CodeCompletion.DomConverter dc = CodeCompletion.CodeCompletionController.comp_modules[FileName] as CodeCompletion.DomConverter;
|
||||
|
|
@ -201,6 +203,8 @@ namespace VisualPascalABC
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (is_comp && mem_delta > 20000000 /*&& mem_delta > 10000000*/)
|
||||
//postavil delta dlja pamjati, posle kototoj delaetsja sborka musora
|
||||
{
|
||||
|
|
|
|||
|
|
@ -170,6 +170,8 @@ namespace VisualPascalABC
|
|||
}
|
||||
}
|
||||
}
|
||||
if (recomp_files.Count > 0)
|
||||
{
|
||||
foreach (string FileName in filesToParse.Keys.ToArray()) // копирование ключей обязательно, иначе будет InvalidOperationException EVA
|
||||
{
|
||||
CodeCompletion.DomConverter dc = CodeCompletion.CodeCompletionController.comp_modules[FileName] as CodeCompletion.DomConverter;
|
||||
|
|
@ -206,6 +208,7 @@ namespace VisualPascalABC
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_comp && mem_delta > 20000000 /*&& mem_delta > 10000000*/)
|
||||
//postavil delta dlja pamjati, posle kototoj delaetsja sborka musora
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue