Skip to content

Commit d464cd3

Browse files
author
Dart CI
committed
Version 2.15.0-290.0.dev
Merge commit 'b0bca6ae6a0cff71ee763c32ce5924f84a40346e' into 'dev'
2 parents a13424e + b0bca6a commit d464cd3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1700
-200
lines changed

pkg/_js_interop_checks/lib/src/transformations/js_util_optimizer.dart

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,10 @@ class JsUtilOptimizer extends Transformer {
139139
VariableGet(function.positionalParameters.first),
140140
StringLiteral(_getExtensionMemberName(node))
141141
], types: [
142-
DynamicType()
142+
function.returnType
143143
]))
144144
..fileOffset = node.fileOffset;
145-
return ReturnStatement(
146-
AsExpression(getPropertyInvocation, function.returnType));
145+
return ReturnStatement(getPropertyInvocation);
147146
}
148147

149148
/// Returns a new function body for the given [node] external setter.
@@ -153,18 +152,18 @@ class JsUtilOptimizer extends Transformer {
153152
ReturnStatement _getExternalSetterBody(Procedure node) {
154153
var function = node.function;
155154
assert(function.positionalParameters.length == 2);
155+
var value = function.positionalParameters.last;
156156
var setPropertyInvocation = StaticInvocation(
157157
_setPropertyTarget,
158158
Arguments([
159159
VariableGet(function.positionalParameters.first),
160160
StringLiteral(_getExtensionMemberName(node)),
161-
VariableGet(function.positionalParameters.last)
161+
VariableGet(value)
162162
], types: [
163-
DynamicType()
163+
value.type
164164
]))
165165
..fileOffset = node.fileOffset;
166-
return ReturnStatement(AsExpression(
167-
_lowerSetProperty(setPropertyInvocation), function.returnType));
166+
return ReturnStatement(_lowerSetProperty(setPropertyInvocation));
168167
}
169168

170169
/// Returns a new function body for the given [node] external method.
@@ -183,11 +182,10 @@ class JsUtilOptimizer extends Transformer {
183182
.map((argument) => VariableGet(argument))
184183
.toList())
185184
], types: [
186-
DynamicType()
185+
function.returnType
187186
]))
188187
..fileOffset = node.fileOffset;
189-
return ReturnStatement(AsExpression(
190-
_lowerCallMethod(callMethodInvocation), function.returnType));
188+
return ReturnStatement(_lowerCallMethod(callMethodInvocation));
191189
}
192190

193191
/// Returns the extension member name.

pkg/analysis_server/doc/api.html

Lines changed: 5 additions & 2 deletions
Large diffs are not rendered by default.

pkg/analysis_server/lib/protocol/protocol_constants.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@ const String SERVER_NOTIFICATION_ERROR = 'server.error';
350350
const String SERVER_NOTIFICATION_ERROR_IS_FATAL = 'isFatal';
351351
const String SERVER_NOTIFICATION_ERROR_MESSAGE = 'message';
352352
const String SERVER_NOTIFICATION_ERROR_STACK_TRACE = 'stackTrace';
353+
const String SERVER_NOTIFICATION_LOG = 'server.log';
354+
const String SERVER_NOTIFICATION_LOG_ENTRY = 'entry';
353355
const String SERVER_NOTIFICATION_STATUS = 'server.status';
354356
const String SERVER_NOTIFICATION_STATUS_ANALYSIS = 'analysis';
355357
const String SERVER_NOTIFICATION_STATUS_PUB = 'pub';

pkg/analysis_server/lib/protocol/protocol_generated.dart

Lines changed: 234 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15871,18 +15871,249 @@ class ServerGetVersionResult implements ResponseResult {
1587115871
int get hashCode => version.hashCode;
1587215872
}
1587315873

