Exemple #1
0
        private IBoundExpression ResolveModuleReferencedProjectNamespace()
        {
            /*  Namespace tier 6:
             *  Module in Referenced Project namespace: An accessible variable, constant, Enum type,
             *  Enum member, property, function or subroutine defined in a procedural module or as a member
             *  of the default instance of a global class module within a referenced project.
             */

            // Part 1: Procedural module as parent
            var accessibleVariable = _declarationFinder.FindMemberReferencedProjectInModule(_project, _module, _parent, DeclarationType.ProceduralModule, _name, DeclarationType.Variable);

            if (IsValidMatch(accessibleVariable, _name))
            {
                return(new SimpleNameExpression(accessibleVariable, ExpressionClassification.Variable, _context));
            }
            var accessibleConstant = _declarationFinder.FindMemberReferencedProjectInModule(_project, _module, _parent, DeclarationType.ProceduralModule, _name, DeclarationType.Constant);

            if (IsValidMatch(accessibleConstant, _name))
            {
                return(new SimpleNameExpression(accessibleConstant, ExpressionClassification.Variable, _context));
            }
            var accessibleType = _declarationFinder.FindMemberReferencedProjectInModule(_project, _module, _parent, DeclarationType.ProceduralModule, _name, DeclarationType.Enumeration);

            if (IsValidMatch(accessibleType, _name))
            {
                return(new SimpleNameExpression(accessibleType, ExpressionClassification.Type, _context));
            }
            var accessibleMember = _declarationFinder.FindMemberReferencedProjectInModule(_project, _module, _parent, DeclarationType.ProceduralModule, _name, DeclarationType.EnumerationMember);

            if (IsValidMatch(accessibleMember, _name))
            {
                return(new SimpleNameExpression(accessibleMember, ExpressionClassification.Value, _context));
            }
            var accessibleProperty = _declarationFinder.FindMemberReferencedProjectInModule(_project, _module, _parent, DeclarationType.ProceduralModule, _name, _propertySearchType);

            if (IsValidMatch(accessibleProperty, _name))
            {
                return(new SimpleNameExpression(accessibleProperty, ExpressionClassification.Property, _context));
            }
            var accessibleFunction = _declarationFinder.FindMemberReferencedProjectInModule(_project, _module, _parent, DeclarationType.ProceduralModule, _name, DeclarationType.Function);

            if (IsValidMatch(accessibleFunction, _name))
            {
                return(new SimpleNameExpression(accessibleFunction, ExpressionClassification.Function, _context));
            }
            var accessibleSubroutine = _declarationFinder.FindMemberReferencedProjectInModule(_project, _module, _parent, DeclarationType.ProceduralModule, _name, DeclarationType.Procedure);

            if (IsValidMatch(accessibleSubroutine, _name))
            {
                return(new SimpleNameExpression(accessibleSubroutine, ExpressionClassification.Subroutine, _context));
            }

            // Part 2: Global class module as parent
            var globalClassModuleVariable = _declarationFinder.FindMemberReferencedProjectInGlobalClassModule(_project, _module, _parent, _name, DeclarationType.Variable);

            if (IsValidMatch(globalClassModuleVariable, _name))
            {
                return(new SimpleNameExpression(globalClassModuleVariable, ExpressionClassification.Variable, _context));
            }
            var globalClassModuleConstant = _declarationFinder.FindMemberReferencedProjectInGlobalClassModule(_project, _module, _parent, _name, DeclarationType.Constant);

            if (IsValidMatch(globalClassModuleConstant, _name))
            {
                return(new SimpleNameExpression(globalClassModuleConstant, ExpressionClassification.Variable, _context));
            }
            var globalClassModuleType = _declarationFinder.FindMemberReferencedProjectInGlobalClassModule(_project, _module, _parent, _name, DeclarationType.Enumeration);

            if (IsValidMatch(globalClassModuleType, _name))
            {
                return(new SimpleNameExpression(globalClassModuleType, ExpressionClassification.Type, _context));
            }
            var globalClassModuleMember = _declarationFinder.FindMemberReferencedProjectInGlobalClassModule(_project, _module, _parent, _name, DeclarationType.EnumerationMember);

            if (IsValidMatch(globalClassModuleMember, _name))
            {
                return(new SimpleNameExpression(globalClassModuleMember, ExpressionClassification.Value, _context));
            }
            var globalClassModuleProperty = _declarationFinder.FindMemberReferencedProjectInGlobalClassModule(_project, _module, _parent, _name, _propertySearchType);

            if (IsValidMatch(globalClassModuleProperty, _name))
            {
                return(new SimpleNameExpression(globalClassModuleProperty, ExpressionClassification.Property, _context));
            }
            var globalClassModuleFunction = _declarationFinder.FindMemberReferencedProjectInGlobalClassModule(_project, _module, _parent, _name, DeclarationType.Function);

            if (IsValidMatch(globalClassModuleFunction, _name))
            {
                return(new SimpleNameExpression(globalClassModuleFunction, ExpressionClassification.Function, _context));
            }
            var globalClassModuleSubroutine = _declarationFinder.FindMemberReferencedProjectInGlobalClassModule(_project, _module, _parent, _name, DeclarationType.Procedure);

            if (IsValidMatch(globalClassModuleSubroutine, _name))
            {
                return(new SimpleNameExpression(globalClassModuleSubroutine, ExpressionClassification.Subroutine, _context));
            }

            return(null);
        }