From 923edf0030be22bc13f456f9fe6a63e4e19dd2bb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 May 2023 12:29:43 -0700 Subject: [PATCH 01/19] Bump actions/checkout from 3.5.0 to 3.5.2 (#178) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.0 to 3.5.2. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/8f4b7f84864484a7bf31766abe9204da3cbe65b3...8e5e7e5ab8b370d6c329ec480221332ada57f0ab) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 761153c..1570da2 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest, windows-latest] sdk: [2.17.0, dev] steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} From a337a9afe00020590d3b232398928ec291b3d80d Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Wed, 10 May 2023 09:37:54 -0700 Subject: [PATCH 02/19] fixed CssPrinter pretty print indent levels (#169) * fixed CssPrinter pretty print indent levels * review comments --- CHANGELOG.md | 1 + lib/src/css_printer.dart | 185 +++++++++++++++++--------- lib/src/tree_printer.dart | 1 + test/compiler_test.dart | 28 ++-- test/declaration_test.dart | 262 +++++++++++++++++++------------------ test/keyframes_test.dart | 4 +- test/mixin_test.dart | 1 - test/nested_test.dart | 27 ++-- test/testing.dart | 28 ++-- test/var_test.dart | 20 ++- test/visitor_test.dart | 30 +++++ 11 files changed, 344 insertions(+), 243 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92dacab..75c5158 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Fixed a regression parsing declaration values containing spaces. - Add support for `lh` and `rlh` units. - Refactor the package example. +- Addressed an issue with the indent level of the `CssPrinter` output. ## 0.17.2 diff --git a/lib/src/css_printer.dart b/lib/src/css_printer.dart index 85e7978..e0507d1 100644 --- a/lib/src/css_printer.dart +++ b/lib/src/css_printer.dart @@ -7,35 +7,91 @@ part of '../visitor.dart'; /// Visitor that produces a formatted string representation of the CSS tree. class CssPrinter extends Visitor { StringBuffer _buff = StringBuffer(); - bool prettyPrint = true; + bool _prettyPrint = true; bool _isInKeyframes = false; + int _indent = 0; + bool _startOfLine = true; /// Walk the [tree] Stylesheet. [pretty] if true emits line breaks, extra /// spaces, friendly property values, etc., if false emits compacted output. @override void visitTree(StyleSheet tree, {bool pretty = false}) { - prettyPrint = pretty; + _prettyPrint = pretty; _buff = StringBuffer(); + _indent = 0; + _startOfLine = true; + visitStyleSheet(tree); } /// Appends [str] to the output buffer. void emit(String str) { - _buff.write(str); + if (_prettyPrint) { + if (_startOfLine) { + _startOfLine = false; + _buff.write(' ' * _indent); + } + _buff.write(str); + } else { + _buff.write(str); + } + } + + void _emitLBrace() { + _indent += 2; + _buff.write('{'); + + if (_prettyPrint) { + _buff.writeln(); + _startOfLine = true; + } + } + + void _emitRBrace() { + _indent -= 2; + + if (_prettyPrint) { + if (!_startOfLine) _buff.write('\n'); + _buff.write('${' ' * _indent}}\n'); + _startOfLine = true; + } else { + _buff.write('}'); + if (_indent == 0) { + _buff.writeln(); + } + } + } + + void _emitSemicolon({bool forceLf = false}) { + if (_prettyPrint) { + _buff.write(';\n'); + _startOfLine = true; + } else { + _buff.write(';'); + if (forceLf) _buff.write('\n'); + } + } + + void _emitLf({bool force = false}) { + if (_prettyPrint) { + _buff.write('\n'); + _startOfLine = true; + } else if (force) { + _buff.write('\n'); + } } /// Returns the output buffer. @override String toString() => _buff.toString().trim(); - String get _newLine => prettyPrint ? '\n' : ''; - String get _sp => prettyPrint ? ' ' : ''; + String get _sp => _prettyPrint ? ' ' : ''; // TODO(terry): When adding obfuscation we'll need isOptimized (compact w/ // obfuscation) and have isTesting (compact no obfuscation) and // isCompact would be !prettyPrint. We'll need another boolean // flag for obfuscation. - bool get _isTesting => !prettyPrint; + bool get _isTesting => !_prettyPrint; @override void visitCalcTerm(CalcTerm node) { @@ -86,28 +142,30 @@ class CssPrinter extends Visitor { @override void visitDocumentDirective(DocumentDirective node) { - emit('$_newLine@-moz-document '); + emit('@-moz-document '); node.functions.first.visit(this); for (var function in node.functions.skip(1)) { emit(',$_sp'); function.visit(this); } - emit('$_sp{'); + emit(_sp); + _emitLBrace(); for (var ruleSet in node.groupRuleBody) { ruleSet.visit(this); } - emit('$_newLine}'); + _emitRBrace(); } @override void visitSupportsDirective(SupportsDirective node) { - emit('$_newLine@supports '); + emit('@supports '); node.condition!.visit(this); - emit('$_sp{'); + emit(_sp); + _emitLBrace(); for (var rule in node.groupRuleBody) { rule.visit(this); } - emit('$_newLine}'); + _emitRBrace(); } @override @@ -143,29 +201,32 @@ class CssPrinter extends Visitor { @override void visitViewportDirective(ViewportDirective node) { - emit('@${node.name}$_sp{$_newLine'); + emit('@${node.name}$_sp'); + _emitLBrace(); node.declarations.visit(this); - emit('}'); + _emitRBrace(); } @override void visitMediaDirective(MediaDirective node) { - emit('$_newLine@media'); + emit('@media'); emitMediaQueries(node.mediaQueries.cast()); - emit('$_sp{'); + emit(_sp); + _emitLBrace(); for (var ruleset in node.rules) { ruleset.visit(this); } - emit('$_newLine}'); + _emitRBrace(); } @override void visitHostDirective(HostDirective node) { - emit('$_newLine@host$_sp{'); + emit('@host$_sp'); + _emitLBrace(); for (var ruleset in node.rules) { ruleset.visit(this); } - emit('$_newLine}'); + _emitRBrace(); } /// @page : pseudoPage { @@ -173,7 +234,7 @@ class CssPrinter extends Visitor { /// } @override void visitPageDirective(PageDirective node) { - emit('$_newLine@page'); + emit('@page'); if (node.hasIdent || node.hasPseudoPage) { if (node.hasIdent) emit(' '); emit(node._ident!); @@ -182,17 +243,19 @@ class CssPrinter extends Visitor { var declsMargin = node._declsMargin; var declsMarginLength = declsMargin.length; - emit('$_sp{$_newLine'); + emit(_sp); + _emitLBrace(); for (var i = 0; i < declsMarginLength; i++) { declsMargin[i].visit(this); } - emit('}'); + _emitRBrace(); } /// @charset "charset encoding" @override void visitCharsetDirective(CharsetDirective node) { - emit('$_newLine@charset "${node.charEncoding}";'); + emit('@charset "${node.charEncoding}"'); + _emitSemicolon(forceLf: true); } @override @@ -201,51 +264,54 @@ class CssPrinter extends Visitor { if (_isTesting) { // Emit assuming url() was parsed; most suite tests use url function. - emit(' @import url(${node.import})'); + emit('@import url(${node.import})'); } else if (isStartingQuote(node.import)) { - emit(' @import ${node.import}'); + emit('@import ${node.import}'); } else { // url(...) isn't needed only a URI can follow an @import directive; emit // url as a string. - emit(' @import "${node.import}"'); + emit('@import "${node.import}"'); } emitMediaQueries(node.mediaQueries); - emit(';'); + _emitSemicolon(forceLf: true); } @override void visitKeyFrameDirective(KeyFrameDirective node) { - emit('$_newLine${node.keyFrameName} '); + emit('${node.keyFrameName} '); node.name!.visit(this); - emit('$_sp{$_newLine'); + emit(_sp); + _emitLBrace(); _isInKeyframes = true; for (final block in node._blocks) { block.visit(this); } _isInKeyframes = false; - emit('}'); + _emitRBrace(); } @override void visitFontFaceDirective(FontFaceDirective node) { - emit('$_newLine@font-face '); - emit('$_sp{$_newLine'); + emit('@font-face'); + emit(_sp); + _emitLBrace(); node._declarations.visit(this); - emit('}'); + _emitRBrace(); } @override void visitKeyFrameBlock(KeyFrameBlock node) { - emit('$_sp$_sp'); node._blockSelectors.visit(this); - emit('$_sp{$_newLine'); + emit(_sp); + _emitLBrace(); node._declarations.visit(this); - emit('$_sp$_sp}$_newLine'); + _emitRBrace(); } @override void visitStyletDirective(StyletDirective node) { - emit('/* @stylet export as ${node.dartClassName} */\n'); + emit('/* @stylet export as ${node.dartClassName} */'); + _emitLf(force: true); } @override @@ -253,49 +319,51 @@ class CssPrinter extends Visitor { bool isStartingQuote(String ch) => '\'"'.contains(ch); if (isStartingQuote(node._uri!)) { - emit(' @namespace ${node.prefix}"${node._uri}"'); + emit('@namespace ${node.prefix}"${node._uri}"'); } else { if (_isTesting) { // Emit exactly was we parsed. - emit(' @namespace ${node.prefix}url(${node._uri})'); + emit('@namespace ${node.prefix}url(${node._uri})'); } else { // url(...) isn't needed only a URI can follow a: // @namespace prefix directive. - emit(' @namespace ${node.prefix}${node._uri}'); + emit('@namespace ${node.prefix}${node._uri}'); } } - emit(';'); + _emitSemicolon(forceLf: true); } @override void visitVarDefinitionDirective(VarDefinitionDirective node) { visitVarDefinition(node.def); - emit(';$_newLine'); + _emitSemicolon(); } @override void visitMixinRulesetDirective(MixinRulesetDirective node) { - emit('@mixin ${node.name} {'); + emit('@mixin ${node.name} '); + _emitLBrace(); for (var ruleset in node.rulesets) { ruleset.visit(this); } - emit('}'); + _emitRBrace(); } @override void visitMixinDeclarationDirective(MixinDeclarationDirective node) { - emit('@mixin ${node.name} {\n'); + emit('@mixin ${node.name}$_sp'); + _emitLBrace(); visitDeclarationGroup(node.declarations); - emit('}'); + _emitRBrace(); } /// Added optional newLine for handling @include at top-level vs/ inside of /// a declaration group. @override void visitIncludeDirective(IncludeDirective node, [bool topLevel = true]) { - if (topLevel) emit(_newLine); + if (topLevel) _emitLf(); emit('@include ${node.name}'); - emit(';'); + _emitSemicolon(forceLf: true); } @override @@ -305,11 +373,11 @@ class CssPrinter extends Visitor { @override void visitRuleSet(RuleSet node) { - emit(_newLine); node.selectorGroup!.visit(this); - emit('$_sp{$_newLine'); + emit(_sp); + _emitLBrace(); node.declarationGroup.visit(this); - emit('}'); + _emitRBrace(); } @override @@ -317,15 +385,12 @@ class CssPrinter extends Visitor { var declarations = node.declarations; var declarationsLength = declarations.length; for (var i = 0; i < declarationsLength; i++) { - if (i > 0) emit(_newLine); - emit('$_sp$_sp'); declarations[i].visit(this); // Don't emit the last semicolon in compact mode. - if (prettyPrint || i < declarationsLength - 1) { - emit(';'); + if (_prettyPrint || i < declarationsLength - 1) { + _emitSemicolon(); } } - if (declarationsLength > 0) emit(_newLine); } @override @@ -333,11 +398,10 @@ class CssPrinter extends Visitor { var marginSymName = TokenKind.idToValue(TokenKind.MARGIN_DIRECTIVES, node.margin_sym); - emit('@$marginSymName$_sp{$_newLine'); - + emit('@$marginSymName$_sp'); + _emitLBrace(); visitDeclarationGroup(node); - - emit('}$_newLine'); + _emitRBrace(); } @override @@ -619,6 +683,7 @@ class CssPrinter extends Visitor { void visitExpressions(Expressions node) { var expressions = node.expressions; var expressionsLength = expressions.length; + for (var i = 0; i < expressionsLength; i++) { // Add space seperator between terms without an operator. // TODO(terry): Should have a BinaryExpression to solve this problem. diff --git a/lib/src/tree_printer.dart b/lib/src/tree_printer.dart index 0398226..4b6fbf8 100644 --- a/lib/src/tree_printer.dart +++ b/lib/src/tree_printer.dart @@ -17,6 +17,7 @@ String treeToDebugString(StyleSheet styleSheet, [bool useSpan = false]) { class _TreePrinter extends Visitor { final TreeOutput output; final bool useSpan; + _TreePrinter(this.output, this.useSpan) { output.printer = this; } diff --git a/test/compiler_test.dart b/test/compiler_test.dart index ad0bfd3..2879040 100644 --- a/test/compiler_test.dart +++ b/test/compiler_test.dart @@ -653,20 +653,20 @@ void testHost() { expect(errors.isEmpty, true, reason: errors.toString()); expect(prettyPrint(stylesheet), r''' @host { -:scope { - white-space: nowrap; - overflow-style: marquee-line; - overflow-x: marquee; -} -* { - color: #f00; -} -*:hover { - font-weight: bold; -} -:nth-child(odd) { - color: #00f; -} + :scope { + white-space: nowrap; + overflow-style: marquee-line; + overflow-x: marquee; + } + * { + color: #f00; + } + *:hover { + font-weight: bold; + } + :nth-child(odd) { + color: #00f; + } }'''); } diff --git a/test/declaration_test.dart b/test/declaration_test.dart index ba94c73..0a1b91c 100644 --- a/test/declaration_test.dart +++ b/test/declaration_test.dart @@ -166,7 +166,7 @@ void testComposites() { } @-webkit-keyframes pulsate { 0% { - -webkit-transform: translate3d(0, 0, 0) scale(1.0); + -webkit-transform: translate3d(0, 0, 0) scale(1.0); } }'''; @@ -311,9 +311,9 @@ void testNewerCss() { final generated = r''' @media screen, print { -.foobar_screen { - width: 10px; -} + .foobar_screen { + width: 10px; + } } @page { height: 22px; @@ -323,14 +323,14 @@ void testNewerCss() { width: 10px; } @page bar:left { -@top-left { - margin: 8px; -} + @top-left { + margin: 8px; + } } @page { -@top-left { - margin: 8px; -} + @top-left { + margin: 8px; + } width: 10px; } @charset "ISO-8859-1"; @@ -355,12 +355,12 @@ void testMediaQueries() { }'''; var generated = ''' @media screen AND (-webkit-min-device-pixel-ratio:0) { -.todo-item .toggle { - background: none; -} -#todo-item .toggle { - height: 40px; -} + .todo-item .toggle { + background: none; + } + #todo-item .toggle { + height: 40px; + } }'''; var stylesheet = parseCss(input, errors: errors, opts: simpleOptions); @@ -386,27 +386,27 @@ void testMediaQueries() { border: 20px; } }'''; - generated = - '''@media handheld AND (min-width:20em), screen AND (min-width:20em) { -#id { - color: #f00; -} -.myclass { - height: 20px; -} + generated = ''' +@media handheld AND (min-width:20em), screen AND (min-width:20em) { + #id { + color: #f00; + } + .myclass { + height: 20px; + } } @media print AND (min-resolution:300dpi) { -#anotherId { - color: #fff; -} + #anotherId { + color: #fff; + } } @media print AND (min-resolution:280dpcm) { -#finalId { - color: #aaa; -} -.class2 { - border: 20px; -} + #finalId { + color: #aaa; + } + .class2 { + border: 20px; + } }'''; stylesheet = parseCss(input, errors: errors..clear(), opts: simpleOptions); @@ -421,9 +421,12 @@ void testMediaQueries() { font-size: 10em; } }'''; - generated = '@media ONLY screen AND (min-device-width:4000px) ' - 'AND (min-device-height:2000px), screen AND (another:100px) {\n' - 'html {\n font-size: 10em;\n}\n}'; + generated = ''' +@media ONLY screen AND (min-device-width:4000px) AND (min-device-height:2000px), screen AND (another:100px) { + html { + font-size: 10em; + } +}'''; stylesheet = parseCss(input, errors: errors..clear(), opts: simpleOptions); @@ -439,7 +442,7 @@ void testMediaQueries() { }'''; generated = '@media screen, print AND (min-device-width:4000px) AND ' '(min-device-height:2000px), screen AND (another:100px) {\n' - 'html {\n font-size: 10em;\n}\n}'; + ' html {\n font-size: 10em;\n }\n}'; stylesheet = parseCss(input, errors: errors..clear(), opts: simpleOptions); @@ -482,15 +485,16 @@ void testMediaQueries() { } } }'''; - generated = '''@media (min-width:840px) { -.cell { - width: calc(33% - 16px); -} -@supports (display: grid) { -.cell { - grid-column-end: span 4; -} -} + generated = ''' +@media (min-width:840px) { + .cell { + width: calc(33% - 16px); + } + @supports (display: grid) { + .cell { + grid-column-end: span 4; + } + } }'''; expectCss(input, generated); } @@ -504,10 +508,11 @@ void testMozDocument() { color: #000; } }'''; - var expected = '''@-moz-document url-prefix() { -div { - color: #000; -} + var expected = ''' +@-moz-document url-prefix() { + div { + color: #000; + } }'''; var styleSheet = parseCss(css, errors: errors); expect(styleSheet, isNotNull); @@ -521,10 +526,11 @@ div { color: #000; } }'''; - expected = '''@-moz-document url-prefix("http://www.w3.org/Style/") { -div { - color: #000; -} + expected = ''' +@-moz-document url-prefix("http://www.w3.org/Style/") { + div { + color: #000; + } }'''; styleSheet = parseCss(css, errors: errors); expect(styleSheet, isNotNull); @@ -538,10 +544,11 @@ div { color: #000; } }'''; - expected = '''@-moz-document domain("google.com") { -div { - color: #000; -} + expected = ''' +@-moz-document domain("google.com") { + div { + color: #000; + } }'''; styleSheet = parseCss(css, errors: errors); expect(styleSheet, isNotNull); @@ -558,7 +565,7 @@ div { 'url("http://www.w3.org/"), ' 'url-prefix("http://www.w3.org/Style/"), ' 'domain("google.com"), ' - 'regexp("https:.*") {\ndiv {\n color: #000;\n}\n}'; + 'regexp("https:.*") {\n div {\n color: #000;\n }\n}'; styleSheet = parseCss(css, errors: errors); expect(styleSheet, isNotNull); expect(errors, isEmpty); @@ -573,10 +580,11 @@ void testSupports() { -webkit-appearance: none; } }'''; - var expected = '''@supports (-webkit-appearance: none) { -div { - -webkit-appearance: none; -} + var expected = ''' +@supports (-webkit-appearance: none) { + div { + -webkit-appearance: none; + } }'''; expectCss(css, expected); @@ -585,10 +593,11 @@ div { @supports not ( display: flex ) { body { width: 100%; } }'''; - expected = '''@supports not (display: flex) { -body { - width: 100%; -} + expected = ''' +@supports not (display: flex) { + body { + width: 100%; + } }'''; expectCss(css, expected); @@ -606,9 +615,9 @@ body { '(-moz-box-shadow: 0 0 2px #000 inset) or ' '(-webkit-box-shadow: 0 0 2px #000 inset) or ' '(-o-box-shadow: 0 0 2px #000 inset) {\n' - '.box {\n' - ' box-shadow: 0 0 2px #000 inset;\n' - '}\n' + ' .box {\n' + ' box-shadow: 0 0 2px #000 inset;\n' + ' }\n' '}'; expectCss(css, expected); @@ -625,10 +634,10 @@ body { expected = '@supports ' '((transition-property: color) or (animation-name: foo)) and ' '(transform: rotate(10deg)) {\n' - 'div {\n' - ' transition-property: color;\n' - ' transform: rotate(10deg);\n' - '}\n' + ' div {\n' + ' transition-property: color;\n' + ' transform: rotate(10deg);\n' + ' }\n' '}'; expectCss(css, expected); @@ -682,7 +691,7 @@ void testFontFace() { src: url(fonts/BBCBengali.ttf) format("opentype"); unicode-range: U+0A-FF, U+980-9FF, U+????, U+3???; }'''; - final generated = '''@font-face { + final generated = '''@font-face { font-family: BBCBengali; src: url("fonts/BBCBengali.ttf") format("opentype"); unicode-range: U+0A-FF, U+980-9FF, U+????, U+3???; @@ -698,7 +707,7 @@ void testFontFace() { src: url(http://example.com/fonts/Gentium.ttf); src: url(http://example.com/fonts/Gentium.ttf); }'''; - final generated1 = '''@font-face { + final generated1 = '''@font-face { font-family: Gentium; src: url("http://example.com/fonts/Gentium.ttf"); src: url("http://example.com/fonts/Gentium.ttf"); @@ -715,7 +724,7 @@ src: url(ideal-sans-serif.woff) format("woff"), url(basic-sans-serif.ttf) format("opentype"), local(Gentium Bold); }'''; - final generated2 = '@font-face {\n' + final generated2 = '@font-face {\n' ' src: url("ideal-sans-serif.woff") ' 'format("woff"), url("basic-sans-serif.ttf") ' 'format("opentype"), local(Gentium Bold);\n}'; @@ -734,7 +743,7 @@ src: url(ideal-sans-serif.woff) format("woff"), font-weight: bold; }'''; final generated3 = ''' -@font-face { +@font-face { font-family: MyGentium Text Ornaments; src: local(Gentium Bold), local(Gentium-Bold), url("GentiumBold.ttf"); font-weight: bold; @@ -751,7 +760,7 @@ src: url(ideal-sans-serif.woff) format("woff"), src: local(STIXGeneral), url(/stixfonts/STIXGeneral.otf); unicode-range: U+000-49F, U+2000-27FF, U+2900-2BFF, U+1D400-1D7FF; }'''; - final generated4 = '''@font-face { + final generated4 = '''@font-face { font-family: STIXGeneral; src: local(STIXGeneral), url("/stixfonts/STIXGeneral.otf"); unicode-range: U+000-49F, U+2000-27FF, U+2900-2BFF, U+1D400-1D7FF; @@ -799,33 +808,34 @@ div[href^='test'] { } '''; - final generated = '@import "simple.css"; ' - '@import "test.css" print; ' - '@import "test.css" screen, print; ' - '@import "http://google.com/maps/maps.css";\n' - 'div[href^="test"] {\n' - ' height: 10px;\n' - '}\n' - '@-webkit-keyframes pulsate {\n' - ' from {\n' - ' -webkit-transform: translate3d(0, 0, 0) scale(1.0);\n' - ' }\n' - ' 10% {\n' - ' -webkit-transform: translate3d(0, 0, 0) scale(1.0);\n' - ' }\n' - ' 30% {\n' - ' -webkit-transform: translate3d(0, 2, 0) scale(1.0);\n' - ' }\n' - '}\n' - '.foobar {\n' - ' grid-columns: 10px ("content" 1fr 10px) [4];\n' - '}\n' - '.test-background {\n' - ' background: url("http://www.foo.com/bar.png");\n' - '}\n' - '.test-background-with-multiple-properties {\n' - ' background: #000 url("http://www.foo.com/bar.png");\n' - '}'; + final generated = ''' +@import "simple.css"; +@import "test.css" print; +@import "test.css" screen, print; +@import "http://google.com/maps/maps.css"; +div[href^="test"] { + height: 10px; +} +@-webkit-keyframes pulsate { + from { + -webkit-transform: translate3d(0, 0, 0) scale(1.0); + } + 10% { + -webkit-transform: translate3d(0, 0, 0) scale(1.0); + } + 30% { + -webkit-transform: translate3d(0, 2, 0) scale(1.0); + } +} +.foobar { + grid-columns: 10px ("content" 1fr 10px) [4]; +} +.test-background { + background: url("http://www.foo.com/bar.png"); +} +.test-background-with-multiple-properties { + background: #000 url("http://www.foo.com/bar.png"); +}'''; var stylesheet = parseCss(input, errors: errors); expect(errors.isEmpty, true, reason: errors.toString()); @@ -865,14 +875,15 @@ div { color: rgba(0, 0, 0, 0.2); } '''; - final generated = 'div{color:green!important;background:red blue green}' - '.foo p[bar]{color:blue}' - '@page{@top-left{color:red}}' - '@page:first{}' - '@page foo:first{}' - '@media screen AND (max-width:800px){div{font-size:24px}}' - '@keyframes foo{0%{transform:scaleX(0)}}' - 'div{color:rgba(0,0,0,0.2)}'; + final generated = ''' +div{color:green!important;background:red blue green} +.foo p[bar]{color:blue} +@page{@top-left{color:red}} +@page:first{} +@page foo:first{} +@media screen AND (max-width:800px){div{font-size:24px}} +@keyframes foo{0%{transform:scaleX(0)}} +div{color:rgba(0,0,0,0.2)}'''; var stylesheet = parseCss(input, errors: errors); @@ -1145,7 +1156,8 @@ background-position: 0 0; } }'''; - final generated = '''.testIE-6 { + final generated = ''' +.testIE-6 { _zoom: 5; } .clearfix { @@ -1180,42 +1192,42 @@ input.search-query { } @-webkit-keyframes progress-bar-stripes { from { - background-position: 40px 0; + background-position: 40px 0; } to { - background-position: 0 0; + background-position: 0 0; } } @-moz-keyframes progress-bar-stripes { from { - background-position: 40px 0; + background-position: 40px 0; } to { - background-position: 0 0; + background-position: 0 0; } } @keyframes progress-bar-stripes { from { - background-position: 40px 0; + background-position: 40px 0; } to { - background-position: 0 0; + background-position: 0 0; } } @-o-keyframes progress-bar-stripes { from { - background-position: 40px 0; + background-position: 40px 0; } to { - background-position: 0 0; + background-position: 0 0; } } @keyframes progress-bar-stripes { from { - background-position: 40px 0; + background-position: 40px 0; } to { - background-position: 0 0; + background-position: 0 0; } }'''; diff --git a/test/keyframes_test.dart b/test/keyframes_test.dart index 0c9456f..3560c0d 100644 --- a/test/keyframes_test.dart +++ b/test/keyframes_test.dart @@ -17,8 +17,8 @@ void main() { final expected = r''' @keyframes ping { 75%, 100% { - transform: scale(2); - opacity: 0; + transform: scale(2); + opacity: 0; } }'''; expect(prettyPrint(stylesheet), expected); diff --git a/test/mixin_test.dart b/test/mixin_test.dart index 0432b1c..a60674a 100644 --- a/test/mixin_test.dart +++ b/test/mixin_test.dart @@ -397,7 +397,6 @@ void mixinManyArgs() { } ''', r''' var-values: #f00, #0f0, #00f; - .primary { color: #f00; background-color: #0f0; diff --git a/test/nested_test.dart b/test/nested_test.dart index a594969..a579868 100644 --- a/test/nested_test.dart +++ b/test/nested_test.dart @@ -238,7 +238,7 @@ div > span[attr="foo"] { void complexNest() { final input = ''' -@font-face { font-family: arial; } +@font-face { font-family: arial; } div { color: #f0f0f0; } #header + div { color: url(abc.png); @@ -276,7 +276,7 @@ div { color: #f0f0f0; } span { color: #1f1f2f; } '''; - final generated = r'''@font-face { + final generated = r'''@font-face { font-family: arial; } div { @@ -353,17 +353,18 @@ void mediaNesting() { } } '''; - final generated = r'''@media screen AND (-webkit-min-device-pixel-ratio:0) { -#toggle-all { - image: url("test.jpb"); - color: #f00; -} -#toggle-all div, #toggle-all table { - background: none; -} -#toggle-all div a, #toggle-all table a { - width: 100px; -} + final generated = r''' +@media screen AND (-webkit-min-device-pixel-ratio:0) { + #toggle-all { + image: url("test.jpb"); + color: #f00; + } + #toggle-all div, #toggle-all table { + background: none; + } + #toggle-all div a, #toggle-all table a { + width: 100px; + } }'''; compileAndValidate(input, generated); diff --git a/test/testing.dart b/test/testing.dart index d93c4a3..00e6ce7 100644 --- a/test/testing.dart +++ b/test/testing.dart @@ -10,16 +10,18 @@ import 'package:csslib/visitor.dart'; export 'package:csslib/src/preprocessor_options.dart'; -const simpleOptionsWithCheckedAndWarningsAsErrors = PreprocessorOptions( - useColors: false, - checked: true, - warningsAsErrors: true, - inputFile: 'memory'); +const PreprocessorOptions simpleOptionsWithCheckedAndWarningsAsErrors = + PreprocessorOptions( + useColors: false, + checked: true, + warningsAsErrors: true, + inputFile: 'memory', +); -const simpleOptions = +const PreprocessorOptions simpleOptions = PreprocessorOptions(useColors: false, inputFile: 'memory'); -const options = PreprocessorOptions( +const PreprocessorOptions options = PreprocessorOptions( useColors: false, warningsAsErrors: true, inputFile: 'memory'); /// Spin-up CSS parser in checked mode to detect any problematic CSS. Normally, @@ -49,17 +51,11 @@ StyleSheet polyFillCompileCss(String input, {List? errors, PreprocessorOptions? opts}) => compileCss(input, errors: errors, polyfill: true, opts: opts); -/// CSS emitter walks the style sheet tree and emits readable CSS. -final _emitCss = CssPrinter(); - -/// Simple Visitor does nothing but walk tree. -final _cssVisitor = Visitor(); - /// Pretty printer for CSS. String prettyPrint(StyleSheet ss) { // Walk the tree testing basic Visitor class. walkTree(ss); - return (_emitCss..visitTree(ss, pretty: true)).toString(); + return (CssPrinter()..visitTree(ss, pretty: true)).toString(); } /// Helper function to emit compact (non-pretty printed) CSS for suite test @@ -67,12 +63,12 @@ String prettyPrint(StyleSheet ss) { /// expected suite test results. String compactOutput(StyleSheet ss) { walkTree(ss); - return (_emitCss..visitTree(ss, pretty: false)).toString(); + return (CssPrinter()..visitTree(ss, pretty: false)).toString(); } /// Walks the style sheet tree does nothing; insures the basic walker works. void walkTree(StyleSheet ss) { - _cssVisitor.visitTree(ss); + Visitor().visitTree(ss); } String dumpTree(StyleSheet ss) => treeToDebugString(ss); diff --git a/test/var_test.dart b/test/var_test.dart index 079955f..482fda9 100644 --- a/test/var_test.dart +++ b/test/var_test.dart @@ -179,12 +179,12 @@ void expressionsVar() { content: var(content); text-shadow: var(text-shadow); } -@font-face { +@font-face { font-family: var(font-family); src: var(src); unicode-range: var(unicode-range); } -@font-face { +@font-face { font-family: var(font-family); src: var(src-1); unicode-range: var(unicode-range-1); @@ -214,12 +214,12 @@ void expressionsVar() { content: "✔"; text-shadow: 0 -1px 0 #bfbfbf; } -@font-face { +@font-face { font-family: Gentium; src: url("http://example.com/fonts/Gentium.ttf"); unicode-range: U+000-49F, U+2000-27FF, U+2900-2BFF, U+1D400-1D7FF; } -@font-face { +@font-face { font-family: Gentium; src: local(Gentium Bold), local(Gentium-Bold), url("GentiumBold.ttf"); unicode-range: U+0A-FF, U+980-9FF, U+????, U+3???; @@ -602,12 +602,12 @@ void parserVar() { content: var(content); text-shadow: var(text-shadow); } -@font-face { +@font-face { font-family: var(font-family); src: var(src); unicode-range: var(unicode-range); } -@font-face { +@font-face { font-family: var(font-family); src: var(src-1); unicode-range: var(unicode-range-1); @@ -637,12 +637,12 @@ void parserVar() { content: "✔"; text-shadow: 0 -1px 0 #bfbfbf; } -@font-face { +@font-face { font-family: Gentium; src: url("http://example.com/fonts/Gentium.ttf"); unicode-range: U+000-49F, U+2000-27FF, U+2900-2BFF, U+1D400-1D7FF; } -@font-face { +@font-face { font-family: Gentium; src: local(Gentium Bold), local(Gentium-Bold), url("GentiumBold.ttf"); unicode-range: U+0A-FF, U+980-9FF, U+????, U+3???; @@ -667,7 +667,6 @@ void testVar() { final generated = ''' var-color-background: #f00; var-color-foreground: #00f; - .test { background-color: var(color-background); color: var(color-foreground); @@ -692,7 +691,6 @@ var-color-foreground: #00f; final generated2 = ''' var-color-background: #f00; var-color-foreground: #00f; - .test { background-color: var(color-background); color: var(color-foreground); @@ -720,7 +718,6 @@ void testLess() { final generated = ''' var-color-background: #f00; var-color-foreground: #00f; - .test { background-color: var(color-background); color: var(color-foreground); @@ -745,7 +742,6 @@ var-color-foreground: #00f; final generated2 = ''' var-color-background: #f00; var-color-foreground: #00f; - .test { background-color: var(color-background); color: var(color-foreground); diff --git a/test/visitor_test.dart b/test/visitor_test.dart index f845993..a70f91f 100644 --- a/test/visitor_test.dart +++ b/test/visitor_test.dart @@ -109,4 +109,34 @@ div.myComponent_xyzzy { void main() { test('Class Visitors', testClassVisitors); test('Polyfill', testPolyFill); + test('pretty-print', testPrettyPrint); +} + +void testPrettyPrint() { + final input = ''' +.good { color: red; } +@media screen { .better { color: blue; } } +.best { color: green }'''; + + var styleSheet = parseCss(input); + + // pretty print + expect(prettyPrint(styleSheet), ''' +.good { + color: #f00; +} +@media screen { + .better { + color: #00f; + } +} +.best { + color: #008000; +}'''); + + // compact output + expect(compactOutput(styleSheet), ''' +.good{color:red} +@media screen{.better{color:blue}} +.best{color:green}'''); } From 3976e6fed0160952a112cc3595aa089e6fc5299e Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Wed, 10 May 2023 09:38:21 -0700 Subject: [PATCH 03/19] address an issue parsing font names (#168) * address an issue parsing font names * update comment * update changelog * Apply suggestions from code review Co-authored-by: Leon Senft * review feedback * dart format --------- Co-authored-by: Leon Senft --- .gitignore | 1 + CHANGELOG.md | 1 + lib/parser.dart | 126 +++++++++++++++++++------------------ lib/src/messages.dart | 10 +++ lib/src/token.dart | 2 +- lib/src/token_kind.dart | 1 + lib/src/tokenizer.dart | 3 + test/declaration_test.dart | 60 ++++++++++++++++++ test/mixin_test.dart | 31 ++------- test/testing.dart | 7 +++ 10 files changed, 155 insertions(+), 87 deletions(-) diff --git a/.gitignore b/.gitignore index 79f51c3..c107fc6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .dart_tool .packages pubspec.lock +doc/api/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 75c5158..0144382 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - Add markdown badges to the readme. - Adopted `package:dart_flutter_team_lints` linting rules. +- Addressed an issue parsing font names not surrounded by quotes. - Fixed the reported span for `Expression` nodes. - Fixed a regression parsing declaration values containing spaces. - Add support for `lh` and `rlh` units. diff --git a/lib/parser.dart b/lib/parser.dart index f190a07..15dd764 100644 --- a/lib/parser.dart +++ b/lib/parser.dart @@ -2228,10 +2228,54 @@ class _Parser { dynamic /* Expression | List | ... */ processTerm( [bool ieFilter = false]) { var start = _peekToken.span; - Token? t; // token for term's value - dynamic value; // value of term (numeric values) - var unary = ''; + + dynamic processIdentifier() { + var nameValue = identifier(); // Snarf up the ident we'll remap, maybe. + + if (!ieFilter && _maybeEat(TokenKind.LPAREN)) { + var calc = processCalc(nameValue); + if (calc != null) return calc; + // FUNCTION + return processFunction(nameValue); + } + if (ieFilter) { + if (_maybeEat(TokenKind.COLON) && + nameValue.name.toLowerCase() == 'progid') { + // IE filter:progid: + return processIEFilter(start); + } else { + // Handle filter: where name is any filter e.g., alpha, + // chroma, Wave, blur, etc. + return processIEFilter(start); + } + } + + // TODO(terry): Need to have a list of known identifiers today only + // 'from' is special. + if (nameValue.name == 'from') { + return LiteralTerm(nameValue, nameValue.name, _makeSpan(start)); + } + + // What kind of identifier is it, named color? + var colorEntry = TokenKind.matchColorName(nameValue.name); + if (colorEntry == null) { + if (isChecked) { + var propName = nameValue.name; + var errMsg = TokenKind.isPredefinedName(propName) + ? 'Improper use of property value $propName' + : 'Unknown property value $propName'; + _warning(errMsg, _makeSpan(start)); + } + return LiteralTerm(nameValue, nameValue.name, _makeSpan(start)); + } + + // Yes, process the color as an RGB value. + var rgbColor = + TokenKind.decimalToHex(TokenKind.colorValue(colorEntry), 6); + return _parseHex(rgbColor, _makeSpan(start)); + } + switch (_peek()) { case TokenKind.HASH: _eat(TokenKind.HASH); @@ -2261,20 +2305,20 @@ class _Parser { return _parseHex( ' ${(processTerm() as LiteralTerm).text}', _makeSpan(start)); case TokenKind.INTEGER: - t = _next(); - value = int.parse('$unary${t.text}'); - break; + var t = _next(); + var value = int.parse('$unary${t.text}'); + return processDimension(t, value, _makeSpan(start)); case TokenKind.DOUBLE: - t = _next(); - value = double.parse('$unary${t.text}'); - break; + var t = _next(); + var value = double.parse('$unary${t.text}'); + return processDimension(t, value, _makeSpan(start)); case TokenKind.SINGLE_QUOTE: - value = processQuotedString(false); - value = "'${_escapeString(value as String, single: true)}'"; + var value = processQuotedString(false); + value = "'${_escapeString(value, single: true)}'"; return LiteralTerm(value, value, _makeSpan(start)); case TokenKind.DOUBLE_QUOTE: - value = processQuotedString(false); - value = '"${_escapeString(value as String)}"'; + var value = processQuotedString(false); + value = '"${_escapeString(value)}"'; return LiteralTerm(value, value, _makeSpan(start)); case TokenKind.LPAREN: _next(); @@ -2304,49 +2348,7 @@ class _Parser { return ItemTerm(term.value, term.text, _makeSpan(start)); case TokenKind.IDENTIFIER: - var nameValue = identifier(); // Snarf up the ident we'll remap, maybe. - - if (!ieFilter && _maybeEat(TokenKind.LPAREN)) { - var calc = processCalc(nameValue); - if (calc != null) return calc; - // FUNCTION - return processFunction(nameValue); - } - if (ieFilter) { - if (_maybeEat(TokenKind.COLON) && - nameValue.name.toLowerCase() == 'progid') { - // IE filter:progid: - return processIEFilter(start); - } else { - // Handle filter: where name is any filter e.g., alpha, - // chroma, Wave, blur, etc. - return processIEFilter(start); - } - } - - // TODO(terry): Need to have a list of known identifiers today only - // 'from' is special. - if (nameValue.name == 'from') { - return LiteralTerm(nameValue, nameValue.name, _makeSpan(start)); - } - - // What kind of identifier is it, named color? - var colorEntry = TokenKind.matchColorName(nameValue.name); - if (colorEntry == null) { - if (isChecked) { - var propName = nameValue.name; - var errMsg = TokenKind.isPredefinedName(propName) - ? 'Improper use of property value $propName' - : 'Unknown property value $propName'; - _warning(errMsg, _makeSpan(start)); - } - return LiteralTerm(nameValue, nameValue.name, _makeSpan(start)); - } - - // Yes, process the color as an RGB value. - var rgbColor = - TokenKind.decimalToHex(TokenKind.colorValue(colorEntry), 6); - return _parseHex(rgbColor, _makeSpan(start)); + return processIdentifier(); case TokenKind.UNICODE_RANGE: String? first; String? second; @@ -2394,11 +2396,15 @@ class _Parser { return expr.expressions; } break; + default: + // For tokens that we don't match above, but that are identifier like + // ('PT', 'PX', ...) handle them like identifiers. + if (TokenKind.isKindIdentifier(_peek())) { + return processIdentifier(); + } else { + return null; + } } - - return t != null - ? processDimension(t, value as Object, _makeSpan(start)) - : null; } /// Process all dimension units. diff --git a/lib/src/messages.dart b/lib/src/messages.dart index 4aa4b90..cf97c22 100644 --- a/lib/src/messages.dart +++ b/lib/src/messages.dart @@ -43,6 +43,16 @@ class Message { Message(this.level, this.message, {this.span, this.useColors = false}); + String get describe { + var span = this.span; + if (span == null) { + return message; + } + + var start = span.start; + return '${start.line + 1}:${start.column + 1}:$message'; + } + @override String toString() { var output = StringBuffer(); diff --git a/lib/src/token.dart b/lib/src/token.dart index 8bd9ca1..5a07535 100644 --- a/lib/src/token.dart +++ b/lib/src/token.dart @@ -28,7 +28,7 @@ class Token { String toString() { var kindText = TokenKind.kindToString(kind); var actualText = text.trim(); - if (kindText != actualText) { + if (actualText.isNotEmpty && kindText != actualText) { if (actualText.length > 10) { actualText = '${actualText.substring(0, 8)}...'; } diff --git a/lib/src/token_kind.dart b/lib/src/token_kind.dart index c13198c..b654379 100644 --- a/lib/src/token_kind.dart +++ b/lib/src/token_kind.dart @@ -192,6 +192,7 @@ class TokenKind { static const int MARGIN_DIRECTIVE_RIGHTBOTTOM = 685; // Simple selector type. + // TODO: These are unused and should be removed in a future version. static const int CLASS_NAME = 700; // .class static const int ELEMENT_NAME = 701; // tagName static const int HASH_NAME = 702; // #elementId diff --git a/lib/src/tokenizer.dart b/lib/src/tokenizer.dart index 356963f..8c79b1b 100644 --- a/lib/src/tokenizer.dart +++ b/lib/src/tokenizer.dart @@ -4,6 +4,9 @@ part of '../parser.dart'; +// TODO: We should update the tokenization to follow what's described in the +// spec: https://www.w3.org/TR/css-syntax-3/#tokenization. + class Tokenizer extends TokenizerBase { /// U+ prefix for unicode characters. // ignore: non_constant_identifier_names diff --git a/test/declaration_test.dart b/test/declaration_test.dart index 0a1b91c..e9aaf99 100644 --- a/test/declaration_test.dart +++ b/test/declaration_test.dart @@ -771,6 +771,65 @@ src: url(ideal-sans-serif.woff) format("woff"), expect(prettyPrint(stylesheet), generated4); } +void testFontFamily() { + test('quoted', () { + var errors = []; + var stylesheet = parseCss(''' +body { + font-family: "Arial Narrow"; +}''', errors: errors..clear(), opts: simpleOptions); + expect(errors.isEmpty, true, reason: errors.toString()); + expect(prettyPrint(stylesheet), ''' +body { + font-family: "Arial Narrow"; +}'''); + var ruleSet = stylesheet.topLevels.first as RuleSet; + var declaration = + ruleSet.declarationGroup.declarations.first as Declaration; + var expressions = declaration.expression as Expressions; + expect(declaration.property, 'font-family'); + expect(printExpressions(expressions), '"Arial Narrow"'); + }); + + test('without quotes', () { + var errors = []; + var stylesheet = parseCss(''' +body { + font-family: Arial Narrow; +}''', errors: errors..clear(), opts: simpleOptions); + expect(errors.isEmpty, true, reason: errors.toString()); + expect(prettyPrint(stylesheet), ''' +body { + font-family: Arial Narrow; +}'''); + var ruleSet = stylesheet.topLevels.first as RuleSet; + var declaration = + ruleSet.declarationGroup.declarations.first as Declaration; + var expressions = declaration.expression as Expressions; + expect(declaration.property, 'font-family'); + expect(printExpressions(expressions), 'Arial Narrow'); + }); + + test('starts with identifier', () { + var errors = []; + var stylesheet = parseCss(''' +body { + font-family: PT Sans; +}''', errors: errors..clear(), opts: simpleOptions); + expect(errors.isEmpty, true, reason: errors.toString()); + expect(prettyPrint(stylesheet), ''' +body { + font-family: PT Sans; +}'''); + var ruleSet = stylesheet.topLevels.first as RuleSet; + var declaration = + ruleSet.declarationGroup.declarations.first as Declaration; + var expressions = declaration.expression as Expressions; + expect(declaration.property, 'font-family'); + expect(printExpressions(expressions), 'PT Sans'); + }); +} + void testCssFile() { var errors = []; final input = r''' @@ -1392,6 +1451,7 @@ void main() { test('Supports', testSupports); test('Viewport', testViewport); test('Font-Face', testFontFace); + group('font-family', testFontFamily); test('CSS file', testCssFile); test('Compact Emitter', testCompactEmitter); test('Selector Negation', testNotSelectors); diff --git a/test/mixin_test.dart b/test/mixin_test.dart index a60674a..205a697 100644 --- a/test/mixin_test.dart +++ b/test/mixin_test.dart @@ -603,32 +603,11 @@ foo { compileCss(input, errors: errors, opts: options); - expect(errors.isNotEmpty, true); - expect(errors.length, 6, reason: errors.toString()); - var error = errors[0]; - expect(error.message, 'parsing error expected ;'); - expect(error.span!.start.line, 6); - expect(error.span!.end.offset, 69); - error = errors[1]; - expect(error.message, 'expected :, but found }'); - expect(error.span!.start.line, 7); - expect(error.span!.end.offset, 73); - error = errors[2]; - expect(error.message, 'parsing error expected }'); - expect(error.span!.start.line, 9); - expect(error.span!.end.offset, 83); - error = errors[3]; - expect(error.message, 'expected {, but found end of file()'); - expect(error.span!.start.line, 9); - expect(error.span!.end.offset, 86); - error = errors[4]; - expect(error.message, 'expected }, but found end of file()'); - expect(error.span!.start.line, 10); - expect(error.span!.end.offset, 86); - error = errors[5]; - expect(error.message, 'Using top-level mixin a as a declaration'); - expect(error.span!.start.line, 5); - expect(error.span!.end.offset, 56); + expect(errors, hasLength(4)); + expect(errors[0].describe, '7:4:parsing error expected ;'); + expect(errors[1].describe, '8:1:expected :, but found }'); + expect(errors[2].describe, '10:11:expected }, but found end of file'); + expect(errors[3].describe, '6:4:Using top-level mixin a as a declaration'); } void main() { diff --git a/test/testing.dart b/test/testing.dart index 00e6ce7..15421bf 100644 --- a/test/testing.dart +++ b/test/testing.dart @@ -66,6 +66,13 @@ String compactOutput(StyleSheet ss) { return (CssPrinter()..visitTree(ss, pretty: false)).toString(); } +String printExpressions(Expressions node) { + var printer = CssPrinter(); + // TODO: It would be nice if TreeNode had an `accept` method. + printer.visitExpressions(node); + return printer.toString(); +} + /// Walks the style sheet tree does nothing; insures the basic walker works. void walkTree(StyleSheet ss) { Visitor().visitTree(ss); From c9e47d0af8cea9ef7d02e40a16bb0f2930a4e768 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 10 May 2023 09:51:22 -0700 Subject: [PATCH 04/19] Require Dart 2.19, latest lints, skin hanging test (#175) ...instead of ignoring it Also some tiny spelling fixes Co-authored-by: Devon Carew --- .github/workflows/test-package.yml | 2 +- CHANGELOG.md | 3 ++- lib/src/analyzer.dart | 4 ++-- lib/src/tokenizer.dart | 2 +- lib/src/tree_printer.dart | 2 +- pubspec.yaml | 4 ++-- test/big_1_test.dart | 2 -- test/compiler_test.dart | 2 -- test/debug_test.dart | 5 ++--- test/declaration_test.dart | 2 -- test/error_test.dart | 4 +--- test/extend_test.dart | 2 -- test/mixin_test.dart | 3 +-- test/nested_test.dart | 2 -- test/selector_test.dart | 2 -- test/var_test.dart | 2 -- test/visitor_test.dart | 2 -- 17 files changed, 13 insertions(+), 32 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 1570da2..0876c22 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.17.0, dev] + sdk: [2.19.0, dev] steps: - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f diff --git a/CHANGELOG.md b/CHANGELOG.md index 0144382..bcdd3d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Add support for `lh` and `rlh` units. - Refactor the package example. - Addressed an issue with the indent level of the `CssPrinter` output. +- Require Dart 2.19. ## 0.17.2 @@ -188,7 +189,7 @@ ## 0.12.0+1 -* Allow the lastest version of `logging` package. +* Allow the latest version of `logging` package. ## 0.12.0 diff --git a/lib/src/analyzer.dart b/lib/src/analyzer.dart index 2c4efa9..c839977 100644 --- a/lib/src/analyzer.dart +++ b/lib/src/analyzer.dart @@ -584,8 +584,8 @@ class CallMixin extends Visitor { } } - /// Given a mixin's defined arguments return a cloned mixin defintion that has - /// replaced all defined arguments with user's supplied VarUsages. + /// Given a mixin's defined arguments return a cloned mixin definition that + /// has replaced all defined arguments with user's supplied VarUsages. MixinDefinition transform(List> callArgs) { // TODO(terry): Handle default arguments and varArgs. // Transform mixin with callArgs. diff --git a/lib/src/tokenizer.dart b/lib/src/tokenizer.dart index 8c79b1b..15f5ad0 100644 --- a/lib/src/tokenizer.dart +++ b/lib/src/tokenizer.dart @@ -75,7 +75,7 @@ class Tokenizer extends TokenizerBase { // looks like a number dot followed by digit(s). var number = finishNumber(); if (number.kind == TokenKind.INTEGER) { - // It's a number but it's preceeded by a dot, so make it a double. + // It's a number but it's preceded by a dot, so make it a double. _startIndex = start; return _finishToken(TokenKind.DOUBLE); } else { diff --git a/lib/src/tree_printer.dart b/lib/src/tree_printer.dart index 4b6fbf8..2e11e9e 100644 --- a/lib/src/tree_printer.dart +++ b/lib/src/tree_printer.dart @@ -322,7 +322,7 @@ class _TreePrinter extends Visitor { void visitVarDefinition(VarDefinition node) { heading('Var', node); output.depth++; - output.write('defintion'); + output.write('definition'); super.visitVarDefinition(node); output.writeNode('expression', node.expression); output.depth--; diff --git a/pubspec.yaml b/pubspec.yaml index f0ef372..b3ab1f8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,13 +4,13 @@ description: A library for parsing and analyzing CSS (Cascading Style Sheets) repository: https://github.com/dart-lang/csslib environment: - sdk: '>=2.17.0 <3.0.0' + sdk: '>=2.19.0 <3.0.0' dependencies: source_span: ^1.8.0 dev_dependencies: - dart_flutter_team_lints: ^0.1.0 + dart_flutter_team_lints: ^1.0.0 path: ^1.8.0 term_glyph: ^1.2.0 test: ^1.16.0 diff --git a/test/big_1_test.dart b/test/big_1_test.dart index fdcc988..6db7980 100644 --- a/test/big_1_test.dart +++ b/test/big_1_test.dart @@ -2,8 +2,6 @@ // 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. -library big_1_test; - import 'package:csslib/src/messages.dart'; import 'package:test/test.dart'; diff --git a/test/compiler_test.dart b/test/compiler_test.dart index 2879040..f43c1ea 100644 --- a/test/compiler_test.dart +++ b/test/compiler_test.dart @@ -2,8 +2,6 @@ // 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. -library compiler_test; - import 'dart:convert'; import 'package:csslib/parser.dart'; diff --git a/test/debug_test.dart b/test/debug_test.dart index 05e9b00..878493b 100644 --- a/test/debug_test.dart +++ b/test/debug_test.dart @@ -2,13 +2,12 @@ // 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. -library debug; - import 'package:test/test.dart'; + import 'testing.dart'; void main() { - test('excercise debug', () { + test('exercise debug', () { var style = parseCss(_input); var debugValue = style.toDebugString(); diff --git a/test/declaration_test.dart b/test/declaration_test.dart index e9aaf99..499c8cd 100644 --- a/test/declaration_test.dart +++ b/test/declaration_test.dart @@ -4,8 +4,6 @@ // ignore_for_file: lines_longer_than_80_chars -library declaration_test; - import 'package:csslib/src/messages.dart'; import 'package:csslib/visitor.dart'; import 'package:test/test.dart'; diff --git a/test/error_test.dart b/test/error_test.dart index fb8ff57..030fc24 100644 --- a/test/error_test.dart +++ b/test/error_test.dart @@ -2,8 +2,6 @@ // 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. -library error_test; - import 'package:csslib/src/messages.dart'; import 'package:term_glyph/term_glyph.dart' as glyph; import 'package:test/test.dart'; @@ -72,7 +70,7 @@ error on line 1, column 24: Unknown property value inherit void testUnsupportedLineHeights() { var errors = []; - // line-height value in percentge unit. + // line-height value in percentage unit. var input = '.foobar { line-height: 120%; }'; var stylesheet = parseCss(input, errors: errors); diff --git a/test/extend_test.dart b/test/extend_test.dart index 37b433a..0990490 100644 --- a/test/extend_test.dart +++ b/test/extend_test.dart @@ -2,8 +2,6 @@ // 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. -library extend_test; - import 'package:csslib/src/messages.dart'; import 'package:test/test.dart'; diff --git a/test/mixin_test.dart b/test/mixin_test.dart index 205a697..684f914 100644 --- a/test/mixin_test.dart +++ b/test/mixin_test.dart @@ -2,8 +2,6 @@ // 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. -library mixin_test; - import 'package:csslib/src/messages.dart'; import 'package:test/test.dart'; @@ -633,6 +631,7 @@ void main() { group('Mixin arguments', () { test('simple arg', mixinArg); + test('many args', mixinArgs, skip: 'hangs at runtime'); test('multiple args and var decls as args', mixinManyArgs); }); diff --git a/test/nested_test.dart b/test/nested_test.dart index a579868..4ec72ea 100644 --- a/test/nested_test.dart +++ b/test/nested_test.dart @@ -2,8 +2,6 @@ // 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. -library nested_test; - import 'package:csslib/src/messages.dart'; import 'package:test/test.dart'; diff --git a/test/selector_test.dart b/test/selector_test.dart index ae4dbbd..6d63cf8 100644 --- a/test/selector_test.dart +++ b/test/selector_test.dart @@ -2,8 +2,6 @@ // 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. -library selector_test; - import 'package:csslib/parser.dart'; import 'package:term_glyph/term_glyph.dart' as glyph; import 'package:test/test.dart'; diff --git a/test/var_test.dart b/test/var_test.dart index 482fda9..b3b0933 100644 --- a/test/var_test.dart +++ b/test/var_test.dart @@ -2,8 +2,6 @@ // 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. -library var_test; - import 'package:csslib/src/messages.dart'; import 'package:term_glyph/term_glyph.dart' as glyph; import 'package:test/test.dart'; diff --git a/test/visitor_test.dart b/test/visitor_test.dart index a70f91f..851f407 100644 --- a/test/visitor_test.dart +++ b/test/visitor_test.dart @@ -2,8 +2,6 @@ // 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. -library visitor_test; - import 'package:csslib/src/messages.dart'; import 'package:csslib/visitor.dart'; import 'package:test/test.dart'; From c4e904c4249ca676b2e350f3ea5c046ec3f000ab Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Wed, 10 May 2023 09:59:38 -0700 Subject: [PATCH 05/19] rev for publishing (#179) --- CHANGELOG.md | 2 +- pubspec.yaml | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bcdd3d2..8e38f27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.17.3-dev +## 0.17.3 - Add markdown badges to the readme. - Adopted `package:dart_flutter_team_lints` linting rules. diff --git a/pubspec.yaml b/pubspec.yaml index b3ab1f8..8772246 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,10 +1,13 @@ name: csslib -version: 0.17.3-dev -description: A library for parsing and analyzing CSS (Cascading Style Sheets) +version: 0.17.3 +description: A library for parsing and analyzing CSS (Cascading Style Sheets). repository: https://github.com/dart-lang/csslib +topics: + - css + environment: - sdk: '>=2.19.0 <3.0.0' + sdk: '>=2.19.0 <4.0.0' dependencies: source_span: ^1.8.0 From 35bef7fe4dfc98b1fbc77a21b80df0765e6c8690 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Thu, 11 May 2023 12:47:38 -0700 Subject: [PATCH 06/19] Simplify TopLevelIncludes visitor (#180) This is a static method on a private class so there is no usage outside the library and it is safe to refactor. The returned `bool` was not read, and the `messages` argument was unused. Remove both to simplify `replace()` implementation. --- lib/src/analyzer.dart | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/src/analyzer.dart b/lib/src/analyzer.dart index c839977..9d6f4ff 100644 --- a/lib/src/analyzer.dart +++ b/lib/src/analyzer.dart @@ -456,8 +456,7 @@ class TopLevelIncludes extends Visitor { if (map.containsKey(node.name)) { var mixinDef = map[node.name]; if (mixinDef is MixinRulesetDirective) { - _TopLevelIncludeReplacer.replace( - _messages, _styleSheet!, node, mixinDef.rulesets); + _TopLevelIncludeReplacer.replace(_styleSheet!, node, mixinDef.rulesets); } else if (currDef is MixinRulesetDirective && _anyRulesets(currDef)) { final mixinRuleset = currDef; var index = mixinRuleset.rulesets.indexOf(node); @@ -508,16 +507,13 @@ class TopLevelIncludes extends Visitor { class _TopLevelIncludeReplacer extends Visitor { final IncludeDirective _include; final List _newRules; - bool _foundAndReplaced = false; /// Look for the [ruleSet] inside of an @media directive; if found then /// replace with the [newRules]. If [ruleSet] is found and replaced return /// true. - static bool replace(Messages messages, StyleSheet styleSheet, - IncludeDirective include, List newRules) { - var visitor = _TopLevelIncludeReplacer(include, newRules); - visitor.visitStyleSheet(styleSheet); - return visitor._foundAndReplaced; + static void replace(StyleSheet styleSheet, IncludeDirective include, + List newRules) { + _TopLevelIncludeReplacer(include, newRules).visitStyleSheet(styleSheet); } _TopLevelIncludeReplacer(this._include, this._newRules); @@ -528,7 +524,6 @@ class _TopLevelIncludeReplacer extends Visitor { if (index != -1) { node.topLevels.insertAll(index + 1, _newRules); node.topLevels.replaceRange(index, index + 1, [NoOp()]); - _foundAndReplaced = true; } super.visitStyleSheet(node); } @@ -540,7 +535,6 @@ class _TopLevelIncludeReplacer extends Visitor { node.rulesets.insertAll(index + 1, _newRules); // Only the resolve the @include once. node.rulesets.replaceRange(index, index + 1, [NoOp()]); - _foundAndReplaced = true; } super.visitMixinRulesetDirective(node); } From 1ff82fd12e849b63fc2a3fd51152c15efd13ec7a Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Mon, 15 May 2023 14:34:12 -0700 Subject: [PATCH 07/19] blast_repo fixes (#181) dependabot --- .github/dependabot.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 1603cdd..725f03a 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -3,7 +3,9 @@ version: 2 updates: - - package-ecosystem: "github-actions" - directory: "/" + - package-ecosystem: github-actions + directory: / schedule: - interval: "monthly" + interval: monthly + labels: + - autosubmit From b2b9b55ada8ba0c6efb1eb9db0983ac4f6ab522d Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Thu, 18 May 2023 11:31:55 -0700 Subject: [PATCH 08/19] address a regression in the compact output format (#183) --- lib/src/css_printer.dart | 3 --- test/declaration_test.dart | 9 +-------- test/visitor_test.dart | 8 ++------ 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/lib/src/css_printer.dart b/lib/src/css_printer.dart index e0507d1..463c855 100644 --- a/lib/src/css_printer.dart +++ b/lib/src/css_printer.dart @@ -56,9 +56,6 @@ class CssPrinter extends Visitor { _startOfLine = true; } else { _buff.write('}'); - if (_indent == 0) { - _buff.writeln(); - } } } diff --git a/test/declaration_test.dart b/test/declaration_test.dart index 499c8cd..5dc24f6 100644 --- a/test/declaration_test.dart +++ b/test/declaration_test.dart @@ -933,14 +933,7 @@ div { } '''; final generated = ''' -div{color:green!important;background:red blue green} -.foo p[bar]{color:blue} -@page{@top-left{color:red}} -@page:first{} -@page foo:first{} -@media screen AND (max-width:800px){div{font-size:24px}} -@keyframes foo{0%{transform:scaleX(0)}} -div{color:rgba(0,0,0,0.2)}'''; +div{color:green!important;background:red blue green}.foo p[bar]{color:blue}@page{@top-left{color:red}}@page:first{}@page foo:first{}@media screen AND (max-width:800px){div{font-size:24px}}@keyframes foo{0%{transform:scaleX(0)}}div{color:rgba(0,0,0,0.2)}'''; var stylesheet = parseCss(input, errors: errors); diff --git a/test/visitor_test.dart b/test/visitor_test.dart index 851f407..5442903 100644 --- a/test/visitor_test.dart +++ b/test/visitor_test.dart @@ -112,9 +112,7 @@ void main() { void testPrettyPrint() { final input = ''' -.good { color: red; } -@media screen { .better { color: blue; } } -.best { color: green }'''; +.good { color: red; }@media screen { .better { color: blue; } }.best { color: green }'''; var styleSheet = parseCss(input); @@ -134,7 +132,5 @@ void testPrettyPrint() { // compact output expect(compactOutput(styleSheet), ''' -.good{color:red} -@media screen{.better{color:blue}} -.best{color:green}'''); +.good{color:red}@media screen{.better{color:blue}}.best{color:green}'''); } From be2e11eedd4b1f12a674fd9246b9f8dd2da9aa5d Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Tue, 6 Jun 2023 14:31:27 -0700 Subject: [PATCH 09/19] rev to 1.0.0 (#185) --- CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e38f27..70e7747 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.0 + +- Rev to `1.0.0` (note however that there are no API changes from `0.17.x`). + ## 0.17.3 - Add markdown badges to the readme. diff --git a/pubspec.yaml b/pubspec.yaml index 8772246..e0eab9a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: csslib -version: 0.17.3 +version: 1.0.0 description: A library for parsing and analyzing CSS (Cascading Style Sheets). repository: https://github.com/dart-lang/csslib From 7e91228c2c2428455e5bc63bbf89c7bf0f3401b0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 1 Jul 2023 04:16:12 +0000 Subject: [PATCH 10/19] Bump actions/checkout from 3.5.2 to 3.5.3 (#187) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.2 to 3.5.3.
Release notes

Sourced from actions/checkout's releases.

v3.5.3

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v3...v3.5.3

Changelog

Sourced from actions/checkout's changelog.

Changelog

v3.5.3

v3.5.2

v3.5.1

v3.5.0

v3.4.0

v3.3.0

v3.2.0

v3.1.0

v3.0.2

v3.0.1

v3.0.0

v2.3.1

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=3.5.2&new-version=3.5.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- .github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 0876c22..2234ba9 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest, windows-latest] sdk: [2.19.0, dev] steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} From bd30a1a773ec66d3e435dfc53fc140f1967716da Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Sep 2023 04:51:19 +0000 Subject: [PATCH 11/19] Bump actions/checkout from 3.5.3 to 3.6.0 (#188) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.3 to 3.6.0.
Release notes

Sourced from actions/checkout's releases.

v3.6.0

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v3.5.3...v3.6.0

Changelog

Sourced from actions/checkout's changelog.

Changelog

v3.6.0

v3.5.3

v3.5.2

v3.5.1

v3.5.0

v3.4.0

v3.3.0

v3.2.0

v3.1.0

v3.0.2

v3.0.1

v3.0.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=3.5.3&new-version=3.6.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- .github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 2234ba9..24f05df 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest, windows-latest] sdk: [2.19.0, dev] steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} From 4b1ee3ff05497a808872ffb02afe2ea6ff19a498 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Oct 2023 04:12:22 +0000 Subject: [PATCH 12/19] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#189) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.5.0 to 1.5.1.
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.
Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.

