Skip to content

Commit c28e1a5

Browse files
committed
WIP
1 parent 121862e commit c28e1a5

File tree

4 files changed

+40
-20
lines changed

4 files changed

+40
-20
lines changed

Rewrite/Rewrite.Rpc/LanguageServer.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
using Rewrite.Core;
44
using Rewrite.Core.Config;
55
using Rewrite.MSBuild;
6+
using StreamJsonRpc;
67
using static Rewrite.Rpc.RpcObjectData.ObjectState;
78

89
namespace Rewrite.Rpc;
910

10-
public class LanguageServer : ILanguageServer
11+
public class LanguageServer(RecipeManager recipeManager, ILanguageServer counterparty) : ILanguageServer
1112
{
13+
private readonly ILanguageServer _counterparty = counterparty;
14+
1215
/// <summary>
1316
/// Keeps track of the local and remote state of objects that are used in
1417
/// visits and other operations for which incremental state sharing is useful
@@ -30,12 +33,8 @@ public class LanguageServer : ILanguageServer
3033
/// </summary>
3134
private readonly Dictionary<object, int> _localRefs = new ();
3235

33-
private RecipeManager _recipeManager;
36+
private RecipeManager _recipeManager = recipeManager;
3437

35-
public LanguageServer(RecipeManager recipeManager)
36-
{
37-
_recipeManager = recipeManager;
38-
}
3938

4039
public Task<string[]> Parse(ParseRequest request)
4140
{
@@ -44,6 +43,7 @@ public Task<string[]> Parse(ParseRequest request)
4443

4544
public async Task<VisitResponse> Visit(VisitRequest request)
4645
{
46+
4747
var before = await GetObject<Tree>(request.TreeId);
4848
var p = (IExecutionContext)(await GetVisitorP(request))!;
4949

Rewrite/Rewrite.Rpc/RpcObjectData.cs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,17 @@ namespace Rewrite.Rpc;
66
public class RpcObjectData
77
{
88
public const int ADDED_LIST_ITEM = -1;
9-
public RpcObjectData(ObjectState state, string? valueType, object? value, int? @ref, string? trace)
10-
{
11-
State = state;
12-
ValueType = valueType;
13-
Value = value;
14-
Ref = @ref;
15-
Trace = trace;
16-
}
9+
1710

1811
[System.Text.Json.Serialization.JsonConverter(typeof(StringEnumConverter))]
19-
public ObjectState State { get; set; }
12+
public required ObjectState State { get; init; }
2013

21-
public string? ValueType { get; set; }
14+
public string? ValueType { get; init; }
2215

23-
public object? Value { get; set; }
16+
public object? Value { get; init; }
2417

25-
public int? Ref { get; set; }
26-
public string? Trace { get; set; }
18+
public int? Ref { get; init; }
19+
public string? Trace { get; init; }
2720

2821
public T? GetValue<T>()
2922
{
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Runtime.CompilerServices;
2+
3+
namespace Rewrite.Rpc;
4+
5+
public class TreeChangeComputer
6+
{
7+
public List<RpcObjectData> GetChanges(object before, object after)
8+
{
9+
var result = new List<RpcObjectData>();
10+
if (before == after)
11+
{
12+
result.Add(new RpcObjectData { State = RpcObjectData.ObjectState.NO_CHANGE });
13+
}
14+
// else if (beforeVal == null) {
15+
}
16+
}
17+
18+
public class SessionCache
19+
{
20+
private readonly Dictionary<string, object?> _remoteObjects = new();
21+
private readonly Dictionary<string, object> _localObjects = new();
22+
// private readonly Dictionary<string, Recipe> _preparedRecipes = new();
23+
public void Test()
24+
{
25+
_localObjects.GetValue()
26+
}
27+
}

Rewrite/src/Rewrite.CSharp/CSharp/Tree/Cs.g.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public partial interface Cs : J
2929
#endif
3030
bool Core.Tree.IsAcceptable<R, P>(ITreeVisitor<R, P> v, P p)
3131
{
32-
return v.IsAdaptableTo(typeof(CSharpVisitorAsync<>)) || v.IsAdaptableTo(typeof(CSharpVisitor<>));
32+
return v.IsAdaptableTo(typeof(CSharpVisitor<>));
3333
}
3434
#if DEBUG_VISITOR
3535
[DebuggerStepThrough]

0 commit comments

Comments
 (0)