ソースを参照

Selector now can begin with a combinator. (Ticket #10754)

Change-Id: Id2f1a006e4caaf790f573ee823fcc41312f30261
tags/7.0.1
Haijian Wang 11年前
コミット
cc5252a98e

+ 1118
- 1144
theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java
ファイル差分が大きすぎるため省略します
ファイルの表示


+ 28
- 19
theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj ファイルの表示

@@ -1058,9 +1058,6 @@ void skipUnknownRule() :
| n=<UNICODERANGE>
| n=<URL>
| n=";"
| n="+"
| n=">"
| n="~"
| n="-"
| n=<UNKNOWN>
) {
@@ -1083,13 +1080,18 @@ char combinator() :
char connector = ' ';
}
{
"+" ( <S> )* { return '+'; }
| ">" ( <S> )* { return '>'; }
| "~" ( <S> )* { return '~'; }
| <S> ( ( "+" { connector = '+'; }
| ">" { connector = '>'; }
| "~" { connector = '~'; } )
( <S> )* )? { return connector; }
(connector = combinatorChar()
| <S> (connector = combinatorChar())?) { return connector; }
}

/**to refactor combinator and reuse in selector().*/
char combinatorChar() :
{Token t;}
{
(t = <PLUS> | t = <PRECEDES> | t = <SIBLING>) (<S>)*
{
return t.image.charAt(0);
}
}

void microsoftExtension() :
@@ -1202,12 +1204,14 @@ void styleRule() :
*/
String selector() :
{
String selector;
String selector = null;
char comb;
}
{
try {
selector=simple_selector(null, ' ')
// the selector can begin either a simple_selector, or a combinatorChar(+, >, ~).
// when beginning with combinatorChar, the next one should be a simple_selector().
(selector=simple_selector(null, ' ') | (comb=combinatorChar() selector=simple_selector(selector, comb)))
( LOOKAHEAD(2) comb=combinator()
selector=simple_selector(selector, comb) )* (<S>)*
{
@@ -1267,22 +1271,27 @@ String simple_selector(String selector, char comb) :
if (cond != null) {
simple_current = simple_current + cond;
}
if (selector != null) {
switch (comb) {
StringBuilder builder = new StringBuilder();
switch (comb) {
case ' ':
selector = selector + comb + simple_current;
if(selector!=null){
builder.append(selector).append(" ");
}
break;
case '+':
case '>':
case '~':
selector = selector + " " + comb + " " + simple_current;
if(selector!=null){
builder.append(selector).append(" ");
}
builder.append(comb).append(" ");
break;
default:
throw new ParseException("invalid state. send a bug report");
}
} else {
selector= simple_current;
}
builder.append(simple_current);
selector = builder.toString();
if (pseudoElt != null) {
selector = selector + pseudoElt;
}

+ 15
- 15
theme-compiler/src/com/vaadin/sass/internal/parser/ParserTokenManager.java ファイルの表示

@@ -1,3 +1,18 @@
/*
* 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;

@@ -5835,21 +5850,6 @@ public class ParserTokenManager implements ParserConstants {
int jjmatchedPos;
int jjmatchedKind;

/*
* 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.
*/
/** Get the next Token. */
public Token getNextToken() {
Token specialToken = null;

+ 9
- 0
theme-compiler/tests/resources/automatic/css/nested-selector-begin-with-plus.css ファイルの表示

@@ -0,0 +1,9 @@
.v-panel {
display: block;
max-width: 84em;
margin: auto;
}
.v-panel + .abc {
margin-top: 1em;
}

+ 9
- 0
theme-compiler/tests/resources/automatic/scss/nested-selector-begin-with-plus.scss ファイルの表示

@@ -0,0 +1,9 @@
.v-panel {
display: block;
max-width: 84em;
margin: auto;
+ .abc {
margin-top: 1em;
}
}

theme-compiler/tests/resources/sasslangbroken/css/95-test_nested_selector_with_child_selector_hack_extender_and_sibling_selector_extendee.css → theme-compiler/tests/resources/sasslang/css/95-test_nested_selector_with_child_selector_hack_extender_and_sibling_selector_extendee.css ファイルの表示


theme-compiler/tests/resources/sasslangbroken/scss/95-test_nested_selector_with_child_selector_hack_extender_and_sibling_selector_extendee.scss → theme-compiler/tests/resources/sasslang/scss/95-test_nested_selector_with_child_selector_hack_extender_and_sibling_selector_extendee.scss ファイルの表示


読み込み中…
キャンセル
保存