Skip to content

Commit c2ff2ca

Browse files
pqcommit-bot@chromium.org
authored andcommitted
collection API use de-linting
Change-Id: I8879f48d484830ff594295b983363b7e3245f092 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108668 Commit-Queue: Phil Quitslund <[email protected]> Reviewed-by: Konstantin Shcheglov <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 205b778 commit c2ff2ca

38 files changed

+60
-58
lines changed

pkg/analysis_server/analysis_options.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@ linter:
33
- empty_constructor_bodies # pedantic
44
- empty_statements
55
- prefer_equal_for_default_values # pedantic
6+
- prefer_is_empty # pedantic
7+
- prefer_is_not_empty # pedantic
68
- unnecessary_brace_in_string_interps
79
- valid_regexps # pedantic

pkg/analysis_server/lib/src/computer/computer_outline.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ class _FunctionBodyOutlinesVisitor extends RecursiveAstVisitor {
463463
engine.ExecutableElement executableElement = nameElement;
464464

465465
String extractString(NodeList<Expression> arguments) {
466-
if (arguments != null && arguments.length > 0) {
466+
if (arguments != null && arguments.isNotEmpty) {
467467
Expression argument = arguments[0];
468468
if (argument is StringLiteral) {
469469
String value = argument.stringValue;

pkg/analysis_server/lib/src/lsp/handlers/commands/simple_edit_handler.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ abstract class SimpleEditCommandHandler
2929
List<SourceEdit> edits) async {
3030
// If there are no edits to apply, just complete the command without going
3131
// back to the client.
32-
if (edits.length == 0) {
32+
if (edits.isEmpty) {
3333
return success();
3434
}
3535

pkg/analysis_server/lib/src/services/completion/completion_performance.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class CompletionPerformance {
2323
}
2424

2525
int get elapsedInMilliseconds =>
26-
operations.length > 0 ? operations.last.elapsed.inMilliseconds : 0;
26+
operations.isNotEmpty ? operations.last.elapsed.inMilliseconds : 0;
2727

2828
String get suggestionCount {
2929
if (notificationCount < 1) return '';

pkg/analysis_server/lib/src/services/completion/dart/arglist_contributor.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ bool _isAppendingToArgList(DartCompletionRequest request) {
4141
if (entity == node.rightParenthesis) {
4242
return true;
4343
}
44-
if (node.arguments.length > 0 && node.arguments.last == entity) {
44+
if (node.arguments.isNotEmpty && node.arguments.last == entity) {
4545
return entity is SimpleIdentifier;
4646
}
4747
}
@@ -172,7 +172,7 @@ class ArgListContributor extends DartCompletionContributor {
172172
ParameterElement parameter, bool appendColon, bool appendComma) {
173173
String name = parameter.name;
174174
String type = parameter.type?.displayName;
175-
if (name != null && name.length > 0 && !namedArgs.contains(name)) {
175+
if (name != null && name.isNotEmpty && !namedArgs.contains(name)) {
176176
String completion = name;
177177
if (appendColon) {
178178
completion += ': ';
@@ -220,7 +220,7 @@ class ArgListContributor extends DartCompletionContributor {
220220
}
221221

222222
void _addSuggestions(Iterable<ParameterElement> parameters) {
223-
if (parameters == null || parameters.length == 0) {
223+
if (parameters == null || parameters.isEmpty) {
224224
return;
225225
}
226226
Iterable<ParameterElement> requiredParam =

pkg/analysis_server/lib/src/services/completion/dart/field_formal_contributor.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class FieldFormalContributor extends DartCompletionContributor {
4444
SimpleIdentifier fieldId = param.identifier;
4545
if (fieldId != null && fieldId != request.target.entity) {
4646
String fieldName = fieldId.name;
47-
if (fieldName != null && fieldName.length > 0) {
47+
if (fieldName != null && fieldName.isNotEmpty) {
4848
referencedFields.add(fieldName);
4949
}
5050
}
@@ -61,7 +61,7 @@ class FieldFormalContributor extends DartCompletionContributor {
6161
SimpleIdentifier fieldId = varDecl.name;
6262
if (fieldId != null) {
6363
String fieldName = fieldId.name;
64-
if (fieldName != null && fieldName.length > 0) {
64+
if (fieldName != null && fieldName.isNotEmpty) {
6565
if (!referencedFields.contains(fieldName)) {
6666
CompletionSuggestion suggestion = createSuggestion(
6767
fieldId.staticElement,

pkg/analysis_server/lib/src/services/completion/dart/label_contributor.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class _LabelVisitor extends LocalDeclarationVisitor {
145145
CompletionSuggestion _addSuggestion(SimpleIdentifier id) {
146146
if (id != null) {
147147
String completion = id.name;
148-
if (completion != null && completion.length > 0 && completion != '_') {
148+
if (completion != null && completion.isNotEmpty && completion != '_') {
149149
CompletionSuggestion suggestion = new CompletionSuggestion(
150150
CompletionSuggestionKind.IDENTIFIER,
151151
DART_RELEVANCE_DEFAULT,

pkg/analysis_server/lib/src/services/completion/dart/library_prefix_contributor.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class LibraryPrefixContributor extends DartCompletionContributor {
3333
List<CompletionSuggestion> suggestions = <CompletionSuggestion>[];
3434
for (ImportElement element in imports) {
3535
String completion = element.prefix?.name;
36-
if (completion != null && completion.length > 0) {
36+
if (completion != null && completion.isNotEmpty) {
3737
LibraryElement libElem = element.importedLibrary;
3838
if (libElem != null) {
3939
CompletionSuggestion suggestion = createSuggestion(libElem,

pkg/analysis_server/lib/src/services/completion/dart/local_constructor_contributor.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class _Visitor extends LocalDeclarationVisitor {
127127
}
128128

129129
String name = constructorDecl.name?.name;
130-
if (name != null && name.length > 0) {
130+
if (name != null && name.isNotEmpty) {
131131
completion = '$completion.$name';
132132
}
133133

pkg/analysis_server/lib/src/services/completion/dart/local_library_contributor.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ class LibraryElementSuggestionBuilder extends GeneralizingElementVisitor
169169
createSuggestion(constructor, relevance: relevance);
170170
if (suggestion != null) {
171171
String name = suggestion.completion;
172-
name = name.length > 0 ? '$className.$name' : className;
173-
if (prefix != null && prefix.length > 0) {
172+
name = name.isNotEmpty ? '$className.$name' : className;
173+
if (prefix != null && prefix.isNotEmpty) {
174174
name = '$prefix.$name';
175175
}
176176
suggestion.completion = name;

0 commit comments

Comments
 (0)