示例#1
0
        public override void OnAttribute(Boo.Lang.Ast.Attribute attribute, ref Boo.Lang.Ast.Attribute resultingNode)
        {
            // Neste primeiro passo tentamos apenas
            // resolver ast attributes.
            // Um passo posterior (resoluo de nomes e tipos) ir
            // assegurar que todos os nomes tenham sido resolvidos e colocar
            // mensagens de erro de acordo
            IBinding binding = ResolveQualifiedName(attribute, attribute.Name);

            if (null == binding)
            {
                binding = ResolveQualifiedName(attribute, BuildAttributeName(attribute.Name));
            }

            if (null != binding)
            {
                if (BindingType.Ambiguous == binding.BindingType)
                {
                    Errors.AmbiguousName(attribute, attribute.Name, ((AmbiguousBinding)binding).Bindings);
                }
                else
                {
                    if (BindingType.TypeReference != binding.BindingType)
                    {
                        Errors.NameNotType(attribute, attribute.Name);
                    }
                    else
                    {
                        ITypeBinding attributeType = ((ITypedBinding)binding).BoundType;
                        if (IsAstAttribute(attributeType))
                        {
                            ExternalTypeBinding externalType = attributeType as ExternalTypeBinding;
                            if (null == externalType)
                            {
                                Errors.AstAttributeMustBeExternal(attribute, attributeType);
                            }
                            else
                            {
                                ScheduleAttributeApplication(attribute, externalType.Type);

                                // remove it from parent
                                resultingNode = null;
                            }
                        }
                        else
                        {
                            if (!IsSystemAttribute(attributeType))
                            {
                                Errors.TypeNotAttribute(attribute, attributeType.FullName);
                            }
                            else
                            {
                                // remember the attribute's type
                                BindingManager.Bind(attribute, attributeType);
                            }
                        }
                    }
                }
            }
        }