Browse Source

Removed dependency on Value.ExpressionTree from Grid visualizer and WatchPad.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4956 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Martin Koníček 16 years ago
parent
commit
0c173cf688
  1. 5
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/WatchPad.cs
  2. 22
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs
  3. 16
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/GridVisualizer/GridVisualizerWindow.xaml.cs

5
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/WatchPad.cs

@ -197,8 +197,9 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
foreach (var nod in watches) { foreach (var nod in watches) {
try { try {
LoggingService.Info("Evaluating: " + (string.IsNullOrEmpty(nod.Name) ? "is null or empty!" : nod.Name)); LoggingService.Info("Evaluating: " + (string.IsNullOrEmpty(nod.Name) ? "is null or empty!" : nod.Name));
Value val = ExpressionEvaluator.Evaluate(nod.Name, nod.Language, debuggedProcess.SelectedStackFrame); var nodExpression = debugger.GetExpression(nod.Name);
ExpressionNode valNode = new ExpressionNode(null, nod.Name, val.ExpressionTree); //Value val = ExpressionEvaluator.Evaluate(nod.Name, nod.Language, debuggedProcess.SelectedStackFrame);
ExpressionNode valNode = new ExpressionNode(null, nod.Name, nodExpression);
nodes.Add(new TreeViewVarNode(debuggedProcess, watchList, valNode)); nodes.Add(new TreeViewVarNode(debuggedProcess, watchList, valNode));
} catch (GetValueException) { } catch (GetValueException) {
string error = String.Format(StringParser.Parse("${res:MainWindow.Windows.Debug.Watch.InvalidExpression}"), nod.Name); string error = String.Format(StringParser.Parse("${res:MainWindow.Windows.Debug.Watch.InvalidExpression}"), nod.Name);

22
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs

@ -37,6 +37,7 @@
// //
#endregion #endregion
using ICSharpCode.NRefactory.Ast;
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.Drawing;
@ -44,7 +45,6 @@ using System.IO;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using Debugger; using Debugger;
using Debugger.AddIn; using Debugger.AddIn;
using Debugger.AddIn.TreeModel; using Debugger.AddIn.TreeModel;
@ -341,9 +341,20 @@ namespace ICSharpCode.SharpDevelop.Services
{ {
if (!CanEvaluate) { if (!CanEvaluate) {
return null; return null;
} else {
return ExpressionEvaluator.Evaluate(variableName, SupportedLanguage.CSharp, debuggedProcess.SelectedStackFrame);
} }
return ExpressionEvaluator.Evaluate(variableName, SupportedLanguage.CSharp, debuggedProcess.SelectedStackFrame);
}
/// <summary>
/// Gets Expression for given variable. Can throw GetValueException.
/// <exception cref="GetValueException">Thrown when getting expression fails. Exception message explains reason.</exception>
/// </summary>
public Expression GetExpression(string variableName)
{
if (!CanEvaluate) {
throw new GetValueException("Cannot evaluate now - debugged process is either null or running or has no selected stack frame");
}
return ExpressionEvaluator.ParseExpression(variableName, SupportedLanguage.CSharp);
} }
public bool IsManaged(int processId) public bool IsManaged(int processId)
@ -387,11 +398,8 @@ namespace ICSharpCode.SharpDevelop.Services
/// </summary> /// </summary>
public object GetTooltipControl(string variableName) public object GetTooltipControl(string variableName)
{ {
if (!CanEvaluate) {
return null;
}
try { try {
var tooltipExpression = ExpressionEvaluator.ParseExpression(variableName, SupportedLanguage.CSharp); var tooltipExpression = GetExpression(variableName);
ExpressionNode expressionNode = new ExpressionNode(ExpressionNode.GetImageForLocalVariable(), variableName, tooltipExpression); ExpressionNode expressionNode = new ExpressionNode(ExpressionNode.GetImageForLocalVariable(), variableName, tooltipExpression);
return new DebuggerTooltipControl(expressionNode); return new DebuggerTooltipControl(expressionNode);
} catch (GetValueException) { } catch (GetValueException) {

16
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/GridVisualizer/GridVisualizerWindow.xaml.cs

@ -111,29 +111,31 @@ namespace Debugger.AddIn.Visualizers.GridVisualizer
if (listViewScroller != null) { if (listViewScroller != null) {
listViewScroller.ScrollToVerticalOffset(0); listViewScroller.ScrollToVerticalOffset(0);
} }
Value val = null; Value shownValue = null;
ICSharpCode.NRefactory.Ast.Expression shownExpr = null;
try { try {
val = debuggerService.GetValueFromName(txtExpression.Text); shownExpr = debuggerService.GetExpression(txtExpression.Text);
shownValue = shownExpr.Evaluate(debuggerService.DebuggedProcess);
} catch(GetValueException) { } catch(GetValueException) {
// display ex.Message // display ex.Message
} }
if (val != null && !val.IsNull) { if (shownValue != null && !shownValue.IsNull) {
GridValuesProvider gridValuesProvider; GridValuesProvider gridValuesProvider;
// Value is IList // Value is IList
DebugType iListType, listItemType; DebugType iListType, listItemType;
if (val.Type.ResolveIListImplementation(out iListType, out listItemType)) { if (shownValue.Type.ResolveIListImplementation(out iListType, out listItemType)) {
gridValuesProvider = CreateListValuesProvider(val.ExpressionTree, iListType, listItemType); gridValuesProvider = CreateListValuesProvider(shownExpr, iListType, listItemType);
} else { } else {
// Value is IEnumerable // Value is IEnumerable
DebugType iEnumerableType, itemType; DebugType iEnumerableType, itemType;
if (val.Type.ResolveIEnumerableImplementation(out iEnumerableType, out itemType)) { if (shownValue.Type.ResolveIEnumerableImplementation(out iEnumerableType, out itemType)) {
// original // original
/*var lazyListViewWrapper = new LazyItemsControl<ObjectValue>(this.listView, initialIEnumerableItemsCount); /*var lazyListViewWrapper = new LazyItemsControl<ObjectValue>(this.listView, initialIEnumerableItemsCount);
var enumerableValuesProvider = new EnumerableValuesProvider(val.ExpressionTree, iEnumerableType, itemType); var enumerableValuesProvider = new EnumerableValuesProvider(val.ExpressionTree, iEnumerableType, itemType);
lazyListViewWrapper.ItemsSource = new VirtualizingIEnumerable<ObjectValue>(enumerableValuesProvider.ItemsSource); lazyListViewWrapper.ItemsSource = new VirtualizingIEnumerable<ObjectValue>(enumerableValuesProvider.ItemsSource);
gridValuesProvider = enumerableValuesProvider;*/ gridValuesProvider = enumerableValuesProvider;*/
DebugType debugListType; DebugType debugListType;
var debugListExpression = DebuggerHelpers.CreateDebugListExpression(val.ExpressionTree, itemType, out debugListType); var debugListExpression = DebuggerHelpers.CreateDebugListExpression(shownExpr, itemType, out debugListType);
gridValuesProvider = CreateListValuesProvider(debugListExpression, debugListType, itemType); gridValuesProvider = CreateListValuesProvider(debugListExpression, debugListType, itemType);
} else { } else {
// Value cannot be displayed in GridVisualizer // Value cannot be displayed in GridVisualizer

Loading…
Cancel
Save