aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMika Murtojarvi <mika@vaadin.com>2014-02-11 13:10:15 +0200
committerVaadin Code Review <review@vaadin.com>2014-02-13 07:58:42 +0000
commitb008768b93c9dcd73272012e2628ea2074c42b32 (patch)
treecbb1d26c2c75153e28885ef47988caed58859164
parentef208a686c9b32a66d317ceaf571a1b0387625bb (diff)
downloadvaadin-framework-b008768b93c9dcd73272012e2628ea2074c42b32.tar.gz
vaadin-framework-b008768b93c9dcd73272012e2628ea2074c42b32.zip
Implement parenthesis-handling fixes for Sass in Vaadin 7.1 (#12834)
These are the same changes that were done for the master-branch in (#12833). Change-Id: I397028c7b0ba06567adaad9f0f0095157f7ae8f9 Merge: no
-rw-r--r--theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java34
-rw-r--r--theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj34
-rw-r--r--theme-compiler/tests/resources/w3ctests/scss/css3-modsel-67.0.scss3
3 files changed, 63 insertions, 8 deletions
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 ab0f6161d7..bc25042a5c 100644
--- a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java
+++ b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java
@@ -2667,7 +2667,7 @@ boolean isPseudoElement = false;
}
jj_consume_token(S);
}
- d = skipStatementUntilRightParan();
+ d = skipStatementUntilMatchingRightParan();
jj_consume_token(RPARAN);
// accept anything between function and a right parenthesis
String f = convertIdent(n.image);
@@ -6202,9 +6202,35 @@ LexicalUnitImpl result = null;
return skipStatementUntil(lBrace);
}
- String skipStatementUntilRightParan() throws ParseException {
- int[] rParan = {RPARAN};
- return skipStatementUntil(rParan);
+ String skipStatementUntilMatchingRightParan() throws ParseException {
+ int[] leftTokens = {LPARAN, FUNCTION}; // a FUNCTION also contains "("
+ int[] rightTokens = {RPARAN};
+ StringBuffer s = new StringBuffer();
+ int difference = 1;
+ Token tok;
+ while(difference != 0){
+ tok = getToken(1);
+ if(tok.kind == EOF) {
+ return null;
+ }
+ for(int sym : leftTokens){
+ if(tok.kind == sym){
+ difference++;
+ }
+ }
+ for(int sym : rightTokens){
+ if(tok.kind == sym){
+ difference--;
+ }
+ }
+ if(difference != 0){
+ if (tok.image != null) {
+ s.append(tok.image);
+ }
+ getNextToken();
+ }
+ }
+ return s.toString().trim();
}
String skipStatementUntil(int[] symbols) throws ParseException {
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 9e1b781a6a..44e06a33b1 100644
--- a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj
+++ b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj
@@ -1445,7 +1445,7 @@ boolean isPseudoElement = false;
}
}
}
- | ( n=<FUNCTION> ( <S> )* d=skipStatementUntilRightParan() <RPARAN>
+ | ( n=<FUNCTION> ( <S> )* d=skipStatementUntilMatchingRightParan() <RPARAN>
{
// accept anything between function and a right parenthesis
String f = convertIdent(n.image);
@@ -2842,9 +2842,35 @@ String skipStatementUntilLeftBrace(){
}
JAVACODE
-String skipStatementUntilRightParan(){
- int[] rParan = {RPARAN};
- return skipStatementUntil(rParan);
+String skipStatementUntilMatchingRightParan(){
+ int[] leftTokens = {LPARAN, FUNCTION}; // a FUNCTION also contains "("
+ int[] rightTokens = {RPARAN};
+ StringBuffer s = new StringBuffer();
+ int difference = 1;
+ Token tok;
+ while(difference != 0){
+ tok = getToken(1);
+ if(tok.kind == EOF) {
+ return null;
+ }
+ for(int sym : leftTokens){
+ if(tok.kind == sym){
+ difference++;
+ }
+ }
+ for(int sym : rightTokens){
+ if(tok.kind == sym){
+ difference--;
+ }
+ }
+ if(difference != 0){
+ if (tok.image != null) {
+ s.append(tok.image);
+ }
+ getNextToken();
+ }
+ }
+ return s.toString().trim();
}
JAVACODE
diff --git a/theme-compiler/tests/resources/w3ctests/scss/css3-modsel-67.0.scss b/theme-compiler/tests/resources/w3ctests/scss/css3-modsel-67.0.scss
new file mode 100644
index 0000000000..4e177b1149
--- /dev/null
+++ b/theme-compiler/tests/resources/w3ctests/scss/css3-modsel-67.0.scss
@@ -0,0 +1,3 @@
+/* Source: http://www.w3.org/Style/CSS/Test/CSS3/Selectors/current/html/tests/css3-modsel-67.html */
+div.stub * { background-color : red }
+div.stub *:not(:lang(fr)) { background-color : green }