@@ -6,6 +6,7 @@ import 'dart:async';
66
77import 'package:analysis_server/lsp_protocol/protocol_generated.dart' ;
88import 'package:analysis_server/src/lsp/json_parsing.dart' ;
9+ import 'package:analysis_server/src/protocol/protocol_internal.dart' ;
910import 'package:analyzer/src/generated/utilities_general.dart' ;
1011
1112const jsonRpcVersion = '2.0' ;
@@ -20,6 +21,18 @@ ErrorOr<R> error<R>(ErrorCodes code, String message, [String data]) =>
2021
2122ErrorOr <R > failure <R >(ErrorOr <dynamic > error) => ErrorOr <R >.error (error.error);
2223
24+ /// Returns if two objects are equal, recursively checking items in
25+ /// Maps/Lists.
26+ bool lspEquals (dynamic obj1, dynamic obj2) {
27+ if (obj1 is List && obj2 is List ) {
28+ return listEqual (obj1, obj2, lspEquals);
29+ } else if (obj1 is Map && obj2 is Map ) {
30+ return mapEqual (obj1, obj2, lspEquals);
31+ } else {
32+ return obj1.runtimeType == obj2.runtimeType && obj1 == obj2;
33+ }
34+ }
35+
2336/// Returns an objects hash code, recursively combining hashes for items in
2437/// Maps/Lists.
2538int lspHashCode (dynamic obj) {
@@ -69,7 +82,8 @@ class Either2<T1, T2> {
6982 int get hashCode => map (lspHashCode, lspHashCode);
7083
7184 @override
72- bool operator == (o) => o is Either2 <T1 , T2 > && o._t1 == _t1 && o._t2 == _t2;
85+ bool operator == (o) =>
86+ o is Either2 <T1 , T2 > && lspEquals (o._t1, _t1) && lspEquals (o._t2, _t2);
7387
7488 T map <T >(T Function (T1 ) f1, T Function (T2 ) f2) {
7589 return _which == 1 ? f1 (_t1) : f2 (_t2);
@@ -108,7 +122,10 @@ class Either3<T1, T2, T3> {
108122
109123 @override
110124 bool operator == (o) =>
111- o is Either3 <T1 , T2 , T3 > && o._t1 == _t1 && o._t2 == _t2 && o._t3 == _t3;
125+ o is Either3 <T1 , T2 , T3 > &&
126+ lspEquals (o._t1, _t1) &&
127+ lspEquals (o._t2, _t2) &&
128+ lspEquals (o._t3, _t3);
112129
113130 T map <T >(T Function (T1 ) f1, T Function (T2 ) f2, T Function (T3 ) f3) {
114131 switch (_which) {
@@ -170,10 +187,10 @@ class Either4<T1, T2, T3, T4> {
170187 @override
171188 bool operator == (o) =>
172189 o is Either4 <T1 , T2 , T3 , T4 > &&
173- o._t1 == _t1 &&
174- o._t2 == _t2 &&
175- o._t3 == _t3 &&
176- o._t4 == _t4;
190+ lspEquals ( o._t1, _t1) &&
191+ lspEquals ( o._t2, _t2) &&
192+ lspEquals ( o._t3, _t3) &&
193+ lspEquals ( o._t4, _t4) ;
177194
178195 T map <T >(T Function (T1 ) f1, T Function (T2 ) f2, T Function (T3 ) f3,
179196 T Function (T4 ) f4) {
0 commit comments