public static void AddTypes (ProjectProperties projectprop, MetricsContext ctx) { ProjectDom dom = ProjectDomService.GetProjectDom (projectprop.Project); foreach (IType ob in dom.Types) { projectprop.AddInstance(ob); } }
public static void AddTypes (ProjectProperties projectprop, MetricsContext ctx) { var dom = TypeSystemService.GetCompilation (projectprop.Project); foreach (var ob in dom.MainAssembly.GetAllTypeDefinitions ()) { projectprop.AddInstance(ob); } }
public static void EvaluateOOMetrics (MetricsContext ctx, ProjectProperties projprop) { foreach(var cls in projprop.Classes) ObjectOrientedMetrics.ClassEvaluateInheritanceTree(ctx, cls.Value); foreach (var namesp in projprop.Namespaces){ foreach (var cls in namesp.Value.Classes){ ObjectOrientedMetrics.ClassEvaluateInheritanceTree(ctx, cls.Value); } } }
internal static void ProcessInnerTypes(ProjectProperties projprop) { foreach (var namesp in projprop.Namespaces) { namesp.Value.ProcessClasses(); projprop.CyclometricComplexity += namesp.Value.CyclometricComplexity; projprop.LOCReal += namesp.Value.LOCReal; projprop.LOCComments += namesp.Value.LOCComments; } foreach (var cls in projprop.Classes) { cls.Value.ProcessInnerClasses(); projprop.CyclometricComplexity += cls.Value.CyclometricComplexity; projprop.LOCReal += cls.Value.LOCReal; projprop.LOCComments += cls.Value.LOCComments; } }
public static void EvaluateComplexityMetrics (MetricsContext ctx, ProjectProperties project) { mctx = ctx; PrefixName = new Stack<string>(0); lock(mctx) { foreach (var file in project.Project.Files) { /*if(file.BuildAction != BuildAction.Compile) continue;*/ // Files not set to compile are sometimes not accessible if(file.Name.Contains("svn-base")) continue; string text=""; try { text = System.IO.File.ReadAllText(file.FilePath); } catch (System.UnauthorizedAccessException uae) { continue; } catch (System.IO.FileNotFoundException fnf) { // This exception arises in Nrefactory...WTF? 0_0 continue; } ProjProp = project; File = file; Mono.TextEditor.Document doc = new Mono.TextEditor.Document (); doc.Text = text; FileDoc = doc; FileText = new List<LineSegment>(); foreach(LineSegment segment in doc.Lines) FileText.Add(segment); using (ICSharpCode.NRefactory.IParser parser = ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader(text))) { parser.Parse(); if (parser.Errors.Count > 0) { //Error handling TODO } else { foreach (var it in parser.CompilationUnit.Children) { ProcessNode (ctx, it); } } } } } }
protected void FillTree (ProjectProperties projprop) { var rootIter = widget.metricStore.AppendValues ( ImageService.GetPixbuf("md-project", Gtk.IconSize.Menu), projprop.Project.Name, projprop.CyclometricComplexity.ToString(), "", projprop.LOCReal.ToString(), projprop.LOCComments.ToString(), projprop); FillNamespaces(projprop.Namespaces, rootIter); FillClasses(projprop.Classes, rootIter); FillEnums(projprop.Enums, rootIter); FillStructs(projprop.Structs, rootIter); FillDelegates(projprop.Delegates, rootIter); FillInterfaces(projprop.Interfaces, rootIter); }