public void UpdateFoldings(FoldingManager manager, TextDocument document) { var newFoldings = this.CreateNewFoldings(document); var firstErrorOffset = -1; manager.UpdateFoldings(newFoldings, firstErrorOffset); }
public void UpdateFoldings(IEnumerable <NewFolding> newFoldings, int firstErrorOffset) { if (foldingManager != null) { foldingManager.UpdateFoldings(newFoldings, firstErrorOffset); } }
public void UpdateFoldings(FoldingManager manager, ICSharpCode.AvalonEdit.Document.TextDocument document) { int firstErrorOffset; IEnumerable <NewFolding> newFoldings = CreateNewFoldings(document, out firstErrorOffset); manager.UpdateFoldings(newFoldings, firstErrorOffset); }
public void UpdateFoldings(FoldingManager manager, TextDocument document) { int firstErrorOffset; var newFoldings = CreateNewFoldings(document, out firstErrorOffset); manager.UpdateFoldings(newFoldings, firstErrorOffset); }
/// <summary> /// Create <see cref="NewFolding"/>s for the specified document and updates the folding manager with them. /// </summary> public void UpdateFoldings(FoldingManager manager, TextDocument document) { int firstErrorOffset; IEnumerable <NewFolding> foldings = CreateNewFoldings(document, out firstErrorOffset); manager.UpdateFoldings(foldings, firstErrorOffset); }
/// <summary> /// Shows the given output in the text view. /// </summary> void ShowOutput(AvalonEditTextOutput textOutput, IHighlightingDefinition highlighting = null, DecompilerTextViewState state = null) { Debug.WriteLine("Showing {0} characters of output", textOutput.TextLength); Stopwatch w = Stopwatch.StartNew(); textEditor.ScrollToHome(); if (foldingManager != null) { FoldingManager.Uninstall(foldingManager); foldingManager = null; } textEditor.Document = null; // clear old document while we're changing the highlighting uiElementGenerator.UIElements = textOutput.UIElements; referenceElementGenerator.References = textOutput.References; definitionLookup = textOutput.DefinitionLookup; textEditor.SyntaxHighlighting = highlighting; Debug.WriteLine(" Set-up: {0}", w.Elapsed); w.Restart(); textEditor.Document = textOutput.GetDocument(); Debug.WriteLine(" Assigning document: {0}", w.Elapsed); w.Restart(); if (textOutput.Foldings.Count > 0) { if (state != null) { state.RestoreFoldings(textOutput.Foldings); textEditor.ScrollToVerticalOffset(state.VerticalOffset); textEditor.ScrollToHorizontalOffset(state.HorizontalOffset); } foldingManager = FoldingManager.Install(textEditor.TextArea); foldingManager.UpdateFoldings(textOutput.Foldings.OrderBy(f => f.StartOffset), -1); Debug.WriteLine(" Updating folding: {0}", w.Elapsed); w.Restart(); } }
public void Test_UpdateFoldings_Preserves_Foldings() { // Arrange. var doc = new TextDocument(@" This is some test text. It needs to span multiple lines in order to demonstrate folding. "); var manager = new FoldingManager(doc); // Act. manager.UpdateFoldings(new[] { new NewFolding(17, 57) { DefaultClosed = true }, new NewFolding(101, 148) { DefaultClosed = true } }); // Assert. Assert.True(manager.AllFoldings.All(f => f.IsFolded)); }
/// <summary> /// Shows the given output in the text view. /// </summary> void ShowOutput(AvaloniaEditTextOutput textOutput, IHighlightingDefinition highlighting = null, DecompilerTextViewState state = null) { Debug.WriteLine("Showing {0} characters of output", textOutput.TextLength); Stopwatch w = Stopwatch.StartNew(); ClearLocalReferenceMarks(); textEditor.ScrollToHome(); if (foldingManager != null) { FoldingManager.Uninstall(foldingManager); foldingManager = null; } textEditor.Document = null; // clear old document while we're changing the highlighting uiElementGenerator.UIElements = textOutput.UIElements; referenceElementGenerator.References = textOutput.References; references = textOutput.References; definitionLookup = textOutput.DefinitionLookup; textEditor.SyntaxHighlighting = highlighting; textEditor.Options.EnableEmailHyperlinks = textOutput.EnableHyperlinks; textEditor.Options.EnableHyperlinks = textOutput.EnableHyperlinks; if (activeRichTextColorizer != null) { textEditor.TextArea.TextView.LineTransformers.Remove(activeRichTextColorizer); } if (textOutput.HighlightingModel != null) { activeRichTextColorizer = new RichTextColorizer(textOutput.HighlightingModel); textEditor.TextArea.TextView.LineTransformers.Insert(highlighting == null ? 0 : 1, activeRichTextColorizer); } // Change the set of active element generators: foreach (var elementGenerator in activeCustomElementGenerators) { textEditor.TextArea.TextView.ElementGenerators.Remove(elementGenerator); } activeCustomElementGenerators.Clear(); foreach (var elementGenerator in textOutput.elementGenerators) { textEditor.TextArea.TextView.ElementGenerators.Add(elementGenerator); activeCustomElementGenerators.Add(elementGenerator); } Debug.WriteLine(" Set-up: {0}", w.Elapsed); w.Restart(); textEditor.Document = textOutput.GetDocument(); Debug.WriteLine(" Assigning document: {0}", w.Elapsed); w.Restart(); if (textOutput.Foldings.Count > 0) { if (state != null) { state.RestoreFoldings(textOutput.Foldings); textEditor.ScrollToVerticalOffset(state.VerticalOffset); textEditor.ScrollToHorizontalOffset(state.HorizontalOffset); } foldingManager = FoldingManager.Install(textEditor.TextArea); foldingManager.UpdateFoldings(textOutput.Foldings.OrderBy(f => f.StartOffset), -1); Debug.WriteLine(" Updating folding: {0}", w.Elapsed); w.Restart(); } }
public void UpdateFoldings(ParseInformation parseInfo) { IEnumerable <NewFolding> newFoldings = GetNewFoldings(parseInfo); foldingManager.UpdateFoldings(newFoldings, -1); isFirstUpdate = false; }
/// <summary> /// Creates new foldings and updates a <see cref="FoldingManager"/> with them. /// </summary> public static IEnumerable <NewFolding> GenerateFoldings(this FoldingManager manager, TextDocument document, IFoldingStrategy strategy) { int firstErrorOffset; var newFoldings = strategy.CreateNewFoldings(document, out firstErrorOffset).ToList(); manager.UpdateFoldings(newFoldings); return(newFoldings); }
public void SuspendUpdate(bool clearFoldings = false) { m_Timer.Stop(); if (clearFoldings) { FoldingManager.UpdateFoldings(new List <NewFolding>(), -1); } }
public void UpdateFoldings(FoldingManager manager, TextDocument document) { var firstErrorOffset = -1; var foldings = CreateNewFoldings(document, firstErrorOffset); var sortedItems = foldings.OrderBy(x => x.StartOffset); manager.UpdateFoldings(sortedItems, firstErrorOffset); }
/// <summary> /// Create <see cref="NewFolding"/>s for the specified document and updates the folding manager with them. /// </summary> public void UpdateFoldings(FoldingManager manager, TextDocument document) { int firstErrorOffset; IEnumerable <NewFolding> foldings = CreateNewFoldings(document, out firstErrorOffset); var errors = foldings.Where(f => f.StartOffset <0 || f.EndOffset> document.TextLength).ToArray(); manager.UpdateFoldings(foldings, firstErrorOffset); }
/// <summary> /// Shows the given output in the text view. /// </summary> void ShowOutput(AvalonEditTextOutput textOutput, IHighlightingDefinition highlighting = null, DecompilerTextViewState state = null) { Debug.WriteLine("Showing {0} characters of output", textOutput.TextLength); Stopwatch w = Stopwatch.StartNew(); ClearLocalReferenceMarks(); textEditor.ScrollToHome(); if (foldingManager != null) { FoldingManager.Uninstall(foldingManager); foldingManager = null; } textEditor.Document = null; // clear old document while we're changing the highlighting uiElementGenerator.UIElements = textOutput.UIElements; referenceElementGenerator.References = textOutput.References; references = textOutput.References; definitionLookup = textOutput.DefinitionLookup; textEditor.SyntaxHighlighting = highlighting; // Change the set of active element generators: foreach (var elementGenerator in activeCustomElementGenerators) { textEditor.TextArea.TextView.ElementGenerators.Remove(elementGenerator); } activeCustomElementGenerators.Clear(); foreach (var elementGenerator in textOutput.elementGenerators) { textEditor.TextArea.TextView.ElementGenerators.Add(elementGenerator); activeCustomElementGenerators.Add(elementGenerator); } Debug.WriteLine(" Set-up: {0}", w.Elapsed); w.Restart(); textEditor.Document = textOutput.GetDocument(); Debug.WriteLine(" Assigning document: {0}", w.Elapsed); w.Restart(); if (textOutput.Foldings.Count > 0) { if (state != null) { state.RestoreFoldings(textOutput.Foldings); textEditor.ScrollToVerticalOffset(state.VerticalOffset); textEditor.ScrollToHorizontalOffset(state.HorizontalOffset); } foldingManager = FoldingManager.Install(textEditor.TextArea); foldingManager.UpdateFoldings(textOutput.Foldings.OrderBy(f => f.StartOffset), -1); Debug.WriteLine(" Updating folding: {0}", w.Elapsed); w.Restart(); } // update class bookmarks var document = textEditor.Document; manager.UpdateClassMemberBookmarks(textOutput.DefinitionLookup.ToDictionary(line => document.GetLineByOffset(line).LineNumber), typeof(TypeBookmark), typeof(MemberBookmark)); }
public void UpdateFoldings(StatementCollection statements) { var foldings = statements.FoldingSections .Where(IsMultilineOrNestedSection) .Select(s => new NewFolding(s.FoldingStart, s.FoldingEnd) { Name = s.Placeholder }); FoldingManager.UpdateFoldings(foldings, -1); }
public void UpdateFoldings(FoldingManager foldingManager, TextDocument textDocument) { // Clear foldings if the list isn't empty. if (this.foldings.Foldings.Count > 0) { this.foldings.Foldings.Clear(); } CreateNewFoldings(textDocument); foldingManager.UpdateFoldings(this.foldings.Foldings, this.foldings.FirstErrorOffset); }
private void tecCode_TextChanged(object sender, EventArgs e) { innerContent = textEditor.Text; SendSavedMessage(); if (foldingManager != null) { if (xmlFoldingStrategy != null) { xmlFoldingStrategy.UpdateFoldings(foldingManager, textEditor.Document); } else if (htmlFoldingStrategy != null) { htmlFoldingStrategy.UpdateFoldings(foldingManager, textEditor.Document); } else { foldingManager.UpdateFoldings(CreateBraceFoldings(textEditor.Document), -1); } } }
/// <summary> /// Restores the state of the foldings in the current text editor. /// </summary> /// <param name="foldings">The object representing the state of the foldings.</param> public void RestoreFoldings(object foldings) { var list = foldings as IEnumerable <NewFolding>; if (list == null) { return; } EnableFolding = true; FoldingManager.Clear(); FoldingManager.UpdateFoldings(list, -1); }
public void UpdateFoldings(ParseInformation parseInfo) { if (!textArea.Document.Version.Equals(parseInfo.ParsedVersion)) { SD.Log.Debug("Folding update ignored; parse information is outdated version"); return; } SD.Log.Debug("Update Foldings"); int firstErrorOffset = -1; IEnumerable <NewFolding> newFoldings = parseInfo.GetFoldings(textArea.Document, out firstErrorOffset); newFoldings = newFoldings.OrderBy(f => f.StartOffset); foldingManager.UpdateFoldings(newFoldings, firstErrorOffset); }
public void EnableFolding(bool enableFolding) { if (enableFolding) { switch (item.Type) { case CodeItemType.JavaScript: case CodeItemType.Style: { if (!foldingManagerInstalled) { foldingManager = FoldingManager.Install(textEditor.TextArea); foldingManagerInstalled = true; } foldingManager.UpdateFoldings(CreateBraceFoldings(textEditor.Document), -1); } break; case CodeItemType.LiquidTemplate: { if (!foldingManagerInstalled) { foldingManager = FoldingManager.Install(textEditor.TextArea); foldingManagerInstalled = true; } htmlFoldingStrategy = new HtmlFoldingStrategy(); htmlFoldingStrategy.UpdateFoldings(foldingManager, textEditor.Document); } break; } FoldingEnabled = true; } else { if (foldingManager != null) { foldingManager.Clear(); } FoldingEnabled = false; } }
public void FoldingUpdate(List <TOKEN> Tokens, int len) { List <NewFolding> newFoldings = new List <NewFolding>(); FodlingExec(Tokens, len, newFoldings); int lencash = len; try { textEditor.Dispatcher.Invoke(new Action(() => { if (lencash == textEditor.Document.TextLength) { foldingManager.UpdateFoldings(newFoldings, -1); } }), DispatcherPriority.Normal); } catch (Exception) { } }
protected override void UpdateFolding() { IEnumerable <NewFolding> newFoldings = CreateNewFoldings(); FoldingManager.UpdateFoldings(newFoldings, -1); }
public void UpdateFoldings(FoldingManager manager, TextDocument document) { manager.UpdateFoldings(CreateNewFoldings(document), 0); }
public void UpdateFoldings(FoldingManager manager, Block abstractSyntaxTree, string text) { manager.UpdateFoldings(GenerateFoldings(abstractSyntaxTree, text), -1); }
protected virtual void ApplyCodeFoldingData(CodeFoldingResult codeFoldingResult, int firstErrorOffset) { var foldings = codeFoldingResult.FoldingData; foldingManager.UpdateFoldings(foldings, firstErrorOffset); }
public void RemoveFoldings(FoldingManager manager, TextDocument document) { //IEnumerable<NewFolding> newFoldings = CreateNewFoldings(document, out int firstErrorOffset); manager.UpdateFoldings(new List <NewFolding>(), -1); }
public void UpdateFoldings(TextDocument document) { _foldingManager.UpdateFoldings(_strategy.UpdateFoldings(document), -1); }
public void UpdateFolds(IEnumerable <NewFolding> folds) { foldingManager.UpdateFoldings(folds, -1); }
public static void UpdateFolding(FoldingManager manager, TextDocument document, IDocumentItem morestachioDocument) { var foldings = CreateNewFoldings(document, morestachioDocument); manager.UpdateFoldings(foldings, -1); }
/// <summary> /// Shows the given output in the text view. /// </summary> void ShowOutput(AvalonEditTextOutput textOutput, IHighlightingDefinition highlighting = null, DecompilerTextViewState state = null) { Debug.WriteLine("Showing {0} characters of output", textOutput.TextLength); Stopwatch w = Stopwatch.StartNew(); ClearLocalReferenceMarks(); textEditor.ScrollToHome(); if (foldingManager != null) { FoldingManager.Uninstall(foldingManager); foldingManager = null; } textEditor.Document = null; // clear old document while we're changing the highlighting uiElementGenerator.UIElements = textOutput.UIElements; referenceElementGenerator.References = textOutput.References; references = textOutput.References; definitionLookup = textOutput.DefinitionLookup; textEditor.SyntaxHighlighting = highlighting; // Change the set of active element generators: foreach (var elementGenerator in activeCustomElementGenerators) { textEditor.TextArea.TextView.ElementGenerators.Remove(elementGenerator); } activeCustomElementGenerators.Clear(); foreach (var elementGenerator in textOutput.elementGenerators) { textEditor.TextArea.TextView.ElementGenerators.Add(elementGenerator); activeCustomElementGenerators.Add(elementGenerator); } Debug.WriteLine(" Set-up: {0}", w.Elapsed); w.Restart(); textEditor.Document = textOutput.GetDocument(); Debug.WriteLine(" Assigning document: {0}", w.Elapsed); w.Restart(); if (textOutput.Foldings.Count > 0) { if (state != null) { state.RestoreFoldings(textOutput.Foldings); textEditor.ScrollToVerticalOffset(state.VerticalOffset); textEditor.ScrollToHorizontalOffset(state.HorizontalOffset); } foldingManager = FoldingManager.Install(textEditor.TextArea); foldingManager.UpdateFoldings(textOutput.Foldings.OrderBy(f => f.StartOffset), -1); Debug.WriteLine(" Updating folding: {0}", w.Elapsed); w.Restart(); } // update debugger info DebugInformation.CodeMappings = textOutput.DebuggerMemberMappings.ToDictionary(m => m.MetadataToken); // update class bookmarks var document = textEditor.Document; manager.Bookmarks.Clear(); foreach (var pair in textOutput.DefinitionLookup.definitions) { IMemberRef member = pair.Key as IMemberRef; int offset = pair.Value; if (member != null) { int line = document.GetLocation(offset).Line; manager.Bookmarks.Add(new MemberBookmark(member, line)); } } }