Files
sdk/pkg/analysis_server/tool/lsp_spec/utils.dart
T
Danny Tuppeny adf9500581 [analysis_server] Update Interactive Forms definitions based on the latest spec
I had previously been using a slightly outdated version of the protocol. This updates things to match what's in Hongxiang's definition at https://github.com/Dart-Code/Dart-Code/pull/6059.

Change-Id: I98578383fb7a68bb0f2f1a813753192a17c2df40
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505221
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2026-05-21 09:51:15 -07:00

52 lines
1.2 KiB
Dart

// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'meta_model.dart';
/// Helper to create a field.
Field field(
String name, {
String? comment,
required String type,
bool array = false,
bool literal = false,
bool canBeNull = false,
bool canBeUndefined = false,
}) {
var fieldType = array
? ArrayType(TypeReference(type))
: literal
? LiteralType(TypeReference.string, type)
: TypeReference(type);
return Field(
name: name,
comment: comment,
type: fieldType,
allowsNull: canBeNull,
allowsUndefined: canBeUndefined,
);
}
/// Helper to create an interface type.
Interface interface(
String name,
List<Member> fields, {
String? baseType,
List<String>? baseTypes,
String? comment,
bool abstract = false,
}) {
return Interface(
name: name,
abstract: abstract,
comment: comment,
baseTypes: [
if (baseType != null) TypeReference(baseType),
...?baseTypes?.map(TypeReference.new),
],
members: fields,
);
}