15874+
/// ServerLogEntry
15875+
///
15876+
/// {
15877+
/// "time": int
15878+
/// "kind": ServerLogEntryKind
15879+
/// "data": String
15880+
/// }
15881+
///
15882+
/// Clients may not extend, implement or mix-in this class.
15883+
class ServerLogEntry implements HasToJson {
15884+
/// The time (milliseconds since epoch) at which the server created this log
15885+
/// entry.
15886+
int time;
15887+
15888+
/// The kind of the entry, used to determine how to interpret the "data"
15889+
/// field.
15890+
ServerLogEntryKind kind;
15891+
15892+
/// The payload of the entry, the actual format is determined by the "kind"
15893+
/// field.
15894+
String data;
15895+
15896+
ServerLogEntry(this.time, this.kind, this.data);
15897+
15898+
factory ServerLogEntry.fromJson(
15899+
JsonDecoder jsonDecoder, String jsonPath, Object? json) {
15900+
json ??= {};
15901+
if (json is Map) {
15902+
int time;
15903+
if (json.containsKey('time')) {
15904+
time = jsonDecoder.decodeInt(jsonPath + '.time', json['time']);
15905+
} else {
15906+
throw jsonDecoder.mismatch(jsonPath, 'time');
15907+
}
15908+
ServerLogEntryKind kind;
15909+
if (json.containsKey('kind')) {
15910+
kind = ServerLogEntryKind.fromJson(
15911+
jsonDecoder, jsonPath + '.kind', json['kind']);
15912+
} else {
15913+
throw jsonDecoder.mismatch(jsonPath, 'kind');
15914+
}
15915+
String data;
15916+
if (json.containsKey('data')) {
15917+
data = jsonDecoder.decodeString(jsonPath + '.data', json['data']);
15918+
} else {
15919+
throw jsonDecoder.mismatch(jsonPath, 'data');
15920+
}
15921+
return ServerLogEntry(time, kind, data);
15922+
} else {
15923+
throw jsonDecoder.mismatch(jsonPath, 'ServerLogEntry', json);
15924+
}
15925+
}
15926+
15927+
@override
15928+
Map<String, Object> toJson() {
15929+
var result = <String, Object>{};
15930+
result['time'] = time;
15931+
result['kind'] = kind.toJson();
15932+
result['data'] = data;
15933+
return result;
15934+
}
15935+
15936+
@override
15937+
String toString() => json.encode(toJson());
15938+
15939+
@override
15940+
bool operator ==(other) {
15941+
if (other is ServerLogEntry) {
15942+
return time == other.time && kind == other.kind && data == other.data;
15943+
}
15944+
return false;
15945+
}
15946+
15947+
@override
15948+
int get hashCode => Object.hash(
15949+
time,
15950+
kind,
15951+
data,
15952+
);
15953+
}
15954+
15955+
/// ServerLogEntryKind
15956+
///
15957+
/// enum {
15958+
/// NOTIFICATION
15959+
/// RAW
15960+
/// REQUEST
15961+
/// RESPONSE
15962+
/// }
15963+
///
15964+
/// Clients may not extend, implement or mix-in this class.
15965+
class ServerLogEntryKind implements Enum {
15966+
/// A notification from the server, such as "analysis.highlights". The "data"
15967+
/// field contains a JSON object with abbreviated notification.
15968+
static const ServerLogEntryKind NOTIFICATION =
15969+
ServerLogEntryKind._('NOTIFICATION');
15970+
15971+
/// Arbitrary string, describing some event that happened in the server, e.g.
15972+
/// starting a file analysis, and details which files were accessed. These
15973+
/// entries are not structured, but provide context information about
15974+
/// requests and notification, and can be related by "time" for further
15975+
/// manual analysis.
15976+
static const ServerLogEntryKind RAW = ServerLogEntryKind._('RAW');
15977+
15978+
/// A request from the client, as the server views it, e.g.
15979+
/// "edit.getAssists". The "data" field contains a JSON object with
15980+
/// abbreviated request.
15981+
static const ServerLogEntryKind REQUEST = ServerLogEntryKind._('REQUEST');
15982+
15983+
/// Various counters and measurements related to execution of a request. The
15984+
/// "data" field contains a JSON object with following fields:
15985+
///
15986+
/// - "id" - the id of the request - copied from the request.
15987+
/// - "method" - the method of the request, e.g. "edit.getAssists".
15988+
/// - "clientRequestTime" - the time (milliseconds since epoch) at which the
15989+
/// client made the request - copied from the request.
15990+
/// - "serverRequestTime" - the time (milliseconds since epoch) at which the
15991+
/// server received and decoded the JSON request.
15992+
/// - "responseTime" - the time (milliseconds since epoch) at which the
15993+
/// server created the response to be encoded into JSON and sent to the
15994+
/// client.
15995+
static const ServerLogEntryKind RESPONSE = ServerLogEntryKind._('RESPONSE');
15996+
15997+
/// A list containing all of the enum values that are defined.
15998+
static const List<ServerLogEntryKind> VALUES = <ServerLogEntryKind>[
15999+
NOTIFICATION,
16000+
RAW,
16001+
REQUEST,
16002+
RESPONSE
16003+
];
16004+
16005+
@override
16006+
final String name;
16007+
16008+
const ServerLogEntryKind._(this.name);
16009+
16010+
factory ServerLogEntryKind(String name) {
16011+
switch (name) {
16012+
case 'NOTIFICATION':
16013+
return NOTIFICATION;
16014+
case 'RAW':
16015+
return RAW;
16016+
case 'REQUEST':
16017+
return REQUEST;
16018+
case 'RESPONSE':
16019+
return RESPONSE;
16020+
}
16021+
throw Exception('Illegal enum value: $name');
16022+
}
16023+
16024+
factory ServerLogEntryKind.fromJson(
16025+
JsonDecoder jsonDecoder, String jsonPath, Object? json) {
16026+
if (json is String) {
16027+
try {
16028+
return ServerLogEntryKind(json);
16029+
} catch (_) {
16030+
// Fall through
16031+
}
16032+
}
16033+
throw jsonDecoder.mismatch(jsonPath, 'ServerLogEntryKind', json);
16034+
}
16035+
16036+
@override
16037+
String toString() => 'ServerLogEntryKind.$name';
16038+
16039+
String toJson() => name;
16040+
}
16041+
16042+
/// server.log params
16043+
///
16044+
/// {
16045+
/// "entry": ServerLogEntry
16046+
/// }
16047+
///
16048+
/// Clients may not extend, implement or mix-in this class.
16049+
class ServerLogParams implements HasToJson {
16050+
ServerLogEntry entry;
16051+
16052+
ServerLogParams(this.entry);
16053+
16054+
factory ServerLogParams.fromJson(
16055+
JsonDecoder jsonDecoder, String jsonPath, Object? json) {
16056+
json ??= {};
16057+
if (json is Map) {
16058+
ServerLogEntry entry;
16059+
if (json.containsKey('entry')) {
16060+
entry = ServerLogEntry.fromJson(
16061+
jsonDecoder, jsonPath + '.entry', json['entry']);
16062+
} else {
16063+
throw jsonDecoder.mismatch(jsonPath, 'entry');
16064+
}
16065+
return ServerLogParams(entry);
16066+
} else {
16067+
throw jsonDecoder.mismatch(jsonPath, 'server.log params', json);
16068+
}
16069+
}
16070+
16071+
factory ServerLogParams.fromNotification(Notification notification) {
16072+
return ServerLogParams.fromJson(
16073+
ResponseDecoder(null), 'params', notification.params);
16074+
}
16075+
16076+
@override
16077+
Map<String, Object> toJson() {
16078+
var result = <String, Object>{};
16079+
result['entry'] = entry.toJson();
16080+
return result;
16081+
}
16082+
16083+
Notification toNotification() {
16084+
return Notification('server.log', toJson());
16085+
}
16086+
16087+
@override
16088+
String toString() => json.encode(toJson());
16089+
16090+
@override
16091+
bool operator ==(other) {
16092+
if (other is ServerLogParams) {
16093+
return entry == other.entry;
16094+
}
16095+
return false;
16096+
}
16097+
16098+
@override
16099+
int get hashCode => entry.hashCode;
16100+
}
16101+
1587416102
/// ServerService
1587516103
///
1587616104
/// enum {
16105+
/// LOG
1587716106
/// STATUS
1587816107
/// }
1587916108
///
1588016109
/// Clients may not extend, implement or mix-in this class.
1588116110
class ServerService implements Enum {
16111+
static const ServerService LOG = ServerService._('LOG');
16112+
1588216113
static const ServerService STATUS = ServerService._('STATUS');
1588316114

1588416115
/// A list containing all of the enum values that are defined.
15885-
static const List<ServerService> VALUES = <ServerService>[STATUS];
16116+
static const List<ServerService> VALUES = <ServerService>[LOG, STATUS];
1588616117

1588716118
@override
1588816119
final String name;
@@ -15891,6 +16122,8 @@ class ServerService implements Enum {
1589116122

1589216123
factory ServerService(String name) {
1589316124
switch (name) {
16125+
case 'LOG':
16126+
return LOG;
1589416127
case 'STATUS':
1589516128
return STATUS;
1589616129
}

pkg/analysis_server/lib/src/analysis_server.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import 'package:analysis_server/src/operation/operation_analysis.dart';
3232
import 'package:analysis_server/src/plugin/notification_manager.dart';
3333
import 'package:analysis_server/src/protocol_server.dart' as server;
3434
import 'package:analysis_server/src/search/search_domain.dart';
35+
import 'package:analysis_server/src/server/completion_request_aborting.dart';
3536
import 'package:analysis_server/src/server/crash_reporting_attachments.dart';
3637
import 'package:analysis_server/src/server/detachable_filesystem_manager.dart';
3738
import 'package:analysis_server/src/server/diagnostic_server.dart';
@@ -40,6 +41,7 @@ import 'package:analysis_server/src/server/features.dart';
4041
import 'package:analysis_server/src/server/sdk_configuration.dart';
4142
import 'package:analysis_server/src/services/flutter/widget_descriptions.dart';
4243
import 'package:analysis_server/src/utilities/process.dart';
44+
import 'package:analysis_server/src/utilities/request_statistics.dart';
4345
import 'package:analyzer/dart/analysis/results.dart';
4446
import 'package:analyzer/dart/ast/ast.dart';
4547
import 'package:analyzer/exception/exception.dart';
@@ -114,6 +116,9 @@ class AnalysisServer extends AbstractAnalysisServer {
114116

115117
final DetachableFileSystemManager? detachableFileSystemManager;
116118

119+
final CompletionRequestAborting completionRequestAborting =
120+
CompletionRequestAborting();
121+
117122
/// Initialize a newly created server to receive requests from and send
118123
/// responses to the given [channel].
119124
///
@@ -130,6 +135,7 @@ class AnalysisServer extends AbstractAnalysisServer {
130135
InstrumentationService instrumentationService, {
131136
http.Client? httpClient,
132137
ProcessRunner? processRunner,
138+
RequestStatisticsHelper? requestStatistics,
133139
DiagnosticServer? diagnosticServer,
134140
this.detachableFileSystemManager,
135141
// Disable to avoid using this in unit tests.
@@ -144,6 +150,7 @@ class AnalysisServer extends AbstractAnalysisServer {
144150
httpClient,
145151
processRunner,
146152
NotificationManager(channel, baseResourceProvider.pathContext),
153+
requestStatistics: requestStatistics,
147154
enableBazelWatcher: enableBazelWatcher,
148155
) {
149156
var contextManagerCallbacks =
@@ -164,7 +171,7 @@ class AnalysisServer extends AbstractAnalysisServer {
164171
io.pid,
165172
).toNotification(),
166173
);
167-
channel.listen(handleRequest, onDone: done, onError: error);
174+
channel.requests.listen(handleRequest, onDone: done, onError: error);
168175
handlers = <server.RequestHandler>[
169176
ServerDomainHandler(this),
170177
AnalysisDomainHandler(this),

0 commit comments

Comments
 (0)