[analysis_server] Fix names of canParse functions for nested generics

Change-Id: I4f641d8cb4cc2aadfd38c5fc0b06fd11445c4165
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248587
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Danny Tuppeny
2022-06-15 19:29:48 +00:00
committed by Commit Bot
parent de5469376c
commit 8038192b9d
2 changed files with 69 additions and 36 deletions
@@ -15842,7 +15842,7 @@ class InlayHint implements ToJsonable {
allowsUndefined: true, allowsNull: false)) {
return false;
}
if (!_canParseListString(obj, reporter, 'label',
if (!_canParseListInlayHintLabelPartString(obj, reporter, 'label',
allowsUndefined: false, allowsNull: false)) {
return false;
}
@@ -19463,7 +19463,8 @@ class NotebookCellTextDocumentFilter implements ToJsonable {
allowsUndefined: true, allowsNull: false)) {
return false;
}
return _canParseEither3String(obj, reporter, 'notebook',
return _canParseNotebookDocumentFilter1NotebookDocumentFilter2NotebookDocumentFilter3String(
obj, reporter, 'notebook',
allowsUndefined: false, allowsNull: false);
} else {
reporter.reportError('must be of type NotebookCellTextDocumentFilter');
@@ -20566,7 +20567,8 @@ class NotebookDocumentSyncOptionsNotebookSelector implements ToJsonable {
allowsUndefined: true, allowsNull: false)) {
return false;
}
return _canParseEither3String(obj, reporter, 'notebook',
return _canParseNotebookDocumentFilter1NotebookDocumentFilter2NotebookDocumentFilter3String(
obj, reporter, 'notebook',
allowsUndefined: false, allowsNull: false);
} else {
reporter.reportError(
@@ -20654,7 +20656,8 @@ class NotebookDocumentSyncOptionsNotebookSelector2 implements ToJsonable {
allowsUndefined: false, allowsNull: false)) {
return false;
}
return _canParseEither3String(obj, reporter, 'notebook',
return _canParseNotebookDocumentFilter1NotebookDocumentFilter2NotebookDocumentFilter3String(
obj, reporter, 'notebook',
allowsUndefined: true, allowsNull: false);
} else {
reporter.reportError(
@@ -37401,36 +37404,6 @@ bool _canParseDocumentSymbolClientCapabilitiesTagSupport(
return true;
}
bool _canParseEither3String(
Map<String, Object?> map, LspJsonReporter reporter, String fieldName,
{required bool allowsUndefined, required bool allowsNull}) {
reporter.push(fieldName);
try {
if (!allowsUndefined && !map.containsKey(fieldName)) {
reporter.reportError('must not be undefined');
return false;
}
final value = map[fieldName];
final nullCheck = allowsNull || allowsUndefined;
if (!nullCheck && value == null) {
reporter.reportError('must not be null');
return false;
}
if ((!nullCheck || value != null) &&
(!NotebookDocumentFilter1.canParse(value, reporter) &&
!NotebookDocumentFilter2.canParse(value, reporter) &&
!NotebookDocumentFilter3.canParse(value, reporter) &&
value is! String)) {
reporter.reportError(
'must be of type Either2<Either3<NotebookDocumentFilter1, NotebookDocumentFilter2, NotebookDocumentFilter3>, String>');
return false;
}
} finally {
reporter.pop();
}
return true;
}
bool _canParseExecuteCommandClientCapabilities(
Map<String, Object?> map, LspJsonReporter reporter, String fieldName,
{required bool allowsUndefined, required bool allowsNull}) {
@@ -38849,6 +38822,35 @@ bool _canParseListFoldingRangeKind(
return true;
}
bool _canParseListInlayHintLabelPartString(
Map<String, Object?> map, LspJsonReporter reporter, String fieldName,
{required bool allowsUndefined, required bool allowsNull}) {
reporter.push(fieldName);
try {
if (!allowsUndefined && !map.containsKey(fieldName)) {
reporter.reportError('must not be undefined');
return false;
}
final value = map[fieldName];
final nullCheck = allowsNull || allowsUndefined;
if (!nullCheck && value == null) {
reporter.reportError('must not be null');
return false;
}
if ((!nullCheck || value != null) &&
(value is! List<Object?> ||
value.any((item) => !InlayHintLabelPart.canParse(item, reporter)) &&
value is! String)) {
reporter.reportError(
'must be of type Either2<List<InlayHintLabelPart>, String>');
return false;
}
} finally {
reporter.pop();
}
return true;
}
bool _canParseListInsertTextMode(
Map<String, Object?> map, LspJsonReporter reporter, String fieldName,
{required bool allowsUndefined, required bool allowsNull}) {
@@ -40260,6 +40262,37 @@ bool _canParseNotebookDocumentClientCapabilities(
return true;
}
bool
_canParseNotebookDocumentFilter1NotebookDocumentFilter2NotebookDocumentFilter3String(
Map<String, Object?> map, LspJsonReporter reporter, String fieldName,
{required bool allowsUndefined, required bool allowsNull}) {
reporter.push(fieldName);
try {
if (!allowsUndefined && !map.containsKey(fieldName)) {
reporter.reportError('must not be undefined');
return false;
}
final value = map[fieldName];
final nullCheck = allowsNull || allowsUndefined;
if (!nullCheck && value == null) {
reporter.reportError('must not be null');
return false;
}
if ((!nullCheck || value != null) &&
(!NotebookDocumentFilter1.canParse(value, reporter) &&
!NotebookDocumentFilter2.canParse(value, reporter) &&
!NotebookDocumentFilter3.canParse(value, reporter) &&
value is! String)) {
reporter.reportError(
'must be of type Either2<Either3<NotebookDocumentFilter1, NotebookDocumentFilter2, NotebookDocumentFilter3>, String>');
return false;
}
} finally {
reporter.pop();
}
return true;
}
bool _canParseNotebookDocumentIdentifier(
Map<String, Object?> map, LspJsonReporter reporter, String fieldName,
{required bool allowsUndefined, required bool allowsNull}) {
@@ -247,7 +247,7 @@ String _memberNameForType(TypeBase type) {
type = resolveTypeAlias(type);
}
var dartType = type is UnionType
? type.types.map((e) => e.dartType).join()
? type.types.map(_memberNameForType).join()
: type is ArrayType
? 'List${_memberNameForType(type.elementType)}'
: type is MapType
@@ -696,7 +696,7 @@ void _writeFromJsonCode(
_writeFromJsonCodeForLiteralUnion(buffer, type, valueCode,
allowsNull: allowsNull);
} else if (type is UnionType) {
var functionName = type.types.map((t) => _memberNameForType(t)).join();
var functionName = type.types.map(_memberNameForType).join();
functionName = '_either$functionName';