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); }
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); }
/// <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()); }
/// <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()); }
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); }
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); }
public XmlCompletionItemCollection(XmlCompletionItemCollection items) : this() { AddRange(items); }