Skip to content

Commit

Permalink
Deprecated warning on old import-once and import-multiple #126
Browse files Browse the repository at this point in the history
  • Loading branch information
meri committed Feb 15, 2014
1 parent bb2d597 commit 573db1b
Show file tree
Hide file tree
Showing 29 changed files with 66 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ public void mixinsCycle(List<MixinReference> 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 <url>` have been deprecated. Use `@import (once) <url>` instead. Input file is less.js incompatible."));
}

public void deprecatedImportMultiple(Import errorNode) {
collector.addWarning(new CompilationWarning(errorNode, "`@import-multiple <url>` have been deprecated. Use `@import (multiple) <url>` 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."));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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}";
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
Warnings produced by compilation of testCase
WARNING 2:1 `@import-once <url>` have been deprecated. Use `@import (once) <url>` 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.
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Warnings produced by compilation of testCase
WARNING 1:1 `@import-multiple <url>` have been deprecated. Use `@import (multiple) <url>` instead. Input file is less.js incompatible.
WARNING 2:1 `@import-multiple <url>` have been deprecated. Use `@import (multiple) <url>` instead. Input file is less.js incompatible.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Warnings produced by compilation of testCase
WARNING 11:1 `@import-once <url>` have been deprecated. Use `@import (once) <url>` instead. Input file is less.js incompatible.
WARNING 12:1 `@import-once <url>` have been deprecated. Use `@import (once) <url>` instead. Input file is less.js incompatible.
WARNING 13:1 `@import-once <url>` have been deprecated. Use `@import (once) <url>` instead. Input file is less.js incompatible.
WARNING 14:1 `@import-once <url>` have been deprecated. Use `@import (once) <url>` instead. Input file is less.js incompatible.
WARNING 15:1 `@import-once <url>` have been deprecated. Use `@import (once) <url>` instead. Input file is less.js incompatible.
WARNING 17:1 `@import-multiple <url>` have been deprecated. Use `@import (multiple) <url>` instead. Input file is less.js incompatible.
WARNING 18:1 `@import-multiple <url>` have been deprecated. Use `@import (multiple) <url>` instead. Input file is less.js incompatible.
WARNING 19:1 `@import-multiple <url>` have been deprecated. Use `@import (multiple) <url>` instead. Input file is less.js incompatible.
WARNING 20:1 `@import-multiple <url>` have been deprecated. Use `@import (multiple) <url>` instead. Input file is less.js incompatible.
WARNING 21:1 `@import-multiple <url>` have been deprecated. Use `@import (multiple) <url>` instead. Input file is less.js incompatible.
Original file line number Diff line number Diff line change
@@ -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";
Original file line number Diff line number Diff line change
@@ -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}";
Expand Down
Original file line number Diff line number Diff line change
@@ -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}";
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import-multiple "import/namespaces-and-mixins.less";
@import (multiple) "import/namespaces-and-mixins.less";

h1 {
.mixin;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
chained-import-1 {
content: ~"chained-import-1";
}
@import-once "chained-import-2.less";
@import (once) "chained-import-2.less";
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
chained-import-1 {
content: ~"chained-referenced-import-1";
}
@import-multiple "@{filename2}2.less";
@import (multiple) "@{filename2}2.less";
Original file line number Diff line number Diff line change
@@ -1 +1 @@
@import-multiple "namespaces-and-mixins.less";
@import (multiple) "namespaces-and-mixins.less";
Original file line number Diff line number Diff line change
@@ -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";
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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";
8 changes: 4 additions & 4 deletions src/test/resources/less.js-v1.3.3/less/import-once.less
Original file line number Diff line number Diff line change
@@ -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";
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.chained-import-1 {
content: ~"chained-import-1";
}
@import-once "chained-import-2.less";
@import (once) "chained-import-2.less";
4 changes: 2 additions & 2 deletions src/test/resources/source-map/content/sm-imports.less
Original file line number Diff line number Diff line change
Expand Up @@ -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";

0 comments on commit 573db1b

Please sign in to comment.