コード例 #1
0
 public XmlCompletionItemCollection GetAttributeCompletion(string textUpToCursor, XmlSchemaCompletion defaultSchema)
 {
     if (!XmlParser.IsInsideAttributeValue(textUpToCursor, textUpToCursor.Length))
     {
         XmlElementPath path = XmlParser.GetActiveElementStartPath(textUpToCursor, textUpToCursor.Length);
         path.Compact();
         if (path.Elements.HasItems)
         {
             return(GetAttributeCompletion(path, defaultSchema));
         }
     }
     return(new XmlCompletionItemCollection());
 }
コード例 #2
0
 public XmlCompletionItemCollection GetAttributeValueCompletion(char charTyped, string textUpToCursor, XmlSchemaCompletion defaultSchema)
 {
     if (XmlParser.IsAttributeValueChar(charTyped))
     {
         string attributeName = XmlParser.GetAttributeName(textUpToCursor, textUpToCursor.Length);
         if (attributeName.Length > 0)
         {
             XmlElementPath elementPath = XmlParser.GetActiveElementStartPath(textUpToCursor, textUpToCursor.Length);
             return(GetAttributeValueCompletion(elementPath, attributeName, defaultSchema));
         }
     }
     return(new XmlCompletionItemCollection());
 }
コード例 #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);
        }