コード例 #1
0
ファイル: LongMethod.cs プロジェクト: Robby777/ambientsmell
		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 );
		}
コード例 #2
0
        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));
        }
コード例 #3
0
		public SwitchStatementComponent( MethodComponent unit, string name) : base( name, name )
		{
			this.MethodComponent = unit;
		}
コード例 #4
0
		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 );
						}
					}
				}
			}
		}
コード例 #5
0
		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 );
						}
					}
				}
			}
		}
コード例 #6
0
ファイル: FileScanner.cs プロジェクト: Robby777/ambientsmell
		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;
				}
			}
		}