public void ProcessStuff(ClassComponent cls) { foreach (MethodComponent method in cls.Methods) { int i = 0; SwitchStatementComponent current = null; foreach (LineModel line in method.Lines) { if (line.HasSwitch) { string sw = method.TextLines[i]; int start = sw.IndexOf("(") + 1; int end = sw.LastIndexOf(")"); string typeCode = sw.Substring(start, end - start); if (!m_htTypeCodes.ContainsKey(typeCode)) { m_htTypeCodes[typeCode] = new SwitchStatementComponent(method, typeCode); } current = (SwitchStatementComponent)m_htTypeCodes[typeCode]; current.Count++; } if (line.HasCase && current != null && current.Count == 1) { current.CaseCount++; } i++; } } foreach (ClassComponent inner in cls.InnerClasses) { ProcessStuff(inner); } }
public int Compare(object x, object y) { SwitchStatementComponent xx = (SwitchStatementComponent)x; SwitchStatementComponent yy = (SwitchStatementComponent)y; int value = xx.Count.CompareTo(yy.Count); if (value == 0) { value = xx.CaseCount.CompareTo(yy.CaseCount); } return(value * (m_direction == SortDirection.Ascending ? 1 : -1)); }
protected void CreateMethodClip( SwitchStatementComponent swtch, int x, int y, int w, int h ) { MovieClip clip = m_panelClip.CreateSubMovieClip( x, y, w, h ); clip.Object = swtch.MethodComponent; // Back rectangle clip.Graphics.FillRectangle( m_backBrush, 0, 0, w, h); // Dots MovieClip dots = clip.CreateSubMovieClip( (3*w)/4, 0, w/4, h ); dots.Object = swtch.MethodComponent; for( int d = 0; d < swtch.CaseCount; d++ ) { // extra spacing in between disconnected chains? MovieClip dot = dots.CreateSubMovieClip( 0, 0, 4, 4 ); dot.Graphics.FillEllipse( Brushes.Yellow, 0, 0, 3, 3 ); } Space( 2, 2, dots.Children, dots.Width ); // Text clip.LeftString( swtch.Name + " (" + swtch.Count + ")", Brushes.White ); }
public void ProcessStuff( ClassComponent cls ) { foreach( MethodComponent method in cls.Methods ) { int i = 0; SwitchStatementComponent current = null; foreach( LineModel line in method.Lines ) { if( line.HasSwitch ) { string sw = method.TextLines[i]; int start = sw.IndexOf( "(" ) + 1; int end = sw.LastIndexOf( ")" ); string typeCode = sw.Substring( start, end - start ); if( ! m_htTypeCodes.ContainsKey( typeCode ) ) { m_htTypeCodes[ typeCode ] = new SwitchStatementComponent( method, typeCode ); } current = (SwitchStatementComponent)m_htTypeCodes[ typeCode ]; current.Count++; } if( line.HasCase && current != null && current.Count == 1) { current.CaseCount++; } i++; } } foreach( ClassComponent inner in cls.InnerClasses ) { ProcessStuff( inner ); } }