Browse Source

support interpolation in property name (#9410)

Change-Id: Idfb058daf796875cadf0262a2b8150fc1c103915
tags/7.0.0.rc1
Haijian Wang 11 years ago
parent
commit
a13ea142d9

+ 915
- 884
theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java
File diff suppressed because it is too large
View File


+ 16
- 11
theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj View File

@@ -907,10 +907,10 @@ void fontFace() :
}
{
try {
<FONT_FACE_SYM> ( <S> )*
<LBRACE> (<S>)*
<FONT_FACE_SYM> ( <S> )*
<LBRACE> (<S>)*
{ start = true; documentHandler.startFontFace(); }
( declaration() )? ( ";" ( <S> )* ( declaration() )? )*
( declaration() )? ( ";" ( <S> )* ( declaration() )? )*
<RBRACE> (<S>)*
} catch (ParseException e) {
reportError(getLocator(), e);
@@ -928,7 +928,7 @@ void fontFace() :
*/
void atRuleDeclaration() :
{Token n;
String ret;
String ret;
}
{
n=<ATKEYWORD>
@@ -993,7 +993,7 @@ char connector = ' ';
"+" ( <S> )* { return '+'; }
| ">" ( <S> )* { return '>'; }
| "~" ( <S> )* { return '~'; }
| <S> ( ( "+" { connector = '+'; }
| <S> ( ( "+" { connector = '+'; }
| ">" { connector = '>'; }
| "~" { connector = '~'; } )
( <S> )* )? { return connector; }
@@ -1032,10 +1032,13 @@ void microsoftExtension() :
* @exception ParseException exception during the parse
*/
String property() :
{Token n;
{Token t;String s = "";
}
{
n=<IDENT> ( <S> )* { return convertIdent(n.image); }
(t = <IDENT>{s += t.image; }|t = < INTERPOLATION >{ s += t.image; })+(< S >)*
{
return s;
}
}

String variableName() :
@@ -1595,7 +1598,7 @@ void includeDirective() :
{
<INCLUDE_SYM>
(<S>)*
(name = property()|name = variableName(){ name = "$"+name;}|name = interpolation()
(name = property()|name = variableName(){ name = "$"+name;}
|(name = functionName()
args = argValuelist()) <RPARAN>)(";"(<S>)*)+
{documentHandler.includeDirective(name, args);}
@@ -1603,7 +1606,9 @@ void includeDirective() :

String interpolation() :
{
Token n; } {
Token n;
}
{
n = < INTERPOLATION >
{
return n.image; } }
@@ -2759,12 +2764,12 @@ void _parseDeclarationBlock() :
{
}
{
( <S> )*
( <S> )*
( declaration() )? ( ";" ( <S> )* ( declaration() )? )*
}

ArrayList<String> _parseSelectors() :
{ ArrayList<String> p = null;
{ ArrayList<String> p = null;
}
{
try {

+ 0
- 15
theme-compiler/src/com/vaadin/sass/internal/parser/ParserConstants.java View File

@@ -1,18 +1,3 @@
/*
* Copyright 2000-2013 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
/* Generated By:JavaCC: Do not edit this line. ParserConstants.java */
package com.vaadin.sass.internal.parser;


+ 0
- 15
theme-compiler/src/com/vaadin/sass/internal/parser/ParserTokenManager.java View File

@@ -1,18 +1,3 @@
/*
* Copyright 2000-2013 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
/* Generated By:JavaCC: Do not edit this line. ParserTokenManager.java */
package com.vaadin.sass.internal.parser;
import java.io.*;

+ 5
- 0
theme-compiler/src/com/vaadin/sass/internal/tree/RuleNode.java View File

@@ -87,6 +87,11 @@ public class RuleNode extends Node implements IVariableNode {

String interpolation = "#{$" + node.getName() + "}";

if (variable != null && variable.contains(interpolation)) {
variable = variable.replaceAll(Pattern.quote(interpolation),
node.getExpr().toString());
}

if (value.getLexicalUnitType() == LexicalUnitImpl.SAC_FUNCTION) {

if (value.getParameters() != null) {

+ 6
- 0
theme-compiler/tests/resources/automatic/css/interpolation-in-property-name.css View File

@@ -0,0 +1,6 @@
.rounded-top {
border-top-radius: 10px;
-moz-border-radius-top: 10px;
top-radius: 10px;
no-interpolation: no-interpolation;
}

+ 9
- 0
theme-compiler/tests/resources/automatic/scss/interpolation-in-property-name.scss View File

@@ -0,0 +1,9 @@
$side: top;
$radius: 10px;

.rounded-#{$side} {
border-#{$side}-radius: $radius;
-moz-border-radius-#{$side}: $radius;
#{$side}-radius: $radius;
no-interpolation: no-interpolation;
}

Loading…
Cancel
Save