diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 258f493..aa92829 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -44,7 +44,7 @@ jobs: matrix: # Add macos-latest and/or windows-latest if relevant for this package. os: [ubuntu-latest] - sdk: [2.17.0, dev] + sdk: [3.1, dev] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d diff --git a/CHANGELOG.md b/CHANGELOG.md index ac86fb6..a20b6e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.1.2-wip + +* Increase the SDK minimum to `3.1.0`. + ## 2.1.1 * Increase the SDK minimum to `2.17.0`. diff --git a/analysis_options.yaml b/analysis_options.yaml index 5575818..178039f 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,15 +1,7 @@ -include: package:lints/recommended.yaml +include: package:dart_flutter_team_lints/analysis_options.yaml linter: rules: - - always_declare_return_types - - avoid_dynamic_calls - avoid_unused_constructor_parameters - cancel_subscriptions - - directives_ordering - - omit_local_variable_types - package_api_docs - - prefer_single_quotes - - test_types_in_equals - - throw_in_finally - - unawaited_futures diff --git a/lib/boolean_selector.dart b/lib/boolean_selector.dart index 3a66ec4..1c42641 100644 --- a/lib/boolean_selector.dart +++ b/lib/boolean_selector.dart @@ -41,11 +41,11 @@ abstract class BooleanSelector { bool evaluate(bool Function(String variable) semantics); /// Returns a new [BooleanSelector] that matches only inputs matched by both - /// [this] and [other]. + /// `this` and [other]. BooleanSelector intersection(BooleanSelector other); /// Returns a new [BooleanSelector] that matches all inputs matched by either - /// [this] or [other]. + /// `this` or [other]. BooleanSelector union(BooleanSelector other); /// Throws a [FormatException] if any variables are undefined. diff --git a/lib/src/ast.dart b/lib/src/ast.dart index 0adfe99..d0d8583 100644 --- a/lib/src/ast.dart +++ b/lib/src/ast.dart @@ -20,7 +20,7 @@ abstract class Node { /// All the variables in this node, in the order they appear. Iterable get variables; - /// Calls the appropriate [Visitor] method on [this] and returns the result. + /// Calls the appropriate [Visitor] method on `this` and returns the result. T accept(Visitor visitor); } @@ -44,7 +44,7 @@ class VariableNode implements Node { String toString() => name; @override - bool operator ==(other) => other is VariableNode && name == other.name; + bool operator ==(Object other) => other is VariableNode && name == other.name; @override int get hashCode => name.hashCode; @@ -71,7 +71,7 @@ class NotNode implements Node { child is VariableNode || child is NotNode ? '!$child' : '!($child)'; @override - bool operator ==(other) => other is NotNode && child == other.child; + bool operator ==(Object other) => other is NotNode && child == other.child; @override int get hashCode => ~child.hashCode; @@ -109,7 +109,7 @@ class OrNode implements Node { } @override - bool operator ==(other) => + bool operator ==(Object other) => other is OrNode && left == other.left && right == other.right; @override @@ -148,7 +148,7 @@ class AndNode implements Node { } @override - bool operator ==(other) => + bool operator ==(Object other) => other is AndNode && left == other.left && right == other.right; @override @@ -190,7 +190,7 @@ class ConditionalNode implements Node { } @override - bool operator ==(other) => + bool operator ==(Object other) => other is ConditionalNode && condition == other.condition && whenTrue == other.whenTrue && diff --git a/lib/src/impl.dart b/lib/src/impl.dart index 16dc3ec..cafb1a4 100644 --- a/lib/src/impl.dart +++ b/lib/src/impl.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'package:source_span/source_span.dart'; + import '../boolean_selector.dart'; import 'ast.dart'; import 'evaluator.dart'; @@ -12,9 +14,9 @@ import 'validator.dart'; /// The concrete implementation of a [BooleanSelector] parsed from a string. /// -/// This is separate from [BooleanSelector] so that [intersect] and [union] can -/// check to see whether they're passed a [BooleanSelectorImpl] or a different -/// class that implements [BooleanSelector]. +/// This is separate from [BooleanSelector] so that [intersection] and [union] +/// can check to see whether they're passed a [BooleanSelectorImpl] or a +/// different class that implements [BooleanSelector]. class BooleanSelectorImpl implements BooleanSelector { /// The parsed AST. final Node _selector; @@ -62,7 +64,7 @@ class BooleanSelectorImpl implements BooleanSelector { String toString() => _selector.toString(); @override - bool operator ==(other) => + bool operator ==(Object other) => other is BooleanSelectorImpl && _selector == other._selector; @override diff --git a/lib/src/intersection_selector.dart b/lib/src/intersection_selector.dart index 6c1d314..3bf468c 100644 --- a/lib/src/intersection_selector.dart +++ b/lib/src/intersection_selector.dart @@ -19,7 +19,7 @@ class IntersectionSelector implements BooleanSelector { IntersectionSelector(this._selector1, this._selector2); @override - bool evaluate(semantics) => + bool evaluate(bool Function(String variable) semantics) => _selector1.evaluate(semantics) && _selector2.evaluate(semantics); @override @@ -39,7 +39,7 @@ class IntersectionSelector implements BooleanSelector { String toString() => '($_selector1) && ($_selector2)'; @override - bool operator ==(other) => + bool operator ==(Object other) => other is IntersectionSelector && _selector1 == other._selector1 && _selector2 == other._selector2; diff --git a/lib/src/scanner.dart b/lib/src/scanner.dart index 00e5ef7..25c4a11 100644 --- a/lib/src/scanner.dart +++ b/lib/src/scanner.dart @@ -73,24 +73,16 @@ class Scanner { return Token(TokenType.endOfFile, _scanner.spanFrom(_scanner.state)); } - switch (_scanner.peekChar()) { - case 0x28 /* ( */ : - return _scanOperator(TokenType.leftParen); - case 0x29 /* ) */ : - return _scanOperator(TokenType.rightParen); - case 0x3F /* ? */ : - return _scanOperator(TokenType.questionMark); - case 0x3A /* : */ : - return _scanOperator(TokenType.colon); - case 0x21 /* ! */ : - return _scanOperator(TokenType.not); - case 0x7C /* | */ : - return _scanOr(); - case 0x26 /* & */ : - return _scanAnd(); - default: - return _scanIdentifier(); - } + return switch (_scanner.peekChar()) { + 0x28 /* ( */ => _scanOperator(TokenType.leftParen), + 0x29 /* ) */ => _scanOperator(TokenType.rightParen), + 0x3F /* ? */ => _scanOperator(TokenType.questionMark), + 0x3A /* : */ => _scanOperator(TokenType.colon), + 0x21 /* ! */ => _scanOperator(TokenType.not), + 0x7C /* | */ => _scanOr(), + 0x26 /* & */ => _scanAnd(), + _ => _scanIdentifier() + }; } /// Scans a single-character operator and returns a token of type [type]. diff --git a/lib/src/union_selector.dart b/lib/src/union_selector.dart index 838e3d4..e355eb2 100644 --- a/lib/src/union_selector.dart +++ b/lib/src/union_selector.dart @@ -37,7 +37,7 @@ class UnionSelector implements BooleanSelector { String toString() => '($_selector1) && ($_selector2)'; @override - bool operator ==(other) => + bool operator ==(Object other) => other is UnionSelector && _selector1 == other._selector1 && _selector2 == other._selector2; diff --git a/pubspec.yaml b/pubspec.yaml index 670f6aa..b042a9e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,17 +1,17 @@ name: boolean_selector -version: 2.1.1 +version: 2.1.2-wip description: >- A flexible syntax for boolean expressions, based on a simplified version of Dart's expression syntax. repository: https://github.com/dart-lang/boolean_selector environment: - sdk: '>=2.17.0 <3.0.0' + sdk: ^3.1.0 dependencies: source_span: ^1.8.0 string_scanner: ^1.1.0 dev_dependencies: - lints: ^2.0.0 + dart_flutter_team_lints: ^2.0.0 test: ^1.16.0 diff --git a/test/parser_test.dart b/test/parser_test.dart index 5fbc0d2..ba55e70 100644 --- a/test/parser_test.dart +++ b/test/parser_test.dart @@ -7,16 +7,16 @@ import 'package:boolean_selector/src/parser.dart'; import 'package:test/test.dart'; /// A matcher that asserts that a value is a [ConditionalNode]. -final _isConditionalNode = TypeMatcher(); +const _isConditionalNode = TypeMatcher(); /// A matcher that asserts that a value is an [OrNode]. -final _isOrNode = TypeMatcher(); +const _isOrNode = TypeMatcher(); /// A matcher that asserts that a value is an [AndNode]. -final _isAndNode = TypeMatcher(); +const _isAndNode = TypeMatcher(); /// A matcher that asserts that a value is a [NotNode]. -final _isNotNode = TypeMatcher(); +const _isNotNode = TypeMatcher(); void main() { group('parses a conditional expression', () { diff --git a/test/scanner_test.dart b/test/scanner_test.dart index 30091d1..7ad78e2 100644 --- a/test/scanner_test.dart +++ b/test/scanner_test.dart @@ -7,7 +7,7 @@ import 'package:boolean_selector/src/token.dart'; import 'package:test/test.dart'; /// A matcher that asserts that a value is a [IdentifierToken]. -final _isIdentifierToken = TypeMatcher(); +const _isIdentifierToken = TypeMatcher(); void main() { group('peek()', () {