Browse Source

Debugger tooltips are filled with real content.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@669 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 21 years ago
parent
commit
352a57c1b0
  1. 1
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj
  2. 48
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/DynamicTreeDebuggerRow.cs
  3. 66
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs
  4. 10
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs
  5. 16
      src/Main/Base/Project/Src/Services/Debugger/DebuggerGridControl.cs
  6. 4
      src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs
  7. 25
      src/Main/Base/Project/Src/Services/Debugger/DefaultDebugger.cs
  8. 6
      src/Main/Base/Project/Src/Services/Debugger/IDebugger.cs

1
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj

@ -59,6 +59,7 @@
<Compile Include="Src\Pads\VariableListItems\PlaceHolderItem.cs" /> <Compile Include="Src\Pads\VariableListItems\PlaceHolderItem.cs" />
<Compile Include="Src\Pads\VariableListItems\VariableItem.cs" /> <Compile Include="Src\Pads\VariableListItems\VariableItem.cs" />
<Compile Include="Src\Pads\VariableListItems\VariableListItem.cs" /> <Compile Include="Src\Pads\VariableListItems\VariableListItem.cs" />
<Compile Include="Src\Service\DynamicTreeDebuggerRow.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\..\..\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj"> <ProjectReference Include="..\..\..\..\..\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj">

48
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/DynamicTreeDebuggerRow.cs

@ -0,0 +1,48 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
using DebuggerLibrary;
using ICSharpCode.SharpDevelop.Gui.TreeGrid;
namespace ICSharpCode.SharpDevelop.Services
{
public class DynamicTreeDebuggerRow:DynamicTreeRow
{
// Columns:
// 0 = plus sign
// 1 = icon
// 2 = text
// 3 = value
Variable variable;
public Variable Variable {
get {
return variable;
}
set {
variable = value;
}
}
public DynamicTreeDebuggerRow()
{
}
public DynamicTreeDebuggerRow(Variable variable)
{
if (variable == null) throw new ArgumentNullException("variable");
this.variable = variable;
this.ChildWindowCaption = variable.Name;
this[2].Text = variable.Name;
this[3].Text = variable.ToString();
}
}
}

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

@ -20,6 +20,7 @@ using System.CodeDom.Compiler;
using ICSharpCode.TextEditor; using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document; using ICSharpCode.TextEditor.Document;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Gui.TreeGrid;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Services; using ICSharpCode.SharpDevelop.Services;
using System.Runtime.Remoting; using System.Runtime.Remoting;
@ -191,28 +192,69 @@ namespace ICSharpCode.SharpDevelop.Services
} }
/// <summary> /// <summary>
/// Gets the current value of the variable as string that can be displayed in tooltips. /// Gets variable of given name.
/// Returns null if unsuccessful.
/// </summary> /// </summary>
public string GetValueAsString(string variableName) public Variable GetVariableFromName(string variableName)
{ {
if (debugger == null || debugger.IsRunning) return null; if (debugger == null || debugger.IsRunning) return null;
VariableCollection collection = debugger.LocalVariables; VariableCollection collection = debugger.LocalVariables;
if (collection == null) {
return null;
}
object val; if (collection == null) return null;
try { try {
val = collection[variableName].Value; return collection[variableName];
} catch (DebuggerException) { } catch (DebuggerException) {
return null; return null;
} }
if (val == null) { }
return "<null>";
} else if (val is string) {
return "\"" + val.ToString() + "\""; /// <summary>
/// Gets the current value of the variable as string that can be displayed in tooltips.
/// Returns null if unsuccessful.
/// </summary>
public string GetValueAsString(string variableName)
{
Variable variable = GetVariableFromName(variableName);
if (variable == null) {
return null;
} else { } else {
return val.ToString(); return variable.ToString();
}
}
/// <summary>
/// Gets the tooltip control that shows the value of given variable.
/// Return null if no tooltip is available.
/// </summary>
public DebuggerGridControl GetTooltipControl(string variableName)
{
Variable variable = GetVariableFromName(variableName);
if (variable == null) {
return null;
} else {
DynamicTreeDebuggerRow newRow = new DynamicTreeDebuggerRow(variable);
newRow.Expanding += TooltipControlRowExpanding;
return new DebuggerGridControl(newRow);
}
}
/// <summary>
/// Called when plus is pressed in debugger tooltip.
/// Sets the data to be show in the next level.
/// </summary>
void TooltipControlRowExpanding(object sender, EventArgs args)
{
DynamicTreeDebuggerRow row = (DynamicTreeDebuggerRow) sender;
row.ChildRows.Clear();
foreach(Variable variable in row.Variable.SubVariables) {
DynamicTreeDebuggerRow newRow = new DynamicTreeDebuggerRow(variable);
newRow.Expanding += TooltipControlRowExpanding;
row.ChildRows.Add(newRow);
} }
} }

