internal void AddBaseConstruct(IBaseConstruct bc, Version t) { baseConstructs.SetObject(bc, t); foreach (IBaseConstruct bcChild in bc.WalkChildren()) { bool found = false; foreach (CodeRootMapNode crChild in children) { if (!crChild.IsTheSame(bcChild)) { continue; } crChild.AddBaseConstruct(bcChild, t); found = true; break; } if (!found) { AddBaseConstructAsNewChild(bcChild, t); } } }
internal void RemoveBaseConstruct(IBaseConstruct bc, bool cleanUpTree) { if (bc == null) { return; } if (UserObj == bc) { UserObj = null; } else if (NewGenObj == bc) { NewGenObj = null; } else if (PrevGenObj == bc) { PrevGenObj = null; } else { return; } foreach (IBaseConstruct child in bc.WalkChildren()) { GetChildNode(child).RemoveBaseConstruct(child, false); } if (cleanUpTree) { ParentTree.CleanUpTree(); } }
/// <summary> /// Returns the IBaseConstruct for Class1 /// </summary> /// <param name="cr"></param> /// <returns></returns> private static void AssertBasicConstructsExist(ICodeRoot cr) { Assert.That(cr.WalkChildren(), Has.Count(1)); IBaseConstruct namespaceBC = cr.WalkChildren()[0]; Assert.That(namespaceBC.FullyQualifiedIdentifer, Is.EqualTo("Slyce.IntelliMerge.UnitTesting.Resources.CSharp")); Assert.That(namespaceBC.WalkChildren(), Has.Count(1)); IBaseConstruct classBC = namespaceBC.WalkChildren()[0]; Assert.That(classBC.FullyQualifiedIdentifer, Is.EqualTo(string.Format("Slyce.IntelliMerge.UnitTesting.Resources.CSharp{0}Class1", BaseConstructConstants.FullyQualifiedIdentifierSeparator))); Assert.That(classBC.WalkChildren(), Has.Count(1)); IBaseConstruct methodBC = classBC.WalkChildren()[0]; Assert.That(methodBC.FullyQualifiedIdentifer, Is.EqualTo(string.Format("Slyce.IntelliMerge.UnitTesting.Resources.CSharp{0}Class1{0}Method ()", BaseConstructConstants.FullyQualifiedIdentifierSeparator))); return; }
/// <summary> /// Adds the Base Construct to this node, and processes its children to add them too. /// </summary> /// <param name="bc"></param> /// <param name="t"></param> public CodeRootMapNode AddBaseConstructAsNewChild(IBaseConstruct bc, Version t) { if (bc == null) { return(null); } CodeRootMapNode node = new CodeRootMapNode(ParentTree, this); node.SetBaseConstruct(bc, t); foreach (IBaseConstruct child in bc.WalkChildren()) { node.AddBaseConstructAsNewChild(child, t); } return(node); }
public static void SetupBaseConstructs(MockRepository mocks, IBaseConstruct bc1, IBaseConstruct bc2, ICodeRoot coderoot) { using (mocks.Record()) { Expect.Call(bc1.ShortName).Repeat.Any().Return("bc1"); Expect.Call(bc2.ShortName).Repeat.Any().Return("bc2"); Expect.Call(bc1.IsTheSame(bc1)).Repeat.Any().Return(true); Expect.Call(bc2.IsTheSame(bc2)).Repeat.Any().Return(true); Expect.Call(bc2.WalkChildren()).Repeat.AtLeastOnce().Return(new List <IBaseConstruct>().AsReadOnly()); List <IBaseConstruct> bc1Children = new List <IBaseConstruct>(); bc1Children.Add(bc2); Expect.Call(bc1.WalkChildren()).Repeat.AtLeastOnce().Return(bc1Children.AsReadOnly()); List <IBaseConstruct> rootChildren = new List <IBaseConstruct>(); rootChildren.Add(bc1); Expect.On(coderoot).Call(coderoot.WalkChildren()).Repeat.AtLeastOnce().Return(rootChildren.AsReadOnly()); } }
public static void SetupBaseConstructs(MockRepository mocks, IBaseConstruct bc1, IBaseConstruct bc2, ICodeRoot coderoot) { using(mocks.Record()) { Expect.Call(bc1.ShortName).Repeat.Any().Return("bc1"); Expect.Call(bc2.ShortName).Repeat.Any().Return("bc2"); Expect.Call(bc1.IsTheSame(bc1)).Repeat.Any().Return(true); Expect.Call(bc2.IsTheSame(bc2)).Repeat.Any().Return(true); Expect.Call(bc2.WalkChildren()).Repeat.AtLeastOnce().Return(new List<IBaseConstruct>().AsReadOnly()); List<IBaseConstruct> bc1Children = new List<IBaseConstruct>(); bc1Children.Add(bc2); Expect.Call(bc1.WalkChildren()).Repeat.AtLeastOnce().Return(bc1Children.AsReadOnly()); List<IBaseConstruct> rootChildren = new List<IBaseConstruct>(); rootChildren.Add(bc1); Expect.On(coderoot).Call(coderoot.WalkChildren()).Repeat.AtLeastOnce().Return(rootChildren.AsReadOnly()); } }