Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        public Declaration FindMemberReferencedProjectInGlobalClassModule(Declaration callingProject, Declaration callingModule, Declaration callingParent, string memberName, DeclarationType memberType)
        {
            var memberMatches     = FindAllInReferencedProjectByPriority(callingProject, memberName, p => p.DeclarationType.HasFlag(memberType) && (Declaration.GetModuleParent(p) == null || Declaration.GetModuleParent(p).DeclarationType == DeclarationType.ClassModule) && ((ClassModuleDeclaration)Declaration.GetModuleParent(p)).IsGlobalClassModule);
            var accessibleMembers = memberMatches.Where(m => AccessibilityCheck.IsMemberAccessible(callingProject, callingModule, callingParent, m));
            var match             = accessibleMembers.FirstOrDefault();

            return(match);
        }
Exemplo n.º 4
0
        public Declaration FindMemberReferencedProject(Declaration callingProject, Declaration callingModule, Declaration callingParent, string memberName, DeclarationType memberType)
        {
            bool isInstanceSensitive = IsInstanceSensitive(memberType);
            var  memberMatches       = FindAllInReferencedProjectByPriority(callingProject, memberName, p => (!isInstanceSensitive || Declaration.GetModuleParent(p) == null || Declaration.GetModuleParent(p).DeclarationType != DeclarationType.ClassModule) && p.DeclarationType.HasFlag(memberType));
            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.GetMemberProject(m).Equals(callingProject) &&
                                                 memberModule.Equals(Declaration.GetMemberModule(m)));
            var accessibleMembers = memberMatches.Where(m => AccessibilityCheck.IsMemberAccessible(callingProject, callingModule, callingParent, m));
            var match             = accessibleMembers.FirstOrDefault();

            return(match);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        public Declaration FindMemberReferencedProjectInModule(Declaration callingProject, Declaration callingModule, Declaration callingParent, Declaration memberModule, string memberName, DeclarationType memberType)
        {
            var memberMatches     = FindAllInReferencedProjectByPriority(callingProject, memberName, p => p.DeclarationType.HasFlag(memberType) && memberModule.Equals(Declaration.GetModuleParent(p)));
            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 = FindMemberReferencedProjectInModule(callingProject, callingModule, callingParent, supertype, memberName, memberType);
                if (supertypeMember != null)
                {
                    return(supertypeMember);
                }
            }
            return(null);
        }
Exemplo n.º 8
0
        public Declaration FindMemberWithParent(Declaration callingProject, Declaration callingModule, Declaration callingParent, Declaration parent, string memberName, DeclarationType memberType)
        {
            var allMatches    = MatchName(memberName);
            var memberMatches = allMatches.Where(m =>
                                                 m.DeclarationType.HasFlag(memberType) &&
                                                 parent.Equals(m.ParentDeclaration));
            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(parent))
            {
                var supertypeMember = FindMemberWithParent(callingProject, callingModule, callingParent, supertype, memberName, memberType);
                if (supertypeMember != null)
                {
                    return(supertypeMember);
                }
            }
            return(null);
        }