diff options
author | Mika Murtojarvi <mika@vaadin.com> | 2014-01-17 13:50:35 +0200 |
---|---|---|
committer | Mika Murtojarvi <mika@vaadin.com> | 2014-02-06 11:14:50 +0200 |
commit | 915c37b569600a8d37db2a0800a30474da49e255 (patch) | |
tree | 1d59454a97d6328ab503bc24ce8fbc47d840d3f2 /theme-compiler | |
parent | 2c1f8e67a71ad1163dd5b87f070987a05dfe35c5 (diff) | |
download | vaadin-framework-915c37b569600a8d37db2a0800a30474da49e255.tar.gz vaadin-framework-915c37b569600a8d37db2a0800a30474da49e255.zip |
Sass compiler now treats null-valued variables as unassigned (#12430).
Change-Id: I13a11b4c7d148646ad3eb5492d9dd8d736e63f39
Diffstat (limited to 'theme-compiler')
11 files changed, 332 insertions, 252 deletions
diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/CharStream.java b/theme-compiler/src/com/vaadin/sass/internal/parser/CharStream.java index c22f19451b..e43320453c 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/CharStream.java +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/CharStream.java @@ -127,4 +127,4 @@ interface CharStream { void Done(); } -/* JavaCC - OriginalChecksum=deb80d024b50bdc8bfaadaf528157233 (do not edit this line) */ +/* JavaCC - OriginalChecksum=18aae0a549695f0fec96a11297b442bb (do not edit this line) */ diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/LexicalUnitImpl.java b/theme-compiler/src/com/vaadin/sass/internal/parser/LexicalUnitImpl.java index cfd428e094..5035263588 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/LexicalUnitImpl.java +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/LexicalUnitImpl.java @@ -247,6 +247,9 @@ public class LexicalUnitImpl implements LexicalUnit, SCSSLexicalUnit, case SCSS_VARIABLE: text = "$" + s; break; + case SCSS_NULL: + text = ""; + break; case LexicalUnit.SAC_OPERATOR_COMMA: text = ","; break; @@ -492,6 +495,11 @@ public class LexicalUnitImpl implements LexicalUnit, SCSSLexicalUnit, return new LexicalUnitImpl(line, column, previous, SCSS_VARIABLE, name); } + public static LexicalUnitImpl createNull(int line, int column, + LexicalUnitImpl previous) { + return new LexicalUnitImpl(line, column, previous, SCSS_NULL, "null"); + } + public static LexicalUnitImpl createNumber(int line, int column, LexicalUnitImpl previous, float v) { int i = (int) v; diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java index 6b4a03b038..ab0f6161d7 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java @@ -2755,6 +2755,7 @@ boolean isPseudoElement = false; break label_70; } } + exp = replaceNullValues(exp); documentHandler.variable(name, exp, guarded); } catch (JumpException e) { skipAfterExpression(); @@ -2783,6 +2784,23 @@ boolean isPseudoElement = false; } } + LexicalUnitImpl replaceNullValues(LexicalUnitImpl unit) throws ParseException { + if(unit == null){ + return null; + } + if (unit.getNextLexicalUnit() != null) { + unit.setNextLexicalUnit(replaceNullValues(unit.getNextLexicalUnit())); + } + if (unit.getLexicalUnitType() == SCSSLexicalUnit.SAC_IDENT + && "null".equals(unit.getStringValue())) { + LexicalUnitImpl next = unit.getNextLexicalUnit(); + unit = LexicalUnitImpl.createNull(unit.getLineNumber(), unit.getColumnNumber(), + unit.getPreviousLexicalUnit()); + unit.setNextLexicalUnit(next); + } + return unit; + } + final public void controlDirective() throws ParseException { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case IF_SYM: @@ -6625,11 +6643,6 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_218() { - if (jj_3R_217()) return true; - return false; - } - private boolean jj_3R_182() { Token xsp; xsp = jj_scanpos; @@ -6643,6 +6656,11 @@ LexicalUnitImpl result = null; return false; } + private boolean jj_3R_218() { + if (jj_3R_217()) return true; + return false; + } + private boolean jj_3R_217() { Token xsp; xsp = jj_scanpos; @@ -6707,6 +6725,11 @@ LexicalUnitImpl result = null; return false; } + private boolean jj_3_7() { + if (jj_3R_186()) return true; + return false; + } + private boolean jj_3R_290() { if (jj_scan_token(IDENT)) return true; return false; @@ -6723,8 +6746,8 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3_7() { - if (jj_3R_186()) return true; + private boolean jj_3R_207() { + if (jj_scan_token(LBRACE)) return true; return false; } @@ -6733,8 +6756,8 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_207() { - if (jj_scan_token(LBRACE)) return true; + private boolean jj_3R_206() { + if (jj_3R_190()) return true; return false; } @@ -6751,11 +6774,6 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_206() { - if (jj_3R_190()) return true; - return false; - } - private boolean jj_3_6() { if (jj_3R_185()) return true; if (jj_scan_token(LBRACE)) return true; @@ -6783,11 +6801,6 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_310() { - if (jj_scan_token(STRING)) return true; - return false; - } - private boolean jj_3R_259() { if (jj_scan_token(FUNCTION)) return true; Token xsp; @@ -6801,6 +6814,26 @@ LexicalUnitImpl result = null; return false; } + private boolean jj_3R_250() { + if (jj_3R_263()) return true; + return false; + } + + private boolean jj_3R_249() { + if (jj_3R_262()) return true; + return false; + } + + private boolean jj_3R_248() { + if (jj_3R_261()) return true; + return false; + } + + private boolean jj_3R_310() { + if (jj_scan_token(STRING)) return true; + return false; + } + private boolean jj_3R_308() { if (jj_scan_token(STARMATCH)) return true; return false; @@ -6876,21 +6909,6 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_250() { - if (jj_3R_263()) return true; - return false; - } - - private boolean jj_3R_249() { - if (jj_3R_262()) return true; - return false; - } - - private boolean jj_3R_248() { - if (jj_3R_261()) return true; - return false; - } - private boolean jj_3R_223() { if (jj_scan_token(LBRACKET)) return true; Token xsp; @@ -6909,6 +6927,16 @@ LexicalUnitImpl result = null; return false; } + private boolean jj_3R_183() { + if (jj_scan_token(COMMA)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + return false; + } + private boolean jj_3R_302() { if (jj_scan_token(INTERPOLATION)) return true; return false; @@ -6924,6 +6952,37 @@ LexicalUnitImpl result = null; return false; } + private boolean jj_3R_260() { + if (jj_scan_token(DOT)) return true; + return false; + } + + private boolean jj_3R_247() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_260()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_scan_token(72)) { + jj_scanpos = xsp; + if (jj_scan_token(49)) { + jj_scanpos = xsp; + if (jj_scan_token(50)) { + jj_scanpos = xsp; + if (jj_scan_token(52)) return true; + } + } + } + return false; + } + + private boolean jj_3_5() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_183()) jj_scanpos = xsp; + if (jj_3R_184()) return true; + return false; + } + private boolean jj_3R_266() { Token xsp; xsp = jj_scanpos; @@ -6939,6 +6998,11 @@ LexicalUnitImpl result = null; return false; } + private boolean jj_3R_246() { + if (jj_scan_token(STRING)) return true; + return false; + } + private boolean jj_3R_219() { Token xsp; xsp = jj_scanpos; @@ -6962,59 +7026,52 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_183() { - if (jj_scan_token(COMMA)) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { jj_scanpos = xsp; break; } - } - return false; - } - - private boolean jj_3R_301() { - if (jj_scan_token(IDENT)) return true; + private boolean jj_3R_245() { + if (jj_3R_259()) return true; return false; } - private boolean jj_3R_284() { + private boolean jj_3R_202() { Token xsp; xsp = jj_scanpos; - if (jj_3R_301()) { + if (jj_3R_246()) { jj_scanpos = xsp; - if (jj_3R_302()) return true; + if (jj_3R_247()) { + jj_scanpos = xsp; + if (jj_3R_248()) { + jj_scanpos = xsp; + if (jj_3R_249()) { + jj_scanpos = xsp; + if (jj_3R_250()) return true; + } + } + } } return false; } - private boolean jj_3R_260() { - if (jj_scan_token(DOT)) return true; + private boolean jj_3R_244() { + if (jj_scan_token(DIMEN)) return true; return false; } - private boolean jj_3R_247() { + private boolean jj_3R_301() { + if (jj_scan_token(IDENT)) return true; + return false; + } + + private boolean jj_3R_284() { Token xsp; xsp = jj_scanpos; - if (jj_3R_260()) jj_scanpos = xsp; - xsp = jj_scanpos; - if (jj_scan_token(72)) { - jj_scanpos = xsp; - if (jj_scan_token(49)) { - jj_scanpos = xsp; - if (jj_scan_token(50)) { + if (jj_3R_301()) { jj_scanpos = xsp; - if (jj_scan_token(52)) return true; - } - } + if (jj_3R_302()) return true; } return false; } - private boolean jj_3_5() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_183()) jj_scanpos = xsp; - if (jj_3R_184()) return true; + private boolean jj_3R_243() { + if (jj_scan_token(KHZ)) return true; return false; } @@ -7023,11 +7080,6 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_246() { - if (jj_scan_token(STRING)) return true; - return false; - } - private boolean jj_3R_221() { if (jj_scan_token(DOT)) return true; Token xsp; @@ -7039,32 +7091,18 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_245() { - if (jj_3R_259()) return true; + private boolean jj_3R_242() { + if (jj_scan_token(HZ)) return true; return false; } - private boolean jj_3R_202() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_246()) { - jj_scanpos = xsp; - if (jj_3R_247()) { - jj_scanpos = xsp; - if (jj_3R_248()) { - jj_scanpos = xsp; - if (jj_3R_249()) { - jj_scanpos = xsp; - if (jj_3R_250()) return true; - } - } - } - } + private boolean jj_3R_298() { + if (jj_3R_221()) return true; return false; } - private boolean jj_3R_298() { - if (jj_3R_221()) return true; + private boolean jj_3R_241() { + if (jj_scan_token(MS)) return true; return false; } @@ -7093,13 +7131,23 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_244() { - if (jj_scan_token(DIMEN)) return true; + private boolean jj_3R_240() { + if (jj_scan_token(SECOND)) return true; return false; } - private boolean jj_3R_243() { - if (jj_scan_token(KHZ)) return true; + private boolean jj_3R_239() { + if (jj_scan_token(GRAD)) return true; + return false; + } + + private boolean jj_3R_238() { + if (jj_scan_token(RAD)) return true; + return false; + } + + private boolean jj_3R_237() { + if (jj_scan_token(DEG)) return true; return false; } @@ -7108,8 +7156,8 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_242() { - if (jj_scan_token(HZ)) return true; + private boolean jj_3R_236() { + if (jj_scan_token(EXS)) return true; return false; } @@ -7134,6 +7182,11 @@ LexicalUnitImpl result = null; return false; } + private boolean jj_3R_235() { + if (jj_scan_token(REM)) return true; + return false; + } + private boolean jj_3R_275() { Token xsp; xsp = jj_scanpos; @@ -7155,11 +7208,6 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_241() { - if (jj_scan_token(MS)) return true; - return false; - } - private boolean jj_3R_280() { if (jj_3R_222()) return true; return false; @@ -7191,13 +7239,13 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_282() { - if (jj_3R_223()) return true; + private boolean jj_3R_234() { + if (jj_scan_token(LEM)) return true; return false; } - private boolean jj_3R_240() { - if (jj_scan_token(SECOND)) return true; + private boolean jj_3R_282() { + if (jj_3R_223()) return true; return false; } @@ -7206,6 +7254,11 @@ LexicalUnitImpl result = null; return false; } + private boolean jj_3R_233() { + if (jj_scan_token(EMS)) return true; + return false; + } + private boolean jj_3R_273() { Token xsp; xsp = jj_scanpos; @@ -7229,23 +7282,23 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_239() { - if (jj_scan_token(GRAD)) return true; + private boolean jj_3R_232() { + if (jj_scan_token(PX)) return true; return false; } - private boolean jj_3R_238() { - if (jj_scan_token(RAD)) return true; + private boolean jj_3R_231() { + if (jj_scan_token(IN)) return true; return false; } - private boolean jj_3R_237() { - if (jj_scan_token(DEG)) return true; + private boolean jj_3R_230() { + if (jj_scan_token(PC)) return true; return false; } - private boolean jj_3R_236() { - if (jj_scan_token(EXS)) return true; + private boolean jj_3R_229() { + if (jj_scan_token(MM)) return true; return false; } @@ -7259,11 +7312,6 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_235() { - if (jj_scan_token(REM)) return true; - return false; - } - private boolean jj_3R_198() { if (jj_3R_222()) return true; Token xsp; @@ -7274,13 +7322,13 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_279() { - if (jj_3R_223()) return true; + private boolean jj_3R_228() { + if (jj_scan_token(CM)) return true; return false; } - private boolean jj_3R_234() { - if (jj_scan_token(LEM)) return true; + private boolean jj_3R_279() { + if (jj_3R_223()) return true; return false; } @@ -7294,6 +7342,11 @@ LexicalUnitImpl result = null; return false; } + private boolean jj_3R_227() { + if (jj_scan_token(PT)) return true; + return false; + } + private boolean jj_3R_196() { if (jj_3R_220()) return true; Token xsp; @@ -7325,13 +7378,13 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_233() { - if (jj_scan_token(EMS)) return true; + private boolean jj_3R_226() { + if (jj_scan_token(PERCENTAGE)) return true; return false; } - private boolean jj_3R_232() { - if (jj_scan_token(PX)) return true; + private boolean jj_3R_209() { + if (jj_3R_254()) return true; return false; } @@ -7345,8 +7398,8 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_231() { - if (jj_scan_token(IN)) return true; + private boolean jj_3R_225() { + if (jj_scan_token(NUMBER)) return true; return false; } @@ -7369,8 +7422,8 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_230() { - if (jj_scan_token(PC)) return true; + private boolean jj_3R_224() { + if (jj_3R_258()) return true; return false; } @@ -7380,41 +7433,6 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_229() { - if (jj_scan_token(MM)) return true; - return false; - } - - private boolean jj_3R_228() { - if (jj_scan_token(CM)) return true; - return false; - } - - private boolean jj_3R_227() { - if (jj_scan_token(PT)) return true; - return false; - } - - private boolean jj_3R_226() { - if (jj_scan_token(PERCENTAGE)) return true; - return false; - } - - private boolean jj_3R_209() { - if (jj_3R_254()) return true; - return false; - } - - private boolean jj_3R_225() { - if (jj_scan_token(NUMBER)) return true; - return false; - } - - private boolean jj_3R_224() { - if (jj_3R_258()) return true; - return false; - } - private boolean jj_3R_201() { Token xsp; xsp = jj_scanpos; @@ -7503,12 +7521,6 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3_2() { - if (jj_3R_180()) return true; - if (jj_3R_181()) return true; - return false; - } - private boolean jj_3R_254() { if (jj_3R_189()) return true; return false; @@ -7519,57 +7531,45 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_204() { - if (jj_scan_token(COMMA)) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { jj_scanpos = xsp; break; } - } - if (jj_3R_203()) return true; - return false; - } - - private boolean jj_3R_251() { - if (jj_3R_181()) return true; + private boolean jj_3R_208() { + if (jj_3R_184()) return true; return false; } - private boolean jj_3R_203() { + private boolean jj_3R_187() { Token xsp; xsp = jj_scanpos; - if (jj_3R_251()) { + if (jj_3R_208()) { jj_scanpos = xsp; - if (jj_3R_252()) return true; - } - while (true) { - xsp = jj_scanpos; - if (jj_3_2()) { jj_scanpos = xsp; break; } - } - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + if (jj_3R_209()) return true; } return false; } - private boolean jj_3R_208() { - if (jj_3R_184()) return true; + private boolean jj_3_9() { + if (jj_3R_188()) return true; return false; } - private boolean jj_3R_187() { + private boolean jj_3_2() { + if (jj_3R_180()) return true; + if (jj_3R_181()) return true; + return false; + } + + private boolean jj_3R_204() { + if (jj_scan_token(COMMA)) return true; Token xsp; - xsp = jj_scanpos; - if (jj_3R_208()) { - jj_scanpos = xsp; - if (jj_3R_209()) return true; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } } + if (jj_3R_203()) return true; return false; } - private boolean jj_3_9() { - if (jj_3R_188()) return true; + private boolean jj_3R_251() { + if (jj_3R_181()) return true; return false; } @@ -7593,23 +7593,26 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3_1() { - if (jj_3R_179()) return true; + private boolean jj_3R_263() { + if (jj_scan_token(UNICODERANGE)) return true; return false; } - private boolean jj_3R_185() { - if (jj_3R_203()) return true; + private boolean jj_3R_203() { Token xsp; + xsp = jj_scanpos; + if (jj_3R_251()) { + jj_scanpos = xsp; + if (jj_3R_252()) return true; + } while (true) { xsp = jj_scanpos; - if (jj_3R_204()) { jj_scanpos = xsp; break; } + if (jj_3_2()) { jj_scanpos = xsp; break; } + } + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } } - return false; - } - - private boolean jj_3R_263() { - if (jj_scan_token(UNICODERANGE)) return true; return false; } @@ -7636,6 +7639,21 @@ LexicalUnitImpl result = null; return false; } + private boolean jj_3_1() { + if (jj_3R_179()) return true; + return false; + } + + private boolean jj_3R_185() { + if (jj_3R_203()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_204()) { jj_scanpos = xsp; break; } + } + return false; + } + private boolean jj_3R_215() { if (jj_scan_token(MINUS)) return true; Token xsp; @@ -7658,11 +7676,6 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_265() { - if (jj_scan_token(INTERPOLATION)) return true; - return false; - } - private boolean jj_3_3() { if (jj_3R_179()) return true; return false; @@ -7698,16 +7711,6 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_192() { - if (jj_scan_token(SEMICOLON)) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { jj_scanpos = xsp; break; } - } - return false; - } - private boolean jj_3R_210() { if (jj_scan_token(COMMA)) return true; Token xsp; @@ -7740,6 +7743,31 @@ LexicalUnitImpl result = null; return false; } + private boolean jj_3R_265() { + if (jj_scan_token(INTERPOLATION)) return true; + return false; + } + + private boolean jj_3R_216() { + if (jj_scan_token(GUARDED_SYM)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_192() { + if (jj_scan_token(SEMICOLON)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + return false; + } + private boolean jj_3R_189() { if (jj_scan_token(VARIABLE)) return true; Token xsp; @@ -7779,16 +7807,6 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_216() { - if (jj_scan_token(GUARDED_SYM)) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { jj_scanpos = xsp; break; } - } - return false; - } - private boolean jj_3R_191() { if (jj_3R_216()) return true; return false; diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj index 482b8597d3..9e1b781a6a 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj @@ -1491,6 +1491,7 @@ void variable() : ":" ( <S> )* exp=expr() ( guarded=guarded() )?(";"(<S>)*)+ //raw=skipStatementUntilSemiColon() { + exp = replaceNullValues(exp); documentHandler.variable(name, exp, guarded); } }catch (JumpException e) { @@ -1520,6 +1521,24 @@ void variable() : } } +JAVACODE +LexicalUnitImpl replaceNullValues(LexicalUnitImpl unit) { + if(unit == null){ + return null; + } + if (unit.getNextLexicalUnit() != null) { + unit.setNextLexicalUnit(replaceNullValues(unit.getNextLexicalUnit())); + } + if (unit.getLexicalUnitType() == SCSSLexicalUnit.SAC_IDENT + && "null".equals(unit.getStringValue())) { + LexicalUnitImpl next = unit.getNextLexicalUnit(); + unit = LexicalUnitImpl.createNull(unit.getLineNumber(), unit.getColumnNumber(), + unit.getPreviousLexicalUnit()); + unit.setNextLexicalUnit(next); + } + return unit; +} + void controlDirective() : {} { diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/SCSSLexicalUnit.java b/theme-compiler/src/com/vaadin/sass/internal/parser/SCSSLexicalUnit.java index 709d1d3576..84b0563493 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/SCSSLexicalUnit.java +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/SCSSLexicalUnit.java @@ -22,6 +22,8 @@ public interface SCSSLexicalUnit extends LexicalUnit { static final short SCSS_OPERATOR_LEFT_PAREN = 101; static final short SCSS_OPERATOR_RIGHT_PAREN = 102; + static final short SCSS_NULL = 110; + static final short SAC_LEM = 200; static final short SAC_REM = 201; diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/Token.java b/theme-compiler/src/com/vaadin/sass/internal/parser/Token.java index 26d1121f96..ba29df7d33 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/Token.java +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/Token.java @@ -143,4 +143,4 @@ public class Token implements java.io.Serializable { } } -/* JavaCC - OriginalChecksum=dad2146dc89e68f66e77382c9e448fb7 (do not edit this line) */ +/* JavaCC - OriginalChecksum=8b653fc6be4ca9bd10137ee3ad4c32c4 (do not edit this line) */ diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/TokenMgrError.java b/theme-compiler/src/com/vaadin/sass/internal/parser/TokenMgrError.java index f093357e96..1757cf6705 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/TokenMgrError.java +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/TokenMgrError.java @@ -159,4 +159,4 @@ public class TokenMgrError extends Error this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); } } -/* JavaCC - OriginalChecksum=c7c96e9cf4a9320d03dd722437439354 (do not edit this line) */ +/* JavaCC - OriginalChecksum=525946b34c715198d7c29f668b049f5d (do not edit this line) */ diff --git a/theme-compiler/src/com/vaadin/sass/internal/tree/RuleNode.java b/theme-compiler/src/com/vaadin/sass/internal/tree/RuleNode.java index cc6dbb7b75..a8fa87eb0a 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/tree/RuleNode.java +++ b/theme-compiler/src/com/vaadin/sass/internal/tree/RuleNode.java @@ -58,13 +58,18 @@ public class RuleNode extends Node implements IVariableNode { @Override public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append(variable).append(": ").append(value.toString()); - builder.append(important ? " !important;" : ";"); + String stringValue = value.toString() + + (important ? " !important" : ""); + if (!"".equals(stringValue.trim())) { + stringValue = variable + ": " + stringValue + ";"; + } else { + stringValue = ""; + } + if (comment != null) { - builder.append(comment); + stringValue += comment; } - return builder.toString(); + return stringValue; } public boolean isImportant() { diff --git a/theme-compiler/src/com/vaadin/sass/internal/visitor/VariableNodeHandler.java b/theme-compiler/src/com/vaadin/sass/internal/visitor/VariableNodeHandler.java index 6da035426e..a794def8cb 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/visitor/VariableNodeHandler.java +++ b/theme-compiler/src/com/vaadin/sass/internal/visitor/VariableNodeHandler.java @@ -17,16 +17,20 @@ package com.vaadin.sass.internal.visitor; import com.vaadin.sass.internal.ScssStylesheet; +import com.vaadin.sass.internal.parser.SCSSLexicalUnit; import com.vaadin.sass.internal.tree.VariableNode; public class VariableNodeHandler { public static void traverse(VariableNode node) { - if (ScssStylesheet.getVariable(node.getName()) == null - || !node.isGuarded()) { + VariableNode variable = ScssStylesheet.getVariable(node.getName()); + if (!node.isGuarded() + || variable == null + || variable.getExpr() == null + || (variable.getExpr().getLexicalUnitType() == SCSSLexicalUnit.SCSS_NULL && variable + .getExpr().getNextLexicalUnit() == null)) { ScssStylesheet.addVariable(node); } node.getParentNode().removeChild(node); } - } diff --git a/theme-compiler/tests/resources/automatic/css/variable-defaults-with-null.css b/theme-compiler/tests/resources/automatic/css/variable-defaults-with-null.css new file mode 100644 index 0000000000..0e3483817b --- /dev/null +++ b/theme-compiler/tests/resources/automatic/css/variable-defaults-with-null.css @@ -0,0 +1,5 @@ +.test { + first: "Non-null"; + second: "Also non-null"; + third: "Not null"; +}
\ No newline at end of file diff --git a/theme-compiler/tests/resources/automatic/scss/variable-defaults-with-null.scss b/theme-compiler/tests/resources/automatic/scss/variable-defaults-with-null.scss new file mode 100644 index 0000000000..0bfa374304 --- /dev/null +++ b/theme-compiler/tests/resources/automatic/scss/variable-defaults-with-null.scss @@ -0,0 +1,19 @@ +$var: null; +$var: "Non-null" !default; + +$var2: null; +$var2: "Also non-null" !default; +$var2: "Null content" !default; + +$list-of-nulls: null null; +$list-of-nulls: "Non-null" !default; + +$mixed-list: null "Not null" null; +$mixed-list: "null" !default; + +.test { + first: $var; + second: $var2; + hidden: $list-of-nulls; + third: $mixed-list; +}
\ No newline at end of file |