Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Indented syntax improvements] Dart implementation #2467

Open
wants to merge 62 commits into
base: main
Choose a base branch
from

Conversation

jamesnw
Copy link
Contributor

@jamesnw jamesnw commented Dec 16, 2024

Blocked until proposal is accepted.

[skip sass-embedded]

Copy link
Contributor

@nex3 nex3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nex3 This is ready for review. Here are some questions I wanted to flag as you review. Thanks!

  1. allowNewlines is set to true in some cases, like in parser* functions or in scss.dart, where the value is non-impactful. Should this usage be differentiated somehow for clarity?

For classes where it's universally non-impactful, I'd define a local _whitespace() function that takes no arguments with a comment explaining that the value isn't relevant.

  1. There are some places, like in _atRootQuery, where allowNewlines is true because it is inside parentheses. I opted to not use the _inParentheses variable except for one place where the consumption did rely on it, in _supportsCondition. Would it be more idiomatic to use _inParentheses, even if the consumption is in the same function?

I think how it is now is better.

  1. In the + include syntax, I am not supporting whitespace after the + as it can be part of a selector. This differs from the = mixin syntax- should they be the same?

There's already an odd inconsistency here where whitespace is allowed after = but not after +, so I think it's fine to expand that to allowing newlines as well. It's possible that we should deprecate that, but it's not in-scope for this change.

  1. I added paren/bracket context to almostAnyValue, with the only change being that they must be matched. That means the error for a:has(d[)] will be changed from "Expected identifer" to "Expected ]". Since almostAnyValue is used for more than selectors, should I make this functionality opt-in, dependent on a parameter? Based on the places where this is used, I don't foresee issues with bracket matching, but want to verify.

It's fine to change this error. Arguably the bracket error is clearer anyway.

lib/src/parse/keyframe_selector.dart Outdated Show resolved Hide resolved
lib/src/parse/parser.dart Outdated Show resolved Hide resolved
lib/src/parse/parser.dart Outdated Show resolved Hide resolved
lib/src/parse/sass.dart Outdated Show resolved Hide resolved
lib/src/parse/sass.dart Outdated Show resolved Hide resolved
lib/src/parse/stylesheet.dart Outdated Show resolved Hide resolved
lib/src/parse/stylesheet.dart Outdated Show resolved Hide resolved
lib/src/parse/stylesheet.dart Outdated Show resolved Hide resolved
lib/src/parse/stylesheet.dart Outdated Show resolved Hide resolved
lib/src/parse/stylesheet.dart Outdated Show resolved Hide resolved
Copy link
Contributor Author

@jamesnw jamesnw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nex3 This is ready for another round of review, along with the spec draft 1.2. Thanks!

lib/src/parse/stylesheet.dart Outdated Show resolved Hide resolved
@@ -1064,7 +1074,7 @@ abstract class StylesheetParser extends Parser {
ImportRule _importRule(LineScannerState start) {
var imports = <Import>[];
do {
whitespace();
whitespace(allowNewlines: false);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain more what needs to be changed? As far as I can tell, allowNewlines is false throughout the import rule.

lib/src/parse/stylesheet.dart Outdated Show resolved Hide resolved
lib/src/parse/stylesheet.dart Outdated Show resolved Hide resolved
lib/src/parse/stylesheet.dart Outdated Show resolved Hide resolved
lib/src/parse/stylesheet.dart Outdated Show resolved Hide resolved
lib/src/parse/stylesheet.dart Outdated Show resolved Hide resolved
lib/src/parse/sass.dart Outdated Show resolved Hide resolved
lib/src/parse/parser.dart Outdated Show resolved Hide resolved
lib/src/parse/sass.dart Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
lib/src/parse/parser.dart Outdated Show resolved Hide resolved
lib/src/parse/sass.dart Outdated Show resolved Hide resolved
lib/src/parse/sass.dart Outdated Show resolved Hide resolved
lib/src/parse/sass.dart Outdated Show resolved Hide resolved
lib/src/parse/stylesheet.dart Outdated Show resolved Hide resolved
lib/src/parse/stylesheet.dart Outdated Show resolved Hide resolved
Copy link
Contributor Author

@jamesnw jamesnw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CHANGELOG.md Outdated Show resolved Hide resolved
lib/src/parse/sass.dart Outdated Show resolved Hide resolved
lib/src/parse/sass.dart Outdated Show resolved Hide resolved
lib/src/parse/stylesheet.dart Outdated Show resolved Hide resolved
lib/src/parse/stylesheet.dart Outdated Show resolved Hide resolved
lib/src/parse/sass.dart Outdated Show resolved Hide resolved
lib/src/parse/parser.dart Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants