Ejemplo n.º 1
0
        public void GetAttributeCompletionReturnsAttributesFromDuplicateFooSchema()
        {
            string xml =
                "<duplicate-foo-note xmlns='foo'>\r\n" +
                "        <duplicate-foo-text ";

            XmlCompletionItemCollection items = schemas.GetAttributeCompletion(xml, null);

            XmlCompletionItemCollection expectedItems = new XmlCompletionItemCollection();

            expectedItems.Add(new XmlCompletionItem("duplicate-foo-text-attribute", XmlCompletionItemType.XmlAttribute));

            Assert.AreEqual(expectedItems, items);
        }
        public void CorrectAttributesReturnedForElementWhenTwoNamespacesInXml()
        {
            string xml =
                "<b:bar-note xmlns='foo' xmlns:b='bar'>\r\n" +
                "    <foo-note>\r\n" +
                "        <b:bar-text/>\r\n" +
                "        <foo-text ";

            XmlCompletionItemCollection items = schemas.GetAttributeCompletion(xml, null);

            XmlCompletionItemCollection expectedItems = new XmlCompletionItemCollection();

            expectedItems.Add(new XmlCompletionItem("foo-text-attribute", XmlCompletionItemType.XmlAttribute));

            Assert.AreEqual(expectedItems, items);
        }
        protected XmlCompletionItemCollection GetCompletionItemsForAttribute(XmlSchemaCompletion defaultSchema, XmlSchemaCompletionCollection schemas)
        {
            int    offset         = this.Position.Offset;
            string textUpToCursor = this.Text.GetText(0, offset);
            XmlCompletionItemCollection completionItems = new XmlCompletionItemCollection();

            completionItems = schemas.GetAttributeCompletion(textUpToCursor, defaultSchema);
            if (completionItems.Count == 0)
            {
                completionItems = schemas.GetElementCompletion(textUpToCursor, defaultSchema);
                if (this.HasOpenToken == false)
                {
                    completionItems.Select(i => { i.Text = "<" + i.Text; return(i); }).ToList();
                }
                completionItems.Add(new XmlCompletionItem("<?"));
                completionItems.Add(new XmlCompletionItem("<!--"));
            }

            return(completionItems);
        }