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. 27
      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. 8
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/ExtensionMethods.cs

27
src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/AstNodeHelper.cs

@ -16,17 +16,18 @@ @@ -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 @@ -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 @@ -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;
}

10
src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/CSharpOutlineCommands.cs

@ -16,13 +16,13 @@ @@ -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;
/// <summary>
/// RemoveNodeCommand.
/// </summary>

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

@ -20,7 +20,7 @@ using System; @@ -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; @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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;
}

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

@ -155,13 +155,13 @@ namespace CSharpBinding.OutlinePad @@ -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);
}

8
src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/ExtensionMethods.cs

@ -16,11 +16,11 @@ @@ -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
{
/// <summary>
/// Description of TextLocationExtensions.
/// </summary>

Loading…
Cancel
Save