mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 10:49:00 +00:00
analyzer: Remove unused 'hasFix' function
Change-Id: Ic2e34faa847fed295a42aec017a5e88b8f6244ea Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345347 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Samuel Rawlins <srawlins@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
c1581d6636
commit
fd38a69ebc
3 changed files with 28 additions and 26 deletions
|
@ -4,7 +4,6 @@
|
|||
|
||||
import 'package:analysis_server/plugin/protocol/protocol_dart.dart';
|
||||
import 'package:analysis_server/protocol/protocol_generated.dart';
|
||||
import 'package:analysis_server/src/services/correction/fix.dart';
|
||||
import 'package:analysis_server/src/services/search/search_engine.dart'
|
||||
as engine;
|
||||
import 'package:analysis_server/src/utilities/extensions/element.dart';
|
||||
|
@ -147,12 +146,15 @@ AnalysisError newAnalysisError_fromEngine(
|
|||
.toList();
|
||||
}
|
||||
var correction = error.correction;
|
||||
var fix = hasFix(error.errorCode);
|
||||
var url = errorCode.url;
|
||||
return AnalysisError(severity, type, location, message, code,
|
||||
contextMessages: contextMessages,
|
||||
correction: correction,
|
||||
hasFix: fix,
|
||||
// This parameter is only necessary for deprecated IDE support.
|
||||
// Whether the error actually has a fix or not is not important to report
|
||||
// here.
|
||||
// TODO(srawlins): Remove it.
|
||||
hasFix: false,
|
||||
url: url);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,35 +3,15 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analysis_server/plugin/edit/fix/fix_dart.dart';
|
||||
import 'package:analysis_server/src/services/correction/fix/analysis_options/fix_generator.dart';
|
||||
import 'package:analysis_server/src/services/correction/fix/dart/extensions.dart';
|
||||
import 'package:analysis_server/src/services/correction/fix/pubspec/fix_generator.dart';
|
||||
import 'package:analysis_server/src/services/correction/fix_internal.dart';
|
||||
import 'package:analyzer/dart/analysis/results.dart';
|
||||
import 'package:analyzer/dart/element/element.dart';
|
||||
import 'package:analyzer/error/error.dart';
|
||||
import 'package:analyzer/instrumentation/service.dart';
|
||||
import 'package:analyzer/src/error/codes.dart';
|
||||
import 'package:analyzer/src/services/top_level_declarations.dart';
|
||||
import 'package:analyzer_plugin/utilities/change_builder/change_workspace.dart';
|
||||
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
|
||||
|
||||
/// Return `true` if this [errorCode] is likely to have a fix associated with
|
||||
/// it.
|
||||
bool hasFix(ErrorCode errorCode) {
|
||||
if (errorCode is LintCode) {
|
||||
var lintName = errorCode.name;
|
||||
return FixProcessor.lintProducerMap.containsKey(lintName) ||
|
||||
FixProcessor.lintMultiProducerMap.containsKey(lintName);
|
||||
}
|
||||
// TODO(brianwilkerson): Either deprecate the part of the protocol supported
|
||||
// by this function, or handle error codes associated with non-dart files.
|
||||
return FixProcessor.nonLintProducerMap.containsKey(errorCode) ||
|
||||
FixProcessor.nonLintMultiProducerMap.containsKey(errorCode) ||
|
||||
AnalysisOptionsFixGenerator.codesWithFixes.contains(errorCode) ||
|
||||
PubspecFixGenerator.codesWithFixes.contains(errorCode);
|
||||
}
|
||||
|
||||
/// An enumeration of quick fix kinds for the errors found in an analysis
|
||||
/// options file.
|
||||
class AnalysisOptionsFixKind {
|
||||
|
|
|
@ -4,9 +4,12 @@
|
|||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:analysis_server/src/services/correction/fix.dart';
|
||||
import 'package:analysis_server/src/services/correction/fix/analysis_options/fix_generator.dart';
|
||||
import 'package:analysis_server/src/services/correction/fix/pubspec/fix_generator.dart';
|
||||
import 'package:analysis_server/src/services/correction/fix_internal.dart';
|
||||
import 'package:analyzer/error/error.dart';
|
||||
import 'package:analyzer/file_system/physical_file_system.dart';
|
||||
import 'package:analyzer/src/error/codes.dart';
|
||||
import 'package:analyzer/src/lint/registry.dart';
|
||||
import 'package:analyzer_utilities/package_root.dart' as package_root;
|
||||
import 'package:linter/src/rules.dart';
|
||||
|
@ -60,7 +63,7 @@ String? verifyErrorFixStatus() {
|
|||
errorData.codesWithNoEntry.add(name);
|
||||
} else if (info is YamlMap) {
|
||||
var markedAsHavingFix = info['status'] == 'hasFix';
|
||||
if (hasFix(code)) {
|
||||
if (code.hasFix) {
|
||||
if (!markedAsHavingFix) {
|
||||
errorData.codesWithFixes.add(name);
|
||||
}
|
||||
|
@ -78,7 +81,7 @@ String? verifyErrorFixStatus() {
|
|||
errorData.codesWithNoEntry.add(name);
|
||||
} else if (info is YamlMap) {
|
||||
var markedAsHavingFix = info['status'] == 'hasFix';
|
||||
if (hasFix(lintCode)) {
|
||||
if (lintCode.hasFix) {
|
||||
if (!markedAsHavingFix) {
|
||||
errorData.codesWithFixes.add(name);
|
||||
}
|
||||
|
@ -179,3 +182,20 @@ class ErrorData {
|
|||
codesWithoutFixes.isNotEmpty ||
|
||||
entriesWithNoCode.isNotEmpty;
|
||||
}
|
||||
|
||||
extension on ErrorCode {
|
||||
/// Whether this [errorCode] is likely to have a fix associated with
|
||||
/// it.
|
||||
bool get hasFix {
|
||||
final self = this;
|
||||
if (self is LintCode) {
|
||||
var lintName = self.name;
|
||||
return FixProcessor.lintProducerMap.containsKey(lintName) ||
|
||||
FixProcessor.lintMultiProducerMap.containsKey(lintName);
|
||||
}
|
||||
return FixProcessor.nonLintProducerMap.containsKey(self) ||
|
||||
FixProcessor.nonLintMultiProducerMap.containsKey(self) ||
|
||||
AnalysisOptionsFixGenerator.codesWithFixes.contains(self) ||
|
||||
PubspecFixGenerator.codesWithFixes.contains(self);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue