mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 21:40:07 +00:00
de-lint collection size checks
Change-Id: Id8e7ce2ec59ad7cd2b0b9c961594a37d4fef621a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108522 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Phil Quitslund <pquitslund@google.com>
This commit is contained in:
parent
ac41a20081
commit
8f90265176
|
@ -1,6 +1,8 @@
|
|||
linter:
|
||||
rules:
|
||||
- empty_constructor_bodies
|
||||
- empty_constructor_bodies # pedantic
|
||||
- empty_statements
|
||||
- prefer_is_empty # pedantic
|
||||
- prefer_is_not_empty # pedantic
|
||||
- unnecessary_brace_in_string_interps
|
||||
- valid_regexps
|
||||
- valid_regexps # pedantic
|
||||
|
|
|
@ -168,7 +168,7 @@ class _ErrorCollector extends AnalysisErrorListener {
|
|||
new AnalyzerErrorGroup.fromAnalysisErrors(_errors);
|
||||
|
||||
/// Whether any errors where collected.
|
||||
bool get hasErrors => !_errors.isEmpty;
|
||||
bool get hasErrors => _errors.isNotEmpty;
|
||||
|
||||
@override
|
||||
void onError(AnalysisError error) => _errors.add(error);
|
||||
|
|
|
@ -64,7 +64,7 @@ class BreadthFirstVisitor<R> extends GeneralizingAstVisitor<R> {
|
|||
/// breadth-first order.
|
||||
void visitAllNodes(AstNode root) {
|
||||
_queue.add(root);
|
||||
while (!_queue.isEmpty) {
|
||||
while (_queue.isNotEmpty) {
|
||||
AstNode next = _queue.removeFirst();
|
||||
next.accept(this);
|
||||
}
|
||||
|
|
|
@ -352,7 +352,7 @@ class InstrumentationService {
|
|||
void logVersion(String uuid, String clientId, String clientVersion,
|
||||
String serverVersion, String sdkVersion) {
|
||||
String normalize(String value) =>
|
||||
value != null && value.length > 0 ? value : 'unknown';
|
||||
value != null && value.isNotEmpty ? value : 'unknown';
|
||||
|
||||
if (_instrumentationServer != null) {
|
||||
_instrumentationServer.logWithPriority(_join([
|
||||
|
|
|
@ -43,7 +43,7 @@ class LineInfo {
|
|||
LineInfo(this.lineStarts) {
|
||||
if (lineStarts == null) {
|
||||
throw new ArgumentError("lineStarts must be non-null");
|
||||
} else if (lineStarts.length < 1) {
|
||||
} else if (lineStarts.isEmpty) {
|
||||
throw new ArgumentError("lineStarts must be non-empty");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -362,7 +362,7 @@ class ContextBuilder {
|
|||
Map<Folder, YamlMap> embedderYamls = locator.embedderYamls;
|
||||
EmbedderSdk embedderSdk =
|
||||
new EmbedderSdk(resourceProvider, embedderYamls);
|
||||
if (embedderSdk.sdkLibraries.length > 0) {
|
||||
if (embedderSdk.sdkLibraries.isNotEmpty) {
|
||||
//
|
||||
// There is an embedder file that defines the content of the SDK and
|
||||
// there might be an extension file that extends it.
|
||||
|
|
|
@ -12,7 +12,7 @@ DefinedNames computeDefinedNames(CompilationUnit unit) {
|
|||
|
||||
void appendName(Set<String> names, SimpleIdentifier node) {
|
||||
String name = node?.name;
|
||||
if (name != null && name.length != 0) {
|
||||
if (name != null && name.isNotEmpty) {
|
||||
names.add(name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -737,7 +737,7 @@ class AssignmentExpressionImpl extends ExpressionImpl
|
|||
return null;
|
||||
}
|
||||
List<ParameterElement> parameters = executableElement.parameters;
|
||||
if (parameters.length < 1) {
|
||||
if (parameters.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
return parameters[0];
|
||||
|
@ -2567,7 +2567,7 @@ class ConstructorDeclarationImpl extends ClassMemberImpl
|
|||
Token get endToken {
|
||||
if (_body != null) {
|
||||
return _body.endToken;
|
||||
} else if (!_initializers.isEmpty) {
|
||||
} else if (_initializers.isNotEmpty) {
|
||||
return _initializers.endToken;
|
||||
}
|
||||
return _parameters.endToken;
|
||||
|
@ -4151,7 +4151,7 @@ class FieldFormalParameterImpl extends NormalFormalParameterImpl
|
|||
@override
|
||||
Token get beginToken {
|
||||
NodeList<Annotation> metadata = this.metadata;
|
||||
if (!metadata.isEmpty) {
|
||||
if (metadata.isNotEmpty) {
|
||||
return metadata.beginToken;
|
||||
} else if (covariantKeyword != null) {
|
||||
return covariantKeyword;
|
||||
|
@ -6022,7 +6022,7 @@ class IndexExpressionImpl extends ExpressionImpl implements IndexExpression {
|
|||
return null;
|
||||
}
|
||||
List<ParameterElement> parameters = staticElement.parameters;
|
||||
if (parameters.length < 1) {
|
||||
if (parameters.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
return parameters[0];
|
||||
|
@ -6540,7 +6540,7 @@ class LabeledStatementImpl extends StatementImpl implements LabeledStatement {
|
|||
|
||||
@override
|
||||
Token get beginToken {
|
||||
if (!_labels.isEmpty) {
|
||||
if (_labels.isNotEmpty) {
|
||||
return _labels.beginToken;
|
||||
}
|
||||
return _statement.beginToken;
|
||||
|
@ -7609,7 +7609,7 @@ class NodeListImpl<E extends AstNode> with ListMixin<E> implements NodeList<E> {
|
|||
|
||||
@override
|
||||
Token get beginToken {
|
||||
if (_elements.length == 0) {
|
||||
if (_elements.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
return _elements[0].beginToken;
|
||||
|
@ -7670,7 +7670,7 @@ class NodeListImpl<E extends AstNode> with ListMixin<E> implements NodeList<E> {
|
|||
|
||||
@override
|
||||
bool addAll(Iterable<E> nodes) {
|
||||
if (nodes != null && !nodes.isEmpty) {
|
||||
if (nodes != null && nodes.isNotEmpty) {
|
||||
if (nodes is List<E>) {
|
||||
int length = nodes.length;
|
||||
for (int i = 0; i < length; i++) {
|
||||
|
@ -8183,7 +8183,7 @@ class PostfixExpressionImpl extends ExpressionImpl
|
|||
return null;
|
||||
}
|
||||
List<ParameterElement> parameters = staticElement.parameters;
|
||||
if (parameters.length < 1) {
|
||||
if (parameters.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
return parameters[0];
|
||||
|
@ -8366,7 +8366,7 @@ class PrefixExpressionImpl extends ExpressionImpl implements PrefixExpression {
|
|||
return null;
|
||||
}
|
||||
List<ParameterElement> parameters = staticElement.parameters;
|
||||
if (parameters.length < 1) {
|
||||
if (parameters.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
return parameters[0];
|
||||
|
@ -8830,7 +8830,7 @@ class SimpleFormalParameterImpl extends NormalFormalParameterImpl
|
|||
@override
|
||||
Token get beginToken {
|
||||
NodeList<Annotation> metadata = this.metadata;
|
||||
if (!metadata.isEmpty) {
|
||||
if (metadata.isNotEmpty) {
|
||||
return metadata.beginToken;
|
||||
} else if (covariantKeyword != null) {
|
||||
return covariantKeyword;
|
||||
|
@ -9600,7 +9600,7 @@ abstract class SwitchMemberImpl extends AstNodeImpl implements SwitchMember {
|
|||
|
||||
@override
|
||||
Token get beginToken {
|
||||
if (!_labels.isEmpty) {
|
||||
if (_labels.isNotEmpty) {
|
||||
return _labels.beginToken;
|
||||
}
|
||||
return keyword;
|
||||
|
@ -9608,7 +9608,7 @@ abstract class SwitchMemberImpl extends AstNodeImpl implements SwitchMember {
|
|||
|
||||
@override
|
||||
Token get endToken {
|
||||
if (!_statements.isEmpty) {
|
||||
if (_statements.isNotEmpty) {
|
||||
return _statements.endToken;
|
||||
}
|
||||
return colon;
|
||||
|
@ -9946,7 +9946,7 @@ class TryStatementImpl extends StatementImpl implements TryStatement {
|
|||
return _finallyBlock.endToken;
|
||||
} else if (finallyKeyword != null) {
|
||||
return finallyKeyword;
|
||||
} else if (!_catchClauses.isEmpty) {
|
||||
} else if (_catchClauses.isNotEmpty) {
|
||||
return _catchClauses.endToken;
|
||||
}
|
||||
return _body.endToken;
|
||||
|
|
|
@ -422,7 +422,7 @@ class ApiElementBuilder extends _BaseElementBuilder {
|
|||
SimpleIdentifier methodName = node.name;
|
||||
String nameOfMethod = methodName.name;
|
||||
if (nameOfMethod == TokenType.MINUS.lexeme &&
|
||||
node.parameters.parameters.length == 0) {
|
||||
node.parameters.parameters.isEmpty) {
|
||||
nameOfMethod = "unary-";
|
||||
}
|
||||
MethodElementImpl element =
|
||||
|
|
|
@ -690,7 +690,7 @@ class ClassElementImpl extends AbstractClassElementImpl
|
|||
List<ClassElement> classesToVisit = new List<ClassElement>();
|
||||
HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>();
|
||||
classesToVisit.add(this);
|
||||
while (!classesToVisit.isEmpty) {
|
||||
while (classesToVisit.isNotEmpty) {
|
||||
ClassElement currentElement = classesToVisit.removeAt(0);
|
||||
if (visitedClasses.add(currentElement)) {
|
||||
// check fields
|
||||
|
@ -1534,7 +1534,7 @@ class ClassElementImpl extends AbstractClassElementImpl
|
|||
List<InterfaceType> typesToVisit = new List<InterfaceType>();
|
||||
List<ClassElement> visitedClasses = new List<ClassElement>();
|
||||
typesToVisit.add(startingType);
|
||||
while (!typesToVisit.isEmpty) {
|
||||
while (typesToVisit.isNotEmpty) {
|
||||
InterfaceType currentType = typesToVisit.removeAt(0);
|
||||
ClassElement currentElement = currentType.element;
|
||||
if (!visitedClasses.contains(currentElement)) {
|
||||
|
@ -2598,7 +2598,7 @@ class ConstructorElementImpl extends ExecutableElementImpl
|
|||
bool get isDefaultConstructor {
|
||||
// unnamed
|
||||
String name = this.name;
|
||||
if (name != null && name.length != 0) {
|
||||
if (name != null && name.isNotEmpty) {
|
||||
return false;
|
||||
}
|
||||
// no required parameters
|
||||
|
@ -2752,7 +2752,7 @@ class ConstructorElementImpl extends ExecutableElementImpl
|
|||
String constructorName = displayName;
|
||||
if (enclosingElement == null) {
|
||||
String message;
|
||||
if (constructorName != null && !constructorName.isEmpty) {
|
||||
if (constructorName != null && constructorName.isNotEmpty) {
|
||||
message =
|
||||
'Found constructor element named $constructorName with no enclosing element';
|
||||
} else {
|
||||
|
@ -2763,7 +2763,7 @@ class ConstructorElementImpl extends ExecutableElementImpl
|
|||
} else {
|
||||
name = enclosingElement.displayName;
|
||||
}
|
||||
if (constructorName != null && !constructorName.isEmpty) {
|
||||
if (constructorName != null && constructorName.isNotEmpty) {
|
||||
name = '$name.$constructorName';
|
||||
}
|
||||
appendToWithName(buffer, name);
|
||||
|
|
|
@ -81,7 +81,7 @@ class ConstructorMember extends ExecutableMember implements ConstructorElement {
|
|||
}
|
||||
buffer.write(baseElement.enclosingElement.displayName);
|
||||
String name = displayName;
|
||||
if (name != null && !name.isEmpty) {
|
||||
if (name != null && name.isNotEmpty) {
|
||||
buffer.write('.');
|
||||
buffer.write(name);
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ class ConstructorMember extends ExecutableMember implements ConstructorElement {
|
|||
*/
|
||||
static ConstructorElement from(
|
||||
ConstructorElement constructor, InterfaceType definingType) {
|
||||
if (constructor == null || definingType.typeArguments.length == 0) {
|
||||
if (constructor == null || definingType.typeArguments.isEmpty) {
|
||||
return constructor;
|
||||
}
|
||||
FunctionType baseType = constructor.type;
|
||||
|
@ -354,7 +354,7 @@ class FunctionMember extends ExecutableMember implements FunctionElement {
|
|||
*/
|
||||
static MethodElement from(
|
||||
MethodElement method, ParameterizedType definingType) {
|
||||
if (method == null || definingType.typeArguments.length == 0) {
|
||||
if (method == null || definingType.typeArguments.isEmpty) {
|
||||
return method;
|
||||
}
|
||||
FunctionType baseType = method.type;
|
||||
|
@ -685,7 +685,7 @@ class MethodMember extends ExecutableMember implements MethodElement {
|
|||
* was created.
|
||||
*/
|
||||
static MethodElement from(MethodElement method, InterfaceType definingType) {
|
||||
if (method == null || definingType.typeArguments.length == 0) {
|
||||
if (method == null || definingType.typeArguments.isEmpty) {
|
||||
return method;
|
||||
}
|
||||
FunctionType baseType = method.type;
|
||||
|
|
|
@ -588,7 +588,7 @@ abstract class FunctionTypeImpl extends TypeImpl implements FunctionType {
|
|||
|
||||
// Function types have an empty name when they are defined implicitly by
|
||||
// either a closure or as part of a parameter declaration.
|
||||
if (name == null || name.length == 0) {
|
||||
if (name == null || name.isEmpty) {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
appendTo(buffer, new Set.identity());
|
||||
return buffer.toString();
|
||||
|
@ -1452,7 +1452,7 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
|
|||
List<InterfaceType> interfaces = classElement.interfaces;
|
||||
List<TypeParameterElement> typeParameters = classElement.typeParameters;
|
||||
List<DartType> parameterTypes = classElement.type.typeArguments;
|
||||
if (typeParameters.length == 0) {
|
||||
if (typeParameters.isEmpty) {
|
||||
return interfaces;
|
||||
}
|
||||
int count = interfaces.length;
|
||||
|
@ -1567,7 +1567,7 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
|
|||
return null;
|
||||
}
|
||||
List<DartType> typeParameters = classElement.type.typeArguments;
|
||||
if (typeArguments.length == 0 ||
|
||||
if (typeArguments.isEmpty ||
|
||||
typeArguments.length != typeParameters.length) {
|
||||
return supertype;
|
||||
}
|
||||
|
@ -2258,7 +2258,7 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
|
|||
throw new ArgumentError(
|
||||
"argumentTypes.length (${argumentTypes.length}) != parameterTypes.length (${parameterTypes.length})");
|
||||
}
|
||||
if (argumentTypes.length == 0 || typeArguments.length == 0) {
|
||||
if (argumentTypes.isEmpty || typeArguments.isEmpty) {
|
||||
return this.pruned(prune);
|
||||
}
|
||||
|
||||
|
@ -3567,7 +3567,7 @@ class _FunctionTypeImplLazy extends FunctionTypeImpl {
|
|||
}
|
||||
// If there are no arguments to substitute, or if the arguments size doesn't
|
||||
// match the parameter size, return the base return type.
|
||||
if (typeArguments.length == 0 ||
|
||||
if (typeArguments.isEmpty ||
|
||||
typeArguments.length != typeParameters.length) {
|
||||
return (baseReturnType as TypeImpl).pruned(newPrune);
|
||||
}
|
||||
|
@ -3711,7 +3711,7 @@ class _FunctionTypeImplLazy extends FunctionTypeImpl {
|
|||
// Circularity found. Prune the type declaration.
|
||||
return new CircularFunctionTypeImpl();
|
||||
}
|
||||
if (argumentTypes.length == 0) {
|
||||
if (argumentTypes.isEmpty) {
|
||||
return this.pruned(prune);
|
||||
}
|
||||
List<DartType> typeArgs =
|
||||
|
@ -3745,7 +3745,7 @@ class _FunctionTypeImplLazy extends FunctionTypeImpl {
|
|||
// ignore: deprecated_member_use_from_same_package
|
||||
if (parameter.parameterKind == kind) {
|
||||
TypeImpl type = parameter.type ?? DynamicTypeImpl.instance;
|
||||
if (typeArguments.length != 0 &&
|
||||
if (typeArguments.isNotEmpty &&
|
||||
typeArguments.length == typeParameters.length) {
|
||||
type = type.substitute2(typeArguments, typeParameters, newPrune);
|
||||
} else {
|
||||
|
|
|
@ -509,7 +509,7 @@ class ExitDetector extends GeneralizingAstVisitor<bool> {
|
|||
// For switch members with no statements, don't visit the children.
|
||||
// Otherwise, if there children statements don't exit, mark this as a
|
||||
// non-exiting case.
|
||||
if (!switchMember.statements.isEmpty && !switchMember.accept(this)) {
|
||||
if (switchMember.statements.isNotEmpty && !switchMember.accept(this)) {
|
||||
hasNonExitingCase = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -681,7 +681,7 @@ class InheritanceManager {
|
|||
//
|
||||
resultMap[key] = elements[subtypesOfAllOtherTypesIndexes[0]];
|
||||
} else {
|
||||
if (!subtypesOfAllOtherTypesIndexes.isEmpty) {
|
||||
if (subtypesOfAllOtherTypesIndexes.isNotEmpty) {
|
||||
//
|
||||
// Example: class A inherits 2 methods named 'm'.
|
||||
// One has the function type '(int) -> dynamic' and one has the
|
||||
|
|
|
@ -1001,7 +1001,7 @@ abstract class Scope {
|
|||
*/
|
||||
void define(Element element) {
|
||||
String name = _getName(element);
|
||||
if (name != null && !name.isEmpty) {
|
||||
if (name != null && name.isNotEmpty) {
|
||||
_definedNames ??= new HashMap<String, Element>();
|
||||
_definedNames.putIfAbsent(name, () => element);
|
||||
}
|
||||
|
@ -1100,7 +1100,7 @@ abstract class Scope {
|
|||
String _getName(Element element) {
|
||||
if (element is MethodElement) {
|
||||
MethodElement method = element;
|
||||
if (method.name == "-" && method.parameters.length == 0) {
|
||||
if (method.name == "-" && method.parameters.isEmpty) {
|
||||
return UNARY_MINUS;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -657,7 +657,7 @@ class FolderBasedDartSdk extends AbstractDartSdk {
|
|||
}
|
||||
try {
|
||||
File file = libraryDirectory.getChildAssumingFile(library.path);
|
||||
if (!relativePath.isEmpty) {
|
||||
if (relativePath.isNotEmpty) {
|
||||
File relativeFile = file.parent.getChildAssumingFile(relativePath);
|
||||
if (relativeFile.path == file.path) {
|
||||
// The relative file is the library, so return a Source for the
|
||||
|
@ -694,7 +694,7 @@ class FolderBasedDartSdk extends AbstractDartSdk {
|
|||
|
||||
static String getSdkProperty(ResourceProvider resourceProvider) {
|
||||
String exec = io.Platform.resolvedExecutable;
|
||||
if (exec.length == 0) {
|
||||
if (exec.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
pathos.Context pathContext = resourceProvider.pathContext;
|
||||
|
|
|
@ -2137,7 +2137,7 @@ class AstBuilder extends StackListener {
|
|||
SimpleIdentifier stackTrace;
|
||||
if (catchParameterList != null) {
|
||||
List<FormalParameter> catchParameters = catchParameterList.parameters;
|
||||
if (catchParameters.length > 0) {
|
||||
if (catchParameters.isNotEmpty) {
|
||||
exception = catchParameters[0].identifier;
|
||||
localDeclarations[exception.offset] = exception;
|
||||
}
|
||||
|
|
|
@ -2260,10 +2260,10 @@ class SourcesChangedEvent {
|
|||
}
|
||||
|
||||
/// Return `true` if any sources were added.
|
||||
bool get wereSourcesAdded => _changeSet.addedSources.length > 0;
|
||||
bool get wereSourcesAdded => _changeSet.addedSources.isNotEmpty;
|
||||
|
||||
/// Return `true` if any sources were removed or deleted.
|
||||
bool get wereSourcesRemoved =>
|
||||
_changeSet.removedSources.length > 0 ||
|
||||
_changeSet.removedContainers.length > 0;
|
||||
_changeSet.removedSources.isNotEmpty ||
|
||||
_changeSet.removedContainers.isNotEmpty;
|
||||
}
|
||||
|
|
|
@ -1754,7 +1754,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
|
|||
|
||||
String name = identifier.name;
|
||||
if (element is MethodElement && element.isOperator && name == '-') {
|
||||
if (element.parameters.length == 0) {
|
||||
if (element.parameters.isEmpty) {
|
||||
name = 'unary-';
|
||||
}
|
||||
}
|
||||
|
@ -3116,7 +3116,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
|
|||
LibraryElement prevLibrary = _nameToExportElement[name];
|
||||
if (prevLibrary != null) {
|
||||
if (prevLibrary != exportedLibrary) {
|
||||
if (!name.isEmpty) {
|
||||
if (name.isNotEmpty) {
|
||||
_errorReporter.reportErrorForNode(
|
||||
StaticWarningCode.EXPORT_DUPLICATED_LIBRARY_NAMED, directive, [
|
||||
prevLibrary.definingCompilationUnit.source.uri.toString(),
|
||||
|
@ -3699,7 +3699,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
|
|||
// check if there is another imported library with the same name
|
||||
LibraryElement prevLibrary = _nameToImportElement[name];
|
||||
if (prevLibrary != null) {
|
||||
if (prevLibrary != nodeLibrary && !name.isEmpty) {
|
||||
if (prevLibrary != nodeLibrary && name.isNotEmpty) {
|
||||
_errorReporter.reportErrorForNode(
|
||||
StaticWarningCode.IMPORT_DUPLICATED_LIBRARY_NAMED, directive, [
|
||||
prevLibrary.definingCompilationUnit.source.uri,
|
||||
|
@ -5432,7 +5432,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
|
|||
int loopThroughIndex =
|
||||
math.min(typeArguments.length, parameterElements.length);
|
||||
bool shouldSubstitute =
|
||||
arguments.length != 0 && arguments.length == parameterTypes.length;
|
||||
arguments.isNotEmpty && arguments.length == parameterTypes.length;
|
||||
for (int i = 0; i < loopThroughIndex; i++) {
|
||||
DartType argType = typeArguments[i];
|
||||
TypeAnnotation argumentNode =
|
||||
|
@ -6299,7 +6299,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
|
|||
// Get the parameters for MethodDeclaration or FunctionDeclaration
|
||||
List<ParameterElement> setterParameters = setter.parameters;
|
||||
// If there are no setter parameters, return no type.
|
||||
if (setterParameters.length == 0) {
|
||||
if (setterParameters.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
return setterParameters[0].type;
|
||||
|
|
|
@ -152,7 +152,7 @@ class StringUtilities {
|
|||
}
|
||||
|
||||
static bool isTagName(String s) {
|
||||
if (s == null || s.length == 0) {
|
||||
if (s == null || s.isEmpty) {
|
||||
return false;
|
||||
}
|
||||
int sz = s.length;
|
||||
|
@ -243,7 +243,7 @@ class StringUtilities {
|
|||
}
|
||||
|
||||
static startsWithChar(String str, int c) {
|
||||
return str.length != 0 && str.codeUnitAt(0) == c;
|
||||
return str.isNotEmpty && str.codeUnitAt(0) == c;
|
||||
}
|
||||
|
||||
static String substringBefore(String str, String separator) {
|
||||
|
|
|
@ -130,7 +130,7 @@ class JavaSystemIO {
|
|||
}
|
||||
if (name == 'com.google.dart.sdk') {
|
||||
String exec = Platform.executable;
|
||||
if (exec.length != 0) {
|
||||
if (exec.isNotEmpty) {
|
||||
String sdkPath;
|
||||
// may be "xcodebuild/ReleaseIA32/dart" with "sdk" sibling
|
||||
{
|
||||
|
|
|
@ -1846,7 +1846,7 @@ class Parser {
|
|||
_reportErrorForCurrentToken(
|
||||
ParserErrorCode.MULTIPLE_LIBRARY_DIRECTIVES);
|
||||
} else {
|
||||
if (directives.length > 0) {
|
||||
if (directives.isNotEmpty) {
|
||||
_reportErrorForCurrentToken(
|
||||
ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST);
|
||||
}
|
||||
|
@ -1870,7 +1870,7 @@ class Parser {
|
|||
}
|
||||
|
||||
Directive directive = parseDirective();
|
||||
if (declarations.length > 0 && !directiveFoundAfterDeclaration) {
|
||||
if (declarations.isNotEmpty && !directiveFoundAfterDeclaration) {
|
||||
_reportErrorForToken(ParserErrorCode.DIRECTIVE_AFTER_DECLARATION,
|
||||
directive.beginToken);
|
||||
directiveFoundAfterDeclaration = true;
|
||||
|
|
|
@ -728,7 +728,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
|
|||
// or have the logic centralized elsewhere, instead of doing this logic
|
||||
// here.
|
||||
displayName = element.enclosingElement.displayName;
|
||||
if (!element.displayName.isEmpty) {
|
||||
if (element.displayName.isNotEmpty) {
|
||||
displayName = "$displayName.${element.displayName}";
|
||||
}
|
||||
} else if (element is LibraryElement) {
|
||||
|
@ -8040,7 +8040,7 @@ class TypeResolverVisitor extends ScopedVisitor {
|
|||
variable.declaredType = element.returnType;
|
||||
} else if (variable.type == null) {
|
||||
List<ParameterElement> parameters = element.parameters;
|
||||
DartType type = parameters != null && parameters.length > 0
|
||||
DartType type = parameters != null && parameters.isNotEmpty
|
||||
? parameters[0].type
|
||||
: _dynamicType;
|
||||
variable.declaredType = type;
|
||||
|
|
|
@ -305,7 +305,7 @@ class PackageUriResolver extends UriResolver {
|
|||
* relative to
|
||||
*/
|
||||
PackageUriResolver(this._packagesDirectories) {
|
||||
if (_packagesDirectories.length < 1) {
|
||||
if (_packagesDirectories.isEmpty) {
|
||||
throw new ArgumentError(
|
||||
"At least one package directory must be provided");
|
||||
}
|
||||
|
|
|
@ -1364,7 +1364,7 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
|
|||
*/
|
||||
String _getFirstArgumentAsString(ArgumentList argumentList) {
|
||||
NodeList<Expression> arguments = argumentList.arguments;
|
||||
if (arguments.length > 0) {
|
||||
if (arguments.isNotEmpty) {
|
||||
Expression argument = arguments[0];
|
||||
if (argument is SimpleStringLiteral) {
|
||||
return argument.value;
|
||||
|
@ -1421,7 +1421,7 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
|
|||
}
|
||||
if (accessor.isSetter) {
|
||||
List<DartType> parameterTypes = functionType.normalParameterTypes;
|
||||
if (parameterTypes != null && parameterTypes.length > 0) {
|
||||
if (parameterTypes != null && parameterTypes.isNotEmpty) {
|
||||
return parameterTypes[0];
|
||||
}
|
||||
PropertyAccessorElement getter = accessor.variable.getter;
|
||||
|
|
|
@ -1303,7 +1303,7 @@ class AstTestFactory {
|
|||
TokenFactory.tokenFromType(TokenType.SEMICOLON));
|
||||
|
||||
static TypeArgumentList typeArgumentList(List<TypeAnnotation> types) {
|
||||
if (types == null || types.length == 0) {
|
||||
if (types == null || types.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
return astFactory.typeArgumentList(TokenFactory.tokenFromType(TokenType.LT),
|
||||
|
@ -1345,7 +1345,7 @@ class AstTestFactory {
|
|||
|
||||
static TypeParameterList typeParameterList([List<String> typeNames]) {
|
||||
List<TypeParameter> typeParameters = null;
|
||||
if (typeNames != null && !typeNames.isEmpty) {
|
||||
if (typeNames != null && typeNames.isNotEmpty) {
|
||||
typeParameters = new List<TypeParameter>();
|
||||
for (String typeName in typeNames) {
|
||||
typeParameters.add(typeParameter(typeName));
|
||||
|
|
|
@ -187,7 +187,7 @@ class MultipleMapIterator<K, V> implements MapIterator<K, V> {
|
|||
@override
|
||||
bool moveNext() {
|
||||
if (_iteratorIndex < 0) {
|
||||
if (_iterators.length == 0) {
|
||||
if (_iterators.isEmpty) {
|
||||
_currentIterator = null;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -287,7 +287,7 @@ abstract class AnalysisTask {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (cycle.length > 0) {
|
||||
if (cycle.isNotEmpty) {
|
||||
traverse(cycle[0]);
|
||||
}
|
||||
return path;
|
||||
|
|
|
@ -549,7 +549,7 @@ class TopLevelOptionValidator extends OptionsValidator {
|
|||
AnalysisOptionsWarningCode _warningCode;
|
||||
|
||||
TopLevelOptionValidator(this.pluginName, this.supportedOptions) {
|
||||
assert(supportedOptions != null && !supportedOptions.isEmpty);
|
||||
assert(supportedOptions != null && supportedOptions.isNotEmpty);
|
||||
if (supportedOptions.length > 1) {
|
||||
_valueProposal = StringUtilities.printListOfQuotedNames(supportedOptions);
|
||||
_warningCode =
|
||||
|
|
|
@ -499,14 +499,14 @@ class CodeChecker extends RecursiveAstVisitor {
|
|||
DartType type = DynamicTypeImpl.instance;
|
||||
if (node.typeArguments != null) {
|
||||
NodeList<TypeAnnotation> targs = node.typeArguments.arguments;
|
||||
if (targs.length > 0) {
|
||||
if (targs.isNotEmpty) {
|
||||
type = targs[0].type;
|
||||
}
|
||||
} else {
|
||||
DartType staticType = node.staticType;
|
||||
if (staticType is InterfaceType) {
|
||||
List<DartType> targs = staticType.typeArguments;
|
||||
if (targs != null && targs.length > 0) {
|
||||
if (targs != null && targs.isNotEmpty) {
|
||||
type = targs[0];
|
||||
}
|
||||
}
|
||||
|
@ -605,7 +605,7 @@ class CodeChecker extends RecursiveAstVisitor {
|
|||
DartType valueType = DynamicTypeImpl.instance;
|
||||
if (node.typeArguments != null) {
|
||||
NodeList<TypeAnnotation> typeArguments = node.typeArguments.arguments;
|
||||
if (typeArguments.length > 0) {
|
||||
if (typeArguments.isNotEmpty) {
|
||||
keyType = typeArguments[0].type;
|
||||
}
|
||||
if (typeArguments.length > 1) {
|
||||
|
@ -616,7 +616,7 @@ class CodeChecker extends RecursiveAstVisitor {
|
|||
if (staticType is InterfaceType) {
|
||||
List<DartType> typeArguments = staticType.typeArguments;
|
||||
if (typeArguments != null) {
|
||||
if (typeArguments.length > 0) {
|
||||
if (typeArguments.isNotEmpty) {
|
||||
keyType = typeArguments[0];
|
||||
}
|
||||
if (typeArguments.length > 1) {
|
||||
|
@ -633,14 +633,14 @@ class CodeChecker extends RecursiveAstVisitor {
|
|||
DartType type = DynamicTypeImpl.instance;
|
||||
if (node.typeArguments != null) {
|
||||
NodeList<TypeAnnotation> typeArguments = node.typeArguments.arguments;
|
||||
if (typeArguments.length > 0) {
|
||||
if (typeArguments.isNotEmpty) {
|
||||
type = typeArguments[0].type;
|
||||
}
|
||||
} else {
|
||||
DartType staticType = node.staticType;
|
||||
if (staticType is InterfaceType) {
|
||||
List<DartType> typeArguments = staticType.typeArguments;
|
||||
if (typeArguments != null && typeArguments.length > 0) {
|
||||
if (typeArguments != null && typeArguments.isNotEmpty) {
|
||||
type = typeArguments[0];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -261,7 +261,7 @@ class AstValidator extends UnifyingAstVisitor<void> {
|
|||
* visited.
|
||||
*/
|
||||
void assertValid() {
|
||||
if (!_errors.isEmpty) {
|
||||
if (_errors.isNotEmpty) {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.write("Invalid AST structure:");
|
||||
for (String message in _errors) {
|
||||
|
|
|
@ -100,7 +100,7 @@ class AnalysisDeltaTest extends EngineTestCase {
|
|||
delta.setAnalysisLevel(new TestSource(), AnalysisLevel.ALL);
|
||||
String result = delta.toString();
|
||||
expect(result, isNotNull);
|
||||
expect(result.length > 0, isTrue);
|
||||
expect(result.isNotEmpty, isTrue);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -561,7 +561,7 @@ class StaticTypeVerifier extends GeneralizingAstVisitor<void> {
|
|||
* Assert that all of the visited nodes have a static type associated with them.
|
||||
*/
|
||||
void assertResolved() {
|
||||
if (!_unresolvedExpressions.isEmpty || !_unresolvedTypes.isEmpty) {
|
||||
if (_unresolvedExpressions.isNotEmpty || _unresolvedTypes.isNotEmpty) {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
int unresolvedTypeCount = _unresolvedTypes.length;
|
||||
if (unresolvedTypeCount > 0) {
|
||||
|
|
|
@ -73,15 +73,15 @@ class ResolutionVerifier extends RecursiveAstVisitor<void> {
|
|||
* Assert that all of the visited identifiers were resolved.
|
||||
*/
|
||||
void assertResolved() {
|
||||
if (!_unresolvedNodes.isEmpty || !_wrongTypedNodes.isEmpty) {
|
||||
if (_unresolvedNodes.isNotEmpty || _wrongTypedNodes.isNotEmpty) {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
if (!_unresolvedNodes.isEmpty) {
|
||||
if (_unresolvedNodes.isNotEmpty) {
|
||||
buffer.write("Failed to resolve ");
|
||||
buffer.write(_unresolvedNodes.length);
|
||||
buffer.writeln(" nodes:");
|
||||
_printNodes(buffer, _unresolvedNodes);
|
||||
}
|
||||
if (!_wrongTypedNodes.isEmpty) {
|
||||
if (_wrongTypedNodes.isNotEmpty) {
|
||||
buffer.write("Resolved ");
|
||||
buffer.write(_wrongTypedNodes.length);
|
||||
buffer.writeln(" to the wrong type of element:");
|
||||
|
|
|
@ -197,7 +197,7 @@ class GatheringErrorListener implements AnalysisErrorListener {
|
|||
List<AnalysisError> get errors => _errors;
|
||||
|
||||
/// Return `true` if at least one error has been gathered.
|
||||
bool get hasErrors => _errors.length > 0;
|
||||
bool get hasErrors => _errors.isNotEmpty;
|
||||
|
||||
/// Add the given [errors] to this listener.
|
||||
void addAll(List<AnalysisError> errors) {
|
||||
|
|
|
@ -225,7 +225,7 @@ class FolderBasedDartSdkTest with ResourceProviderMixin {
|
|||
FolderBasedDartSdk sdk = _createDartSdk();
|
||||
String version = sdk.sdkVersion;
|
||||
expect(version, isNotNull);
|
||||
expect(version.length > 0, isTrue);
|
||||
expect(version.isNotEmpty, isTrue);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1078,7 +1078,7 @@ class _ElementWriter {
|
|||
|
||||
ElementLocation location = element.location;
|
||||
List<String> components = location.components.toList();
|
||||
if (components.length >= 1) {
|
||||
if (components.isNotEmpty) {
|
||||
components[0] = onlyName(components[0]);
|
||||
}
|
||||
if (components.length >= 2) {
|
||||
|
|
|
@ -732,7 +732,7 @@ class _CodeGenerator {
|
|||
'Class `$clsName`: TopLevel argument must be a string'
|
||||
' literal');
|
||||
}
|
||||
} else if (annotation.arguments.length != 0) {
|
||||
} else if (annotation.arguments.isNotEmpty) {
|
||||
throw new Exception(
|
||||
'Class `$clsName`: TopLevel requires 0 or 1 arguments');
|
||||
}
|
||||
|
@ -752,7 +752,7 @@ class _CodeGenerator {
|
|||
'Class `$clsName`: @Variant argument must be a string literal',
|
||||
);
|
||||
}
|
||||
} else if (annotation.arguments.length != 0) {
|
||||
} else if (annotation.arguments.isNotEmpty) {
|
||||
throw Exception(
|
||||
'Class `$clsName`: @Variant requires 1 argument',
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue