private IBoundExpression ResolveEnclosingModule(string name)
        {
            /*
             *  Enclosing Module namespace: A function, subroutine or property with a Property Get defined
             *  at the module-level in the enclosing module.
             */
            var function = _declarationFinder.FindMemberEnclosingModule(_module, _parent, name, DeclarationType.Function);

            if (function != null)
            {
                return(new SimpleNameExpression(function, ExpressionClassification.Function, _expression));
            }
            var subroutine = _declarationFinder.FindMemberEnclosingModule(_module, _parent, name, DeclarationType.Procedure);

            if (subroutine != null)
            {
                return(new SimpleNameExpression(subroutine, ExpressionClassification.Subroutine, _expression));
            }
            var propertyGet = _declarationFinder.FindMemberEnclosingModule(_module, _parent, name, DeclarationType.PropertyGet);

            if (propertyGet != null)
            {
                return(new SimpleNameExpression(propertyGet, ExpressionClassification.Property, _expression));
            }
            return(null);
        }
 private IBoundExpression ResolveMemberInReferencedProject(bool lExpressionIsEnclosingProject, IBoundExpression lExpression, string name, Declaration referencedProject, DeclarationType memberType)
 {
     /*
      *  The project does not have an accessible module named <unrestricted-name> and exactly one of
      *  the procedural modules within the project contains a UDT or Enum definition named
      *  <unrestricted-name>. In this case, the member access expression is classified as a type and
      *  refers to the specified UDT or enum.
      */
     if (lExpressionIsEnclosingProject)
     {
         var foundType = _declarationFinder.FindMemberEnclosingModule(_module, _parent, name, memberType);
         if (foundType != null)
         {
             return(new MemberAccessExpression(foundType, ExpressionClassification.Type, _expression, _unrestrictedNameContext, lExpression));
         }
         var accessibleType = _declarationFinder.FindMemberEnclosedProjectWithoutEnclosingModule(_project, _module, _parent, name, memberType);
         if (accessibleType != null)
         {
             return(new MemberAccessExpression(accessibleType, ExpressionClassification.Type, _expression, _unrestrictedNameContext, lExpression));
         }
     }
     else
     {
         var referencedProjectType = _declarationFinder.FindMemberReferencedProject(_project, _module, _parent, referencedProject, name, memberType);
         if (referencedProjectType != null)
         {
             return(new MemberAccessExpression(referencedProjectType, ExpressionClassification.Type, _expression, _unrestrictedNameContext, lExpression));
         }
     }
     return(null);
 }
Exemple #3
0
 private IBoundExpression ResolveMemberInReferencedProject(bool lExpressionIsEnclosingProject, Declaration referencedProject, DeclarationType memberType, ExpressionClassification classification)
 {
     if (lExpressionIsEnclosingProject)
     {
         var foundType = _declarationFinder.FindMemberEnclosingModule(_module, _parent, _name, memberType);
         if (foundType != null)
         {
             return(new MemberAccessExpression(foundType, classification, _context, _unrestrictedNameContext, _lExpression));
         }
         var accessibleType = _declarationFinder.FindMemberEnclosedProjectWithoutEnclosingModule(_project, _module, _parent, _name, memberType);
         if (accessibleType != null)
         {
             return(new MemberAccessExpression(accessibleType, classification, _context, _unrestrictedNameContext, _lExpression));
         }
     }
     else
     {
         var referencedProjectType = _declarationFinder.FindMemberReferencedProject(_project, _module, _parent, referencedProject, _name, memberType);
         if (referencedProjectType != null)
         {
             return(new MemberAccessExpression(referencedProjectType, classification, _context, _unrestrictedNameContext, _lExpression));
         }
     }
     return(null);
 }
        private IBoundExpression ResolveEnclosingModule(string name)
        {
            /*  Namespace tier 1:
             *  Enclosing Module namespace: A UDT or Enum type defined at the module-level in the
             *  enclosing module.
             */
            var udt = _declarationFinder.FindMemberEnclosingModule(_module, _parent, name, DeclarationType.UserDefinedType);

            if (udt != null)
            {
                return(new SimpleNameExpression(udt, ExpressionClassification.Type, _expression));
            }
            var enumType = _declarationFinder.FindMemberEnclosingModule(_module, _parent, name, DeclarationType.Enumeration);

            if (enumType != null)
            {
                return(new SimpleNameExpression(enumType, ExpressionClassification.Type, _expression));
            }
            return(null);
        }
Exemple #5
0
        private IBoundExpression ResolveEnclosingModuleNamespace()
        {
            /*  Namespace tier 2:
             *  Enclosing Module namespace: A variable, constant, Enum type, Enum member, property,
             *  function or subroutine defined at the module-level in the enclosing module.
             */
            var moduleVariable = _declarationFinder.FindMemberEnclosingModule(_module, _parent, _name, DeclarationType.Variable);

            if (IsValidMatch(moduleVariable, _name))
            {
                return(new SimpleNameExpression(moduleVariable, ExpressionClassification.Variable, _context));
            }
            var moduleConstant = _declarationFinder.FindMemberEnclosingModule(_module, _parent, _name, DeclarationType.Constant);

            if (IsValidMatch(moduleConstant, _name))
            {
                return(new SimpleNameExpression(moduleConstant, ExpressionClassification.Variable, _context));
            }
            var enumType = _declarationFinder.FindMemberEnclosingModule(_module, _parent, _name, DeclarationType.Enumeration);

            if (IsValidMatch(enumType, _name))
            {
                return(new SimpleNameExpression(enumType, ExpressionClassification.Type, _context));
            }
            var enumMember = _declarationFinder.FindMemberEnclosingModule(_module, _parent, _name, DeclarationType.EnumerationMember);

            if (IsValidMatch(enumMember, _name))
            {
                return(new SimpleNameExpression(enumMember, ExpressionClassification.Value, _context));
            }
            // Prioritize return value assignments over any other let/set property references.
            if (_parent.DeclarationType == DeclarationType.PropertyGet && _declarationFinder.IsMatch(_parent.IdentifierName, _name))
            {
                return(new SimpleNameExpression(_parent, ExpressionClassification.Property, _context));
            }
            var property = _declarationFinder.FindMemberEnclosingModule(_module, _parent, _name, _propertySearchType);

            if (IsValidMatch(property, _name))
            {
                return(new SimpleNameExpression(property, ExpressionClassification.Property, _context));
            }
            var function = _declarationFinder.FindMemberEnclosingModule(_module, _parent, _name, DeclarationType.Function);

            if (IsValidMatch(function, _name))
            {
                return(new SimpleNameExpression(function, ExpressionClassification.Function, _context));
            }
            var subroutine = _declarationFinder.FindMemberEnclosingModule(_module, _parent, _name, DeclarationType.Procedure);

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