rename local functions with `_`s
These will be flagged by the next linter release which updates `non_constant_identifier_names` to flag local functions.
Change-Id: I6fac27b2b720343d10732afce5cd0e8ae5ce5ebb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242422
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart
index e1c9a9c..09dea2a 100644
--- a/pkg/analyzer/lib/src/dart/analysis/driver.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart
@@ -1935,24 +1935,24 @@
files: contextFiles);
var bytes = contextBuilder.toBuffer();
- String _twoDigits(int n) {
+ String twoDigits(int n) {
if (n >= 10) return '$n';
return '0$n';
}
- String _threeDigits(int n) {
+ String threeDigits(int n) {
if (n >= 100) return '$n';
if (n >= 10) return '0$n';
return '00$n';
}
DateTime time = DateTime.now();
- String m = _twoDigits(time.month);
- String d = _twoDigits(time.day);
- String h = _twoDigits(time.hour);
- String min = _twoDigits(time.minute);
- String sec = _twoDigits(time.second);
- String ms = _threeDigits(time.millisecond);
+ String m = twoDigits(time.month);
+ String d = twoDigits(time.day);
+ String h = twoDigits(time.hour);
+ String min = twoDigits(time.minute);
+ String sec = twoDigits(time.second);
+ String ms = threeDigits(time.millisecond);
String key = 'exception_${time.year}$m${d}_$h$min${sec}_$ms';
_byteStore.put(key, bytes);
diff --git a/pkg/analyzer/lib/src/dart/analysis/referenced_names.dart b/pkg/analyzer/lib/src/dart/analysis/referenced_names.dart
index 0cc56cb..945a0c8 100644
--- a/pkg/analyzer/lib/src/dart/analysis/referenced_names.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/referenced_names.dart
@@ -17,7 +17,7 @@
Set<String> computeSubtypedNames(CompilationUnit unit) {
Set<String> subtypedNames = <String>{};
- void _addSubtypedName(NamedType? type) {
+ void addSubtypedName(NamedType? type) {
if (type != null) {
Identifier name = type.name;
if (name is SimpleIdentifier) {
@@ -28,25 +28,25 @@
}
}
- void _addSubtypedNames(List<NamedType>? types) {
- types?.forEach(_addSubtypedName);
+ void addSubtypedNames(List<NamedType>? types) {
+ types?.forEach(addSubtypedName);
}
for (CompilationUnitMember declaration in unit.declarations) {
if (declaration is ClassDeclaration) {
- _addSubtypedName(declaration.extendsClause?.superclass);
- _addSubtypedNames(declaration.withClause?.mixinTypes);
- _addSubtypedNames(declaration.implementsClause?.interfaces);
+ addSubtypedName(declaration.extendsClause?.superclass);
+ addSubtypedNames(declaration.withClause?.mixinTypes);
+ addSubtypedNames(declaration.implementsClause?.interfaces);
} else if (declaration is ClassTypeAlias) {
- _addSubtypedName(declaration.superclass);
- _addSubtypedNames(declaration.withClause.mixinTypes);
- _addSubtypedNames(declaration.implementsClause?.interfaces);
+ addSubtypedName(declaration.superclass);
+ addSubtypedNames(declaration.withClause.mixinTypes);
+ addSubtypedNames(declaration.implementsClause?.interfaces);
} else if (declaration is EnumDeclaration) {
- _addSubtypedNames(declaration.withClause?.mixinTypes);
- _addSubtypedNames(declaration.implementsClause?.interfaces);
+ addSubtypedNames(declaration.withClause?.mixinTypes);
+ addSubtypedNames(declaration.implementsClause?.interfaces);
} else if (declaration is MixinDeclaration) {
- _addSubtypedNames(declaration.onClause?.superclassConstraints);
- _addSubtypedNames(declaration.implementsClause?.interfaces);
+ addSubtypedNames(declaration.onClause?.superclassConstraints);
+ addSubtypedNames(declaration.implementsClause?.interfaces);
}
}
diff --git a/pkg/analyzer/test/src/dart/element/runtime_type_equality_test.dart b/pkg/analyzer/test/src/dart/element/runtime_type_equality_test.dart
index be647f5..eabafc2 100644
--- a/pkg/analyzer/test/src/dart/element/runtime_type_equality_test.dart
+++ b/pkg/analyzer/test/src/dart/element/runtime_type_equality_test.dart
@@ -242,27 +242,27 @@
}
test_interfaceType_typeArguments() {
- void _equal(DartType T1, DartType T2) {
- this._equal(listNone(T1), listNone(T2));
+ void equal(DartType T1, DartType T2) {
+ _equal(listNone(T1), listNone(T2));
}
- void _notEqual(DartType T1, DartType T2) {
- this._notEqual(listNone(T1), listNone(T2));
+ void notEqual(DartType T1, DartType T2) {
+ _notEqual(listNone(T1), listNone(T2));
}
- _notEqual(intNone, boolNone);
+ notEqual(intNone, boolNone);
- _equal(intNone, intNone);
- _notEqual(intNone, intQuestion);
- _equal(intNone, intStar);
+ equal(intNone, intNone);
+ notEqual(intNone, intQuestion);
+ equal(intNone, intStar);
- _notEqual(intQuestion, intNone);
- _equal(intQuestion, intQuestion);
- _notEqual(intQuestion, intStar);
+ notEqual(intQuestion, intNone);
+ equal(intQuestion, intQuestion);
+ notEqual(intQuestion, intStar);
- _equal(intStar, intNone);
- _notEqual(intStar, intQuestion);
- _equal(intStar, intStar);
+ equal(intStar, intNone);
+ notEqual(intStar, intQuestion);
+ equal(intStar, intStar);
}
test_never() {
diff --git a/pkg/analyzer/test/src/dart/element/upper_lower_bound_test.dart b/pkg/analyzer/test/src/dart/element/upper_lower_bound_test.dart
index 125e786..492f8fa 100644
--- a/pkg/analyzer/test/src/dart/element/upper_lower_bound_test.dart
+++ b/pkg/analyzer/test/src/dart/element/upper_lower_bound_test.dart
@@ -2085,27 +2085,27 @@
var bElementStar = class_(name: 'B', superType: aStar);
var bElementNone = class_(name: 'B', superType: aNone);
- InterfaceType _bTypeStarElement(NullabilitySuffix nullability) {
+ InterfaceType bTypeStarElement(NullabilitySuffix nullability) {
return interfaceType(
bElementStar,
nullabilitySuffix: nullability,
);
}
- InterfaceType _bTypeNoneElement(NullabilitySuffix nullability) {
+ InterfaceType bTypeNoneElement(NullabilitySuffix nullability) {
return interfaceType(
bElementNone,
nullabilitySuffix: nullability,
);
}
- var bStarQuestion = _bTypeStarElement(NullabilitySuffix.question);
- var bStarStar = _bTypeStarElement(NullabilitySuffix.star);
- var bStarNone = _bTypeStarElement(NullabilitySuffix.none);
+ var bStarQuestion = bTypeStarElement(NullabilitySuffix.question);
+ var bStarStar = bTypeStarElement(NullabilitySuffix.star);
+ var bStarNone = bTypeStarElement(NullabilitySuffix.none);
- var bNoneQuestion = _bTypeNoneElement(NullabilitySuffix.question);
- var bNoneStar = _bTypeNoneElement(NullabilitySuffix.star);
- var bNoneNone = _bTypeNoneElement(NullabilitySuffix.none);
+ var bNoneQuestion = bTypeNoneElement(NullabilitySuffix.question);
+ var bNoneStar = bTypeNoneElement(NullabilitySuffix.star);
+ var bNoneNone = bTypeNoneElement(NullabilitySuffix.none);
void assertLUB(DartType type1, DartType type2, DartType expected) {
expect(typeSystem.getLeastUpperBound(type1, type2), expected);
diff --git a/pkg/analyzer/test/util/id_testing_helper.dart b/pkg/analyzer/test/util/id_testing_helper.dart
index f5e4f87..48017a9 100644
--- a/pkg/analyzer/test/util/id_testing_helper.dart
+++ b/pkg/analyzer/test/util/id_testing_helper.dart
@@ -176,12 +176,12 @@
}
});
} else {
- String _formatError(AnalysisError e) {
+ String formatError(AnalysisError e) {
var locationInfo = result.unit.lineInfo.getLocation(e.offset);
return '$locationInfo: ${e.errorCode}: ${e.message}';
}
- onFailure('Errors found:\n ${errors.map(_formatError).join('\n ')}');
+ onFailure('Errors found:\n ${errors.map(formatError).join('\n ')}');
return TestResult<T>.erroneous();
}
}