diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 2030e2e..cbb5213 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -47,7 +47,7 @@ jobs: matrix: # Add macos-latest and/or windows-latest if relevant for this package. os: [ubuntu-latest, windows-latest] - sdk: [2.19.0, dev] + sdk: [3.0, dev] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d diff --git a/CHANGELOG.md b/CHANGELOG.md index 70e7747..071dad0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.1-wip + +- Require Dart 3.0 + ## 1.0.0 - Rev to `1.0.0` (note however that there are no API changes from `0.17.x`). diff --git a/analysis_options.yaml b/analysis_options.yaml index eb67f88..25e2df4 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -5,3 +5,9 @@ analyzer: strict-casts: true strict-inference: true strict-raw-types: true + errors: + comment_references: ignore #too many false positives + +linter: + rules: + - prefer_expression_function_bodies diff --git a/example/main.dart b/example/main.dart index 7aad004..88dc748 100644 --- a/example/main.dart +++ b/example/main.dart @@ -84,9 +84,8 @@ StyleSheet parseCss( String cssInput, { List? errors, css.PreprocessorOptions? opts, -}) { - return css.parse(cssInput, errors: errors, options: opts ?? _default); -} +}) => + css.parse(cssInput, errors: errors, options: opts ?? _default); /// Pretty printer for CSS. String prettyPrint(StyleSheet ss) => diff --git a/lib/parser.dart b/lib/parser.dart index 15dd764..e978069 100644 --- a/lib/parser.dart +++ b/lib/parser.dart @@ -38,7 +38,7 @@ class ParserState extends TokenizerState { void _createMessages({List? errors, PreprocessorOptions? options}) { errors ??= []; - options ??= PreprocessorOptions(useColors: false, inputFile: 'memory'); + options ??= const PreprocessorOptions(useColors: false, inputFile: 'memory'); messages = Messages(options: options, printHandler: errors.add); } @@ -258,9 +258,7 @@ class _Parser { /////////////////////////////////////////////////////////////////// // Basic support methods /////////////////////////////////////////////////////////////////// - int _peek() { - return _peekToken.kind; - } + int _peek() => _peekToken.kind; Token _next({bool unicodeRange = false}) { final next = _previousToken = _peekToken; @@ -268,14 +266,10 @@ class _Parser { return next; } - bool _peekKind(int kind) { - return _peekToken.kind == kind; - } + bool _peekKind(int kind) => _peekToken.kind == kind; // Is the next token a legal identifier? This includes pseudo-keywords. - bool _peekIdentifier() { - return TokenKind.isIdentifier(_peekToken.kind); - } + bool _peekIdentifier() => TokenKind.isIdentifier(_peekToken.kind); /// Marks the parser/tokenizer look ahead to support Less nested selectors. ParserState get _mark => ParserState(_peekToken, _previousToken, tokenizer); @@ -792,9 +786,8 @@ class _Parser { } var declGroup = processDeclarations(checkBrace: false); - if (declGroup.declarations.any((decl) { - return decl is Declaration && decl is! IncludeMixinAtDeclaration; - })) { + if (declGroup.declarations.any((decl) => + decl is Declaration && decl is! IncludeMixinAtDeclaration)) { var newDecls = []; for (var include in productions) { // If declGroup has items that are declarations then we assume @@ -2038,40 +2031,31 @@ class _Parser { DartStyleExpression? processOneNumber(Expressions exprs, int part) { var value = marginValue(exprs.expressions[0]); if (value != null) { - switch (part) { - case _marginPartLeft: - return MarginExpression(exprs.span, left: value); - case _marginPartTop: - return MarginExpression(exprs.span, top: value); - case _marginPartRight: - return MarginExpression(exprs.span, right: value); - case _marginPartBottom: - return MarginExpression(exprs.span, bottom: value); - case _borderPartLeft: - case _borderPartLeftWidth: - return BorderExpression(exprs.span, left: value); - case _borderPartTop: - case _borderPartTopWidth: - return BorderExpression(exprs.span, top: value); - case _borderPartRight: - case _borderPartRightWidth: - return BorderExpression(exprs.span, right: value); - case _borderPartBottom: - case _borderPartBottomWidth: - return BorderExpression(exprs.span, bottom: value); - case _heightPart: - return HeightExpression(exprs.span, value); - case _widthPart: - return WidthExpression(exprs.span, value); - case _paddingPartLeft: - return PaddingExpression(exprs.span, left: value); - case _paddingPartTop: - return PaddingExpression(exprs.span, top: value); - case _paddingPartRight: - return PaddingExpression(exprs.span, right: value); - case _paddingPartBottom: - return PaddingExpression(exprs.span, bottom: value); - } + return switch (part) { + _marginPartLeft => MarginExpression(exprs.span, left: value), + _marginPartTop => MarginExpression(exprs.span, top: value), + _marginPartRight => MarginExpression(exprs.span, right: value), + _marginPartBottom => MarginExpression(exprs.span, bottom: value), + _borderPartLeft || + _borderPartLeftWidth => + BorderExpression(exprs.span, left: value), + _borderPartTop || + _borderPartTopWidth => + BorderExpression(exprs.span, top: value), + _borderPartRight || + _borderPartRightWidth => + BorderExpression(exprs.span, right: value), + _borderPartBottom || + _borderPartBottomWidth => + BorderExpression(exprs.span, bottom: value), + _heightPart => HeightExpression(exprs.span, value), + _widthPart => WidthExpression(exprs.span, value), + _paddingPartLeft => PaddingExpression(exprs.span, left: value), + _paddingPartTop => PaddingExpression(exprs.span, top: value), + _paddingPartRight => PaddingExpression(exprs.span, right: value), + _paddingPartBottom => PaddingExpression(exprs.span, bottom: value), + _ => null + }; } return null; } diff --git a/lib/src/messages.dart b/lib/src/messages.dart index cf97c22..fb1516c 100644 --- a/lib/src/messages.dart +++ b/lib/src/messages.dart @@ -86,7 +86,7 @@ class Messages { final List messages = []; Messages({PreprocessorOptions? options, this.printHandler = print}) - : options = options ?? PreprocessorOptions(); + : options = options ?? const PreprocessorOptions(); /// Report a compile-time CSS error. void error(String message, SourceSpan? span) { diff --git a/lib/src/property.dart b/lib/src/property.dart index f884566..ec6b854 100644 --- a/lib/src/property.dart +++ b/lib/src/property.dart @@ -504,14 +504,12 @@ class Rgba implements _StyleProperty, ColorBase { factory Rgba.fromColor(Color color) => color.rgba; - factory Rgba.fromArgbValue(num value) { - return Rgba( - (value.toInt() & 0xff000000) >> 0x18, // a - (value.toInt() & 0xff0000) >> 0x10, // r - (value.toInt() & 0xff00) >> 8, // g - value.toInt() & 0xff, - ); // b - } + factory Rgba.fromArgbValue(num value) => Rgba( + (value.toInt() & 0xff000000) >> 0x18, // a + (value.toInt() & 0xff0000) >> 0x10, // r + (value.toInt() & 0xff00) >> 8, // g + value.toInt() & 0xff, + ); // b factory Rgba.fromHsla(Hsla hsla) { // Convert to Rgba. @@ -752,10 +750,9 @@ class PointXY implements _StyleProperty { const PointXY(this.x, this.y); @override - String? get cssExpression { - // TODO(terry): TBD - return null; - } + String? get cssExpression => + // TODO(terry): TBD + null; } // TODO(terry): Implement style and color. @@ -779,14 +776,12 @@ class Border implements _StyleProperty { int get height => top! + bottom!; @override - String get cssExpression { - return (top == left && bottom == right && top == right) - ? '${left}px' - : "${top != null ? '$top' : '0'}px " - "${right != null ? '$right' : '0'}px " - "${bottom != null ? '$bottom' : '0'}px " - "${left != null ? '$left' : '0'}px"; - } + String get cssExpression => (top == left && bottom == right && top == right) + ? '${left}px' + : "${top != null ? '$top' : '0'}px " + "${right != null ? '$right' : '0'}px " + "${bottom != null ? '$bottom' : '0'}px " + "${left != null ? '$left' : '0'}px"; } /// Font style constants. @@ -1069,10 +1064,9 @@ class Font implements _StyleProperty { } @override - int get hashCode { - // TODO(jimhug): Lot's of potential collisions here. List of fonts, etc. - return size!.toInt() % family![0].hashCode; - } + int get hashCode => + // TODO(jimhug): Lot's of potential collisions here. List of fonts, etc. + size!.toInt() % family![0].hashCode; @override bool operator ==(Object other) { diff --git a/lib/src/token_kind.dart b/lib/src/token_kind.dart index b654379..3f50402 100644 --- a/lib/src/token_kind.dart +++ b/lib/src/token_kind.dart @@ -507,24 +507,20 @@ class TokenKind { } /// Return the token that matches the unit ident found. - static int matchUnits(String text, int offset, int length) { - return matchList(_UNITS, 'unit', text, offset, length); - } + static int matchUnits(String text, int offset, int length) => + matchList(_UNITS, 'unit', text, offset, length); /// Return the token that matches the directive name found. - static int matchDirectives(String text, int offset, int length) { - return matchList(_DIRECTIVES, 'type', text, offset, length); - } + static int matchDirectives(String text, int offset, int length) => + matchList(_DIRECTIVES, 'type', text, offset, length); /// Return the token that matches the margin directive name found. - static int matchMarginDirectives(String text, int offset, int length) { - return matchList(MARGIN_DIRECTIVES, 'type', text, offset, length); - } + static int matchMarginDirectives(String text, int offset, int length) => + matchList(MARGIN_DIRECTIVES, 'type', text, offset, length); /// Return the token that matches the media operator found. - static int matchMediaOperator(String text, int offset, int length) { - return matchList(MEDIA_OPERATORS, 'type', text, offset, length); - } + static int matchMediaOperator(String text, int offset, int length) => + matchList(MEDIA_OPERATORS, 'type', text, offset, length); static String? idToValue(Iterable identList, int tokenId) { for (var entry in identList) { @@ -564,9 +560,7 @@ class TokenKind { } /// Return RGB value as [int] from a color entry in _EXTENDED_COLOR_NAMES. - static int colorValue(Map entry) { - return entry['value'] as int; - } + static int colorValue(Map entry) => entry['value'] as int; static String? hexToColorName(Object hexValue) { for (final entry in _EXTENDED_COLOR_NAMES) { @@ -604,82 +598,44 @@ class TokenKind { return invertResult.toString(); } - static String kindToString(int kind) { - switch (kind) { - case TokenKind.UNUSED: - return 'ERROR'; - case TokenKind.END_OF_FILE: - return 'end of file'; - case TokenKind.LPAREN: - return '('; - case TokenKind.RPAREN: - return ')'; - case TokenKind.LBRACK: - return '['; - case TokenKind.RBRACK: - return ']'; - case TokenKind.LBRACE: - return '{'; - case TokenKind.RBRACE: - return '}'; - case TokenKind.DOT: - return '.'; - case TokenKind.SEMICOLON: - return ';'; - case TokenKind.AT: - return '@'; - case TokenKind.HASH: - return '#'; - case TokenKind.PLUS: - return '+'; - case TokenKind.GREATER: - return '>'; - case TokenKind.TILDE: - return '~'; - case TokenKind.ASTERISK: - return '*'; - case TokenKind.NAMESPACE: - return '|'; - case TokenKind.COLON: - return ':'; - case TokenKind.PRIVATE_NAME: - return '_'; - case TokenKind.COMMA: - return ','; - case TokenKind.SPACE: - return ' '; - case TokenKind.TAB: - return '\t'; - case TokenKind.NEWLINE: - return '\n'; - case TokenKind.RETURN: - return '\r'; - case TokenKind.PERCENT: - return '%'; - case TokenKind.SINGLE_QUOTE: - return "'"; - case TokenKind.DOUBLE_QUOTE: - return '"'; - case TokenKind.SLASH: - return '/'; - case TokenKind.EQUALS: - return '='; - case TokenKind.CARET: - return '^'; - case TokenKind.DOLLAR: - return '\$'; - case TokenKind.LESS: - return '<'; - case TokenKind.BANG: - return '!'; - case TokenKind.MINUS: - return '-'; - case TokenKind.BACKSLASH: - return '\\'; - default: - throw StateError('Unknown TOKEN'); - } - } + static String kindToString(int kind) => switch (kind) { + TokenKind.UNUSED => 'ERROR', + TokenKind.END_OF_FILE => 'end of file', + TokenKind.LPAREN => '(', + TokenKind.RPAREN => ')', + TokenKind.LBRACK => '[', + TokenKind.RBRACK => ']', + TokenKind.LBRACE => '{', + TokenKind.RBRACE => '}', + TokenKind.DOT => '.', + TokenKind.SEMICOLON => ';', + TokenKind.AT => '@', + TokenKind.HASH => '#', + TokenKind.PLUS => '+', + TokenKind.GREATER => '>', + TokenKind.TILDE => '~', + TokenKind.ASTERISK => '*', + TokenKind.NAMESPACE => '|', + TokenKind.COLON => ':', + TokenKind.PRIVATE_NAME => '_', + TokenKind.COMMA => ',', + TokenKind.SPACE => ' ', + TokenKind.TAB => '\t', + TokenKind.NEWLINE => '\n', + TokenKind.RETURN => '\r', + TokenKind.PERCENT => '%', + TokenKind.SINGLE_QUOTE => "'", + TokenKind.DOUBLE_QUOTE => '"', + TokenKind.SLASH => '/', + TokenKind.EQUALS => '=', + TokenKind.CARET => '^', + TokenKind.DOLLAR => '\$', + TokenKind.LESS => '<', + TokenKind.BANG => '!', + TokenKind.MINUS => '-', + TokenKind.BACKSLASH => '\\', + _ => throw StateError('Unknown TOKEN') + }; static bool isKindIdentifier(int kind) { switch (kind) { @@ -724,9 +680,7 @@ class TokenKind { } } - static bool isIdentifier(int kind) { - return kind == IDENTIFIER; - } + static bool isIdentifier(int kind) => kind == IDENTIFIER; } // Note: these names should match TokenKind names diff --git a/lib/src/tokenizer.dart b/lib/src/tokenizer.dart index 15f5ad0..d090106 100644 --- a/lib/src/tokenizer.dart +++ b/lib/src/tokenizer.dart @@ -234,24 +234,20 @@ class Tokenizer extends TokenizerBase { } } - bool varDef(int ch) { - return ch == 'v'.codeUnitAt(0) && - _maybeEatChar('a'.codeUnitAt(0)) && - _maybeEatChar('r'.codeUnitAt(0)) && - _maybeEatChar('-'.codeUnitAt(0)); - } - - bool varUsage(int ch) { - return ch == 'v'.codeUnitAt(0) && - _maybeEatChar('a'.codeUnitAt(0)) && - _maybeEatChar('r'.codeUnitAt(0)) && - (_peekChar() == '-'.codeUnitAt(0)); - } + bool varDef(int ch) => + ch == 'v'.codeUnitAt(0) && + _maybeEatChar('a'.codeUnitAt(0)) && + _maybeEatChar('r'.codeUnitAt(0)) && + _maybeEatChar('-'.codeUnitAt(0)); + + bool varUsage(int ch) => + ch == 'v'.codeUnitAt(0) && + _maybeEatChar('a'.codeUnitAt(0)) && + _maybeEatChar('r'.codeUnitAt(0)) && + (_peekChar() == '-'.codeUnitAt(0)); @override - Token _errorToken([String? message]) { - return _finishToken(TokenKind.ERROR); - } + Token _errorToken([String? message]) => _finishToken(TokenKind.ERROR); @override int getIdentifierKind() { @@ -444,39 +440,32 @@ class Tokenizer extends TokenizerBase { /// Static helper methods. class TokenizerHelpers { - static bool isIdentifierStart(int c) { - return isIdentifierStartExpr(c) || c == 45 /*-*/; - } + static bool isIdentifierStart(int c) => + isIdentifierStartExpr(c) || c == 45 /*-*/; - static bool isDigit(int c) { - return c >= 48 /*0*/ && c <= 57 /*9*/; - } + static bool isDigit(int c) => c >= 48 /*0*/ && c <= 57 /*9*/; - static bool isHexDigit(int c) { - return isDigit(c) || - (c >= 97 /*a*/ && c <= 102 /*f*/) || - (c >= 65 /*A*/ && c <= 70 /*F*/); - } + static bool isHexDigit(int c) => + isDigit(c) || + (c >= 97 /*a*/ && c <= 102 /*f*/) || + (c >= 65 /*A*/ && c <= 70 /*F*/); - static bool isIdentifierPart(int c) { - return isIdentifierPartExpr(c) || c == 45 /*-*/; - } + static bool isIdentifierPart(int c) => + isIdentifierPartExpr(c) || c == 45 /*-*/; /// Pseudo function expressions identifiers can't have a minus sign. - static bool isIdentifierStartExpr(int c) { - return (c >= 97 /*a*/ && c <= 122 /*z*/) || - (c >= 65 /*A*/ && c <= 90 /*Z*/) || - // Note: Unicode 10646 chars U+00A0 or higher are allowed, see: - // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier - // http://www.w3.org/TR/CSS21/syndata.html#characters - // Also, escaped character should be allowed. - c == 95 /*_*/ || - c >= 0xA0 || - c == 92 /*\*/; - } + static bool isIdentifierStartExpr(int c) => + (c >= 97 /*a*/ && c <= 122 /*z*/) || + (c >= 65 /*A*/ && c <= 90 /*Z*/) || + // Note: Unicode 10646 chars U+00A0 or higher are allowed, see: + // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier + // http://www.w3.org/TR/CSS21/syndata.html#characters + // Also, escaped character should be allowed. + c == 95 /*_*/ || + c >= 0xA0 || + c == 92 /*\*/; /// Pseudo function expressions identifiers can't have a minus sign. - static bool isIdentifierPartExpr(int c) { - return isIdentifierStartExpr(c) || isDigit(c); - } + static bool isIdentifierPartExpr(int c) => + isIdentifierStartExpr(c) || isDigit(c); } diff --git a/lib/src/tokenizer_base.dart b/lib/src/tokenizer_base.dart index bb44fee..bcac7be 100644 --- a/lib/src/tokenizer_base.dart +++ b/lib/src/tokenizer_base.dart @@ -107,14 +107,10 @@ abstract class TokenizerBase { return false; } - Token _finishToken(int kind) { - return Token(kind, _file.span(_startIndex, _index)); - } + Token _finishToken(int kind) => Token(kind, _file.span(_startIndex, _index)); - Token _errorToken([String? message]) { - return ErrorToken( - TokenKind.ERROR, _file.span(_startIndex, _index), message); - } + Token _errorToken([String? message]) => + ErrorToken(TokenKind.ERROR, _file.span(_startIndex, _index), message); Token finishWhitespace() { _index--; diff --git a/lib/src/tree.dart b/lib/src/tree.dart index 3c7df97..94655cf 100644 --- a/lib/src/tree.dart +++ b/lib/src/tree.dart @@ -22,12 +22,11 @@ class Identifier extends TreeNode { dynamic visit(VisitorBase visitor) => visitor.visitIdentifier(this); @override - String toString() { - // Try to use the identifier's original lexeme to preserve any escape codes - // as authored. The name, which may include escaped values, may no longer be - // a valid identifier. - return span?.text ?? name; - } + String toString() => + // Try to use the identifier's original lexeme to preserve any escape + // codes as authored. The name, which may include escaped values, may no + // longer be a valid identifier. + span?.text ?? name; } class Wildcard extends TreeNode { @@ -147,20 +146,13 @@ class SimpleSelectorSequence extends TreeNode { bool get isCombinatorDescendant => combinator == TokenKind.COMBINATOR_DESCENDANT; - String get _combinatorToString { - switch (combinator) { - case TokenKind.COMBINATOR_DESCENDANT: - return ' '; - case TokenKind.COMBINATOR_GREATER: - return ' > '; - case TokenKind.COMBINATOR_PLUS: - return ' + '; - case TokenKind.COMBINATOR_TILDE: - return ' ~ '; - default: - return ''; - } - } + String get _combinatorToString => switch (combinator) { + TokenKind.COMBINATOR_DESCENDANT => ' ', + TokenKind.COMBINATOR_GREATER => ' > ', + TokenKind.COMBINATOR_PLUS => ' + ', + TokenKind.COMBINATOR_TILDE => ' ~ ', + _ => '' + }; @override SimpleSelectorSequence clone() => @@ -243,44 +235,27 @@ class AttributeSelector extends SimpleSelector { int get operatorKind => _op; - String? matchOperator() { - switch (_op) { - case TokenKind.EQUALS: - return '='; - case TokenKind.INCLUDES: - return '~='; - case TokenKind.DASH_MATCH: - return '|='; - case TokenKind.PREFIX_MATCH: - return '^='; - case TokenKind.SUFFIX_MATCH: - return '\$='; - case TokenKind.SUBSTRING_MATCH: - return '*='; - case TokenKind.NO_MATCH: - return ''; - } - return null; - } + String? matchOperator() => switch (_op) { + TokenKind.EQUALS => '=', + TokenKind.INCLUDES => '~=', + TokenKind.DASH_MATCH => '|=', + TokenKind.PREFIX_MATCH => '^=', + TokenKind.SUFFIX_MATCH => '\$=', + TokenKind.SUBSTRING_MATCH => '*=', + TokenKind.NO_MATCH => '', + _ => null + }; // Return the TokenKind for operator used by visitAttributeSelector. - String? matchOperatorAsTokenString() { - switch (_op) { - case TokenKind.EQUALS: - return 'EQUALS'; - case TokenKind.INCLUDES: - return 'INCLUDES'; - case TokenKind.DASH_MATCH: - return 'DASH_MATCH'; - case TokenKind.PREFIX_MATCH: - return 'PREFIX_MATCH'; - case TokenKind.SUFFIX_MATCH: - return 'SUFFIX_MATCH'; - case TokenKind.SUBSTRING_MATCH: - return 'SUBSTRING_MATCH'; - } - return null; - } + String? matchOperatorAsTokenString() => switch (_op) { + TokenKind.EQUALS => 'EQUALS', + TokenKind.INCLUDES => 'INCLUDES', + TokenKind.DASH_MATCH => 'DASH_MATCH', + TokenKind.PREFIX_MATCH => 'PREFIX_MATCH', + TokenKind.SUFFIX_MATCH => 'SUFFIX_MATCH', + TokenKind.SUBSTRING_MATCH => 'SUBSTRING_MATCH', + _ => null + }; String valueToString() { if (value != null) { @@ -406,9 +381,8 @@ class SelectorExpression extends TreeNode { SourceSpan get span => super.span!; @override - SelectorExpression clone() { - return SelectorExpression(expressions.map((e) => e.clone()).toList(), span); - } + SelectorExpression clone() => + SelectorExpression(expressions.map((e) => e.clone()).toList(), span); @override dynamic visit(VisitorBase visitor) => visitor.visitSelectorExpression(this); @@ -824,20 +798,15 @@ class KeyFrameDirective extends Directive { _blocks.add(block); } - String? get keyFrameName { - switch (_keyframeName) { - case TokenKind.DIRECTIVE_KEYFRAMES: - case TokenKind.DIRECTIVE_MS_KEYFRAMES: - return '@keyframes'; - case TokenKind.DIRECTIVE_WEB_KIT_KEYFRAMES: - return '@-webkit-keyframes'; - case TokenKind.DIRECTIVE_MOZ_KEYFRAMES: - return '@-moz-keyframes'; - case TokenKind.DIRECTIVE_O_KEYFRAMES: - return '@-o-keyframes'; - } - return null; - } + String? get keyFrameName => switch (_keyframeName) { + TokenKind.DIRECTIVE_KEYFRAMES || + TokenKind.DIRECTIVE_MS_KEYFRAMES => + '@keyframes', + TokenKind.DIRECTIVE_WEB_KIT_KEYFRAMES => '@-webkit-keyframes', + TokenKind.DIRECTIVE_MOZ_KEYFRAMES => '@-moz-keyframes', + TokenKind.DIRECTIVE_O_KEYFRAMES => '@-o-keyframes', + _ => null + }; @override KeyFrameDirective clone() { @@ -1611,9 +1580,8 @@ class FontExpression extends DartStyleExpression { } /// Merge the two FontExpression and return the result. - factory FontExpression.merge(FontExpression x, FontExpression y) { - return FontExpression._merge(x, y, y.span); - } + factory FontExpression.merge(FontExpression x, FontExpression y) => + FontExpression._merge(x, y, y.span); FontExpression._merge(FontExpression x, FontExpression y, SourceSpan? span) : font = Font.merge(x.font, y.font)!, @@ -1676,9 +1644,8 @@ class MarginExpression extends BoxExpression { } /// Merge the two MarginExpressions and return the result. - factory MarginExpression.merge(MarginExpression x, MarginExpression y) { - return MarginExpression._merge(x, y, y.span); - } + factory MarginExpression.merge(MarginExpression x, MarginExpression y) => + MarginExpression._merge(x, y, y.span); MarginExpression._merge( MarginExpression x, MarginExpression y, SourceSpan? span) @@ -1712,9 +1679,8 @@ class BorderExpression extends BoxExpression { } /// Merge the two BorderExpression and return the result. - factory BorderExpression.merge(BorderExpression x, BorderExpression y) { - return BorderExpression._merge(x, y, y.span); - } + factory BorderExpression.merge(BorderExpression x, BorderExpression y) => + BorderExpression._merge(x, y, y.span); BorderExpression._merge( BorderExpression x, BorderExpression y, SourceSpan? span) @@ -1793,9 +1759,8 @@ class PaddingExpression extends BoxExpression { } /// Merge the two PaddingExpression and return the result. - factory PaddingExpression.merge(PaddingExpression x, PaddingExpression y) { - return PaddingExpression._merge(x, y, y.span); - } + factory PaddingExpression.merge(PaddingExpression x, PaddingExpression y) => + PaddingExpression._merge(x, y, y.span); PaddingExpression._merge( PaddingExpression x, PaddingExpression y, SourceSpan? span) diff --git a/lib/src/validate.dart b/lib/src/validate.dart index b99a898..608c093 100644 --- a/lib/src/validate.dart +++ b/lib/src/validate.dart @@ -2,9 +2,10 @@ // 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:csslib/visitor.dart'; import 'package:source_span/source_span.dart'; +import '../visitor.dart'; + /// Can be thrown on any Css runtime problem includes source location. class CssSelectorException extends SourceSpanException { CssSelectorException(super.message, [super.span]); diff --git a/pubspec.yaml b/pubspec.yaml index e0eab9a..7a1cb94 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: csslib -version: 1.0.0 +version: 1.0.1-wip description: A library for parsing and analyzing CSS (Cascading Style Sheets). repository: https://github.com/dart-lang/csslib @@ -7,13 +7,13 @@ topics: - css environment: - sdk: '>=2.19.0 <4.0.0' + sdk: ^3.0.0 dependencies: source_span: ^1.8.0 dev_dependencies: - dart_flutter_team_lints: ^1.0.0 + dart_flutter_team_lints: ^2.0.0 path: ^1.8.0 term_glyph: ^1.2.0 test: ^1.16.0