Skip to content

Commit

Permalink
sorting file
Browse files Browse the repository at this point in the history
  • Loading branch information
FMorschel committed Oct 3, 2024
1 parent 2365100 commit d7050b1
Showing 1 changed file with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,35 +53,35 @@ class ImportAddHide extends MultiCorrectionProducer {
}

class _ImportAddHide extends ResolvedCorrectionProducer {
_ImportAddHide(this.importDirective, this.element, {required super.context});

final ImportDirective importDirective;
final Element element;

_ImportAddHide(this.importDirective, this.element, {required super.context});

@override
CorrectionApplicability get applicability =>
// TODO(applicability): comment on why.
CorrectionApplicability.singleLocation;

@override
FixKind get fixKind => DartFixKind.IMPORT_LIBRARY_HIDE;

@override
List<String> get fixArguments {
var aliasStr = importDirective.prefix?.name;
var alias = '';
if (aliasStr != null) {
alias = " as '$aliasStr'";
}
return [elementName, importStr, alias];
return [_elementName, _importStr, alias];
}

String get importStr => importDirective.uri.stringValue ?? '';
String get elementName => element.name ?? '';
@override
FixKind get fixKind => DartFixKind.IMPORT_LIBRARY_HIDE;

String get _elementName => element.name ?? '';
String get _importStr => importDirective.uri.stringValue ?? '';

@override
Future<void> compute(ChangeBuilder builder) async {
if (elementName.isEmpty || importStr.isEmpty) {
if (_elementName.isEmpty || _importStr.isEmpty) {
return;
}

Expand All @@ -93,7 +93,7 @@ class _ImportAddHide extends ResolvedCorrectionProducer {
if (hide.isNotEmpty) {
return await builder.addDartFileEdit(file, (builder) {
var hideCombinator = hide.first;
var allNames = <String>[elementName];
var allNames = <String>[_elementName];
for (var name in hideCombinator.hiddenNames) {
allNames.add(name.name);
}
Expand All @@ -105,7 +105,7 @@ class _ImportAddHide extends ResolvedCorrectionProducer {
}

await builder.addDartFileEdit(file, (builder) {
var hideCombinator = ' hide $elementName';
var hideCombinator = ' hide $_elementName';
builder.addSimpleInsertion(importDirective.end - 1, hideCombinator);
});
}
Expand Down

0 comments on commit d7050b1

Please sign in to comment.