Esempio n. 1
0
 public AttributeParamImpl(IXmlAttribute xmlAttribute,IParameterDescriptorProvider parameterDescriptorProvider)
 {
     name = xmlAttribute.AttributeName;
     nameDocumentRange = xmlAttribute.ToTreeNode().NameNode.GetDocumentRange();
     stringValue = xmlAttribute.UnquotedValue;
     this.parameterDescriptorProvider = parameterDescriptorProvider;
 }
        protected override Action <ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress)
        {
            IXmlTagHeader tagHeader = GetTagHeader();

            if (tagHeader == null)
            {
                return(null);
            }

            IXmlTag tag = XmlTagNavigator.GetByTagHeader(tagHeader);

            if (tag == null)
            {
                return(null);
            }

            XmlElementFactory factory = XmlElementFactory.GetInstance(tag);

            IXmlAttribute idAttr = factory.CreateAttributeForTag(tag, "id=\"\"");

            tag.AddAttributeBefore(idAttr, null);

            // continuation to do after transaction committed
            return(textControl =>
                   // move cursor inside new created id attribute
                   textControl.Caret.MoveTo(idAttr.Value.GetDocumentRange().TextRange.StartOffset, CaretVisualPlacement.Generic));
        }
Esempio n. 3
0
        private void CreateModuleReferenceAttributeValue(INHElement element, IXmlAttribute attribute)
        {
            if (attribute.Value == null)
                return;

            ReferenceParser parser = new ReferenceParser();
            IXmlAttributeValue newElement = parser.ParseReferenceModule(attribute.Value);
            ReplaceAttributeValue(attribute, newElement);
        }
Esempio n. 4
0
        private void CreateMappingMemberReferenceAttributeValue(INHElement element, IXmlAttribute attribute, IXmlTagContainer parent)
        {
            if (attribute.Value == null)
                return;

            ReferenceParser parser = new ReferenceParser();
            IQualifier qualifier = GetElementQualifier(element, parent);
            IXmlAttributeValue newElement = parser.ParseReferenceIdentifier(attribute.Value, qualifier);
            ReplaceAttributeValue(attribute, newElement);
        }
Esempio n. 5
0
        public static void SetAttributeValiue(IXmlAttribute attribute, string newValue)
        {
            if (newValue == null)
                throw new ArgumentNullException("newValue");

            Assert.CheckNotNull(attribute.Value, "attribute.Value");
            IXmlAttributeValueNode oldValueNode = attribute.Value.ToTreeNode();
            StringBuffer buffer = new StringBuffer("\"" + newValue + "\"");
            XmlTokenTypes types = XmlTokenTypeFactory.GetTokenTypes(attribute.Language);
            XmlValueToken newValueNode = new XmlValueToken(types.STRING, buffer, 0, buffer.Length);
            LowLevelModificationUtil.ReplaceChildRange(oldValueNode, oldValueNode, new ITreeNode[] { newValueNode });
        }
Esempio n. 6
0
        private void CreateReferenceAttributeValue(IL4NElement element, IXmlAttribute attribute)
        {
            if(attribute.Value == null)
                return;

            ReferenceParser parser = new ReferenceParser();
            IXmlAttributeValue newElement = parser.ParseReferenceName(attribute.Value);
            IXmlAttributeValueNode childNode = attribute.Value.ToTreeNode();
            ITreeNode parent = attribute.ToTreeNode();
            ((CompositeElement)parent).AddChildAfter(newElement.ToTreeNode(), childNode);
            ((CompositeElement)parent).DeleteChildRange(childNode, childNode);
        }
