Exemplo n.º 1
0
        public XmlCompletionItemCollection GetNamespaceCompletion()
        {
            XmlCompletionItemCollection completionItems = new XmlCompletionItemCollection();

            foreach (XmlSchemaCompletion schema in this)
            {
                XmlCompletionItem completionItem = new XmlCompletionItem(schema.NamespaceUri, XmlCompletionItemType.NamespaceUri);
                if (!completionItems.Contains(completionItem))
                {
                    completionItems.Add(completionItem);
                }
            }

            return(completionItems);
        }
Exemplo n.º 2
0
        public bool CtrlSpace(ITextEditor editor)
        {
            string text   = editor.Document.Text;
            int    offset = editor.Caret.Offset;

            XmlSchemaCompletion         defaultSchema   = schemaFileAssociations.GetSchemaCompletion(editor.FileName);
            XmlCompletionItemCollection completionItems = schemas.GetAttributeValueCompletion(text, offset, defaultSchema);

            if (completionItems.HasItems)
            {
                editor.ShowCompletionWindow(completionItems);
                return(true);
            }
            return(false);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns a list of elements that can be children of the
        /// specified element.
        /// </summary>
        string[] GetChildElements(XmlElement element)
        {
            XmlElementPath elementPath = GetElementPath(element);

            List <string>       elements = new List <string>();
            XmlSchemaCompletion schema   = FindSchema(elementPath);

            if (schema != null)
            {
                XmlCompletionItemCollection completionItems = schema.GetChildElementCompletion(elementPath);
                foreach (XmlCompletionItem elementCompletionData in completionItems)
                {
                    elements.Add(elementCompletionData.Text);
                }
            }
            return(elements.ToArray());
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the missing attributes for the specified element based
        /// on its associated schema.
        /// </summary>
        string[] GetMissingAttributes(XmlElement element)
        {
            XmlElementPath      elementPath = GetElementPath(element);
            List <string>       attributes  = new List <string>();
            XmlSchemaCompletion schema      = FindSchema(elementPath);

            if (schema != null)
            {
                XmlCompletionItemCollection completionItems = schema.GetAttributeCompletion(elementPath);
                foreach (XmlCompletionItem item in completionItems)
                {
                    // Ignore existing attributes.
                    if (!element.HasAttribute(item.Text))
                    {
                        attributes.Add(item.Text);
                    }
                }
            }
            return(attributes.ToArray());
        }
Exemplo n.º 5
0
        public XmlCompletionItemCollection GetElementCompletion(XmlElementPathsByNamespace pathsByNamespace, XmlSchemaCompletion defaultSchema)
        {
            XmlCompletionItemCollection items = new XmlCompletionItemCollection();

            foreach (XmlElementPath path in pathsByNamespace)
            {
                items.AddRange(GetChildElementCompletion(path, defaultSchema));
            }

            XmlNamespaceCollection namespaceWithoutPaths = pathsByNamespace.NamespacesWithoutPaths;

            if (items.Count == 0)
            {
                if (!IsDefaultSchemaNamespaceDefinedInPathsByNamespace(namespaceWithoutPaths, defaultSchema))
                {
                    namespaceWithoutPaths.Add(defaultSchema.Namespace);
                }
            }
            items.AddRange(GetRootElementCompletion(namespaceWithoutPaths));
            return(items);
        }
Exemplo n.º 6
0
        public CodeCompletionKeyPressResult HandleKeyPress(ITextEditor editor, char ch)
        {
            XmlSchemaCompletion         defaultSchema   = schemaFileAssociations.GetSchemaCompletion(editor.FileName);
            XmlCompletionItemCollection completionItems = GetCompletionItems(editor, ch, defaultSchema);

            if (completionItems.HasItems)
            {
                completionItems.Sort();
                ICompletionListWindow completionWindow = editor.ShowCompletionWindow(completionItems);
                if (completionWindow != null)
                {
                    SetCompletionWindowWidth(completionWindow, completionItems);
                }
            }

            if ((ch == '<') || (ch == ' ') || (ch == '='))
            {
                return(CodeCompletionKeyPressResult.Completed);
            }
            return(CodeCompletionKeyPressResult.None);
        }
Exemplo n.º 7
0
 public XmlCompletionItemCollection(XmlCompletionItemCollection items)
     : this()
 {
     AddRange(items);
 }