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

VSCodeVariableSource.cs « MonoDevelop.Debugger.VsCodeDebugProtocol « MonoDevelop.Debugger.VSCodeDebugProtocol « addins « src « main - github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 789e4ef0c481903ff63aa635461da0553cf05553 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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);

			Flags = parentVariablesReference > 0 ? ObjectValueFlags.None : ObjectValueFlags.ReadOnly;
			Flags |= GetFlags (variable.PresentationHint);
			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;
		}
	}
}