Esempio n. 7
0
        private void AddAttributeValue(DuplicatesSearcher duplicatesSearcher, IXmlAttribute attribute)
        {
            if(attribute == null)
                return;
            if(attribute.Value == null)
                return;
            if (string.IsNullOrEmpty(attribute.Value.UnquotedValue) || attribute.Value.UnquotedValue.Trim() == string.Empty)
                return;

            TextRange valueRange = attribute.Value.GetDocumentRange().TextRange;
            attribute.Value.GetText().StartsWith("\"");
            valueRange = valueRange.TrimLeft(1);
            attribute.Value.GetText().EndsWith("\"");
            valueRange = valueRange.TrimRight(1);
            duplicatesSearcher.Add(attribute.Value.UnquotedValue, attribute.Value.GetContainingFile().GetDocumentRange(valueRange));
        }
        public override bool IsAvailable(IUserDataHolder dataHolder)
        {
            // grab the tag we're on
            IXmlTagHeader tagHeader = GetTagHeader();

            if (tagHeader == null)
            {
                return(false);
            }

            // check if the attribute is already there (case-insensitive)
            IXmlAttribute idAttr = tagHeader.GetAttribute(attr => StringComparer.OrdinalIgnoreCase.Equals(attr.AttributeName, "id"));

            if (idAttr != null)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 9
0
 protected override void AppendNewChild(IXmlAttribute parent, IXmlAttributeValue child)
 {
     base.AppendNewChild(parent, child);
 }
Esempio n. 10
0
        private void CreateTableReferenceAttributeValue(INHElement element, IXmlAttribute attribute)
        {
            if (attribute.Value == null)
                return;

            var parser = new NHReferenceParser();
            var newElement = parser.ParseReferenceTable(attribute.Value);
            ReplaceAttributeValue(attribute, newElement);
        }
Esempio n. 11
0
 private void ReplaceAttributeValue(IXmlAttribute attribute, IXmlAttributeValue newElement)
 {
     IXmlAttributeValueNode childNode = attribute.Value.ToTreeNode();
     ITreeNode parent = attribute.ToTreeNode();
     ((CompositeElement)parent).AddChildAfter(newElement.ToTreeNode(), childNode);
     ((CompositeElement)parent).DeleteChildRange(childNode, childNode);
 }
Esempio n. 12
0
        private void ProcessAttribute(INHElement element, IXmlAttribute attribute, IXmlTagContainer parent)
        {
            if (element is IClassElement)
            {
                if (attribute.XmlName == "name" || attribute.XmlName == "proxy")
                {
                    CreateTypeReferenceAttributeValue(element, attribute);
                    return;
                }
            }

            if (element is IComponentElement
                || element is ICompositeElementElement
                || element is ICompositeIdElement
                || element is ICompositeIndexElement
                || element is IIndexManyToManyElement
                || element is IKeyManyToOneElement
                || element is IManyToManyElement
                || element is IManyToOneElement
                || element is IMetaValueElement
                || element is INestedCompositeElementElement
                || element is IOneToManyElement
                || element is IOneToOneElement
                || element is IReturnElement)
            {
                if (attribute.XmlName == "class")
                {
                    CreateTypeReferenceAttributeValue(element, attribute);
                    return;
                }
            }

            if(element is ISubclassElement)
            {
                if (attribute.XmlName == "name" || attribute.XmlName == "proxy")
                {
                    CreateTypeReferenceAttributeValue(element, attribute);
                    return;
                }
            }

            IHibernateMappingElement hibernateMappingElement = element as IHibernateMappingElement;
            if (hibernateMappingElement != null)
            {
                if (attribute.XmlName == "assembly")
                {
                    CreateModuleReferenceAttributeValue(hibernateMappingElement, attribute);
                }
                else if (attribute.XmlName == "namespace")
                {
                    CreateNamespaceReferenceAttributeValue(hibernateMappingElement, attribute);
                    return;
                }

            }

            if (element is IAnyElement
                 || element is IArrayElement
                 || element is IBagElement
                 || element is IIdbagElement
                 || element is IIdElement
                 || element is IKeyManyToOneElement
                 || element is IKeyPropertyElement
                 || element is IListElement
                 || element is IManyToOneElement
                 || element is IMapElement
                 || element is IOneToOneElement
                 || element is IPrimitiveArrayElement
                 || element is IPropertyElement
                 || element is IResultsetElement
                 || element is IReturnColumnElement
                 || element is IReturnPropertyElement
                 || element is ISetElement
                 || element is ITimestampElement
                 || element is IVersionElement
                || element is ICompositeIdElement)
            {
                if (attribute.XmlName == "name")
                {
                    CreateMappingMemberReferenceAttributeValue(element, attribute, parent);
                    return;
                }

            }

            if (element is IPropertyElement
                || element is IIdElement
                || element is IKeyPropertyElement
                || element is  IElementElement
                || element is  IDiscriminatorElement
                || element is  ICollectionIdElement
                || element is  IVersionElement
                || element is IReturnScalarElement
                || element is IIndexElement
                || element is IFilterParamElement
            )
            {
                if (attribute.XmlName == "type")
                {
                    CreateTypeWithNHAliasReferenceAttributeValue(element, attribute);
                    return;
                }
            }

            if (attribute.XmlName == "table")
            {
                CreateTableReferenceAttributeValue(element, attribute);
                return;
            }

            if (element is IComponentElement
              || element is ICompositeElementElement
              || element is ICompositeIdElement
              || element is ICompositeIndexElement
              || element is IImportElement
              || element is IIndexManyToManyElement
              || element is IKeyManyToOneElement
              || element is IManyToManyElement
              || element is IManyToOneElement
              || element is IMetaValueElement
              || element is INestedCompositeElementElement
              || element is IOneToManyElement
              || element is IOneToOneElement
              || element is IReturnElement)
             {
                 if (attribute.XmlName == "class")
                 {
                     CreateTypeReferenceAttributeValue(element, attribute);
                     return;
                 }
             }
        }
Esempio n. 13
0
        private void CreateTypeWithNHAliasReferenceAttributeValue(INHElement element, IXmlAttribute attribute)
        {
            if (attribute.Value == null)
                return;

            var parser = new ReferenceParser();
            var newElement = parser.ParseReferenceType(attribute.Value, new NHGlobalQualifier(element));
            ReplaceAttributeValue(attribute, newElement);
        }
Esempio n. 14
0
        private void ProcessAttribute(IL4NElement element, IXmlAttribute attribute)
        {
            ILogger logger = element as ILogger;

            if (logger != null)
            {
                if (attribute.XmlName == L4NConstants.NAME)
                {
                    CreateReferenceAttributeValue(element, attribute);
                }

                return;
            }

            IDeclaredParameter declaredParameter = element as IDeclaredParameter;
            if(declaredParameter != null)
            {
                if (attribute.XmlName == L4NConstants.TYPE)
                {
                    CreateReferenceAttributeValue(element, attribute);
                }
                return;
            }

            IAppender appender = element as IAppender;
            if (appender != null)
            {
                if (attribute.XmlName == L4NConstants.TYPE)
                {
                    CreateReferenceAttributeValue(element, attribute);
                }
                return;
            }
        }
Esempio n. 15
0
 IXmlElement IXmlElement.AddAttribute(IXmlAttribute xmlAttribute)
 {
     _attributes.Add(xmlAttribute);
     return(this);
 }