1b400ed68d
* Move the only 3 files from server_plugin to analysis_server_plugin. * Copy some test infra into analysis_server_plugin. This is temporary, as we need some shared test infra location. Change-Id: If2b41d436c9d3051e590f60ae2eb7ab31e529321 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364161 Commit-Queue: Samuel Rawlins <srawlins@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
37 lines
1.3 KiB
Dart
37 lines
1.3 KiB
Dart
// Copyright (c) 2024, 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 'package:analyzer_plugin/protocol/protocol_common.dart';
|
|
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
|
|
|
|
/// A description of a single proposed fix for some problem.
|
|
final class Fix {
|
|
/// A description of the fix being proposed.
|
|
final FixKind kind;
|
|
|
|
/// The change to be made in order to apply the fix.
|
|
final SourceChange change;
|
|
|
|
/// Initializes a newly created fix to have the given [kind] and [change].
|
|
Fix({required this.kind, required this.change});
|
|
|
|
@override
|
|
String toString() {
|
|
return 'Fix(kind=$kind, change=$change)';
|
|
}
|
|
|
|
/// Sorts fixes by their relevance.
|
|
///
|
|
/// A fix with a higher relevance is sorted before a fix with a lower
|
|
/// relevance. Fixes with the same relevance are sorted alphabetically.
|
|
static int compareFixes(Fix a, Fix b) {
|
|
if (a.kind.priority != b.kind.priority) {
|
|
// A higher priority indicates a higher relevance
|
|
// and should be sorted before a lower priority.
|
|
return b.kind.priority - a.kind.priority;
|
|
}
|
|
return a.change.message.compareTo(b.change.message);
|
|
}
|
|
}
|