From f4fa4e8ec53b0943635edf3f147680c9b9214db8 Mon Sep 17 00:00:00 2001 From: Mika Murtojarvi Date: Tue, 26 Nov 2013 14:14:06 +0200 Subject: [PATCH] Normalize line endings Change-Id: I328a1d3505471c65681dccdaa1a342dbb9c9ab37 --- .../com/vaadin/sass/internal/parser/Parser.jj | 106 +++++++++++++----- 1 file changed, 76 insertions(+), 30 deletions(-) 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 d6861a8652..1c45d815a5 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj @@ -1669,13 +1669,20 @@ ArrayList arglist() : } JAVACODE -boolean checkMixinForNonOptionalArguments(VariableNode arg, boolean hasNonOptionalArguments) { +boolean checkMixinForNonOptionalArguments(VariableNode arg, boolean hasNonOptionalArguments) +{ boolean currentArgHasArguments = arg.getExpr() != null && arg.getExpr().getLexicalUnitType() == LexicalUnitImpl.SCSS_VARIABLE && arg.getExpr().getNextLexicalUnit() != null; - if(currentArgHasArguments) { - if(hasNonOptionalArguments) { throw new ParseException("Sass Error: Required argument $"+ arg.getName() +" must come before any optional arguments."); + + if(currentArgHasArguments) + { + if(hasNonOptionalArguments) + { + throw new ParseException("Sass Error: Required argument $"+ arg.getName() +" must come before any optional arguments."); } return hasNonOptionalArguments; - }else { return true; + }else + { + return true; } } @@ -1690,9 +1697,13 @@ VariableNode mixinArg() : { name=variableName() (< COLON > (< S >)* - ( first = nonVariableTerm(null) { - prev = first; } - (LOOKAHEAD(3)(< COMMA >(< S >)*)? prev = nonVariableTerm(prev))* ) + ( + first = nonVariableTerm(null) + { + prev = first; + } + (LOOKAHEAD(3)(< COMMA >(< S >)*)? prev = nonVariableTerm(prev))* + ) | (variable = < VARIABLE >{ first = LexicalUnitImpl.createVariable(token.beginLine, token.beginColumn, prev, variable.image);} @@ -1879,39 +1890,66 @@ String listModifyDirectiveArgs(int nest) { t = getToken(1); String s = t.image; - if(t.kind == VARIABLE||t.kind == IDENT) { + if(t.kind == VARIABLE||t.kind == IDENT) + { list += s; - }else if(s.toLowerCase().equals("auto")||s.toLowerCase().equals("space")||s.toLowerCase().equals("comma")) { + }else if(s.toLowerCase().equals("auto")||s.toLowerCase().equals("space")||s.toLowerCase().equals("comma")) + { int i = 2; Token temp = getToken(i); boolean isLast = true; while(temp.kind != SEMICOLON) - { if(temp.kind != RPARAN || temp.kind != S) - { isLast = false; } + { + if(temp.kind != RPARAN || temp.kind != S) + { + isLast = false; + } i++; temp = getToken(i); } - if(isLast) { return list; + if(isLast) + { + return list; } - } else if(t.kind == STRING) { list += s.substring(1,s.length()).substring(0,s.length()-2); + } + else if(t.kind == STRING) + { + list += s.substring(1,s.length()).substring(0,s.length()-2); - }else if(t.kind == LPARAN) { nesting++; - if(nesting > nest+1) { throw new CSSParseException("Only one ( ) pair per parameter allowed", getLocator()); + }else if(t.kind == LPARAN) + { + nesting++; + if(nesting > nest+1) + { + throw new CSSParseException("Only one ( ) pair per parameter allowed", getLocator()); } - }else if(t.kind == RPARAN) { nesting--; - if(nesting == 0) { + }else if(t.kind == RPARAN) + { + nesting--; + if(nesting == 0) + { return list; } - } else if(t.kind == COMMA) { - if(nesting == nest) { - return list; }else { - list += ","; } + } else if(t.kind == COMMA) + { + if(nesting == nest) + { + return list; + }else + { + list += ","; + } - }else if(t.kind == S) { - list += " "; } else if(t.kind == LBRACE) { - throw new CSSParseException("Invalid token,'{' found", getLocator()); } - getNextToken(); + }else if(t.kind == S) + { + list += " "; + } else if(t.kind == LBRACE) + { + throw new CSSParseException("Invalid token,'{' found", getLocator()); + } + + getNextToken(); } } @@ -2303,14 +2341,20 @@ LexicalUnitImpl term(LexicalUnitImpl prev) : } } -LexicalUnitImpl variableTerm(LexicalUnitImpl prev) : { +LexicalUnitImpl variableTerm(LexicalUnitImpl prev) : +{ LexicalUnitImpl result = null; - String varName = ""; } { + String varName = ""; +} +{ varName = variableName() {result = LexicalUnitImpl.createVariable(token.beginLine, token.beginColumn, - prev, varName); return result;} } + prev, varName); return result;} +} -LexicalUnitImpl nonVariableTerm(LexicalUnitImpl prev) : { LexicalUnitImpl result = null; +LexicalUnitImpl nonVariableTerm(LexicalUnitImpl prev) : +{ +LexicalUnitImpl result = null; Token n = null; char op = ' '; String varName; @@ -2433,7 +2477,9 @@ LexicalUnitImpl nonVariableTerm(LexicalUnitImpl prev) : { LexicalUnitImpl result | result=unicode(prev) ) ) ( )* { - return result; } } + return result; + } +} /** * Handle all CSS2 functions. -- 2.39.5