Reformat some files owned by the developer experience team.
This will avoid some merge conflicts in a follow-up CL I'm working on that will enable the lints `unnecessary_type_name_in_constructor` and `unnecessary_const_in_enum_constructor` (and will fix declarations accordingly). Change-Id: Ib8be02dc241732a0eb50727618bb2dda6a6a6964 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505043 Commit-Queue: Paul Berry <paulberry@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
committed by
dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent
643733b42e
commit
3fd2becefd
@@ -45,8 +45,10 @@ class Notification {
|
||||
|
||||
/// Initialize a newly created instance based on the given JSON data.
|
||||
factory Notification.fromJson(Map json) {
|
||||
return Notification(json[Notification.EVENT],
|
||||
json[Notification.PARAMS] as Map<String, Object?>);
|
||||
return Notification(
|
||||
json[Notification.EVENT],
|
||||
json[Notification.PARAMS] as Map<String, Object?>,
|
||||
);
|
||||
}
|
||||
|
||||
/// Return a table representing the structure of the Json object that will be
|
||||
@@ -95,9 +97,12 @@ class Request {
|
||||
/// Initialize a newly created [Request] to have the given [id] and [method]
|
||||
/// name. If [params] is supplied, it is used as the "params" map for the
|
||||
/// request. Otherwise an empty "params" map is allocated.
|
||||
Request(this.id, this.method,
|
||||
[Map<String, Object?>? params, this.clientRequestTime])
|
||||
: params = params ?? <String, Object?>{};
|
||||
Request(
|
||||
this.id,
|
||||
this.method, [
|
||||
Map<String, Object?>? params,
|
||||
this.clientRequestTime,
|
||||
]) : params = params ?? <String, Object?>{};
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
@@ -319,111 +324,169 @@ class Response {
|
||||
|
||||
/// Create and return the `DEBUG_PORT_COULD_NOT_BE_OPENED` error response.
|
||||
Response.debugPortCouldNotBeOpened(Request request, dynamic error)
|
||||
: this(request.id,
|
||||
error: RequestError(
|
||||
RequestErrorCode.DEBUG_PORT_COULD_NOT_BE_OPENED, '$error'));
|
||||
: this(
|
||||
request.id,
|
||||
error: RequestError(
|
||||
RequestErrorCode.DEBUG_PORT_COULD_NOT_BE_OPENED,
|
||||
'$error',
|
||||
),
|
||||
);
|
||||
|
||||
/// Initialize a newly created instance to represent the FILE_NOT_ANALYZED
|
||||
/// error condition.
|
||||
Response.fileNotAnalyzed(Request request, String file)
|
||||
: this(request.id,
|
||||
error: RequestError(RequestErrorCode.FILE_NOT_ANALYZED,
|
||||
'File is not analyzed: $file.'));
|
||||
: this(
|
||||
request.id,
|
||||
error: RequestError(
|
||||
RequestErrorCode.FILE_NOT_ANALYZED,
|
||||
'File is not analyzed: $file.',
|
||||
),
|
||||
);
|
||||
|
||||
/// Initialize a newly created instance to represent the FORMAT_INVALID_FILE
|
||||
/// error condition.
|
||||
Response.formatInvalidFile(Request request)
|
||||
: this(request.id,
|
||||
error: RequestError(RequestErrorCode.FORMAT_INVALID_FILE,
|
||||
'Error during `${request.method}`: invalid file.'));
|
||||
: this(
|
||||
request.id,
|
||||
error: RequestError(
|
||||
RequestErrorCode.FORMAT_INVALID_FILE,
|
||||
'Error during `${request.method}`: invalid file.',
|
||||
),
|
||||
);
|
||||
|
||||
/// Initialize a newly created instance to represent the FORMAT_WITH_ERROR
|
||||
/// error condition.
|
||||
Response.formatWithErrors(Request request)
|
||||
: this(request.id,
|
||||
error: RequestError(RequestErrorCode.FORMAT_WITH_ERRORS,
|
||||
'Error during `edit.format`: source contains syntax errors.'));
|
||||
: this(
|
||||
request.id,
|
||||
error: RequestError(
|
||||
RequestErrorCode.FORMAT_WITH_ERRORS,
|
||||
'Error during `edit.format`: source contains syntax errors.',
|
||||
),
|
||||
);
|
||||
|
||||
/// Initialize a newly created instance to represent the
|
||||
/// GET_ERRORS_INVALID_FILE error condition.
|
||||
Response.getErrorsInvalidFile(Request request)
|
||||
: this(request.id,
|
||||
error: RequestError(RequestErrorCode.GET_ERRORS_INVALID_FILE,
|
||||
'Error during `analysis.getErrors`: invalid file.'));
|
||||
: this(
|
||||
request.id,
|
||||
error: RequestError(
|
||||
RequestErrorCode.GET_ERRORS_INVALID_FILE,
|
||||
'Error during `analysis.getErrors`: invalid file.',
|
||||
),
|
||||
);
|
||||
|
||||
/// Initialize a newly created instance to represent the
|
||||
/// GET_IMPORTED_ELEMENTS_INVALID_FILE error condition.
|
||||
Response.getImportedElementsInvalidFile(Request request)
|
||||
: this(request.id,
|
||||
error: RequestError(
|
||||
RequestErrorCode.GET_IMPORTED_ELEMENTS_INVALID_FILE,
|
||||
'Error during `analysis.getImportedElements`: invalid file.'));
|
||||
: this(
|
||||
request.id,
|
||||
error: RequestError(
|
||||
RequestErrorCode.GET_IMPORTED_ELEMENTS_INVALID_FILE,
|
||||
'Error during `analysis.getImportedElements`: invalid file.',
|
||||
),
|
||||
);
|
||||
|
||||
/// Initialize a newly created instance to represent the
|
||||
/// GET_NAVIGATION_INVALID_FILE error condition.
|
||||
Response.getNavigationInvalidFile(Request request)
|
||||
: this(request.id,
|
||||
error: RequestError(RequestErrorCode.GET_NAVIGATION_INVALID_FILE,
|
||||
'Error during `analysis.getNavigation`: invalid file.'));
|
||||
: this(
|
||||
request.id,
|
||||
error: RequestError(
|
||||
RequestErrorCode.GET_NAVIGATION_INVALID_FILE,
|
||||
'Error during `analysis.getNavigation`: invalid file.',
|
||||
),
|
||||
);
|
||||
|
||||
/// Initialize a newly created instance to represent the
|
||||
/// GET_REACHABLE_SOURCES_INVALID_FILE error condition.
|
||||
Response.getReachableSourcesInvalidFile(Request request)
|
||||
: this(request.id,
|
||||
error: RequestError(
|
||||
RequestErrorCode.GET_REACHABLE_SOURCES_INVALID_FILE,
|
||||
'Error during `analysis.getReachableSources`: invalid file.'));
|
||||
: this(
|
||||
request.id,
|
||||
error: RequestError(
|
||||
RequestErrorCode.GET_REACHABLE_SOURCES_INVALID_FILE,
|
||||
'Error during `analysis.getReachableSources`: invalid file.',
|
||||
),
|
||||
);
|
||||
|
||||
/// Initialize a newly created instance to represent the
|
||||
/// GET_SIGNATURE_INVALID_FILE error condition.
|
||||
Response.getSignatureInvalidFile(Request request)
|
||||
: this(request.id,
|
||||
error: RequestError(RequestErrorCode.GET_SIGNATURE_INVALID_FILE,
|
||||
'Error during `analysis.getSignature`: invalid file.'));
|
||||
: this(
|
||||
request.id,
|
||||
error: RequestError(
|
||||
RequestErrorCode.GET_SIGNATURE_INVALID_FILE,
|
||||
'Error during `analysis.getSignature`: invalid file.',
|
||||
),
|
||||
);
|
||||
|
||||
/// Initialize a newly created instance to represent the
|
||||
/// GET_SIGNATURE_INVALID_OFFSET error condition.
|
||||
Response.getSignatureInvalidOffset(Request request)
|
||||
: this(request.id,
|
||||
error: RequestError(RequestErrorCode.GET_SIGNATURE_INVALID_OFFSET,
|
||||
'Error during `analysis.getSignature`: invalid offset.'));
|
||||
: this(
|
||||
request.id,
|
||||
error: RequestError(
|
||||
RequestErrorCode.GET_SIGNATURE_INVALID_OFFSET,
|
||||
'Error during `analysis.getSignature`: invalid offset.',
|
||||
),
|
||||
);
|
||||
|
||||
/// Initialize a newly created instance to represent the
|
||||
/// GET_SIGNATURE_UNKNOWN_FUNCTION error condition.
|
||||
Response.getSignatureUnknownFunction(Request request)
|
||||
: this(request.id,
|
||||
error: RequestError(RequestErrorCode.GET_SIGNATURE_UNKNOWN_FUNCTION,
|
||||
'Error during `analysis.getSignature`: unknown function.'));
|
||||
: this(
|
||||
request.id,
|
||||
error: RequestError(
|
||||
RequestErrorCode.GET_SIGNATURE_UNKNOWN_FUNCTION,
|
||||
'Error during `analysis.getSignature`: unknown function.',
|
||||
),
|
||||
);
|
||||
|
||||
/// Initialize a newly created instance to represent the
|
||||
/// IMPORT_ELEMENTS_INVALID_FILE error condition.
|
||||
Response.importElementsInvalidFile(Request request)
|
||||
: this(request.id,
|
||||
error: RequestError(RequestErrorCode.IMPORT_ELEMENTS_INVALID_FILE,
|
||||
'Error during `edit.importElements`: invalid file.'));
|
||||
: this(
|
||||
request.id,
|
||||
error: RequestError(
|
||||
RequestErrorCode.IMPORT_ELEMENTS_INVALID_FILE,
|
||||
'Error during `edit.importElements`: invalid file.',
|
||||
),
|
||||
);
|
||||
|
||||
/// Initialize a newly created instance to represent an error condition caused
|
||||
/// by an analysis.reanalyze [request] that specifies an analysis root that is
|
||||
/// not in the current list of analysis roots.
|
||||
Response.invalidAnalysisRoot(Request request, String rootPath)
|
||||
: this(request.id,
|
||||
error: RequestError(RequestErrorCode.INVALID_ANALYSIS_ROOT,
|
||||
'Invalid analysis root: $rootPath'));
|
||||
: this(
|
||||
request.id,
|
||||
error: RequestError(
|
||||
RequestErrorCode.INVALID_ANALYSIS_ROOT,
|
||||
'Invalid analysis root: $rootPath',
|
||||
),
|
||||
);
|
||||
|
||||
/// Initialize a newly created instance to represent an error condition caused
|
||||
/// by a [request] that specifies an execution context whose context root does
|
||||
/// not exist.
|
||||
Response.invalidExecutionContext(Request request, String contextId)
|
||||
: this(request.id,
|
||||
error: RequestError(RequestErrorCode.INVALID_EXECUTION_CONTEXT,
|
||||
'Invalid execution context: $contextId'));
|
||||
: this(
|
||||
request.id,
|
||||
error: RequestError(
|
||||
RequestErrorCode.INVALID_EXECUTION_CONTEXT,
|
||||
'Invalid execution context: $contextId',
|
||||
),
|
||||
);
|
||||
|
||||
/// Initialize a newly created instance to represent the
|
||||
/// INVALID_FILE_PATH_FORMAT error condition.
|
||||
Response.invalidFilePathFormat(Request request, path)
|
||||
: this(request.id,
|
||||
error: RequestError(RequestErrorCode.INVALID_FILE_PATH_FORMAT,
|
||||
'Invalid file path format: $path'));
|
||||
: this(
|
||||
request.id,
|
||||
error: RequestError(
|
||||
RequestErrorCode.INVALID_FILE_PATH_FORMAT,
|
||||
'Invalid file path format: $path',
|
||||
),
|
||||
);
|
||||
|
||||
/// Initialize a newly created instance to represent an error condition caused
|
||||
/// by a [request] that had invalid parameter. [path] is the path to the
|
||||
@@ -431,36 +494,54 @@ class Response {
|
||||
/// parameter "foo" contained a key "bar" whose value was the wrong type).
|
||||
/// [expectation] is a description of the type of data that was expected.
|
||||
Response.invalidParameter(Request request, String path, String expectation)
|
||||
: this(request.id,
|
||||
error: RequestError(RequestErrorCode.INVALID_PARAMETER,
|
||||
"Invalid parameter '$path'. $expectation."));
|
||||
: this(
|
||||
request.id,
|
||||
error: RequestError(
|
||||
RequestErrorCode.INVALID_PARAMETER,
|
||||
"Invalid parameter '$path'. $expectation.",
|
||||
),
|
||||
);
|
||||
|
||||
/// Initialize a newly created instance to represent an error condition caused
|
||||
/// by a malformed request.
|
||||
Response.invalidRequestFormat()
|
||||
: this('',
|
||||
error: RequestError(
|
||||
RequestErrorCode.INVALID_REQUEST, 'Invalid request'));
|
||||
: this(
|
||||
'',
|
||||
error: RequestError(
|
||||
RequestErrorCode.INVALID_REQUEST,
|
||||
'Invalid request',
|
||||
),
|
||||
);
|
||||
|
||||
/// Initialize a newly created instance to represent the
|
||||
/// ORGANIZE_DIRECTIVES_ERROR error condition.
|
||||
Response.organizeDirectivesError(Request request, String message)
|
||||
: this(request.id,
|
||||
error: RequestError(
|
||||
RequestErrorCode.ORGANIZE_DIRECTIVES_ERROR, message));
|
||||
: this(
|
||||
request.id,
|
||||
error: RequestError(
|
||||
RequestErrorCode.ORGANIZE_DIRECTIVES_ERROR,
|
||||
message,
|
||||
),
|
||||
);
|
||||
|
||||
/// Initialize a newly created instance to represent the
|
||||
/// REFACTORING_REQUEST_CANCELLED error condition.
|
||||
Response.refactoringRequestCancelled(Request request)
|
||||
: this(request.id,
|
||||
error: RequestError(RequestErrorCode.REFACTORING_REQUEST_CANCELLED,
|
||||
'The `edit.getRefactoring` request was cancelled.'));
|
||||
: this(
|
||||
request.id,
|
||||
error: RequestError(
|
||||
RequestErrorCode.REFACTORING_REQUEST_CANCELLED,
|
||||
'The `edit.getRefactoring` request was cancelled.',
|
||||
),
|
||||
);
|
||||
|
||||
/// Initialize a newly created instance to represent the SERVER_ERROR error
|
||||
/// condition.
|
||||
factory Response.serverError(Request request, exception, stackTrace) {
|
||||
var error =
|
||||
RequestError(RequestErrorCode.SERVER_ERROR, exception.toString());
|
||||
var error = RequestError(
|
||||
RequestErrorCode.SERVER_ERROR,
|
||||
exception.toString(),
|
||||
);
|
||||
if (stackTrace != null) {
|
||||
error.stackTrace = stackTrace.toString();
|
||||
}
|
||||
@@ -470,29 +551,43 @@ class Response {
|
||||
/// Initialize a newly created instance to represent the
|
||||
/// SORT_MEMBERS_INVALID_FILE error condition.
|
||||
Response.sortMembersInvalidFile(Request request)
|
||||
: this(request.id,
|
||||
error: RequestError(RequestErrorCode.SORT_MEMBERS_INVALID_FILE,
|
||||
'Error during `edit.sortMembers`: invalid file.'));
|
||||
: this(
|
||||
request.id,
|
||||
error: RequestError(
|
||||
RequestErrorCode.SORT_MEMBERS_INVALID_FILE,
|
||||
'Error during `edit.sortMembers`: invalid file.',
|
||||
),
|
||||
);
|
||||
|
||||
/// Initialize a newly created instance to represent the
|
||||
/// SORT_MEMBERS_PARSE_ERRORS error condition.
|
||||
Response.sortMembersParseErrors(Request request, int numErrors)
|
||||
: this(request.id,
|
||||
error: RequestError(RequestErrorCode.SORT_MEMBERS_PARSE_ERRORS,
|
||||
'Error during `edit.sortMembers`: file has $numErrors scan/parse errors.'));
|
||||
: this(
|
||||
request.id,
|
||||
error: RequestError(
|
||||
RequestErrorCode.SORT_MEMBERS_PARSE_ERRORS,
|
||||
'Error during `edit.sortMembers`: file has $numErrors scan/parse errors.',
|
||||
),
|
||||
);
|
||||
|
||||
/// Initialize a newly created instance to represent an error condition caused
|
||||
/// by a [request] that cannot be handled by any known handlers.
|
||||
Response.unknownRequest(Request request)
|
||||
: this(request.id,
|
||||
error: RequestError(
|
||||
RequestErrorCode.UNKNOWN_REQUEST, 'Unknown request'));
|
||||
: this(
|
||||
request.id,
|
||||
error: RequestError(
|
||||
RequestErrorCode.UNKNOWN_REQUEST,
|
||||
'Unknown request',
|
||||
),
|
||||
);
|
||||
|
||||
/// Initialize a newly created instance to represent an error condition caused
|
||||
/// by a [request] for a service that is not supported.
|
||||
Response.unsupportedFeature(String requestId, String message)
|
||||
: this(requestId,
|
||||
error: RequestError(RequestErrorCode.UNSUPPORTED_FEATURE, message));
|
||||
: this(
|
||||
requestId,
|
||||
error: RequestError(RequestErrorCode.UNSUPPORTED_FEATURE, message),
|
||||
);
|
||||
|
||||
/// Return a table representing the structure of the Json object that will be
|
||||
/// sent to the client to represent this response.
|
||||
@@ -521,8 +616,11 @@ class Response {
|
||||
RequestError? decodedError;
|
||||
var error = json[Response.ERROR];
|
||||
if (error is Map) {
|
||||
decodedError =
|
||||
RequestError.fromJson(ResponseDecoder(null), '.error', error);
|
||||
decodedError = RequestError.fromJson(
|
||||
ResponseDecoder(null),
|
||||
'.error',
|
||||
error,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, Object?>? decodedResult;
|
||||
|
||||
@@ -57,25 +57,36 @@ class CrashReportSender {
|
||||
this.shouldSend, {
|
||||
http.Client? httpClient,
|
||||
String endpointPath = _crashEndpointPathStaging,
|
||||
}) : _httpClient = httpClient ?? http.Client(),
|
||||
_baseUri =
|
||||
Uri(scheme: 'https', host: _crashServerHost, path: endpointPath);
|
||||
}) : _httpClient = httpClient ?? http.Client(),
|
||||
_baseUri = Uri(
|
||||
scheme: 'https',
|
||||
host: _crashServerHost,
|
||||
path: endpointPath,
|
||||
);
|
||||
|
||||
/// Create a new [CrashReportSender] connected to the staging endpoint.
|
||||
CrashReportSender.staging(
|
||||
String crashProductId,
|
||||
EnablementCallback shouldSend, {
|
||||
http.Client? httpClient,
|
||||
}) : this._(crashProductId, shouldSend,
|
||||
httpClient: httpClient, endpointPath: _crashEndpointPathStaging);
|
||||
}) : this._(
|
||||
crashProductId,
|
||||
shouldSend,
|
||||
httpClient: httpClient,
|
||||
endpointPath: _crashEndpointPathStaging,
|
||||
);
|
||||
|
||||
/// Create a new [CrashReportSender] connected to the prod endpoint.
|
||||
CrashReportSender.prod(
|
||||
String crashProductId,
|
||||
EnablementCallback shouldSend, {
|
||||
http.Client? httpClient,
|
||||
}) : this._(crashProductId, shouldSend,
|
||||
httpClient: httpClient, endpointPath: _crashEndpointPathProd);
|
||||
}) : this._(
|
||||
crashProductId,
|
||||
shouldSend,
|
||||
httpClient: httpClient,
|
||||
endpointPath: _crashEndpointPathProd,
|
||||
);
|
||||
|
||||
/// Sends one crash report.
|
||||
///
|
||||
@@ -192,10 +203,7 @@ class CrashReportAttachment {
|
||||
final String _field;
|
||||
final String _value;
|
||||
|
||||
CrashReportAttachment.string({
|
||||
required this._field,
|
||||
required this._value,
|
||||
});
|
||||
CrashReportAttachment.string({required this._field, required this._value});
|
||||
}
|
||||
|
||||
/// A typedef to allow crash reporting to query as to whether it should send a
|
||||
|
||||
@@ -24,10 +24,12 @@ class _RegExpList {
|
||||
final String substitution;
|
||||
|
||||
_RegExpList(List<String> uncompiledRegexps, this.substitution)
|
||||
: _regExps = uncompiledRegexps.map((s) => RegExp(s)).toList();
|
||||
: _regExps = uncompiledRegexps.map((s) => RegExp(s)).toList();
|
||||
|
||||
String applyTo(String input) => _regExps.fold(
|
||||
input, (previousInput, r) => previousInput.replaceAll(r, substitution));
|
||||
input,
|
||||
(previousInput, r) => previousInput.replaceAll(r, substitution),
|
||||
);
|
||||
}
|
||||
|
||||
/// An ordered list of regular expressions to be substituted out and replaced
|
||||
@@ -72,6 +74,6 @@ final _piiFileRegexps = _RegExpList([
|
||||
/// Not suitable for pre-scrubbed strings that intentionally include things
|
||||
/// that look like filenames.
|
||||
String filterPiiFromErrorMessage(String message) => [
|
||||
_piiPathRegexps,
|
||||
_piiFileRegexps,
|
||||
].fold(message, (previousMessage, r) => r.applyTo(previousMessage));
|
||||
_piiPathRegexps,
|
||||
_piiFileRegexps,
|
||||
].fold(message, (previousMessage, r) => r.applyTo(previousMessage));
|
||||
|
||||
Reference in New Issue
Block a user