Esempio n. 1
0
        XmlCompletionItemCollection GetCompletionItems(ITextEditor editor, XmlSchemaCompletion defaultSchema)
        {
            int    offset         = editor.Caret.Offset;
            string textUpToCursor = editor.Document.GetText(0, offset);

            XmlCompletionItemCollection items = new XmlCompletionItemCollection();

            if (XmlParser.IsInsideAttributeValue(textUpToCursor, offset))
            {
                items = schemas.GetNamespaceCompletion(textUpToCursor);
                if (items.Count == 0)
                {
                    items = schemas.GetAttributeValueCompletion(textUpToCursor, editor.Caret.Offset, defaultSchema);
                }
            }
            else
            {
                items = schemas.GetAttributeCompletion(textUpToCursor, defaultSchema);
                if (items.Count == 0)
                {
                    items = schemas.GetElementCompletion(textUpToCursor, defaultSchema);
                }
            }
            return(items);
        }
Esempio n. 2
0
        XmlCompletionItemCollection GetCompletionItems(ITextEditor editor, char characterTyped, XmlSchemaCompletion defaultSchema)
        {
            string textUpToCursor = GetTextUpToCursor(editor, characterTyped);

            switch (characterTyped)
            {
            case '=':
                return(schemas.GetNamespaceCompletion(textUpToCursor));

            case '<':
                return(schemas.GetElementCompletion(textUpToCursor, defaultSchema));

            case ' ':
                return(schemas.GetAttributeCompletion(textUpToCursor, defaultSchema));
            }
            return(schemas.GetAttributeValueCompletion(characterTyped, textUpToCursor, defaultSchema));
        }