public Declaration FindMemberEnclosingModule(Declaration callingModule, Declaration callingParent, string memberName, DeclarationType memberType) { // We do not explicitly pass the callingProject here because we have to walk up the type hierarchy // and thus the project differs depending on the callingModule. var callingProject = Declaration.GetProjectParent(callingModule); var allMatches = MatchName(memberName); var memberMatches = allMatches.Where(m => m.DeclarationType.HasFlag(memberType) && Declaration.GetProjectParent(m).Equals(callingProject) && callingModule.Equals(Declaration.GetModuleParent(m))); var accessibleMembers = memberMatches.Where(m => AccessibilityCheck.IsMemberAccessible(callingProject, callingModule, callingParent, m)); var match = accessibleMembers.FirstOrDefault(); if (match != null) { return(match); } // Classes such as Worksheet have properties such as Range that can be access in a user defined class such as Sheet1, // that's why we have to walk the type hierarchy and find these implementations. foreach (var supertype in ClassModuleDeclaration.GetSupertypes(callingModule)) { // Only built-in classes such as Worksheet can be considered "real base classes". // User created interfaces work differently and don't allow accessing accessing implementations. if (!supertype.IsBuiltIn) { continue; } var supertypeMatch = FindMemberEnclosingModule(supertype, callingParent, memberName, memberType); if (supertypeMatch != null) { return(supertypeMatch); } } return(match); }
public Declaration FindDefaultInstanceVariableClassEnclosingProject(Declaration callingProject, Declaration callingModule, string defaultInstanceVariableClassName) { var nameMatches = MatchName(defaultInstanceVariableClassName); var moduleMatches = nameMatches.Where(m => m.DeclarationType == DeclarationType.ClassModule && ((ClassModuleDeclaration)m).HasDefaultInstanceVariable && Declaration.GetProjectParent(m).Equals(callingProject)); var accessibleModules = moduleMatches.Where(calledModule => AccessibilityCheck.IsModuleAccessible(callingProject, callingModule, calledModule)); var match = accessibleModules.FirstOrDefault(); return(match); }
public Declaration FindModuleEnclosingProjectWithoutEnclosingModule(Declaration callingProject, Declaration callingModule, string calleeModuleName, DeclarationType moduleType) { var nameMatches = MatchName(calleeModuleName); var moduleMatches = nameMatches.Where(m => m.DeclarationType.HasFlag(moduleType) && Declaration.GetProjectParent(m).Equals(callingProject) && !m.Equals(callingModule)); var accessibleModules = moduleMatches.Where(calledModule => AccessibilityCheck.IsModuleAccessible(callingProject, callingModule, calledModule)); var match = accessibleModules.FirstOrDefault(); return(match); }
public Declaration FindMemberEnclosedProjectWithoutEnclosingModule(Declaration callingProject, Declaration callingModule, Declaration callingParent, string memberName, DeclarationType memberType) { var project = callingProject; var module = callingModule; var parent = callingParent; var allMatches = MatchName(memberName); var memberMatches = allMatches.Where(m => m.DeclarationType.HasFlag(memberType) && Declaration.GetModuleParent(m).DeclarationType == DeclarationType.ProceduralModule && Declaration.GetProjectParent(m).Equals(callingProject) && !callingModule.Equals(Declaration.GetModuleParent(m))); var accessibleMembers = memberMatches.Where(m => AccessibilityCheck.IsMemberAccessible(callingProject, callingModule, callingParent, m)); var match = accessibleMembers.FirstOrDefault(); return(match); }
public Declaration FindMemberEnclosedProjectInModule(Declaration callingProject, Declaration callingModule, Declaration callingParent, Declaration memberModule, string memberName, DeclarationType memberType) { var allMatches = MatchName(memberName); var memberMatches = allMatches.Where(m => m.DeclarationType.HasFlag(memberType) && Declaration.GetProjectParent(m).Equals(callingProject) && memberModule.Equals(Declaration.GetModuleParent(m))); var accessibleMembers = memberMatches.Where(m => AccessibilityCheck.IsMemberAccessible(callingProject, callingModule, callingParent, m)); var match = accessibleMembers.FirstOrDefault(); if (match != null) { return(match); } foreach (var supertype in ClassModuleDeclaration.GetSupertypes(memberModule)) { var supertypeMember = FindMemberEnclosedProjectInModule(callingProject, callingModule, callingParent, supertype, memberName, memberType); if (supertypeMember != null) { return(supertypeMember); } } return(null); }
public Declaration FindMemberReferencedProject(Declaration callingProject, Declaration callingModule, Declaration callingParent, Declaration referencedProject, string memberName, DeclarationType memberType) { var memberMatches = FindAllInReferencedProjectByPriority(callingProject, memberName, p => p.DeclarationType.HasFlag(memberType) && referencedProject.Equals(Declaration.GetProjectParent(p))); var accessibleMembers = memberMatches.Where(m => AccessibilityCheck.IsMemberAccessible(callingProject, callingModule, callingParent, m)); var match = accessibleMembers.FirstOrDefault(); return(match); }
public Declaration FindDefaultInstanceVariableClassReferencedProject(Declaration callingProject, Declaration callingModule, Declaration referencedProject, string calleeModuleName) { var moduleMatches = FindAllInReferencedProjectByPriority(callingProject, calleeModuleName, p => referencedProject.Equals(Declaration.GetProjectParent(p)) && p.DeclarationType == DeclarationType.ClassModule && ((ClassModuleDeclaration)p).HasDefaultInstanceVariable); var accessibleModules = moduleMatches.Where(calledModule => AccessibilityCheck.IsModuleAccessible(callingProject, callingModule, calledModule)); var match = accessibleModules.FirstOrDefault(); return(match); }
public Declaration FindModuleReferencedProject(Declaration callingProject, Declaration callingModule, Declaration referencedProject, string calleeModuleName, DeclarationType moduleType) { var moduleMatches = FindAllInReferencedProjectByPriority(callingProject, calleeModuleName, p => referencedProject.Equals(Declaration.GetProjectParent(p)) && p.DeclarationType.HasFlag(moduleType)); var accessibleModules = moduleMatches.Where(calledModule => AccessibilityCheck.IsModuleAccessible(callingProject, callingModule, calledModule)); var match = accessibleModules.FirstOrDefault(); return(match); }