[analyzer] Map all LSP integer/uintegers on to Dart's int type
Change-Id: I714bafdf378b8a29ba847c8d39ebe96977fc977e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198043 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
107ed1cbbd
commit
b3993c9349
File diff suppressed because it is too large
Load Diff
@@ -46,7 +46,7 @@ const dartSignatureHelpTriggerCharacters = <String>['('];
|
||||
const dartTypeFormattingCharacters = ['}', ';'];
|
||||
|
||||
/// A [ProgressToken] used for reporting progress when the server is analyzing.
|
||||
final analyzingProgressToken = Either2<num, String>.t2('ANALYZING');
|
||||
final analyzingProgressToken = Either2<int, String>.t2('ANALYZING');
|
||||
|
||||
final emptyWorkspaceEdit = WorkspaceEdit();
|
||||
|
||||
|
||||
@@ -516,7 +516,7 @@ class LspAnalysisServer extends AbstractAnalysisServer {
|
||||
completers[requestId] = completer;
|
||||
|
||||
channel.sendRequest(RequestMessage(
|
||||
id: Either2<num, String>.t1(requestId),
|
||||
id: Either2<int, String>.t1(requestId),
|
||||
method: method,
|
||||
params: params,
|
||||
jsonrpc: jsonRpcVersion,
|
||||
|
||||
@@ -17,7 +17,7 @@ abstract class ProgressReporter {
|
||||
/// Creates a reporter for a token that was supplied by the client and does
|
||||
/// not need creating prior to use.
|
||||
factory ProgressReporter.clientProvided(
|
||||
LspAnalysisServer server, Either2<num, String> token) =>
|
||||
LspAnalysisServer server, Either2<int, String> token) =>
|
||||
_TokenProgressReporter(server, token);
|
||||
|
||||
/// Creates a reporter for a new token that must be created prior to being
|
||||
@@ -25,7 +25,7 @@ abstract class ProgressReporter {
|
||||
///
|
||||
/// If [token] is not supplied, a random identifier will be used.
|
||||
factory ProgressReporter.serverCreated(LspAnalysisServer server,
|
||||
[Either2<num, String>? token]) =>
|
||||
[Either2<int, String>? token]) =>
|
||||
_ServerCreatedProgressReporter(server, token);
|
||||
|
||||
ProgressReporter._();
|
||||
@@ -50,10 +50,10 @@ class _ServerCreatedProgressReporter extends _TokenProgressReporter {
|
||||
|
||||
_ServerCreatedProgressReporter(
|
||||
LspAnalysisServer server,
|
||||
Either2<num, String>? token,
|
||||
Either2<int, String>? token,
|
||||
) : super(
|
||||
server,
|
||||
token ?? Either2<num, String>.t2(_randomTokenIdentifier()),
|
||||
token ?? Either2<int, String>.t2(_randomTokenIdentifier()),
|
||||
);
|
||||
|
||||
@override
|
||||
@@ -102,7 +102,7 @@ class _ServerCreatedProgressReporter extends _TokenProgressReporter {
|
||||
|
||||
class _TokenProgressReporter extends ProgressReporter {
|
||||
final LspAnalysisServer _server;
|
||||
final Either2<num, String> _token;
|
||||
final Either2<int, String> _token;
|
||||
bool _needsEnd = false;
|
||||
|
||||
_TokenProgressReporter(this._server, this._token) : super._();
|
||||
|
||||
@@ -20,7 +20,7 @@ class InitializationTest extends AbstractLspAnalysisServerIntegrationTest {
|
||||
Future<void> test_initialize_invalidParams() async {
|
||||
final params = {'processId': 'invalid'};
|
||||
final request = RequestMessage(
|
||||
id: Either2<num, String>.t1(1),
|
||||
id: Either2<int, String>.t1(1),
|
||||
method: Method.initialize,
|
||||
params: params,
|
||||
jsonrpc: jsonRpcVersion,
|
||||
|
||||
@@ -80,7 +80,7 @@ abstract class AbstractCodeActionsTest extends AbstractLspAnalysisServerTest {
|
||||
Future verifyCodeActionEdits(Either2<Command, CodeAction> codeAction,
|
||||
String content, String expectedContent,
|
||||
{bool expectDocumentChanges = false,
|
||||
Either2<num, String>? workDoneToken}) async {
|
||||
Either2<int, String>? workDoneToken}) async {
|
||||
final command = codeAction.map(
|
||||
(command) => command,
|
||||
(codeAction) => codeAction.command!,
|
||||
@@ -97,7 +97,7 @@ abstract class AbstractCodeActionsTest extends AbstractLspAnalysisServerTest {
|
||||
Future<void> verifyCommandEdits(
|
||||
Command command, String content, String expectedContent,
|
||||
{bool expectDocumentChanges = false,
|
||||
Either2<num, String>? workDoneToken}) async {
|
||||
Either2<int, String>? workDoneToken}) async {
|
||||
ApplyWorkspaceEditParams? editParams;
|
||||
|
||||
final commandResponse = await handleExpectedRequest<Object?,
|
||||
|
||||
@@ -499,7 +499,7 @@ class InitializationTest extends AbstractLspAnalysisServerTest {
|
||||
Future<void> test_initialize_invalidParams() async {
|
||||
final params = {'processId': 'invalid'};
|
||||
final request = RequestMessage(
|
||||
id: Either2<num, String>.t1(1),
|
||||
id: Either2<int, String>.t1(1),
|
||||
method: Method.initialize,
|
||||
params: params,
|
||||
jsonrpc: jsonRpcVersion,
|
||||
|
||||
@@ -571,7 +571,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
||||
/// A progress token used in tests where the client-provides the token, which
|
||||
/// should not be validated as being created by the server first.
|
||||
final clientProvidedTestWorkDoneToken =
|
||||
Either2<num, String>.t2('client-test');
|
||||
Either2<int, String>.t2('client-test');
|
||||
|
||||
int _id = 0;
|
||||
late String projectFolderPath,
|
||||
@@ -804,7 +804,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
||||
}
|
||||
|
||||
Future<Object?> executeCommand(Command command,
|
||||
{Either2<num, String>? workDoneToken}) async {
|
||||
{Either2<int, String>? workDoneToken}) async {
|
||||
final request = makeRequest(
|
||||
Method.workspace_executeCommand,
|
||||
ExecuteCommandParams(
|
||||
@@ -1334,7 +1334,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
||||
}
|
||||
|
||||
RequestMessage makeRequest(Method method, ToJsonable? params) {
|
||||
final id = Either2<num, String>.t1(_id++);
|
||||
final id = Either2<int, String>.t1(_id++);
|
||||
return RequestMessage(
|
||||
id: id, method: method, params: params, jsonrpc: jsonRpcVersion);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ class WorkspaceSymbolsTest extends AbstractLspAnalysisServerTest {
|
||||
|
||||
// Create a request that doesn't supply the query param.
|
||||
final request = RequestMessage(
|
||||
id: Either2<num, String>.t1(1),
|
||||
id: Either2<int, String>.t1(1),
|
||||
method: Method.workspace_symbol,
|
||||
params: <String, dynamic>{},
|
||||
jsonrpc: jsonRpcVersion,
|
||||
|
||||
@@ -20,7 +20,7 @@ void main() {
|
||||
|
||||
test('returns correct output for union types', () {
|
||||
final message = RequestMessage(
|
||||
id: Either2<num, String>.t1(1),
|
||||
id: Either2<int, String>.t1(1),
|
||||
method: Method.shutdown,
|
||||
jsonrpc: 'test');
|
||||
final output = json.encode(message.toJson());
|
||||
@@ -113,7 +113,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('ResponseMessage does not include an error with a result', () {
|
||||
final id = Either2<num, String>.t1(1);
|
||||
final id = Either2<int, String>.t1(1);
|
||||
final result = 'my result';
|
||||
final resp =
|
||||
ResponseMessage(id: id, result: result, jsonrpc: jsonRpcVersion);
|
||||
@@ -302,7 +302,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('ResponseMessage can include a null result', () {
|
||||
final id = Either2<num, String>.t1(1);
|
||||
final id = Either2<int, String>.t1(1);
|
||||
final resp = ResponseMessage(id: id, jsonrpc: jsonRpcVersion);
|
||||
final jsonMap = resp.toJson();
|
||||
expect(jsonMap, contains('result'));
|
||||
@@ -310,7 +310,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('ResponseMessage does not include a result for an error', () {
|
||||
final id = Either2<num, String>.t1(1);
|
||||
final id = Either2<int, String>.t1(1);
|
||||
final error =
|
||||
ResponseError(code: ErrorCodes.ParseError, message: 'Error');
|
||||
final resp =
|
||||
@@ -321,7 +321,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('ResponseMessage throws if both result and error are non-null', () {
|
||||
final id = Either2<num, String>.t1(1);
|
||||
final id = Either2<int, String>.t1(1);
|
||||
final result = 'my result';
|
||||
final error =
|
||||
ResponseError(code: ErrorCodes.ParseError, message: 'Error');
|
||||
|
||||
@@ -62,6 +62,14 @@ void recordTypes(List<AstNode> types) {
|
||||
|
||||
TypeBase resolveTypeAlias(TypeBase type, {resolveEnumClasses = false}) {
|
||||
if (type is Type) {
|
||||
// The LSP spec contains type aliases for `integer` and `uinteger` that map
|
||||
// into the `number` type, with comments stating they must be integers. To
|
||||
// preserve the improved typing, do _not_ resolve them to the `number`
|
||||
// type.
|
||||
if (type.name == 'integer' || type.name == 'uinteger') {
|
||||
return type;
|
||||
}
|
||||
|
||||
final alias = _typeAliases[type.name];
|
||||
// Only follow the type if we're not an enum, or we wanted to follow enums.
|
||||
if (alias != null &&
|
||||
|
||||
@@ -118,16 +118,9 @@ String? getImprovedType(String interfaceName, String? fieldName) {
|
||||
'ParameterInformation': {
|
||||
'label': 'String',
|
||||
},
|
||||
'Position': {
|
||||
'character': 'int',
|
||||
'line': 'int',
|
||||
},
|
||||
'ProgressParams': {
|
||||
'value': 'object',
|
||||
},
|
||||
'SemanticTokens': {
|
||||
'data': 'int[]',
|
||||
},
|
||||
'ServerCapabilities': {
|
||||
'changeNotifications': 'bool',
|
||||
},
|
||||
|
||||
@@ -952,6 +952,8 @@ class Type extends TypeBase {
|
||||
'boolean': 'bool',
|
||||
'string': 'String',
|
||||
'number': 'num',
|
||||
'integer': 'int',
|
||||
'uinteger': 'int',
|
||||
'any': 'dynamic',
|
||||
'object': 'dynamic',
|
||||
// Simplify MarkedString from
|
||||
|
||||
Reference in New Issue
Block a user