v1.4.0

  • Automatically create OIDC token for pub.dev.
  • Add a reusable workflow for publishing.

v1.3.0

  • The install location of the Dart SDK is now available in an environment variable, DART_HOME (#43).
  • Fixed an issue where cached downloads could lead to unzip issues on self-hosted runners (#35).

v1.2.0

  • Fixed a path issue impacting git dependencies on Windows.

v1.1.0

  • Added a flavor option setup.sh to allow downloading unpublished builds.

v1.0.0

  • Promoted to 1.0 stable.

v0.5

  • Fixed a Windows pub global activate path issue.

... (truncated)

Commits
  • 8a4b97e Support renaming the be channel to main. (#102)
  • 0970dcf Bump @​actions/http-client from 2.1.0 to 2.1.1 (#101)
  • e58aeb6 updates for the latest version of extension types (#100)
  • deafe40 Convert to extension types (#99)
  • cdb51ff Bump semver from 6.3.0 to 6.3.1 (#98)
  • e2fce12 update JS interop - remove JS typedef references (#97)
  • 42c988f set up a cron to build the action's javascript (#96)
  • 007c7cb blast_repo fixes (#92)
  • 08de7e0 Remove annotations no longer needed (#91)
  • bd8bef0 Bump dart-lang/setup-dart from 1.4.0 to 1.5.0 (#89)
  • Additional commits viewable in compare view

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dart-lang/setup-dart&package-manager=github_actions&previous-version=1.5.0&new-version=1.5.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- .github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 24f05df..97bb7f5 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: ${{ matrix.sdk }} - id: install @@ -50,7 +50,7 @@ jobs: sdk: [2.19.0, dev] steps: - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: ${{ matrix.sdk }} - id: install From f6b68dd9ed9da297f5df4cd31a39787bf35432b3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Oct 2023 04:16:21 +0000 Subject: [PATCH 13/19] Bump actions/checkout from 3.6.0 to 4.1.0 (#190) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 3.6.0 to 4.1.0.
Release notes

Sourced from actions/checkout's releases.

v4.1.0

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4.0.0...v4.1.0

v4.0.0

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v3...v4.0.0

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.1.0

v4.0.0

v3.6.0

v3.5.3

v3.5.2

v3.5.1

v3.5.0

v3.4.0

v3.3.0

v3.2.0

v3.1.0

v3.0.2

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=3.6.0&new-version=4.1.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- .github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 97bb7f5..146229b 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest, windows-latest] sdk: [2.19.0, dev] steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: ${{ matrix.sdk }} From 4bdc553c696e7b5b3493847292d08a5e62aae611 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 04:43:19 +0000 Subject: [PATCH 14/19] Bump actions/checkout from 4.1.0 to 4.1.1 (#192) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.0 to 4.1.1.
Release notes

Sourced from actions/checkout's releases.

v4.1.1

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4.1.0...v4.1.1

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.0&new-version=4.1.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- .github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 146229b..d8ece2a 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest, windows-latest] sdk: [2.19.0, dev] steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: ${{ matrix.sdk }} From 17346e528b19c09b2d20589e0ffa0f01a5ad54ad Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 15:51:39 +0000 Subject: [PATCH 15/19] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#191) Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.5.1 to 1.6.0.
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).
Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.

v1.4.0

  • Automatically create OIDC token for pub.dev.
  • Add a reusable workflow for publishing.

v1.3.0

  • The install location of the Dart SDK is now available in an environment variable, DART_HOME (#43).
  • Fixed an issue where cached downloads could lead to unzip issues on self-hosted runners (#35).

v1.2.0

  • Fixed a path issue impacting git dependencies on Windows.

v1.1.0

  • Added a flavor option setup.sh to allow downloading unpublished builds.

v1.0.0

  • Promoted to 1.0 stable.

v0.5

  • Fixed a Windows pub global activate path issue.

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dart-lang/setup-dart&package-manager=github_actions&previous-version=1.5.1&new-version=1.6.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- .github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index d8ece2a..2030e2e 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 + - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: ${{ matrix.sdk }} - id: install @@ -50,7 +50,7 @@ jobs: sdk: [2.19.0, dev] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 + - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: ${{ matrix.sdk }} - id: install From 1325d75bfff5047bfcaafceee7195bf154352aa1 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 18 Dec 2023 16:37:53 -0800 Subject: [PATCH 16/19] blast_repo fixes (#193) auto-publish, no-response --- .github/workflows/no-response.yml | 37 +++++++++++++++++++++++++++++++ .github/workflows/publish.yaml | 17 ++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 .github/workflows/no-response.yml create mode 100644 .github/workflows/publish.yaml diff --git a/.github/workflows/no-response.yml b/.github/workflows/no-response.yml new file mode 100644 index 0000000..8e5ed57 --- /dev/null +++ b/.github/workflows/no-response.yml @@ -0,0 +1,37 @@ +# A workflow to close issues where the author hasn't responded to a request for +# more information; see https://github.com/actions/stale. + +name: No Response + +# Run as a daily cron. +on: + schedule: + # Every day at 8am + - cron: '0 8 * * *' + +# All permissions not specified are set to 'none'. +permissions: + issues: write + pull-requests: write + +jobs: + no-response: + runs-on: ubuntu-latest + if: ${{ github.repository_owner == 'dart-lang' }} + steps: + - uses: actions/stale@1160a2240286f5da8ec72b1c0816ce2481aabf84 + with: + # Don't automatically mark inactive issues+PRs as stale. + days-before-stale: -1 + # Close needs-info issues and PRs after 14 days of inactivity. + days-before-close: 14 + stale-issue-label: "needs-info" + close-issue-message: > + Without additional information we're not able to resolve this issue. + Feel free to add more info or respond to any questions above and we + can reopen the case. Thanks for your contribution! + stale-pr-label: "needs-info" + close-pr-message: > + Without additional information we're not able to resolve this PR. + Feel free to add more info or respond to any questions above. + Thanks for your contribution! diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..1cb7e9c --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,17 @@ +# A CI configuration to auto-publish pub packages. + +name: Publish + +on: + pull_request: + branches: [ main ] + push: + tags: [ 'v[0-9]+.[0-9]+.[0-9]+' ] + +jobs: + publish: + if: ${{ github.repository_owner == 'dart-lang' }} + uses: dart-lang/ecosystem/.github/workflows/publish.yaml@main + permissions: + id-token: write # Required for authentication using OIDC + pull-requests: write # Required for writing the pull request note From 1ad2d1ec461fb1836180e917220a5a48fd641897 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jan 2024 04:17:04 +0000 Subject: [PATCH 17/19] Bump actions/stale from 8.0.0 to 9.0.0 (#195) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/stale](https://github.com/actions/stale) from 8.0.0 to 9.0.0.
Release notes

Sourced from actions/stale's releases.

v9.0.0

Breaking Changes

  1. Action is now stateful: If the action ends because of operations-per-run then the next run will start from the first unprocessed issue skipping the issues processed during the previous run(s). The state is reset when all the issues are processed. This should be considered for scheduling workflow runs.
  2. Version 9 of this action updated the runtime to Node.js 20. All scripts are now run with Node.js 20 instead of Node.js 16 and are affected by any breaking changes between Node.js 16 and 20.

What Else Changed

  1. Performance optimization that removes unnecessary API calls by @​dsame #1033 fixes #792
  2. Logs displaying current github API rate limit by @​dsame #1032 addresses #1029

For more information, please read the action documentation and its section about statefulness

New Contributors

Full Changelog: https://github.com/actions/stale/compare/v8...v9.0.0

Commits
  • 28ca103 Upgrade Node to v20 (#1110)
  • b69b346 build(deps-dev): bump @​types/node from 18.16.18 to 20.5.1 (#1079)
  • 88a6f4f build(deps-dev): bump typescript from 5.1.3 to 5.2.2 (#1083)
  • 796531a Merge pull request #1080 from akv-platform/fix-delete-cache
  • 8986f62 Don not try to delete cache if it does not exists
  • cab99b3 fix typo proceeded/processed
  • 184e7af Merge pull request #1064 from actions/dependabot/npm_and_yarn/typescript-esli...
  • 523885c chore: update eslint-plugin, parser and eslint-plugin-jest
  • 2487a1d build(deps-dev): bump @​typescript-eslint/eslint-plugin
  • 60c722e Merge pull request #1063 from actions/dependabot/npm_and_yarn/jest-29.6.2
  • Additional commits viewable in compare view

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/stale&package-manager=github_actions&previous-version=8.0.0&new-version=9.0.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- .github/workflows/no-response.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/no-response.yml b/.github/workflows/no-response.yml index 8e5ed57..ab1ac49 100644 --- a/.github/workflows/no-response.yml +++ b/.github/workflows/no-response.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest if: ${{ github.repository_owner == 'dart-lang' }} steps: - - uses: actions/stale@1160a2240286f5da8ec72b1c0816ce2481aabf84 + - uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e with: # Don't automatically mark inactive issues+PRs as stale. days-before-stale: -1 From ec86ee57c89f683352e66c55542bcc1daa425c13 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 9 Jan 2024 14:14:10 -0800 Subject: [PATCH 18/19] Require Dart 3.0, update and fix lints (#194) --- .github/workflows/test-package.yml | 2 +- CHANGELOG.md | 4 + analysis_options.yaml | 6 ++ example/main.dart | 5 +- lib/parser.dart | 78 +++++++--------- lib/src/messages.dart | 2 +- lib/src/property.dart | 42 ++++----- lib/src/token_kind.dart | 142 ++++++++++------------------- lib/src/tokenizer.dart | 77 +++++++--------- lib/src/tokenizer_base.dart | 10 +- lib/src/tree.dart | 135 ++++++++++----------------- lib/src/validate.dart | 3 +- pubspec.yaml | 6 +- 13 files changed, 202 insertions(+), 310 deletions(-) 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 From 62ae85e84590f61169fddbca650e91a57544834b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Feb 2024 04:24:01 +0000 Subject: [PATCH 19/19] Bump dart-lang/setup-dart from 1.6.0 to 1.6.2 (#196) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.6.0 to 1.6.2.
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.6.2

v1.6.1

  • Updated the google storage url for main channel releases.
Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.6.2

v1.6.1

  • Updated the google storage url for main channel releases.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.

v1.4.0

  • Automatically create OIDC token for pub.dev.
  • Add a reusable workflow for publishing.

v1.3.0

  • The install location of the Dart SDK is now available in an environment variable, DART_HOME (#43).
  • Fixed an issue where cached downloads could lead to unzip issues on self-hosted runners (#35).

v1.2.0

  • Fixed a path issue impacting git dependencies on Windows.

v1.1.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dart-lang/setup-dart&package-manager=github_actions&previous-version=1.6.0&new-version=1.6.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- .github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index cbb5213..6bfceb0 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d + - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: ${{ matrix.sdk }} - id: install @@ -50,7 +50,7 @@ jobs: sdk: [3.0, dev] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d + - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: ${{ matrix.sdk }} - id: install