Exemple #1
0
        public XmlCompletionItemCollection GetElementCompletion(string textUpToCursor, XmlSchemaCompletion defaultSchema)
        {
            XmlElementPath parentPath = XmlParser.GetParentElementPath(textUpToCursor);

            return(GetElementCompletionForAllNamespaces(parentPath, defaultSchema));
        }
 void FindSelectedAttributeValue(string xml, int index)
 {
     selectedAttributeValue = XmlParser.GetAttributeValueAtIndex(xml, index);
 }
Exemple #3
0
        public override ICompletionData[] GenerateCompletionData(string fileName, TextArea textArea, char charTyped)
        {
            preSelection = null;
            string text = String.Concat(textArea.Document.GetText(0, textArea.Caret.Offset), charTyped);

            switch (charTyped)
            {
            case '=':
                // Namespace intellisense.
                if (XmlParser.IsNamespaceDeclaration(text, text.Length))
                {
                    return(schemaCompletionDataItems.GetNamespaceCompletionData());;
                }
                break;

            case '<':
                // Child element intellisense.
                XmlElementPath parentPath = XmlParser.GetParentElementPath(text);
                if (parentPath.Elements.Count > 0)
                {
                    return(GetChildElementCompletionData(parentPath));
                }
                else if (defaultSchemaCompletionData != null)
                {
                    return(defaultSchemaCompletionData.GetElementCompletionData(defaultNamespacePrefix));
                }
                break;

            case ' ':
                // Attribute intellisense.
                if (!XmlParser.IsInsideAttributeValue(text, text.Length))
                {
                    XmlElementPath path = XmlParser.GetActiveElementStartPath(text, text.Length);
                    if (path.Elements.Count > 0)
                    {
                        return(GetAttributeCompletionData(path));
                    }
                }
                break;

            default:

                // Attribute value intellisense.
                if (XmlParser.IsAttributeValueChar(charTyped))
                {
                    string attributeName = XmlParser.GetAttributeName(text, text.Length);
                    if (attributeName.Length > 0)
                    {
                        XmlElementPath elementPath = XmlParser.GetActiveElementStartPath(text, text.Length);
                        if (elementPath.Elements.Count > 0)
                        {
                            preSelection = charTyped.ToString();
                            return(GetAttributeValueCompletionData(elementPath, attributeName));
                        }
                    }
                }
                break;
            }

            return(null);
        }
 void FindSelectedElement(string xml, int index)
 {
     path = XmlParser.GetActiveElementStartPathAtIndex(xml, index);
 }