From c29b384d65a9eda33fc33a6aa14f9d9f4526faa8 Mon Sep 17 00:00:00 2001 From: JohnnyBravo75 Date: Mon, 28 Jul 2014 00:44:05 +0200 Subject: [PATCH] -FIX: Update of treenode did not work, new node is created an replaces the old. -CHG: Formating, cleanup --- .../Project/Src/OutlinePad/AstNodeHelper.cs | 27 +++++++------ .../Src/OutlinePad/CSharpOutlineCommands.cs | 10 ++--- .../CSharpOutlineContentHost.xaml.cs | 40 +++---------------- .../Src/OutlinePad/CSharpOutlineNode.cs | 4 +- .../Src/OutlinePad/ExtensionMethods.cs | 8 ++-- 5 files changed, 30 insertions(+), 59 deletions(-) diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/AstNodeHelper.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/AstNodeHelper.cs index 04f9f369d5..ce669d5f37 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/AstNodeHelper.cs +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/AstNodeHelper.cs @@ -16,17 +16,18 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +using System; +using System.IO; +using System.Linq; +using System.Windows; +using System.Windows.Media; +using System.Text; +using ICSharpCode.NRefactory.CSharp; +using ICSharpCode.AvalonEdit.Highlighting; +using System.Collections.Generic; + namespace CSharpBinding.OutlinePad { - using System; - using System.IO; - using System.Linq; - using System.Windows; - using System.Windows.Media; - using System.Text; - using ICSharpCode.NRefactory.CSharp; - using ICSharpCode.AvalonEdit.Highlighting; - internal static class AstNodeHelper { static bool showExtendedInfos = true; @@ -114,17 +115,17 @@ namespace CSharpBinding.OutlinePad || IsOperator(node) ); } - + public static bool IsRegionStart(AstNode node) { return (node is PreProcessorDirective && (node as PreProcessorDirective).Type == PreProcessorDirectiveType.Region); } internal static void SetRegionStartInfos(CSharpOutlineNode node, AstNode dataNode) { var preProcessorNode = (PreProcessorDirective)dataNode; - node.Name = "****** " + preProcessorNode.Argument + " *****"; + node.Name = "*****" + preProcessorNode.Argument + "****"; node.ForegroundBrush = (regionHighLighting.Foreground as SimpleHighlightingBrush).GetBrush(null); // node.Weight = regionHighLighting.FontWeight != null ? regionHighLighting.FontWeight.Value : FontWeights.Normal; - } + } public static bool IsRegionEnd(AstNode node) { return (node is PreProcessorDirective && (node as PreProcessorDirective).Type == PreProcessorDirectiveType.Endregion); @@ -132,7 +133,7 @@ namespace CSharpBinding.OutlinePad internal static void SetRegionEndInfos(CSharpOutlineNode node, AstNode dataNode) { var preProcessorNode = (PreProcessorDirective)dataNode; - node.Name = "*********************"; + node.Name = "********************"; node.ForegroundBrush = (regionHighLighting.Foreground as SimpleHighlightingBrush).GetBrush(null); // node.Weight = regionHighLighting.FontWeight != null ? regionHighLighting.FontWeight.Value : FontWeights.Normal; } diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/CSharpOutlineCommands.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/CSharpOutlineCommands.cs index 4815cc9211..4c5704fa63 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/CSharpOutlineCommands.cs +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/CSharpOutlineCommands.cs @@ -16,13 +16,13 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +using System; +using ICSharpCode.SharpDevelop; +using ICSharpCode.AvalonEdit.Folding; +using System.Linq; + namespace CSharpBinding.OutlinePad { - using System; - using ICSharpCode.SharpDevelop; - using ICSharpCode.AvalonEdit.Folding; - using System.Linq; - /// /// RemoveNodeCommand. /// diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/CSharpOutlineContentHost.xaml.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/CSharpOutlineContentHost.xaml.cs index 46c9b4d9b4..788c5c6a0f 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/CSharpOutlineContentHost.xaml.cs +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/CSharpOutlineContentHost.xaml.cs @@ -20,7 +20,7 @@ using System; using System.Linq; using System.Windows.Controls; using System.Windows.Input; - +using System.Windows.Threading; using ICSharpCode.Core; using ICSharpCode.NRefactory; using ICSharpCode.NRefactory.CSharp; @@ -29,9 +29,6 @@ using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Parser; using CSharpBinding.Parser; -using System.Windows.Threading; -using ICSharpCode.AvalonEdit.Highlighting; -using ICSharpCode.AvalonEdit.Folding; namespace CSharpBinding.OutlinePad { @@ -89,9 +86,6 @@ namespace CSharpBinding.OutlinePad // prevent unnecessary looping, when both CaretLocationChanged and ParseUpdateChanged are fired. if (this.lastCaretLocation.HasValue && this.lastCaretLocation == this.editor.Caret.Location) return; - // same line, mostly in the same region, no update needed (there is a small inaccuracy, when entering a method/member) -// if (this.lastCaretLocation.HasValue && this.lastCaretLocation.Value.Line == this.editor.Caret.Location.Line) -// return; this.lastCaretLocation = this.editor.Caret.Location; selectedNode = null; @@ -108,9 +102,9 @@ namespace CSharpBinding.OutlinePad bool IsRangeInside(TextLocation outerStartLocation, TextLocation outerEndLocation, TextLocation innerStartLocation, TextLocation innerEndLocation) { if (outerStartLocation.IsEmpty || outerStartLocation.IsInfinite() || - outerEndLocation.IsEmpty || outerEndLocation.IsInfinite() || + outerEndLocation.IsEmpty || outerEndLocation.IsInfinite() || innerStartLocation.IsEmpty || innerStartLocation.IsInfinite() || - innerEndLocation.IsEmpty || innerEndLocation.IsInfinite()) + innerEndLocation.IsEmpty || innerEndLocation.IsInfinite()) return false; const int virtualLineLength = 200; @@ -175,19 +169,6 @@ namespace CSharpBinding.OutlinePad for (int i = 0; i < Math.Max(childrenCount, dataCount); i++) { if (i >= childrenCount) { - -// if (AstNodeHelper.IsRegionStart(dataChildren[i])) { -// var regionNode = new CSharpOutlineNode(); -// SetNodeInfos(regionNode, node, dataChildren[i]); -// node.Children.Add(regionNode); -// node = regionNode; -// continue; -// } -// if (AstNodeHelper.IsRegionEnd(dataChildren[i])) { -// node = node.Parent; -// continue; -// } - node.Children.Add(BuildNode(node, dataChildren[i])); } else if (i >= dataCount) { @@ -195,6 +176,8 @@ namespace CSharpBinding.OutlinePad node.Children.RemoveAt(dataCount); } else { + // Create new node, the old node doesn´t update (seems to be a bug) + node.Children[i] = new CSharpOutlineNode(); UpdateNode(node.Children[i] as CSharpOutlineNode, dataChildren[i]); } } @@ -208,20 +191,7 @@ namespace CSharpBinding.OutlinePad // Filter the children, for only the needed/wanted nodes var dataChildren = dataNode.Children.Where(v => AstNodeHelper.IsAllowedNode(v)).ToList(); foreach (var child in dataChildren) { -// if (AstNodeHelper.IsRegionStart(child)) { -// var regionNode = new CSharpOutlineNode(); -// SetNodeInfos(regionNode, node, child); -// node.Children.Add(regionNode); -// node = regionNode; -// continue; -// } -// if (AstNodeHelper.IsRegionEnd(child)) { -// node = node.Parent; -// continue; -// } - node.Children.Add(BuildNode(node, child)); - } return node; } diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/CSharpOutlineNode.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/CSharpOutlineNode.cs index 2d77de1fd2..c279a61d53 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/CSharpOutlineNode.cs +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/CSharpOutlineNode.cs @@ -155,13 +155,13 @@ namespace CSharpBinding.OutlinePad } protected override void OnExpanding() { - var cmd = new HandleFoldingCommand(); + var cmd = new HandleFoldingCommand(); if (cmd.CanExecute(this)) cmd.Execute(this); } protected override void OnCollapsing() { - var cmd = new HandleFoldingCommand(); + var cmd = new HandleFoldingCommand(); if (cmd.CanExecute(this)) cmd.Execute(this); } diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/ExtensionMethods.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/ExtensionMethods.cs index 0b62999986..46eab1fe14 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/ExtensionMethods.cs +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/ExtensionMethods.cs @@ -16,11 +16,11 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -namespace CSharpBinding.OutlinePad -{ - using System; - using ICSharpCode.NRefactory; +using System; +using ICSharpCode.NRefactory; +namespace CSharpBinding.OutlinePad +{ /// /// Description of TextLocationExtensions. ///