private bool TryFillCompletionData(MyXmlDocument doc) { var refsDataCollected = false; foreach (var element in doc.AllElements) { var schemaElement = element.SchemaInfo.SchemaElement; if (schemaElement != null) { refsDataCollected |= this.TryCollectElementData(element, schemaElement); if (!schemaElement.RefName.IsEmpty) { var referencedSchemaElements = doc.Schemas.Schemas(schemaElement.RefName.Namespace) .OfType <XmlSchema>() .Select(s => s.Elements[schemaElement.RefName]) .OfType <XmlSchemaElement>() .ToList(); if (referencedSchemaElements.Count > 1) { Debug.Print("wtf"); } foreach (var referencedSchemaElement in referencedSchemaElements) { refsDataCollected |= this.TryCollectElementData(element, referencedSchemaElement); } } } } return(refsDataCollected); }
private bool TryLoadDocument(ITextView textView, out MyXmlDocument doc) { try { //if (XmlSchemaSetHelper.TryParseXmlDocFromTextView(textView, out var isSchema, out var schemaSetHelper)) //{ // if (schemaSetHelper.TryResolveSchemaSetForXmlDocTextView(out var schemaSet, out var retryLater)) // { this.CurrentSnapshot = textView.TextBuffer.CurrentSnapshot; var text = this.CurrentSnapshot.GetText(); doc = MyXmlDocument.LoadWithTextInfo(new StringReader(text)); if (this.TryResolveSchemas(doc, out var schemaSet)) { doc.Schemas = schemaSet; doc.Validate((sender, ea) => { System.Diagnostics.Debug.Print("Logged: " + ea.Severity + " : " + ea.Message); if (ea.Exception != null) { System.Diagnostics.Debug.Print("Logged: " + ea.Exception.ToString()); } }); if (!this.TryFillCompletionData(doc)) { doc = null; } } else { doc = null; } // } // else // { // doc = null; // if (retryLater) // this.ScheduleReloading(InitTimeout); // } //} //else //{ // doc = null; // if (!isSchema) // this.ScheduleReloading(InitTimeout); //} } catch (Exception ex) { Debug.Print(ex.ToString()); doc = null; } return(doc != null); }
private void ReloadDocument() { if (!_textView.IsClosed) { Debug.Print("Reloading.."); this.DocumentData = this.TryLoadDocument(_textView, out var doc) ? doc : null; this.DocumentDataUpdated?.Invoke(this, EventArgs.Empty); } }
public void ScheduleReloading(TimeSpan interval) { Debug.Print("Scheduling reload in " + interval); this.DocumentData = null; this.DocumentDataUpdated?.Invoke(this, EventArgs.Empty); _reloadTimer.Stop(); _reloadTimer.Interval = interval.TotalMilliseconds; _reloadTimer.Start(); }