public void CompleteAttributeValue(string line, int caretColumn) { // Get information about what's being worked on XMLAnalysis analysis = XMLAnalysis.AnalyzeLine(line, caretColumn); if (analysis.CurrentAttribute == null || !analysis.IsCaretInsideAttributeValue) { return; // Not typing out an attribute value } // Get the tag that's being worked on CompletableXMLTag tag; if (!_tagsByName.TryGetValue(analysis.CurrentTag, out tag)) { return; } // Get the attribute that's being worked on CompletableXMLAttribute attribute = tag.FindAttributeByName(analysis.CurrentAttribute); if (attribute == null || !attribute.HasValues) { return; } // Raise the ValueCompletionAvailable event var args = new ValueCompletionEventArgs(attribute.Values); OnValueCompletionAvailable(args); }
public void CompleteAttributeName(string line, int caretColumn) { // Get information about what's being worked on XMLAnalysis analysis = XMLAnalysis.AnalyzeLine(line, caretColumn); if (!analysis.CanInsertAttribute) { return; } // Get the tag that's being worked on CompletableXMLTag tag; if (!_tagsByName.TryGetValue(analysis.CurrentTag, out tag)) { return; } // Only suggest attributes which haven't been defined yet var suggestions = new List <CompletableXMLAttribute>(); foreach (CompletableXMLAttribute attribute in tag.Attributes) { if (!analysis.Attributes.Contains(attribute.Name)) { suggestions.Add(attribute); } } if (suggestions.Count == 0) { return; } // Raise the AttributeCompletionAvailable event var args = new AttributeCompletionEventArgs(suggestions); OnAttributeCompletionAvailable(args); }