Browse Source

Removed Value.ExpressionTree dependency from WindowsDebugger.GetTooltipControl.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4949 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Martin Koníček 16 years ago
parent
commit
136cbfc513
  1. 21
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs
  2. 17
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Expressions/ExpressionEvaluator.cs

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

@ -339,7 +339,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -339,7 +339,7 @@ namespace ICSharpCode.SharpDevelop.Services
/// </summary>
public Value GetValueFromName(string variableName)
{
if (debuggedProcess == null || debuggedProcess.IsRunning || debuggedProcess.SelectedStackFrame == null) {
if (!CanEvaluate) {
return null;
} else {
return ExpressionEvaluator.Evaluate(variableName, SupportedLanguage.CSharp, debuggedProcess.SelectedStackFrame);
@ -374,22 +374,29 @@ namespace ICSharpCode.SharpDevelop.Services @@ -374,22 +374,29 @@ namespace ICSharpCode.SharpDevelop.Services
}
}
bool CanEvaluate
{
get {
return debuggedProcess != null && !debuggedProcess.IsRunning && debuggedProcess.SelectedStackFrame != null;
}
}
/// <summary>
/// Gets the tooltip control that shows the value of given variable.
/// Return null if no tooltip is available.
/// </summary>
public object GetTooltipControl(string variableName)
{
ExpressionNode expressionNode;
if (!CanEvaluate) {
return null;
}
try {
Value val = GetValueFromName(variableName);
if (val == null) return null;
expressionNode = new ExpressionNode(ExpressionNode.GetImageForLocalVariable(), variableName, val.ExpressionTree);
var tooltipExpression = ExpressionEvaluator.ParseExpression(variableName, SupportedLanguage.CSharp);
ExpressionNode expressionNode = new ExpressionNode(ExpressionNode.GetImageForLocalVariable(), variableName, tooltipExpression);
return new DebuggerTooltipControl(expressionNode);
} catch (GetValueException) {
return null;
}
return new DebuggerTooltipControl(expressionNode);
}
public bool CanSetInstructionPointer(string filename, int line, int column)

17
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Expressions/ExpressionEvaluator.cs

@ -54,6 +54,23 @@ namespace Debugger @@ -54,6 +54,23 @@ namespace Debugger
return new ExpressionEvaluator(context).Evaluate(code, false);
}
/// <summary>
/// Parses string representation of an expression (eg. "a.b[10] + 2") into NRefactory Expression tree.
/// </summary>
public static Expression ParseExpression(string code, SupportedLanguage language)
{
SnippetParser parser = new SnippetParser(language);
INode astRoot = parser.Parse(code);
if (parser.Errors.Count > 0) {
throw new GetValueException(parser.Errors.ErrorOutput);
}
Expression astExpression = astRoot as Expression;
if (astExpression == null) {
throw new GetValueException("Code must be expression");
}
return astExpression;
}
public static string FormatValue(Value val)
{
if (val == null) {

Loading…
Cancel
Save