feat(css/ast): Add value to the whitespace token (#2533)

This commit is contained in:
Alexander Akait 2021-10-28 17:48:31 +03:00 committed by GitHub
parent 69cfa98c50
commit 4f0473616d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
55 changed files with 668 additions and 125 deletions

14
Cargo.lock generated
View File

@ -2504,7 +2504,7 @@ dependencies = [
[[package]]
name = "swc_css"
version = "0.24.0"
version = "0.25.0"
dependencies = [
"swc_css_ast",
"swc_css_codegen",
@ -2515,7 +2515,7 @@ dependencies = [
[[package]]
name = "swc_css_ast"
version = "0.22.0"
version = "0.23.0"
dependencies = [
"is-macro",
"serde",
@ -2526,7 +2526,7 @@ dependencies = [
[[package]]
name = "swc_css_codegen"
version = "0.22.0"
version = "0.23.0"
dependencies = [
"auto_impl",
"bitflags",
@ -2552,7 +2552,7 @@ dependencies = [
[[package]]
name = "swc_css_parser"
version = "0.24.0"
version = "0.25.0"
dependencies = [
"bitflags",
"lexical",
@ -2568,7 +2568,7 @@ dependencies = [
[[package]]
name = "swc_css_utils"
version = "0.19.0"
version = "0.20.0"
dependencies = [
"swc_atoms 0.2.9",
"swc_common",
@ -2578,7 +2578,7 @@ dependencies = [
[[package]]
name = "swc_css_visit"
version = "0.21.0"
version = "0.22.0"
dependencies = [
"swc_atoms 0.2.9",
"swc_common",
@ -3154,7 +3154,7 @@ dependencies = [
[[package]]
name = "swc_stylis"
version = "0.21.0"
version = "0.22.0"
dependencies = [
"swc_atoms 0.2.9",
"swc_common",

View File

@ -6,11 +6,11 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_css"
repository = "https://github.com/swc-project/swc.git"
version = "0.24.0"
version = "0.25.0"
[dependencies]
swc_css_ast = {version = "0.22.0", path = "./ast"}
swc_css_codegen = {version = "0.22.0", path = "./codegen"}
swc_css_parser = {version = "0.24.0", path = "./parser"}
swc_css_utils = {version = "0.19.0", path = "./utils/"}
swc_css_visit = {version = "0.21.0", path = "./visit"}
swc_css_ast = {version = "0.23.0", path = "./ast"}
swc_css_codegen = {version = "0.23.0", path = "./codegen"}
swc_css_parser = {version = "0.25.0", path = "./parser"}
swc_css_utils = {version = "0.20.0", path = "./utils/"}
swc_css_visit = {version = "0.22.0", path = "./visit"}

View File

@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_css_ast"
repository = "https://github.com/swc-project/swc.git"
version = "0.22.0"
version = "0.23.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -83,7 +83,9 @@ pub enum Token {
},
/// One or more whitespace.
WhiteSpace,
WhiteSpace {
value: JsWord,
},
/// `<!--`
CDO,

View File

@ -6,17 +6,17 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_css_codegen"
repository = "https://github.com/swc-project/swc.git"
version = "0.22.0"
version = "0.23.0"
[dependencies]
auto_impl = "0.4.1"
bitflags = "1.3.2"
swc_atoms = {version = "0.2.7", path = "../../atoms"}
swc_common = {version = "0.14.0", path = "../../common"}
swc_css_ast = {version = "0.22.0", path = "../ast/"}
swc_css_ast = {version = "0.23.0", path = "../ast/"}
swc_css_codegen_macros = {version = "0.2.0", path = "macros/"}
[dev-dependencies]
swc_css_parser = {version = "0.24.0", path = "../parser"}
swc_css_visit = {version = "0.21.0", path = "../visit"}
swc_css_parser = {version = "0.25.0", path = "../parser"}
swc_css_visit = {version = "0.22.0", path = "../visit"}
testing = {version = "0.15.0", path = "../../testing"}

View File

@ -560,8 +560,8 @@ where
punct!(self, "#");
self.wr.write_raw(Some(span), &raw)?;
}
Token::WhiteSpace => {
space!(self);
Token::WhiteSpace { value, .. } => {
self.wr.write_raw(None, &value)?;
}
Token::CDC => {
punct!(self, span, "-->");

View File

@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_css_parser"
repository = "https://github.com/swc-project/swc.git"
version = "0.24.0"
version = "0.25.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
@ -17,11 +17,11 @@ bitflags = "1.2.1"
lexical = "5.2.2"
swc_atoms = {version = "0.2.7", path = "../../atoms"}
swc_common = {version = "0.14.0", path = "../../common"}
swc_css_ast = {version = "0.22.0", path = "../ast"}
swc_css_ast = {version = "0.23.0", path = "../ast"}
unicode-xid = "0.2.2"
[dev-dependencies]
serde = "1.0.127"
serde_json = "1.0.66"
swc_css_visit = {version = "0.21.0", path = "../visit"}
swc_css_visit = {version = "0.22.0", path = "../visit"}
testing = {version = "0.15.0", path = "../../testing"}

View File

@ -121,9 +121,11 @@ where
if let Some(c) = self.input.cur() {
if is_whitespace(c) {
self.skip_ws()?;
let value = self.read_ws()?;
return Ok(tok!(" "));
return Ok(Token::WhiteSpace {
value: value.into(),
});
}
}
@ -302,6 +304,34 @@ where
return Ok(Token::Delim { value: c });
}
fn read_ws(&mut self) -> LexResult<String> {
let mut value = String::new();
loop {
let c = self.input.cur();
match c {
Some(c) if is_whitespace(c) => {
self.input.bump();
value.push(c);
}
_ => {
break;
}
}
}
if self.config.allow_wrong_line_comments {
if self.input.is_byte(b'/') && self.input.peek() == Some('/') {
self.skip_line_comment()?;
self.start_pos = self.input.cur_pos();
}
}
Ok(value)
}
fn would_start_number(
&mut self,
maybe_first: Option<char>,
@ -877,16 +907,16 @@ where
fn skip_ws(&mut self) -> LexResult<()> {
loop {
if self.input.cur().is_none() {
break;
}
let c = self.input.cur();
if is_whitespace(self.input.cur().unwrap()) {
self.input.bump();
continue;
match c {
Some(c) if is_whitespace(c) => {
self.input.bump();
}
_ => {
break;
}
}
break;
}
if self.config.allow_wrong_line_comments {

View File

@ -89,7 +89,7 @@ macro_rules! tok {
};
(" ") => {
swc_css_ast::Token::WhiteSpace
swc_css_ast::Token::WhiteSpace { .. }
};
("<!--") => {

View File

@ -396,7 +396,11 @@
"end": 1265,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": "\n "
}
}
},
{
"span": {
@ -412,7 +416,11 @@
"end": 1269,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {
@ -436,7 +444,11 @@
"end": 1276,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": "\n "
}
}
},
{
"span": {
@ -452,7 +464,11 @@
"end": 1281,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {
@ -476,7 +492,11 @@
"end": 1284,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": "\n"
}
}
},
{
"span": {

View File

@ -341,7 +341,8 @@ error: LBrace
33 | @unknown {
| ^
error: WhiteSpace
error: WhiteSpace { value: Atom('
' type=inline) }
--> $DIR/tests/fixture/at-rule/unknown/input.css:33:11
|
33 | @unknown {
@ -355,7 +356,7 @@ error: CDC
34 | --> {}
| ^^^
error: WhiteSpace
error: WhiteSpace { value: Atom(' ' type=inline) }
--> $DIR/tests/fixture/at-rule/unknown/input.css:34:8
|
34 | --> {}
@ -373,7 +374,8 @@ error: RBrace
34 | --> {}
| ^
error: WhiteSpace
error: WhiteSpace { value: Atom('
' type=inline) }
--> $DIR/tests/fixture/at-rule/unknown/input.css:34:11
|
34 | --> {}
@ -387,7 +389,7 @@ error: CDO
35 | <!-- {}
| ^^^^
error: WhiteSpace
error: WhiteSpace { value: Atom(' ' type=inline) }
--> $DIR/tests/fixture/at-rule/unknown/input.css:35:9
|
35 | <!-- {}
@ -405,7 +407,8 @@ error: RBrace
35 | <!-- {}
| ^
error: WhiteSpace
error: WhiteSpace { value: Atom('
' type=inline) }
--> $DIR/tests/fixture/at-rule/unknown/input.css:35:12
|
35 | <!-- {}

View File

@ -45,7 +45,11 @@
"end": 10,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": "\n"
}
}
},
{
"span": {
@ -74,7 +78,11 @@
"end": 13,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {
@ -103,7 +111,11 @@
"end": 16,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": "\n"
}
}
},
{
"span": {
@ -132,7 +144,11 @@
"end": 19,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {
@ -161,7 +177,11 @@
"end": 22,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": "\n"
}
}
},
{
"span": {

View File

@ -56,7 +56,8 @@ error: LBrace
1 | @unknown{
| ^
error: WhiteSpace
error: WhiteSpace { value: Atom('
' type=inline) }
--> $DIR/tests/fixture/esbuild/misc/L0mEf41IMkWcP7NotllkAg/input.css:1:10
|
1 | @unknown{
@ -76,7 +77,7 @@ error: Colon
2 | a: b;
| ^
error: WhiteSpace
error: WhiteSpace { value: Atom(' ' type=inline) }
--> $DIR/tests/fixture/esbuild/misc/L0mEf41IMkWcP7NotllkAg/input.css:2:3
|
2 | a: b;
@ -94,7 +95,8 @@ error: Semi
2 | a: b;
| ^
error: WhiteSpace
error: WhiteSpace { value: Atom('
' type=inline) }
--> $DIR/tests/fixture/esbuild/misc/L0mEf41IMkWcP7NotllkAg/input.css:2:6
|
2 | a: b;
@ -114,7 +116,7 @@ error: Colon
3 | c: d;
| ^
error: WhiteSpace
error: WhiteSpace { value: Atom(' ' type=inline) }
--> $DIR/tests/fixture/esbuild/misc/L0mEf41IMkWcP7NotllkAg/input.css:3:3
|
3 | c: d;
@ -132,7 +134,8 @@ error: Semi
3 | c: d;
| ^
error: WhiteSpace
error: WhiteSpace { value: Atom('
' type=inline) }
--> $DIR/tests/fixture/esbuild/misc/L0mEf41IMkWcP7NotllkAg/input.css:3:6
|
3 | c: d;

View File

@ -523,7 +523,11 @@
"end": 233,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
}
]
}

View File

@ -437,7 +437,7 @@ error: Tokens
13 | --braces: { };
| ^
error: WhiteSpace
error: WhiteSpace { value: Atom(' ' type=inline) }
--> $DIR/tests/fixture/rome/custom-properties/input.css:13:13
|
13 | --braces: { };

View File

@ -1164,7 +1164,11 @@
"end": 298,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {
@ -1347,7 +1351,11 @@
"end": 345,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {

View File

@ -905,7 +905,7 @@ error: Comma
32 | :lang(en, ko) {
| ^
error: WhiteSpace
error: WhiteSpace { value: Atom(' ' type=inline) }
--> $DIR/tests/fixture/rome/selectors/input.css:32:10
|
32 | :lang(en, ko) {
@ -1045,7 +1045,7 @@ error: Comma
38 | ::pseudo-elem(a, b) {
| ^
error: WhiteSpace
error: WhiteSpace { value: Atom(' ' type=inline) }
--> $DIR/tests/fixture/rome/selectors/input.css:38:17
|
38 | ::pseudo-elem(a, b) {

View File

@ -90,7 +90,11 @@
"end": 13,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {
@ -110,7 +114,11 @@
"end": 15,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {

View File

@ -70,7 +70,7 @@ error: Ident { value: Atom('foo' type=inline), raw: Atom('foo' type=inline) }
1 | :global(.foo + a) {
| ^^^
error: WhiteSpace
error: WhiteSpace { value: Atom(' ' type=inline) }
--> $DIR/tests/fixture/styled-jsx/selector/1/input.css:1:13
|
1 | :global(.foo + a) {
@ -82,7 +82,7 @@ error: Delim { value: '+' }
1 | :global(.foo + a) {
| ^
error: WhiteSpace
error: WhiteSpace { value: Atom(' ' type=inline) }
--> $DIR/tests/fixture/styled-jsx/selector/1/input.css:1:15
|
1 | :global(.foo + a) {

View File

@ -567,7 +567,11 @@
"end": 287,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {
@ -596,7 +600,11 @@
"end": 290,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {
@ -713,7 +721,11 @@
"end": 325,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {
@ -864,7 +876,11 @@
"end": 376,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {
@ -939,7 +955,11 @@
"end": 394,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
}
]
}

View File

@ -499,7 +499,7 @@ error: Comma
15 | --bracket-block: {1, 2, 3};
| ^
error: WhiteSpace
error: WhiteSpace { value: Atom(' ' type=inline) }
--> $DIR/tests/fixture/value/custom-property/input.css:15:25
|
15 | --bracket-block: {1, 2, 3};
@ -517,7 +517,7 @@ error: Comma
15 | --bracket-block: {1, 2, 3};
| ^
error: WhiteSpace
error: WhiteSpace { value: Atom(' ' type=inline) }
--> $DIR/tests/fixture/value/custom-property/input.css:15:28
|
15 | --bracket-block: {1, 2, 3};
@ -619,7 +619,7 @@ error: Colon
16 | --JSON: [1, "2", {"three": {"a":1}}, [4]];
| ^
error: WhiteSpace
error: WhiteSpace { value: Atom(' ' type=inline) }
--> $DIR/tests/fixture/value/custom-property/input.css:16:31
|
16 | --JSON: [1, "2", {"three": {"a":1}}, [4]];
@ -745,7 +745,7 @@ error: Tokens
17 | --javascript: function(rule) { console.log(rule) };
| ^^^^^^^^^^^^^^^^^^^
error: WhiteSpace
error: WhiteSpace { value: Atom(' ' type=inline) }
--> $DIR/tests/fixture/value/custom-property/input.css:17:35
|
17 | --javascript: function(rule) { console.log(rule) };
@ -787,7 +787,7 @@ error: RParen
17 | --javascript: function(rule) { console.log(rule) };
| ^
error: WhiteSpace
error: WhiteSpace { value: Atom(' ' type=inline) }
--> $DIR/tests/fixture/value/custom-property/input.css:17:53
|
17 | --javascript: function(rule) { console.log(rule) };

View File

@ -98,7 +98,11 @@
"end": 22,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {

View File

@ -98,7 +98,11 @@
"end": 22,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {

View File

@ -98,7 +98,11 @@
"end": 22,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {

View File

@ -98,7 +98,11 @@
"end": 22,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {

View File

@ -98,7 +98,11 @@
"end": 14,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {

View File

@ -98,7 +98,11 @@
"end": 15,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {

View File

@ -98,7 +98,11 @@
"end": 15,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {
@ -118,7 +122,11 @@
"end": 17,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {

View File

@ -98,7 +98,11 @@
"end": 15,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {

View File

@ -98,7 +98,11 @@
"end": 14,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {

View File

@ -98,7 +98,11 @@
"end": 14,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {

View File

@ -98,7 +98,11 @@
"end": 14,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {

View File

@ -98,7 +98,11 @@
"end": 14,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {

View File

@ -98,7 +98,11 @@
"end": 14,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {

View File

@ -98,7 +98,11 @@
"end": 14,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {

View File

@ -98,7 +98,11 @@
"end": 15,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {

View File

@ -98,7 +98,11 @@
"end": 15,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {

View File

@ -98,7 +98,11 @@
"end": 14,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {

View File

@ -98,7 +98,11 @@
"end": 14,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {

View File

@ -98,7 +98,11 @@
"end": 14,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {

View File

@ -98,7 +98,11 @@
"end": 15,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {

View File

@ -98,7 +98,11 @@
"end": 15,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {

View File

@ -98,7 +98,11 @@
"end": 15,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {

View File

@ -98,7 +98,11 @@
"end": 14,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {
@ -140,7 +144,11 @@
"end": 26,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {
@ -156,7 +164,11 @@
"end": 28,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": "\n"
}
}
}
]
}

View File

@ -262,7 +262,11 @@
"end": 137,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {
@ -399,7 +403,11 @@
"end": 237,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {
@ -585,7 +593,11 @@
"end": 334,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {
@ -660,7 +672,11 @@
"end": 378,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {
@ -817,7 +833,11 @@
"end": 463,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {
@ -892,7 +912,11 @@
"end": 507,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {

View File

@ -108,7 +108,11 @@
"end": 13,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {
@ -183,7 +187,11 @@
"end": 35,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {

View File

@ -127,7 +127,11 @@
"end": 25,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {
@ -148,7 +152,11 @@
"end": 34,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {

View File

@ -714,7 +714,11 @@
"end": 304,
"ctxt": 0
},
"token": "WhiteSpace"
"token": {
"WhiteSpace": {
"value": "\n"
}
}
}
]
}

View File

@ -0,0 +1,10 @@
a {
prop: ;
prop: ;
prop:
;
prop:
;
}

View File

@ -0,0 +1,242 @@
{
"type": "Stylesheet",
"span": {
"start": 0,
"end": 67,
"ctxt": 0
},
"rules": [
{
"type": "StyleRule",
"span": {
"start": 0,
"end": 66,
"ctxt": 0
},
"selectors": [
{
"type": "ComplexSelector",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"selectors": [
{
"type": "CompoundSelector",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"hasNestPrefix": false,
"combinator": null,
"typeSelector": {
"type": "NamespacedName",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"prefix": null,
"name": {
"type": "Text",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"value": "a",
"raw": "a"
}
},
"subclassSelectors": []
}
]
}
],
"block": {
"type": "Block",
"span": {
"start": 2,
"end": 66,
"ctxt": 0
},
"items": [
{
"type": "Tokens",
"span": {
"start": 8,
"end": 14,
"ctxt": 0
},
"tokens": [
{
"span": {
"start": 8,
"end": 12,
"ctxt": 0
},
"token": {
"Ident": {
"value": "prop",
"raw": "prop"
}
}
},
{
"span": {
"start": 12,
"end": 13,
"ctxt": 0
},
"token": "Colon"
},
{
"span": {
"start": 13,
"end": 14,
"ctxt": 0
},
"token": {
"WhiteSpace": {
"value": " "
}
}
}
]
},
{
"type": "Tokens",
"span": {
"start": 20,
"end": 29,
"ctxt": 0
},
"tokens": [
{
"span": {
"start": 20,
"end": 24,
"ctxt": 0
},
"token": {
"Ident": {
"value": "prop",
"raw": "prop"
}
}
},
{
"span": {
"start": 24,
"end": 25,
"ctxt": 0
},
"token": "Colon"
},
{
"span": {
"start": 25,
"end": 29,
"ctxt": 0
},
"token": {
"WhiteSpace": {
"value": " "
}
}
}
]
},
{
"type": "Tokens",
"span": {
"start": 35,
"end": 42,
"ctxt": 0
},
"tokens": [
{
"span": {
"start": 35,
"end": 39,
"ctxt": 0
},
"token": {
"Ident": {
"value": "prop",
"raw": "prop"
}
}
},
{
"span": {
"start": 39,
"end": 40,
"ctxt": 0
},
"token": "Colon"
},
{
"span": {
"start": 40,
"end": 42,
"ctxt": 0
},
"token": {
"WhiteSpace": {
"value": "\n\n"
}
}
}
]
},
{
"type": "Tokens",
"span": {
"start": 48,
"end": 63,
"ctxt": 0
},
"tokens": [
{
"span": {
"start": 48,
"end": 52,
"ctxt": 0
},
"token": {
"Ident": {
"value": "prop",
"raw": "prop"
}
}
},
{
"span": {
"start": 52,
"end": 53,
"ctxt": 0
},
"token": "Colon"
},
{
"span": {
"start": 53,
"end": 63,
"ctxt": 0
},
"token": {
"WhiteSpace": {
"value": " \n\n "
}
}
}
]
}
]
}
}
]
}

View File

@ -0,0 +1,24 @@
error: Expected Declaration value
--> $DIR/tests/recovery/whitespaces/input.css:2:11
|
2 | prop: ;
| ^
error: Expected Declaration value
--> $DIR/tests/recovery/whitespaces/input.css:3:14
|
3 | prop: ;
| ^
error: Expected Declaration value
--> $DIR/tests/recovery/whitespaces/input.css:6:1
|
6 | ;
| ^
error: Expected Declaration value
--> $DIR/tests/recovery/whitespaces/input.css:9:5
|
9 | ;
| ^

View File

@ -6,18 +6,18 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_stylis"
repository = "https://github.com/swc-project/swc.git"
version = "0.21.0"
version = "0.22.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
swc_atoms = {version = "0.2.7", path = "../../atoms"}
swc_common = {version = "0.14.0", path = "../../common"}
swc_css_ast = {version = "0.22.0", path = "../ast"}
swc_css_utils = {version = "0.19.0", path = "../utils/"}
swc_css_visit = {version = "0.21.0", path = "../visit"}
swc_css_ast = {version = "0.23.0", path = "../ast"}
swc_css_utils = {version = "0.20.0", path = "../utils/"}
swc_css_visit = {version = "0.22.0", path = "../visit"}
[dev-dependencies]
swc_css_codegen = {version = "0.22.0", path = "../codegen"}
swc_css_parser = {version = "0.24.0", path = "../parser"}
swc_css_codegen = {version = "0.23.0", path = "../codegen"}
swc_css_parser = {version = "0.25.0", path = "../parser"}
testing = {version = "0.15.0", path = "../../testing"}

View File

@ -454,7 +454,8 @@ fn error_recovery_1() {
"__styled-jsx-placeholder__1
animation: slide 3s ease infinite;
",
"__styled-jsx-placeholder__1 animation: slide 3s ease infinite;",
"__styled-jsx-placeholder__1
animation: slide 3s ease infinite;",
);
t(
@ -462,7 +463,7 @@ fn error_recovery_1() {
__styled-jsx-placeholder__1
",
"-webkit-animation:slide 3s ease infinite;animation:slide 3s ease \
infinite;__styled-jsx-placeholder__1 ;",
infinite;__styled-jsx-placeholder__1\n ;",
);
}

View File

@ -6,11 +6,11 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_css_utils"
repository = "https://github.com/swc-project/swc.git"
version = "0.19.0"
version = "0.20.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
swc_atoms = {version = "0.2.7", path = "../../atoms"}
swc_common = {version = "0.14.0", path = "../../common"}
swc_css_ast = {version = "0.22.0", path = "../ast"}
swc_css_visit = {version = "0.21.0", path = "../visit"}
swc_css_ast = {version = "0.23.0", path = "../ast"}
swc_css_visit = {version = "0.22.0", path = "../visit"}

View File

@ -6,12 +6,12 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_css_visit"
repository = "https://github.com/swc-project/swc.git"
version = "0.21.0"
version = "0.22.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
swc_atoms = {version = "0.2.7", path = "../../atoms"}
swc_common = {version = "0.14.0", path = "../../common"}
swc_css_ast = {version = "0.22.0", path = "../ast/"}
swc_css_ast = {version = "0.23.0", path = "../ast/"}
swc_visit = {version = "0.2.6", path = "../../visit"}