protected void CreateMethodClip( MethodComponent method, int maxLength, int x, int y, int w, int h ) { MovieClip clip = m_panelClip.CreateSubMovieClip( x, y, w, h ); clip.Object = method; // Back rectangle clip.Graphics.FillRectangle( m_backBrush, 0, 0, w, h); double length = method.Lines.Count; double smell_width = w *(length / maxLength); // Smell rectangle clip.Graphics.FillRectangle( m_smellBrush, 0, 0, (int)smell_width, h ); // Iteration/Conditional/Comment markings int lineCount = 0; foreach( LineModel model in method.Lines ) { Pen pen = GetPen( model ); // Hack if( pen != null ) { double ratio = lineCount/length; int mark_x = (int)(ratio*smell_width); clip.Graphics.DrawLine( pen, mark_x, 0, mark_x, h ); } lineCount++; } clip.CenteredString( method.Name + "() " + method.Lines.Count ); }
public int Compare(object x, object y) { MethodComponent xx = (MethodComponent)x; MethodComponent yy = (MethodComponent)y; int value = xx.Lines.Count.CompareTo(yy.Lines.Count); return(value * (m_direction == SortDirection.Ascending ? 1 : -1)); }
public SwitchStatementComponent( MethodComponent unit, string name) : base( name, name ) { this.MethodComponent = unit; }
protected void CollectTemporaryFieldDefs( Hashtable htDefs, Hashtable htUses, MethodComponent m, LineModel line, string strLine ) { if( line.HasCode && line.HasAssignment ) { foreach( FieldComponent tempfield in htUses.Keys ) { int idx = strLine.IndexOf( tempfield.Name ); if( idx > -1 && idx < strLine.IndexOf("=") ) { if( htDefs[ tempfield ] == null ) { htDefs[ tempfield ] = new ArrayList(); } if( ! ((ArrayList)htDefs[ tempfield ] ).Contains( m ) ) { ((ArrayList)htDefs[ tempfield ]).Add( m ); } } } } }
protected void CollectTemporaryFieldUses( Hashtable htUses, ClassComponent cls, MethodComponent m, LineModel line, string strLine ) { if( line.HasConditional ) { foreach( FieldComponent field in cls.Fields ) { if( strLine.IndexOf( field.Name ) > -1) { if( htUses[ field ] == null ) { htUses[ field ] = new ArrayList(); } if( ! ((ArrayList)htUses[ field ]).Contains( m ) ) { ((ArrayList)htUses[ field ]).Add( m ); } } } } }
protected void WalkElements( CodeElement cein, AbstractComponent parent ) { CodeElements ces; switch( cein.Kind ) { // Handle namespaces case EnvDTE.vsCMElement.vsCMElementNamespace: { CodeNamespace cn = (CodeNamespace) cein; ces = cn.Members; foreach (CodeElement ce in ces) WalkElements(ce, parent ); break; } // Handle classes case EnvDTE.vsCMElement.vsCMElementClass: { CodeClass cc = (CodeClass) cein; ClassComponent cls = new ClassComponent( cc.FullName, cc.Name ); cls.CodeClass = cc; parent.Visit( cls ); ces = cc.Members; foreach (CodeElement ce in ces) WalkElements(ce, cls ); break; } // Handle interfaces case EnvDTE.vsCMElement.vsCMElementInterface: { CodeInterface ci = (CodeInterface) cein; // nothing for now. break; } // Handle methods (functions) case EnvDTE.vsCMElement.vsCMElementFunction: { CodeFunction cf = (CodeFunction) cein; MethodComponent mc = new MethodComponent( cf.FullName, cf.Name ); parent.Visit( mc ); mc.CreateRepresentation( GetFunctionText( cf ) ); mc.CodeFunction = cf; break; } // Handle properties case EnvDTE.vsCMElement.vsCMElementProperty: { CodeProperty cp = (CodeProperty) cein; PropertyComponent pc = new PropertyComponent( cp.FullName, cp.Name ); parent.Visit( pc ); break; } // Handle fields (variables) case EnvDTE.vsCMElement.vsCMElementVariable: { CodeVariable cv = (CodeVariable) cein; FieldComponent fc = new FieldComponent( cv.FullName, cv.Name ); parent.Visit( fc ); break; } } }