public static void AddLocToComponent(uint NodeId, uint Key, ulong lastLineNumber) { TLOC.InsertComponentTLOCMap(NodeId, Key, lastLineNumber); var itBegin = MainDeclaration.Instance.RevEdges.constIteratorBegin(NodeId, Types.EdgeKind.edkComponent_Contains); while (itBegin.getValue( ) != null) { AddLocToComponent(itBegin.getValue( ).Id, Key, lastLineNumber); itBegin = itBegin.getNext( ); } }
public static void SetLOC(this Scope limScope) { var intervals = new List <Interval>( ); var m_LOC = ( long )TLOC.Calculate(limScope, ref intervals); if (m_LOC == 0) { return; } unchecked { limScope.TLOC = ( uint )m_LOC; } var memberIt = limScope.HasMemberListIteratorBegin; while (memberIt.getValue( ) != null) { var member = memberIt.getValue( ); // the contents of a method count while its inner member's contents do not // so we calculate the difference between the method's LOC and TLOC first // and subtract only that from the enclosing scope's LOC. if (Lim.Asg.Common.getIsMethod(member) && !Lim.Asg.Common.getIsMethod(limScope)) { var method = member as Method; method.SetLOC( ); var methodLOC = method.LOC; var temp = new List <Interval>( ); var methodTLOC = ( uint )TLOC.Calculate(method, ref temp); m_LOC -= (methodTLOC - methodLOC); } else if (Lim.Asg.Common.getIsScope(member) && limScope.LessOrEqualsThan(member as Scope) && limScope.Id != MainDeclaration.Instance.LimFactory.Root) { var visitedBorders = new Dictionary <uint, HashSet <uint> >( ); var memberScope = member as Scope; var memberIntervals = new List <Interval>( ); var memberTLOC = TLOC.Calculate(memberScope, ref memberIntervals); m_LOC -= (long)memberTLOC; foreach (var interval in memberIntervals) { if (BorderCounts(limScope, interval.Key, interval.From, ref visitedBorders)) { m_LOC++; } if (BorderCounts(limScope, interval.Key, interval.To, ref visitedBorders)) { m_LOC++; } } } memberIt = memberIt.getNext( ); } if (m_LOC < 0) { //Console.WriteLine("Debug: would have been negative, set to 0"); m_LOC = 0; } limScope.LOC = ( uint )m_LOC; }