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()); }
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); }