@@ -1858,6 +1858,147 @@ class SnippetTextEdit implements TextEdit, ToJsonable {
1858
1858
String toString () => jsonEncoder.convert (toJson ());
1859
1859
}
1860
1860
1861
+ class TypeHierarchyAnchor implements ToJsonable {
1862
+ static const jsonHandler = LspJsonHandler (
1863
+ TypeHierarchyAnchor .canParse,
1864
+ TypeHierarchyAnchor .fromJson,
1865
+ );
1866
+
1867
+ TypeHierarchyAnchor ({
1868
+ required this .path,
1869
+ required this .ref,
1870
+ });
1871
+ static TypeHierarchyAnchor fromJson (Map <String , Object ?> json) {
1872
+ final pathJson = json['path' ];
1873
+ final path =
1874
+ (pathJson as List <Object ?>).map ((item) => item as int ).toList ();
1875
+ final refJson = json['ref' ];
1876
+ final ref = refJson as String ;
1877
+ return TypeHierarchyAnchor (
1878
+ path: path,
1879
+ ref: ref,
1880
+ );
1881
+ }
1882
+
1883
+ /// Indices used to navigate from this anchor to the element.
1884
+ final List <int > path;
1885
+
1886
+ /// The ElementLocation for this anchor element.
1887
+ final String ref;
1888
+
1889
+ @override
1890
+ Map <String , Object ?> toJson () {
1891
+ var result = < String , Object ? > {};
1892
+ result['path' ] = path;
1893
+ result['ref' ] = ref;
1894
+ return result;
1895
+ }
1896
+
1897
+ static bool canParse (Object ? obj, LspJsonReporter reporter) {
1898
+ if (obj is Map <String , Object ?>) {
1899
+ if (! _canParseListInt (obj, reporter, 'path' ,
1900
+ allowsUndefined: false , allowsNull: false )) {
1901
+ return false ;
1902
+ }
1903
+ return _canParseString (obj, reporter, 'ref' ,
1904
+ allowsUndefined: false , allowsNull: false );
1905
+ } else {
1906
+ reporter.reportError ('must be of type TypeHierarchyAnchor' );
1907
+ return false ;
1908
+ }
1909
+ }
1910
+
1911
+ @override
1912
+ bool operator == (Object other) {
1913
+ return other is TypeHierarchyAnchor &&
1914
+ other.runtimeType == TypeHierarchyAnchor &&
1915
+ listEqual (path, other.path, (int a, int b) => a == b) &&
1916
+ ref == other.ref;
1917
+ }
1918
+
1919
+ @override
1920
+ int get hashCode => Object .hash (
1921
+ lspHashCode (path),
1922
+ ref,
1923
+ );
1924
+
1925
+ @override
1926
+ String toString () => jsonEncoder.convert (toJson ());
1927
+ }
1928
+
1929
+ class TypeHierarchyItemInfo implements ToJsonable {
1930
+ static const jsonHandler = LspJsonHandler (
1931
+ TypeHierarchyItemInfo .canParse,
1932
+ TypeHierarchyItemInfo .fromJson,
1933
+ );
1934
+
1935
+ TypeHierarchyItemInfo ({
1936
+ this .anchor,
1937
+ required this .ref,
1938
+ });
1939
+ static TypeHierarchyItemInfo fromJson (Map <String , Object ?> json) {
1940
+ final anchorJson = json['anchor' ];
1941
+ final anchor = anchorJson != null
1942
+ ? TypeHierarchyAnchor .fromJson (anchorJson as Map <String , Object ?>)
1943
+ : null ;
1944
+ final refJson = json['ref' ];
1945
+ final ref = refJson as String ;
1946
+ return TypeHierarchyItemInfo (
1947
+ anchor: anchor,
1948
+ ref: ref,
1949
+ );
1950
+ }
1951
+
1952
+ /// An anchor element that can be used to navigate to this element preserving
1953
+ /// type arguments.
1954
+ final TypeHierarchyAnchor ? anchor;
1955
+
1956
+ /// The ElementLocation for this element, used to re-locate the element when
1957
+ /// subtypes/supertypes are fetched later.
1958
+ final String ref;
1959
+
1960
+ @override
1961
+ Map <String , Object ?> toJson () {
1962
+ var result = < String , Object ? > {};
1963
+ if (anchor != null ) {
1964
+ result['anchor' ] = anchor? .toJson ();
1965
+ }
1966
+ result['ref' ] = ref;
1967
+ return result;
1968
+ }
1969
+
1970
+ static bool canParse (Object ? obj, LspJsonReporter reporter) {
1971
+ if (obj is Map <String , Object ?>) {
1972
+ if (! _canParseTypeHierarchyAnchor (obj, reporter, 'anchor' ,
1973
+ allowsUndefined: true , allowsNull: false )) {
1974
+ return false ;
1975
+ }
1976
+ return _canParseString (obj, reporter, 'ref' ,
1977
+ allowsUndefined: false , allowsNull: false );
1978
+ } else {
1979
+ reporter.reportError ('must be of type TypeHierarchyItemInfo' );
1980
+ return false ;
1981
+ }
1982
+ }
1983
+
1984
+ @override
1985
+ bool operator == (Object other) {
1986
+ return other is TypeHierarchyItemInfo &&
1987
+ other.runtimeType == TypeHierarchyItemInfo &&
1988
+ anchor == other.anchor &&
1989
+ ref == other.ref;
1990
+ }
1991
+
1992
+ @override
1993
+ int get hashCode => Object .hash (
1994
+ anchor,
1995
+ ref,
1996
+ );
1997
+
1998
+ @override
1999
+ String toString () => jsonEncoder.convert (toJson ());
2000
+ }
2001
+
1861
2002
class ValidateRefactorResult implements ToJsonable {
1862
2003
static const jsonHandler = LspJsonHandler (
1863
2004
ValidateRefactorResult .canParse,
@@ -2184,6 +2325,32 @@ bool _canParseListFlutterOutlineAttribute(
2184
2325
return true ;
2185
2326
}
2186
2327
2328
+ bool _canParseListInt (
2329
+ Map <String , Object ?> map, LspJsonReporter reporter, String fieldName,
2330
+ {required bool allowsUndefined, required bool allowsNull}) {
2331
+ reporter.push (fieldName);
2332
+ try {
2333
+ if (! allowsUndefined && ! map.containsKey (fieldName)) {
2334
+ reporter.reportError ('must not be undefined' );
2335
+ return false ;
2336
+ }
2337
+ final value = map[fieldName];
2338
+ final nullCheck = allowsNull || allowsUndefined;
2339
+ if (! nullCheck && value == null ) {
2340
+ reporter.reportError ('must not be null' );
2341
+ return false ;
2342
+ }
2343
+ if ((! nullCheck || value != null ) &&
2344
+ (value is ! List <Object ?> || value.any ((item) => item is ! int ))) {
2345
+ reporter.reportError ('must be of type List<int>' );
2346
+ return false ;
2347
+ }
2348
+ } finally {
2349
+ reporter.pop ();
2350
+ }
2351
+ return true ;
2352
+ }
2353
+
2187
2354
bool _canParseListOutline (
2188
2355
Map <String , Object ?> map, LspJsonReporter reporter, String fieldName,
2189
2356
{required bool allowsUndefined, required bool allowsNull}) {
@@ -2395,6 +2562,32 @@ bool _canParseString(
2395
2562
return true ;
2396
2563
}
2397
2564
2565
+ bool _canParseTypeHierarchyAnchor (
2566
+ Map <String , Object ?> map, LspJsonReporter reporter, String fieldName,
2567
+ {required bool allowsUndefined, required bool allowsNull}) {
2568
+ reporter.push (fieldName);
2569
+ try {
2570
+ if (! allowsUndefined && ! map.containsKey (fieldName)) {
2571
+ reporter.reportError ('must not be undefined' );
2572
+ return false ;
2573
+ }
2574
+ final value = map[fieldName];
2575
+ final nullCheck = allowsNull || allowsUndefined;
2576
+ if (! nullCheck && value == null ) {
2577
+ reporter.reportError ('must not be null' );
2578
+ return false ;
2579
+ }
2580
+ if ((! nullCheck || value != null ) &&
2581
+ ! TypeHierarchyAnchor .canParse (value, reporter)) {
2582
+ reporter.reportError ('must be of type TypeHierarchyAnchor' );
2583
+ return false ;
2584
+ }
2585
+ } finally {
2586
+ reporter.pop ();
2587
+ }
2588
+ return true ;
2589
+ }
2590
+
2398
2591
bool _canParseUri (
2399
2592
Map <String , Object ?> map, LspJsonReporter reporter, String fieldName,
2400
2593
{required bool allowsUndefined, required bool allowsNull}) {
0 commit comments