public override bool Equals(object obj) { InheritanceNode testObj = obj as InheritanceNode; return(testObj.classDecl == this.classDecl && testObj.subClasses.SequenceEqual(this.subClasses)); }
// returns the InheritanceTree for a given method public InheritanceTree GetInheritanceTree(MethodDeclarationSyntax method) { InheritanceNode rootClass = new InheritanceNode(GetClass(method)); InheritanceNode tree = CreateSubTree(rootClass, method); return(new InheritanceTree(method, rootClass)); }
// recoursivly creates an inheritance tree for a given method and it's given base class public InheritanceNode CreateSubTree(InheritanceNode tree, MethodDeclarationSyntax method) { ClassDeclarationSyntax baseClass = tree.GetBaseClass(); List <ClassDeclarationSyntax> methodInheritedClasses = GetDirectDerivedClasses(baseClass).Where(c => !ClassOverridesOrHidesMethod(c, method)).ToList(); tree.SetSubClasses(methodInheritedClasses.Select(c => new InheritanceNode(c)).ToList()); foreach (var subClass in tree.GetSubClasses()) { CreateSubTree(subClass, method); } return(tree); }
public InheritanceTree(MethodDeclarationSyntax method, InheritanceNode rootClass) { this.method = method; this.rootClass = rootClass; }