Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/addins/MonoDevelop.Debugger.VSCodeDebugProtocol/MonoDevelop.Debugger.VsCodeDebugProtocol/VSCodeVariableSource.cs')
-rw-r--r--main/src/addins/MonoDevelop.Debugger.VSCodeDebugProtocol/MonoDevelop.Debugger.VsCodeDebugProtocol/VSCodeVariableSource.cs76
1 files changed, 76 insertions, 0 deletions
diff --git a/main/src/addins/MonoDevelop.Debugger.VSCodeDebugProtocol/MonoDevelop.Debugger.VsCodeDebugProtocol/VSCodeVariableSource.cs b/main/src/addins/MonoDevelop.Debugger.VSCodeDebugProtocol/MonoDevelop.Debugger.VsCodeDebugProtocol/VSCodeVariableSource.cs
new file mode 100644
index 0000000000..a488f98f2c
--- /dev/null
+++ b/main/src/addins/MonoDevelop.Debugger.VSCodeDebugProtocol/MonoDevelop.Debugger.VsCodeDebugProtocol/VSCodeVariableSource.cs
@@ -0,0 +1,76 @@
+using System;
+
+using Mono.Debugging.Client;
+
+using Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Messages;
+
+namespace MonoDevelop.Debugger.VsCodeDebugProtocol
+{
+ class VSCodeVariableSource : VSCodeObjectSource
+ {
+ readonly Variable variable;
+ readonly string display;
+ readonly string value;
+ readonly string name;
+ readonly string type;
+
+ public VSCodeVariableSource (VSCodeDebuggerSession session, Variable variable, int parentVariablesReference, int frameId) : base (session, parentVariablesReference, frameId)
+ {
+ this.variable = variable;
+
+ var actualType = GetActualTypeName (variable.Type);
+
+ // FIXME: can we use VariablePresentationHint.AttributesValue.ReadOnly/Constant/Static etc for Flags?
+ Flags = parentVariablesReference > 0 ? ObjectValueFlags.None : ObjectValueFlags.ReadOnly;
+ name = GetFixedVariableName (variable.Name);
+ type = actualType.Replace (", ", ",");
+
+ if (actualType != "void")
+ value = GetFixedValue (variable.Value, type, actualType);
+ else
+ value = "No return value.";
+ display = variable.Value;
+
+ if (name[0] == '[')
+ Flags |= ObjectValueFlags.ArrayElement;
+
+ if (type == null || value == $"'{name}' threw an exception of type '{type}'")
+ Flags |= ObjectValueFlags.Error;
+ }
+
+ protected override string Display {
+ get { return display; }
+ }
+
+ protected override string Expression {
+ get { return variable.EvaluateName; }
+ }
+
+ protected override string Name {
+ get { return name; }
+ }
+
+ protected override string Type {
+ get { return type; }
+ }
+
+ protected override string Value {
+ get { return value; }
+ }
+
+ protected override int VariablesReference {
+ get { return variable.VariablesReference; }
+ }
+
+ static string GetFixedVariableName (string name)
+ {
+ // Check for a type attribute and strip it off.
+ var index = name.LastIndexOf (" [", StringComparison.Ordinal);
+
+ if (index != -1)
+ return name.Remove (index);
+
+ return name;
+ }
+ }
+}