Skip to content

Commit 16e326b

Browse files
committed
Рефакторинг контейнеров переменных
1 parent 674f401 commit 16e326b

11 files changed

Lines changed: 241 additions & 303 deletions

src/OneScript.DebugProtocol/EvaluatedVariableLocator.cs

Lines changed: 0 additions & 99 deletions
This file was deleted.

src/OneScript.DebugProtocol/StackFrame.cs

Lines changed: 1 addition & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@ This Source Code Form is subject to the terms of the
55
at http://mozilla.org/MPL/2.0/.
66
----------------------------------------------------------*/
77
using System;
8-
using System.Collections;
9-
using System.Collections.Generic;
108
using System.Runtime.Serialization;
119
using Newtonsoft.Json;
1210

1311
namespace OneScript.DebugProtocol
1412
{
1513
[DataContract, JsonObject, Serializable]
16-
public class StackFrame : IVariableLocator
14+
public class StackFrame
1715
{
1816
[DataMember]
1917
public int Index { get; set; }
@@ -27,85 +25,6 @@ public class StackFrame : IVariableLocator
2725
[DataMember]
2826
public string Source { get; set; }
2927

30-
[DataMember]
31-
public Variable[] Variables { get; set; }
32-
3328
public int ThreadId { get; set; }
34-
35-
int IVariableLocator.Count
36-
{
37-
get
38-
{
39-
if (Variables == null)
40-
return 0;
41-
42-
return Variables.Length;
43-
}
44-
}
45-
46-
Variable IVariableLocator.this[int index]
47-
{
48-
get
49-
{
50-
if (Variables == null)
51-
throw new ArgumentOutOfRangeException();
52-
53-
return Variables[index];
54-
}
55-
}
56-
57-
IEnumerator<Variable> IEnumerable<Variable>.GetEnumerator()
58-
{
59-
if (Variables == null)
60-
{
61-
return EmptyEnumerator<Variable>.Instance;
62-
}
63-
64-
return ((IEnumerable<Variable>)Variables).GetEnumerator();
65-
}
66-
67-
IEnumerator IEnumerable.GetEnumerator()
68-
{
69-
return ((IVariableLocator) this).GetEnumerator();
70-
}
71-
72-
void IVariableLocator.Hydrate(IDebuggerService process)
73-
{
74-
if (Variables != null)
75-
return;
76-
var variables = process.GetVariables(ThreadId, Index, Array.Empty<int>());
77-
Variables = variables;
78-
}
79-
80-
public IVariableLocator CreateChildLocator(int variableIndex)
81-
{
82-
return new VariableLocator(ThreadId, Index, variableIndex);
83-
}
84-
}
85-
86-
internal class EmptyEnumerator<T> : IEnumerator<T>
87-
{
88-
public static EmptyEnumerator<T> Instance { get; } = new EmptyEnumerator<T>();
89-
90-
private EmptyEnumerator()
91-
{
92-
}
93-
94-
public bool MoveNext()
95-
{
96-
return false;
97-
}
98-
99-
public void Reset()
100-
{
101-
}
102-
103-
public T Current { get; } = default;
104-
105-
object IEnumerator.Current => Current;
106-
107-
public void Dispose()
108-
{
109-
}
11029
}
11130
}

src/OneScript.DebugProtocol/VariableLocator.cs

Lines changed: 0 additions & 99 deletions
This file was deleted.

src/VSCode.DebugAdapter/DebugeeProcess.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,9 @@ public StackFrame[] GetStackTrace(int threadId, int firstFrameIdx, int limit)
362362

363363
}
364364

365-
public void FillVariables(IVariableLocator locator)
365+
public Variable[] FetchVariables(IVariablesProvider provider)
366366
{
367-
locator.Hydrate(_debugger);
367+
return provider.FetchVariables(_debugger);
368368
}
369369

370370
public Variable Evaluate(StackFrame frame, string expression)

0 commit comments

Comments
 (0)