10
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs

@ -80,7 +80,15 @@ namespace DebuggerLibrary
public override string ToString() public override string ToString()
{ {
return String.Format("Name = {0,-25} Value = {1,-30} Type = {2,-30}", Name, Value, Type); //return String.Format("Name = {0,-25} Value = {1,-30} Type = {2,-30}", Name, Value, Type);
if (Value == null) {
return "<null>";
} else if (Value is string) {
return "\"" + Value.ToString() + "\"";
} else {
return Value.ToString();
}
} }

16
src/Main/Base/Project/Src/Services/Debugger/DebuggerGridControl.cs

@ -20,10 +20,12 @@ namespace ICSharpCode.Core
// 2 = text // 2 = text
// 3 = value // 3 = value
DynamicTreeRow row = new DynamicTreeRow(); DynamicTreeRow row;
public DebuggerGridControl(string text, string value) public DebuggerGridControl(DynamicTreeRow row)
{ {
this.row = row;
BeginUpdate(); BeginUpdate();
Columns.Add(new DynamicListColumn()); Columns.Add(new DynamicListColumn());
Columns.Add(new DynamicListColumn()); Columns.Add(new DynamicListColumn());
@ -37,14 +39,10 @@ namespace ICSharpCode.Core
Columns[2].AutoSize = true; Columns[2].AutoSize = true;
Columns[3].AutoSize = true; Columns[3].AutoSize = true;
Rows.Add(row); Rows.Add(row);
row.ChildWindowCaption = text;
row[2].Text = text;
row[3].Text = value;
foreach (DynamicListColumn col in Columns) { foreach (DynamicListColumn col in Columns) {
row.ChildColumns.Add(col.Clone()); row.ChildColumns.Add(col.Clone());
} }
row.Expanding += RowExpanding;
row.Expanded += delegate { isExpanded = true; }; row.Expanded += delegate { isExpanded = true; };
row.Collapsed += delegate { isExpanded = false; }; row.Collapsed += delegate { isExpanded = false; };
@ -93,11 +91,5 @@ namespace ICSharpCode.Core
return !isExpanded; return !isExpanded;
} }
} }
void RowExpanding(object sender, EventArgs e)
{
row.ChildRows.Clear();
row.ChildRows.Add(row);
}
} }
} }

4
src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs

@ -351,8 +351,8 @@ namespace ICSharpCode.Core
if (toolTipText != null) { if (toolTipText != null) {
if (Control.ModifierKeys == Keys.Control) { if (Control.ModifierKeys == Keys.Control) {
toolTipText = "expr: " + expressionResult.ToString() + "\n" + toolTipText; toolTipText = "expr: " + expressionResult.ToString() + "\n" + toolTipText;
} else if (debuggerCanShowValue) { } else if (debuggerCanShowValue && currentDebugger != null) {
toolTipControl = new DebuggerGridControl("hello", "world"); toolTipControl = currentDebugger.GetTooltipControl(expressionResult.ToString().Replace("<","").Replace(">",""));
toolTipText = null; toolTipText = null;
} }
} }

25
src/Main/Base/Project/Src/Services/Debugger/DefaultDebugger.cs

@ -105,6 +105,23 @@ namespace ICSharpCode.Core
throw new NotSupportedException(); throw new NotSupportedException();
} }
/// <summary>
/// Gets the current value of the variable as string that can be displayed in tooltips.
/// </summary>
public string GetValueAsString(string variable)
{
return null;
}
/// <summary>
/// Gets the tooltip control that shows the value of given variable.
/// Return null if no tooltip is available.
/// </summary>
public DebuggerGridControl GetTooltipControl(string variable)
{
return null;
}
public event EventHandler DebugStarted; public event EventHandler DebugStarted;
protected virtual void OnDebugStarted(EventArgs e) protected virtual void OnDebugStarted(EventArgs e)
@ -134,14 +151,6 @@ namespace ICSharpCode.Core
} }
} }
/// <summary>
/// Gets the current value of the variable as string that can be displayed in tooltips.
/// </summary>
public string GetValueAsString(string variable)
{
return null;
}
public void Dispose() public void Dispose()
{ {
Stop(); Stop();

6
src/Main/Base/Project/Src/Services/Debugger/IDebugger.cs

@ -61,6 +61,12 @@ namespace ICSharpCode.Core
/// </summary> /// </summary>
string GetValueAsString(string variable); string GetValueAsString(string variable);
/// <summary>
/// Gets the tooltip control that shows the value of given variable.
/// Return null if no tooltip is available.
/// </summary>
DebuggerGridControl GetTooltipControl(string variable);
/// <summary> /// <summary>
/// Ocurrs after the debugger has started. /// Ocurrs after the debugger has started.
/// </summary> /// </summary>

Loading…
Cancel
Save