From 573db1b373fba2ca3e085780417750802835bf7a Mon Sep 17 00:00:00 2001 From: meri Date: Sat, 15 Feb 2014 16:25:34 +0100 Subject: [PATCH] Deprecated warning on old import-once and import-multiple #126 --- .../sommeri/less4j/core/parser/ASTBuilderSwitch.java | 2 ++ .../sommeri/less4j/core/problems/ProblemsHandler.java | 8 ++++++++ .../import/import-deep-incorrect.less | 2 +- .../import/import-file-not-exists.css | 1 + .../import/import-file-not-exists.err | 3 +++ .../import/import-file-not-exists.less | 3 ++- .../import/import-interpolated-complicated.less | 6 +++--- .../import/import-interpolated-dependence.less | 6 +++--- ...media-queries.css => import-old-media-queries.css} | 0 .../import/import-old-media-queries.err | 3 +++ ...dia-queries.less => import-old-media-queries.less} | 0 ...iles.css => import-old-multiplicity-css-files.css} | 0 .../import/import-old-multiplicity-css-files.err | 11 +++++++++++ ...es.less => import-old-multiplicity-css-files.less} | 0 .../import/import-once-order.less | 4 ++-- ...port-syntactically-incorrect-unclosed-ruleset.less | 2 +- ...import-syntactically-incorrect-wrong-variable.less | 2 +- .../import/import-types-combinations.less | 6 +++--- .../import/import-variables-and-mixins-chained.less | 2 +- .../import/import-variables-and-mixins.less | 2 +- .../import/import/chained-import-1.less | 2 +- .../import/import/chained-reference-import-1.less | 2 +- .../import/import/import-namespaces-and-mixins.less | 2 +- .../import/imports-depend-on-each-other.less | 4 ++-- .../unknown-input-file/import-types-combinations.err | 8 ++++---- .../unknown-input-file/import-types-combinations.less | 8 ++++---- .../resources/less.js-v1.3.3/less/import-once.less | 8 ++++---- .../source-map/content/import/chained-import-1.less | 2 +- src/test/resources/source-map/content/sm-imports.less | 4 ++-- 29 files changed, 66 insertions(+), 37 deletions(-) rename src/test/resources/compile-basic-features/import/{import-media-queries.css => import-old-media-queries.css} (100%) create mode 100644 src/test/resources/compile-basic-features/import/import-old-media-queries.err rename src/test/resources/compile-basic-features/import/{import-media-queries.less => import-old-media-queries.less} (100%) rename src/test/resources/compile-basic-features/import/{import-css-files.css => import-old-multiplicity-css-files.css} (100%) create mode 100644 src/test/resources/compile-basic-features/import/import-old-multiplicity-css-files.err rename src/test/resources/compile-basic-features/import/{import-css-files.less => import-old-multiplicity-css-files.less} (100%) diff --git a/src/main/java/com/github/sommeri/less4j/core/parser/ASTBuilderSwitch.java b/src/main/java/com/github/sommeri/less4j/core/parser/ASTBuilderSwitch.java index 4885db0c..3dce21fc 100644 --- a/src/main/java/com/github/sommeri/less4j/core/parser/ASTBuilderSwitch.java +++ b/src/main/java/com/github/sommeri/less4j/core/parser/ASTBuilderSwitch.java @@ -1072,9 +1072,11 @@ public Import handleImport(HiddenTokenAwareTree token) { break; case LessLexer.IMPORT_ONCE_SYM: result.setMultiplicity(Import.ImportMultiplicity.IMPORT_ONCE); + problemsHandler.deprecatedImportOnce(result); break; case LessLexer.IMPORT_MULTIPLE_SYM: result.setMultiplicity(Import.ImportMultiplicity.IMPORT_MULTIPLE); + problemsHandler.deprecatedImportMultiple(result); break; default: throw new BugHappened(GRAMMAR_MISMATCH, token); diff --git a/src/main/java/com/github/sommeri/less4j/core/problems/ProblemsHandler.java b/src/main/java/com/github/sommeri/less4j/core/problems/ProblemsHandler.java index ac7a32eb..42a44cdb 100644 --- a/src/main/java/com/github/sommeri/less4j/core/problems/ProblemsHandler.java +++ b/src/main/java/com/github/sommeri/less4j/core/problems/ProblemsHandler.java @@ -131,6 +131,14 @@ public void mixinsCycle(List cycle) { collector.addError(new CompilationError(cycle.get(0), "Cyclic references among mixins: " + printer.toMixinReferencesString(cycle))); } + public void deprecatedImportOnce(Import errorNode) { + collector.addWarning(new CompilationWarning(errorNode, "`@import-once ` have been deprecated. Use `@import (once) ` instead. Input file is less.js incompatible.")); + } + + public void deprecatedImportMultiple(Import errorNode) { + collector.addWarning(new CompilationWarning(errorNode, "`@import-multiple ` have been deprecated. Use `@import (multiple) ` instead. Input file is less.js incompatible.")); + } + public void deprecatedSyntaxEscapedSelector(EscapedSelector errorNode) { collector.addWarning(new CompilationWarning(errorNode, "Selector fragment (~" + errorNode.getQuoteType() + errorNode.getValue() + errorNode.getQuoteType() + ") uses deprecated (~\"escaped-selector\") syntax. Use selector interpolation @{variableName} instead.")); } diff --git a/src/test/resources/compile-basic-features/import/import-deep-incorrect.less b/src/test/resources/compile-basic-features/import/import-deep-incorrect.less index 67d9f203..4cf7d191 100644 --- a/src/test/resources/compile-basic-features/import/import-deep-incorrect.less +++ b/src/test/resources/compile-basic-features/import/import-deep-incorrect.less @@ -1,4 +1,4 @@ -@import-once url(import/import-deep-incorrect.less); +@import (once) url(import/import-deep-incorrect.less); @variable: value; h1 { content: ~"@{variable}"; diff --git a/src/test/resources/compile-basic-features/import/import-file-not-exists.css b/src/test/resources/compile-basic-features/import/import-file-not-exists.css index be902e53..2da15ce3 100644 --- a/src/test/resources/compile-basic-features/import/import-file-not-exists.css +++ b/src/test/resources/compile-basic-features/import/import-file-not-exists.css @@ -1,4 +1,5 @@ @import url(somewhere/this-file-does-not-exists.less); +@import url(somewhere/this-file-does-not-exists-old-syntax.less); .class { padding: 2 2 2 2; } diff --git a/src/test/resources/compile-basic-features/import/import-file-not-exists.err b/src/test/resources/compile-basic-features/import/import-file-not-exists.err index c6928711..9d28b1db 100644 --- a/src/test/resources/compile-basic-features/import/import-file-not-exists.err +++ b/src/test/resources/compile-basic-features/import/import-file-not-exists.err @@ -1,2 +1,5 @@ +Warnings produced by compilation of testCase +WARNING 2:1 `@import-once ` have been deprecated. Use `@import (once) ` instead. Input file is less.js incompatible. Errors produced by compilation of testCase ERROR 1:1 The file somewhere/this-file-does-not-exists.less does not exist. +ERROR 2:1 The file somewhere/this-file-does-not-exists-old-syntax.less does not exist. \ No newline at end of file diff --git a/src/test/resources/compile-basic-features/import/import-file-not-exists.less b/src/test/resources/compile-basic-features/import/import-file-not-exists.less index 4becae81..cc79ad0a 100644 --- a/src/test/resources/compile-basic-features/import/import-file-not-exists.less +++ b/src/test/resources/compile-basic-features/import/import-file-not-exists.less @@ -1,4 +1,5 @@ -@import-once url(somewhere/this-file-does-not-exists.less); +@import (once) url(somewhere/this-file-does-not-exists.less); +@import-once url(somewhere/this-file-does-not-exists-old-syntax.less); .class { padding: 2 2 2 2; } \ No newline at end of file diff --git a/src/test/resources/compile-basic-features/import/import-interpolated-complicated.less b/src/test/resources/compile-basic-features/import/import-interpolated-complicated.less index 3c52bfc7..ff3e2e57 100644 --- a/src/test/resources/compile-basic-features/import/import-interpolated-complicated.less +++ b/src/test/resources/compile-basic-features/import/import-interpolated-complicated.less @@ -1,14 +1,14 @@ @filename: "chained-reference-import-"; @filename2: "chained-reference-import-"; -@import-multiple "import/@{filename}1.less"; +@import (multiple) "import/@{filename}1.less"; .mainMixin { color: green; } .see-global { - @import-multiple url("import/@{filename}2.less"); + @import (multiple) url("import/@{filename}2.less"); } .redefined { - @import-multiple url('import/@{filename}import-2.less'); + @import (multiple) url('import/@{filename}import-2.less'); @filename: "chained-reference-"; } @definitelyLast: 3; diff --git a/src/test/resources/compile-basic-features/import/import-interpolated-dependence.less b/src/test/resources/compile-basic-features/import/import-interpolated-dependence.less index b3832011..860453f4 100644 --- a/src/test/resources/compile-basic-features/import/import-interpolated-dependence.less +++ b/src/test/resources/compile-basic-features/import/import-interpolated-dependence.less @@ -1,10 +1,10 @@ @variable: "import/imports-dependence-1"; -@import-multiple "@{variable}.less"; +@import (multiple) "@{variable}.less"; .mainMixin { color: @another; } .see-global { - @import-multiple "@{variable}.less"; + @import (multiple) "@{variable}.less"; } -@import-multiple "@{variable}.less"; +@import (multiple) "@{variable}.less"; @definitelyLast: 3; diff --git a/src/test/resources/compile-basic-features/import/import-media-queries.css b/src/test/resources/compile-basic-features/import/import-old-media-queries.css similarity index 100% rename from src/test/resources/compile-basic-features/import/import-media-queries.css rename to src/test/resources/compile-basic-features/import/import-old-media-queries.css diff --git a/src/test/resources/compile-basic-features/import/import-old-media-queries.err b/src/test/resources/compile-basic-features/import/import-old-media-queries.err new file mode 100644 index 00000000..b2c45999 --- /dev/null +++ b/src/test/resources/compile-basic-features/import/import-old-media-queries.err @@ -0,0 +1,3 @@ +Warnings produced by compilation of testCase +WARNING 1:1 `@import-multiple ` have been deprecated. Use `@import (multiple) ` instead. Input file is less.js incompatible. +WARNING 2:1 `@import-multiple ` have been deprecated. Use `@import (multiple) ` instead. Input file is less.js incompatible. \ No newline at end of file diff --git a/src/test/resources/compile-basic-features/import/import-media-queries.less b/src/test/resources/compile-basic-features/import/import-old-media-queries.less similarity index 100% rename from src/test/resources/compile-basic-features/import/import-media-queries.less rename to src/test/resources/compile-basic-features/import/import-old-media-queries.less diff --git a/src/test/resources/compile-basic-features/import/import-css-files.css b/src/test/resources/compile-basic-features/import/import-old-multiplicity-css-files.css similarity index 100% rename from src/test/resources/compile-basic-features/import/import-css-files.css rename to src/test/resources/compile-basic-features/import/import-old-multiplicity-css-files.css diff --git a/src/test/resources/compile-basic-features/import/import-old-multiplicity-css-files.err b/src/test/resources/compile-basic-features/import/import-old-multiplicity-css-files.err new file mode 100644 index 00000000..99af087d --- /dev/null +++ b/src/test/resources/compile-basic-features/import/import-old-multiplicity-css-files.err @@ -0,0 +1,11 @@ +Warnings produced by compilation of testCase +WARNING 11:1 `@import-once ` have been deprecated. Use `@import (once) ` instead. Input file is less.js incompatible. +WARNING 12:1 `@import-once ` have been deprecated. Use `@import (once) ` instead. Input file is less.js incompatible. +WARNING 13:1 `@import-once ` have been deprecated. Use `@import (once) ` instead. Input file is less.js incompatible. +WARNING 14:1 `@import-once ` have been deprecated. Use `@import (once) ` instead. Input file is less.js incompatible. +WARNING 15:1 `@import-once ` have been deprecated. Use `@import (once) ` instead. Input file is less.js incompatible. +WARNING 17:1 `@import-multiple ` have been deprecated. Use `@import (multiple) ` instead. Input file is less.js incompatible. +WARNING 18:1 `@import-multiple ` have been deprecated. Use `@import (multiple) ` instead. Input file is less.js incompatible. +WARNING 19:1 `@import-multiple ` have been deprecated. Use `@import (multiple) ` instead. Input file is less.js incompatible. +WARNING 20:1 `@import-multiple ` have been deprecated. Use `@import (multiple) ` instead. Input file is less.js incompatible. +WARNING 21:1 `@import-multiple ` have been deprecated. Use `@import (multiple) ` instead. Input file is less.js incompatible. \ No newline at end of file diff --git a/src/test/resources/compile-basic-features/import/import-css-files.less b/src/test/resources/compile-basic-features/import/import-old-multiplicity-css-files.less similarity index 100% rename from src/test/resources/compile-basic-features/import/import-css-files.less rename to src/test/resources/compile-basic-features/import/import-old-multiplicity-css-files.less diff --git a/src/test/resources/compile-basic-features/import/import-once-order.less b/src/test/resources/compile-basic-features/import/import-once-order.less index f83fa32f..4b5a89b6 100644 --- a/src/test/resources/compile-basic-features/import/import-once-order.less +++ b/src/test/resources/compile-basic-features/import/import-once-order.less @@ -1,5 +1,5 @@ -@import-once "import/chained-import-1.less"; +@import (once) "import/chained-import-1.less"; h1 { color: green; } -@import-once "import/chained-import-2.less"; +@import (once) "import/chained-import-2.less"; diff --git a/src/test/resources/compile-basic-features/import/import-syntactically-incorrect-unclosed-ruleset.less b/src/test/resources/compile-basic-features/import/import-syntactically-incorrect-unclosed-ruleset.less index e2c78c88..150a9352 100644 --- a/src/test/resources/compile-basic-features/import/import-syntactically-incorrect-unclosed-ruleset.less +++ b/src/test/resources/compile-basic-features/import/import-syntactically-incorrect-unclosed-ruleset.less @@ -1,4 +1,4 @@ -@import-once url(import/syntactically-incorrect-unclosed-ruleset.less); +@import (once) url(import/syntactically-incorrect-unclosed-ruleset.less); @variable: value; h1 { content: ~"@{variable}"; diff --git a/src/test/resources/compile-basic-features/import/import-syntactically-incorrect-wrong-variable.less b/src/test/resources/compile-basic-features/import/import-syntactically-incorrect-wrong-variable.less index dde0074c..64655479 100644 --- a/src/test/resources/compile-basic-features/import/import-syntactically-incorrect-wrong-variable.less +++ b/src/test/resources/compile-basic-features/import/import-syntactically-incorrect-wrong-variable.less @@ -1,4 +1,4 @@ -@import-once url(import/syntactically-incorrect-wrong-variable.less); +@import (once) url(import/syntactically-incorrect-wrong-variable.less); @variable: value; h1 { content: ~"@{variable}"; diff --git a/src/test/resources/compile-basic-features/import/import-types-combinations.less b/src/test/resources/compile-basic-features/import/import-types-combinations.less index 07f3f046..53f7de6c 100644 --- a/src/test/resources/compile-basic-features/import/import-types-combinations.less +++ b/src/test/resources/compile-basic-features/import/import-types-combinations.less @@ -1,5 +1,5 @@ @import "import/one-simple-ruleset.less"; @import "import/one-simple-ruleset.less"; -@import-once "import/one-simple-ruleset.less"; -@import-once "import/one-simple-ruleset.less"; -//@import-multiple "import/one-simple-ruleset.less"; +@import (once) "import/one-simple-ruleset.less"; +@import (once) "import/one-simple-ruleset.less"; +//@import (multiple) "import/one-simple-ruleset.less"; diff --git a/src/test/resources/compile-basic-features/import/import-variables-and-mixins-chained.less b/src/test/resources/compile-basic-features/import/import-variables-and-mixins-chained.less index 16cf90c7..ae4f72fe 100644 --- a/src/test/resources/compile-basic-features/import/import-variables-and-mixins-chained.less +++ b/src/test/resources/compile-basic-features/import/import-variables-and-mixins-chained.less @@ -6,7 +6,7 @@ #space .mixin; @fromImporter: "h1"; } -@import-multiple "import/import-namespaces-and-mixins.less"; +@import (multiple) "import/import-namespaces-and-mixins.less"; :after { .mixin; diff --git a/src/test/resources/compile-basic-features/import/import-variables-and-mixins.less b/src/test/resources/compile-basic-features/import/import-variables-and-mixins.less index 83133a6e..7e59231c 100644 --- a/src/test/resources/compile-basic-features/import/import-variables-and-mixins.less +++ b/src/test/resources/compile-basic-features/import/import-variables-and-mixins.less @@ -1,4 +1,4 @@ -@import-multiple "import/namespaces-and-mixins.less"; +@import (multiple) "import/namespaces-and-mixins.less"; h1 { .mixin; diff --git a/src/test/resources/compile-basic-features/import/import/chained-import-1.less b/src/test/resources/compile-basic-features/import/import/chained-import-1.less index 4bfadf88..17e0e5d0 100644 --- a/src/test/resources/compile-basic-features/import/import/chained-import-1.less +++ b/src/test/resources/compile-basic-features/import/import/chained-import-1.less @@ -1,4 +1,4 @@ chained-import-1 { content: ~"chained-import-1"; } -@import-once "chained-import-2.less"; +@import (once) "chained-import-2.less"; diff --git a/src/test/resources/compile-basic-features/import/import/chained-reference-import-1.less b/src/test/resources/compile-basic-features/import/import/chained-reference-import-1.less index a57a1708..95ac62e0 100644 --- a/src/test/resources/compile-basic-features/import/import/chained-reference-import-1.less +++ b/src/test/resources/compile-basic-features/import/import/chained-reference-import-1.less @@ -1,4 +1,4 @@ chained-import-1 { content: ~"chained-referenced-import-1"; } -@import-multiple "@{filename2}2.less"; \ No newline at end of file +@import (multiple) "@{filename2}2.less"; \ No newline at end of file diff --git a/src/test/resources/compile-basic-features/import/import/import-namespaces-and-mixins.less b/src/test/resources/compile-basic-features/import/import/import-namespaces-and-mixins.less index c76a9f20..4a781c8b 100644 --- a/src/test/resources/compile-basic-features/import/import/import-namespaces-and-mixins.less +++ b/src/test/resources/compile-basic-features/import/import/import-namespaces-and-mixins.less @@ -1 +1 @@ -@import-multiple "namespaces-and-mixins.less"; +@import (multiple) "namespaces-and-mixins.less"; diff --git a/src/test/resources/compile-basic-features/import/imports-depend-on-each-other.less b/src/test/resources/compile-basic-features/import/imports-depend-on-each-other.less index cdb61fc9..a253e219 100644 --- a/src/test/resources/compile-basic-features/import/imports-depend-on-each-other.less +++ b/src/test/resources/compile-basic-features/import/imports-depend-on-each-other.less @@ -1,2 +1,2 @@ -@import-once "import/cyclic-1.less"; -@import-once "import/cyclic-2.less"; +@import (once) "import/cyclic-1.less"; +@import (once) "import/cyclic-2.less"; diff --git a/src/test/resources/compile-basic-features/import/unknown-input-file/import-types-combinations.err b/src/test/resources/compile-basic-features/import/unknown-input-file/import-types-combinations.err index 5ad55439..c053630c 100644 --- a/src/test/resources/compile-basic-features/import/unknown-input-file/import-types-combinations.err +++ b/src/test/resources/compile-basic-features/import/unknown-input-file/import-types-combinations.err @@ -1,7 +1,7 @@ Warnings produced by compilation of testCase WARNING 4:9 Attempt to import less file with an unknown compiled file location. Import statement left unchanged. WARNING 5:9 Attempt to import less file with an unknown compiled file location. Import statement left unchanged. -WARNING 6:14 Attempt to import less file with an unknown compiled file location. Import statement left unchanged. -WARNING 7:14 Attempt to import less file with an unknown compiled file location. Import statement left unchanged. -WARNING 8:18 Attempt to import less file with an unknown compiled file location. Import statement left unchanged. -WARNING 9:18 Attempt to import less file with an unknown compiled file location. Import statement left unchanged. +WARNING 6:16 Attempt to import less file with an unknown compiled file location. Import statement left unchanged. +WARNING 7:16 Attempt to import less file with an unknown compiled file location. Import statement left unchanged. +WARNING 8:20 Attempt to import less file with an unknown compiled file location. Import statement left unchanged. +WARNING 9:20 Attempt to import less file with an unknown compiled file location. Import statement left unchanged. \ No newline at end of file diff --git a/src/test/resources/compile-basic-features/import/unknown-input-file/import-types-combinations.less b/src/test/resources/compile-basic-features/import/unknown-input-file/import-types-combinations.less index 9d7648d2..c0c4b557 100644 --- a/src/test/resources/compile-basic-features/import/unknown-input-file/import-types-combinations.less +++ b/src/test/resources/compile-basic-features/import/unknown-input-file/import-types-combinations.less @@ -3,7 +3,7 @@ h1 { } @import "import\one-simple-ruleset.less"; @import "import\one-simple-ruleset.less"; -@import-once "import\one-simple-ruleset.less"; -@import-once "import\one-simple-ruleset.less"; -@import-multiple "import\one-simple-ruleset.less"; -@import-multiple "import\one-simple-ruleset.less"; +@import (once) "import\one-simple-ruleset.less"; +@import (once) "import\one-simple-ruleset.less"; +@import (multiple) "import\one-simple-ruleset.less"; +@import (multiple) "import\one-simple-ruleset.less"; diff --git a/src/test/resources/less.js-v1.3.3/less/import-once.less b/src/test/resources/less.js-v1.3.3/less/import-once.less index 02c9670b..ab26f899 100644 --- a/src/test/resources/less.js-v1.3.3/less/import-once.less +++ b/src/test/resources/less.js-v1.3.3/less/import-once.less @@ -1,4 +1,4 @@ -@import-once "import/import-once-test-c"; -@import-once "import/import-once-test-c"; -//@import-once "import/import-once-test-c.less"; -//@import-once "import/deeper/import-once-test-a"; +@import (once) "import/import-once-test-c"; +@import (once) "import/import-once-test-c"; +//@import (once) "import/import-once-test-c.less"; +//@import (once) "import/deeper/import-once-test-a"; diff --git a/src/test/resources/source-map/content/import/chained-import-1.less b/src/test/resources/source-map/content/import/chained-import-1.less index ee416c88..83482697 100644 --- a/src/test/resources/source-map/content/import/chained-import-1.less +++ b/src/test/resources/source-map/content/import/chained-import-1.less @@ -1,4 +1,4 @@ .chained-import-1 { content: ~"chained-import-1"; } -@import-once "chained-import-2.less"; +@import (once) "chained-import-2.less"; diff --git a/src/test/resources/source-map/content/sm-imports.less b/src/test/resources/source-map/content/sm-imports.less index 6189d618..e00949a2 100644 --- a/src/test/resources/source-map/content/sm-imports.less +++ b/src/test/resources/source-map/content/sm-imports.less @@ -4,8 +4,8 @@ * - last long * */ -@import-once "import/chained-import-1.less"; +@import (once) "import/chained-import-1.less"; .maintitle { color: green; } -@import-once "import/chained-import-2.less"; +@import (once) "import/chained-import-2.less";