Browse Source

-FIX: Update of treenode did not work, new node is created an replaces the old.

-CHG: Formating, cleanup
pull/520/head
JohnnyBravo75 11 years ago
parent
commit
c29b384d65
  1. 25
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/AstNodeHelper.cs
  2. 10
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/CSharpOutlineCommands.cs
  3. 40
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/CSharpOutlineContentHost.xaml.cs
  4. 4
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/CSharpOutlineNode.cs
  5. 6
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/ExtensionMethods.cs

25
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 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // 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 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 { internal static class AstNodeHelper {
static bool showExtendedInfos = true; static bool showExtendedInfos = true;
@ -121,10 +122,10 @@ namespace CSharpBinding.OutlinePad
internal static void SetRegionStartInfos(CSharpOutlineNode node, AstNode dataNode) { internal static void SetRegionStartInfos(CSharpOutlineNode node, AstNode dataNode) {
var preProcessorNode = (PreProcessorDirective)dataNode; var preProcessorNode = (PreProcessorDirective)dataNode;
node.Name = "****** " + preProcessorNode.Argument + " *****"; node.Name = "*****" + preProcessorNode.Argument + "****";
node.ForegroundBrush = (regionHighLighting.Foreground as SimpleHighlightingBrush).GetBrush(null); node.ForegroundBrush = (regionHighLighting.Foreground as SimpleHighlightingBrush).GetBrush(null);
// node.Weight = regionHighLighting.FontWeight != null ? regionHighLighting.FontWeight.Value : FontWeights.Normal; // node.Weight = regionHighLighting.FontWeight != null ? regionHighLighting.FontWeight.Value : FontWeights.Normal;
} }
public static bool IsRegionEnd(AstNode node) { public static bool IsRegionEnd(AstNode node) {
return (node is PreProcessorDirective && (node as PreProcessorDirective).Type == PreProcessorDirectiveType.Endregion); 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) { internal static void SetRegionEndInfos(CSharpOutlineNode node, AstNode dataNode) {
var preProcessorNode = (PreProcessorDirective)dataNode; var preProcessorNode = (PreProcessorDirective)dataNode;
node.Name = "*********************"; node.Name = "********************";
node.ForegroundBrush = (regionHighLighting.Foreground as SimpleHighlightingBrush).GetBrush(null); node.ForegroundBrush = (regionHighLighting.Foreground as SimpleHighlightingBrush).GetBrush(null);
// node.Weight = regionHighLighting.FontWeight != null ? regionHighLighting.FontWeight.Value : FontWeights.Normal; // node.Weight = regionHighLighting.FontWeight != null ? regionHighLighting.FontWeight.Value : FontWeights.Normal;
} }

10
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 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System;
using ICSharpCode.SharpDevelop;
using ICSharpCode.AvalonEdit.Folding;
using System.Linq;
namespace CSharpBinding.OutlinePad namespace CSharpBinding.OutlinePad
{ {
using System;
using ICSharpCode.SharpDevelop;
using ICSharpCode.AvalonEdit.Folding;
using System.Linq;
/// <summary> /// <summary>
/// RemoveNodeCommand. /// RemoveNodeCommand.
/// </summary> /// </summary>

40
src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/CSharpOutlineContentHost.xaml.cs

@ -20,7 +20,7 @@ using System;
using System.Linq; using System.Linq;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Threading;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.NRefactory; using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.CSharp; using ICSharpCode.NRefactory.CSharp;
@ -29,9 +29,6 @@ using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Parser; using ICSharpCode.SharpDevelop.Parser;
using CSharpBinding.Parser; using CSharpBinding.Parser;
using System.Windows.Threading;
using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.AvalonEdit.Folding;
namespace CSharpBinding.OutlinePad namespace CSharpBinding.OutlinePad
{ {
@ -89,9 +86,6 @@ namespace CSharpBinding.OutlinePad
// prevent unnecessary looping, when both CaretLocationChanged and ParseUpdateChanged are fired. // prevent unnecessary looping, when both CaretLocationChanged and ParseUpdateChanged are fired.
if (this.lastCaretLocation.HasValue && this.lastCaretLocation == this.editor.Caret.Location) if (this.lastCaretLocation.HasValue && this.lastCaretLocation == this.editor.Caret.Location)
return; 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; this.lastCaretLocation = this.editor.Caret.Location;
selectedNode = null; selectedNode = null;
@ -108,9 +102,9 @@ namespace CSharpBinding.OutlinePad
bool IsRangeInside(TextLocation outerStartLocation, TextLocation outerEndLocation, bool IsRangeInside(TextLocation outerStartLocation, TextLocation outerEndLocation,
TextLocation innerStartLocation, TextLocation innerEndLocation) { TextLocation innerStartLocation, TextLocation innerEndLocation) {
if (outerStartLocation.IsEmpty || outerStartLocation.IsInfinite() || if (outerStartLocation.IsEmpty || outerStartLocation.IsInfinite() ||
outerEndLocation.IsEmpty || outerEndLocation.IsInfinite() || outerEndLocation.IsEmpty || outerEndLocation.IsInfinite() ||
innerStartLocation.IsEmpty || innerStartLocation.IsInfinite() || innerStartLocation.IsEmpty || innerStartLocation.IsInfinite() ||
innerEndLocation.IsEmpty || innerEndLocation.IsInfinite()) innerEndLocation.IsEmpty || innerEndLocation.IsInfinite())
return false; return false;
const int virtualLineLength = 200; const int virtualLineLength = 200;
@ -175,19 +169,6 @@ namespace CSharpBinding.OutlinePad
for (int i = 0; i < Math.Max(childrenCount, dataCount); i++) { for (int i = 0; i < Math.Max(childrenCount, dataCount); i++) {
if (i >= childrenCount) { 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])); node.Children.Add(BuildNode(node, dataChildren[i]));
} else if (i >= dataCount) { } else if (i >= dataCount) {
@ -195,6 +176,8 @@ namespace CSharpBinding.OutlinePad
node.Children.RemoveAt(dataCount); node.Children.RemoveAt(dataCount);
} else { } 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]); UpdateNode(node.Children[i] as CSharpOutlineNode, dataChildren[i]);
} }
} }
@ -208,20 +191,7 @@ namespace CSharpBinding.OutlinePad
// Filter the children, for only the needed/wanted nodes // Filter the children, for only the needed/wanted nodes
var dataChildren = dataNode.Children.Where(v => AstNodeHelper.IsAllowedNode(v)).ToList(); var dataChildren = dataNode.Children.Where(v => AstNodeHelper.IsAllowedNode(v)).ToList();
foreach (var child in dataChildren) { 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)); node.Children.Add(BuildNode(node, child));
} }
return node; return node;
} }

4
src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/CSharpOutlineNode.cs

@ -155,13 +155,13 @@ namespace CSharpBinding.OutlinePad
} }
protected override void OnExpanding() { protected override void OnExpanding() {
var cmd = new HandleFoldingCommand(); var cmd = new HandleFoldingCommand();
if (cmd.CanExecute(this)) if (cmd.CanExecute(this))
cmd.Execute(this); cmd.Execute(this);
} }
protected override void OnCollapsing() { protected override void OnCollapsing() {
var cmd = new HandleFoldingCommand(); var cmd = new HandleFoldingCommand();
if (cmd.CanExecute(this)) if (cmd.CanExecute(this))
cmd.Execute(this); cmd.Execute(this);
} }

6
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 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System;
using ICSharpCode.NRefactory;
namespace CSharpBinding.OutlinePad namespace CSharpBinding.OutlinePad
{ {
using System;
using ICSharpCode.NRefactory;
/// <summary> /// <summary>
/// Description of TextLocationExtensions. /// Description of TextLocationExtensions.
/// </summary> /// </summary>

Loading…
Cancel
Save