public void GetSupertypesReturnsAnEmptyEnumerableForDeclarationsWithDeclarationTypeClassModuleWhichAreNoClassModuleDeclarations() { var projectDeclaration = GetTestProject("testProject"); var fakeClassModule = GetTestFakeClassModule(projectDeclaration, "testFakeClass"); Assert.IsFalse(ClassModuleDeclaration.GetSupertypes(fakeClassModule).Any()); }
public void GetSupertypesReturnsAnEmptyEnumerableForProceduralModules() { var projectDeclaration = GetTestProject("testProject"); var proceduralModule = GetTestProceduralModule(projectDeclaration, "testModule"); Assert.IsFalse(ClassModuleDeclaration.GetSupertypes(proceduralModule).Any()); }
public void GetSupertypesReturnsTheSupertypesOfAClassModule() { var projectDeclaration = GetTestProject("testProject"); var supertype = GetTestClassModule(projectDeclaration, "testSupertype", true, null); var classModule = GetTestClassModule(projectDeclaration, "testClass", true, null); classModule.AddSupertype(supertype); Assert.AreEqual(supertype, ClassModuleDeclaration.GetSupertypes(classModule).First()); }
private static bool IsEnclosingModule(Declaration callingModule, Declaration calleeMember) { if (callingModule.Equals(calleeMember.ParentScopeDeclaration)) { return(true); } foreach (var supertype in ClassModuleDeclaration.GetSupertypes(callingModule)) { if (IsEnclosingModule(supertype, calleeMember)) { return(true); } } return(false); }
private static bool IsInstanceMemberOfModuleOrOneOfItsSupertypes(Declaration module, Declaration member) { return(IsInstanceMemberOfModule(module, member) || ClassModuleDeclaration.GetSupertypes(module).Any(supertype => IsInstanceMemberOfModuleOrOneOfItsSupertypes(supertype, member))); //ClassModuleDeclaration.GetSuperTypes never returns null. }