XmlCompletionItemCollection GetCompletionItems(TextEditor editor, XmlSchemaCompletion defaultSchema) { var offset = editor.TextArea.Caret.Offset; var textUpToCursor = editor.Document.GetText(0, offset); var items = new XmlCompletionItemCollection(); if (XmlParser.IsInsideAttributeValue(textUpToCursor, offset)) { items = _schemas.GetNamespaceCompletion(textUpToCursor); if (items.Count == 0) { items = _schemas.GetAttributeValueCompletion(textUpToCursor, editor.TextArea.Caret.Offset, defaultSchema); } } else { items = _schemas.GetAttributeCompletion(textUpToCursor, defaultSchema); if (items.Count == 0) { items = _schemas.GetElementCompletion(textUpToCursor, defaultSchema); } } return(items); }
public XmlCompletionItemCollection GetAttributeValueCompletion(string text, int offset, XmlSchemaCompletion defaultSchema) { if (XmlParser.IsInsideAttributeValue(text, offset)) { var path = XmlParser.GetActiveElementStartPath(text, offset); var attributeName = XmlParser.GetAttributeNameAtIndex(text, offset); return(GetAttributeValueCompletion(path, attributeName, defaultSchema)); } return(new XmlCompletionItemCollection()); }
public XmlCompletionItemCollection GetAttributeCompletion(string textUpToCursor, XmlSchemaCompletion defaultSchema) { if (!XmlParser.IsInsideAttributeValue(textUpToCursor, textUpToCursor.Length)) { var path = XmlParser.GetActiveElementStartPath(textUpToCursor, textUpToCursor.Length); path.Compact(); if (path.Elements.HasItems) { return(GetAttributeCompletion(path, defaultSchema)); } } return(new XmlCompletionItemCollection()); }