diff options
-rw-r--r-- | sass/src/com/vaadin/sass/handler/SCSSDocumentHandlerImpl.java | 4 | ||||
-rw-r--r-- | sass/src/com/vaadin/sass/parser/Parser.java | 63 | ||||
-rw-r--r-- | sass/src/com/vaadin/sass/parser/Parser.jj | 8 | ||||
-rw-r--r-- | sass/src/com/vaadin/sass/tree/CommentNode.java | 22 | ||||
-rw-r--r-- | tests/sass/resources/css/comments.css (renamed from tests/sass/resources/basic/comments.css) | 2 | ||||
-rw-r--r-- | tests/sass/resources/scss/comments.scss | 12 | ||||
-rw-r--r-- | tests/sass/src/com/vaadin/sass/CssTestSuite.java | 4 | ||||
-rw-r--r-- | tests/sass/src/com/vaadin/sass/ScssTestSuite.java | 3 | ||||
-rw-r--r-- | tests/sass/src/com/vaadin/sass/testcases/css/Comments.java | 23 | ||||
-rw-r--r-- | tests/sass/src/com/vaadin/sass/testcases/scss/Comments.java | 43 |
10 files changed, 125 insertions, 59 deletions
diff --git a/sass/src/com/vaadin/sass/handler/SCSSDocumentHandlerImpl.java b/sass/src/com/vaadin/sass/handler/SCSSDocumentHandlerImpl.java index f4e9398599..ccfa327829 100644 --- a/sass/src/com/vaadin/sass/handler/SCSSDocumentHandlerImpl.java +++ b/sass/src/com/vaadin/sass/handler/SCSSDocumentHandlerImpl.java @@ -13,6 +13,7 @@ import org.w3c.css.sac.SelectorList; import com.vaadin.sass.ScssStylesheet; import com.vaadin.sass.tree.BlockNode; +import com.vaadin.sass.tree.CommentNode; import com.vaadin.sass.tree.EachNode; import com.vaadin.sass.tree.ExtendNode; import com.vaadin.sass.tree.ForNode; @@ -123,7 +124,8 @@ public class SCSSDocumentHandlerImpl implements SCSSDocumentHandler { @Override public void comment(String text) throws CSSException { - System.out.println("comment(String text): " + text); + CommentNode node = new CommentNode(text); + nodeStack.peek().appendChild(node); } @Override diff --git a/sass/src/com/vaadin/sass/parser/Parser.java b/sass/src/com/vaadin/sass/parser/Parser.java index df70d812aa..cc9c39176e 100644 --- a/sass/src/com/vaadin/sass/parser/Parser.java +++ b/sass/src/com/vaadin/sass/parser/Parser.java @@ -556,6 +556,9 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { label_7: while (true) { ; + if(token.specialToken!=null){ + documentHandler.comment(token.specialToken.image); + } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case VARIABLE: variable(); @@ -4142,36 +4145,6 @@ LexicalUnit exp; finally { jj_save(3, xla); } } - private boolean jj_3R_130() { - 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_129() { - if (jj_scan_token(DIV)) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { jj_scanpos = xsp; break; } - } - return false; - } - - private boolean jj_3R_119() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_129()) { - jj_scanpos = xsp; - if (jj_3R_130()) return true; - } - return false; - } - private boolean jj_3R_168() { if (jj_scan_token(UNICODERANGE)) return true; return false; @@ -4694,6 +4667,36 @@ LexicalUnit exp; return false; } + private boolean jj_3R_130() { + 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_129() { + if (jj_scan_token(DIV)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_119() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_129()) { + jj_scanpos = xsp; + if (jj_3R_130()) return true; + } + return false; + } + /** Generated Token Manager. */ public ParserTokenManager token_source; /** Current token. */ diff --git a/sass/src/com/vaadin/sass/parser/Parser.jj b/sass/src/com/vaadin/sass/parser/Parser.jj index 67fe870e03..2f43be5f6e 100644 --- a/sass/src/com/vaadin/sass/parser/Parser.jj +++ b/sass/src/com/vaadin/sass/parser/Parser.jj @@ -731,7 +731,13 @@ void afterImportDeclaration() : Locator l; } { - ( ( variable() | mixinDirective() | includeDirective() | styleRule() | media()| page() | fontFace() + ( + { + if(token.specialToken!=null){ + documentHandler.comment(token.specialToken.image); + } + } + ( variable() | mixinDirective() | includeDirective() | styleRule() | media()| page() | fontFace() | { l = getLocator(); } ret=skipStatement() { if ((ret == null) || (ret.length() == 0)) { diff --git a/sass/src/com/vaadin/sass/tree/CommentNode.java b/sass/src/com/vaadin/sass/tree/CommentNode.java new file mode 100644 index 0000000000..442e5f995e --- /dev/null +++ b/sass/src/com/vaadin/sass/tree/CommentNode.java @@ -0,0 +1,22 @@ +package com.vaadin.sass.tree; + +public class CommentNode extends Node { + private String comment; + + public CommentNode(String comment) { + this.comment = comment; + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + + @Override + public String toString() { + return comment.trim(); + } +} diff --git a/tests/sass/resources/basic/comments.css b/tests/sass/resources/css/comments.css index 96d6b312c8..32f348da9e 100644 --- a/tests/sass/resources/basic/comments.css +++ b/tests/sass/resources/css/comments.css @@ -1,3 +1,5 @@ +/** 0sprite: verticals; sprite-image: url(../common/img/vertical-sprites.png); sprite-layout: vertical */ +/** 1sprite: verticals; sprite-image: url(../common/img/vertical-sprites.png); sprite-layout: vertical */ .v-button:focus { background-image: url(img/left-focus.png);/** sprite-ref: buttons */ outline: none; diff --git a/tests/sass/resources/scss/comments.scss b/tests/sass/resources/scss/comments.scss new file mode 100644 index 0000000000..7e2ccac3b5 --- /dev/null +++ b/tests/sass/resources/scss/comments.scss @@ -0,0 +1,12 @@ +/** 0sprite: verticals; sprite-image: url(../common/img/vertical-sprites.png); sprite-layout: vertical */ +$black:#000000; +/** 1sprite: verticals; sprite-image: url(../common/img/vertical-sprites.png); sprite-layout: vertical */ +.v-button:focus { + background-image: url(img/left-focus.png);/** sprite-ref: buttons */ + outline: none; +} + +.v-button:focus .v-button-wrap { + background-image: url(img/right-focus.png);/** sprite-ref: buttons; sprite-alignment: right */ + outline: none; +}
\ No newline at end of file diff --git a/tests/sass/src/com/vaadin/sass/CssTestSuite.java b/tests/sass/src/com/vaadin/sass/CssTestSuite.java index e15da68e0c..0ee1f79450 100644 --- a/tests/sass/src/com/vaadin/sass/CssTestSuite.java +++ b/tests/sass/src/com/vaadin/sass/CssTestSuite.java @@ -4,14 +4,12 @@ import org.junit.runner.RunWith; import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; -import com.vaadin.sass.testcases.css.Comments; import com.vaadin.sass.testcases.css.Media; import com.vaadin.sass.testcases.css.Properties; import com.vaadin.sass.testcases.css.Reindeer; import com.vaadin.sass.testcases.css.Selectors; @RunWith(Suite.class) -@SuiteClasses({ Selectors.class, Properties.class, Reindeer.class, Media.class, - Comments.class }) +@SuiteClasses({ Selectors.class, Properties.class, Reindeer.class, Media.class, }) public class CssTestSuite { } diff --git a/tests/sass/src/com/vaadin/sass/ScssTestSuite.java b/tests/sass/src/com/vaadin/sass/ScssTestSuite.java index 9ab0a76597..5a5351577d 100644 --- a/tests/sass/src/com/vaadin/sass/ScssTestSuite.java +++ b/tests/sass/src/com/vaadin/sass/ScssTestSuite.java @@ -4,6 +4,7 @@ import org.junit.runner.RunWith; import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; +import com.vaadin.sass.testcases.scss.Comments; import com.vaadin.sass.testcases.scss.ControlDirectives; import com.vaadin.sass.testcases.scss.Extends; import com.vaadin.sass.testcases.scss.Functions; @@ -20,7 +21,7 @@ import com.vaadin.sass.tree.ImportNodeTest; @SuiteClasses({ ControlDirectives.class, Extends.class, Functions.class, ImportNodeTest.class, Imports.class, Mixins.class, NestedProperties.class, Nesting.class, ParentImports.class, - Variables.class, ParentSelector.class }) + Variables.class, ParentSelector.class, Comments.class }) public class ScssTestSuite { } diff --git a/tests/sass/src/com/vaadin/sass/testcases/css/Comments.java b/tests/sass/src/com/vaadin/sass/testcases/css/Comments.java deleted file mode 100644 index c0690418e2..0000000000 --- a/tests/sass/src/com/vaadin/sass/testcases/css/Comments.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.vaadin.sass.testcases.css; - -import java.io.IOException; -import java.net.URISyntaxException; - -import junit.framework.Assert; - -import org.junit.Test; -import org.w3c.css.sac.CSSException; - -import com.vaadin.sass.TestBase; - -public class Comments extends TestBase { - String css = "/basic/comments.css"; - - @Test - public void testParser() throws CSSException, URISyntaxException, - IOException { - testParser(css); - Assert.assertEquals("Original CSS and parsed CSS doesn't match", - originalScss, parsedScss); - } -} diff --git a/tests/sass/src/com/vaadin/sass/testcases/scss/Comments.java b/tests/sass/src/com/vaadin/sass/testcases/scss/Comments.java new file mode 100644 index 0000000000..bca87d268f --- /dev/null +++ b/tests/sass/src/com/vaadin/sass/testcases/scss/Comments.java @@ -0,0 +1,43 @@ +package com.vaadin.sass.testcases.scss; + +import java.io.IOException; +import java.net.URISyntaxException; + +import junit.framework.Assert; + +import org.junit.Test; +import org.w3c.css.sac.CSSException; + +import com.vaadin.sass.ScssStylesheet; +import com.vaadin.sass.TestBase; +import com.vaadin.sass.handler.SCSSDocumentHandler; +import com.vaadin.sass.handler.SCSSDocumentHandlerImpl; +import com.vaadin.sass.parser.Parser; +import com.vaadin.sass.tree.CommentNode; + +public class Comments extends TestBase { + String scss = "/scss/comments.scss"; + String css = "/scss/comments.css"; + + @Test + public void testParser() throws CSSException, URISyntaxException, + IOException { + Parser parser = new Parser(); + SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl(); + parser.setDocumentHandler(handler); + parser.parseStyleSheet(getClass().getResource(scss).getPath()); + ScssStylesheet root = handler.getStyleSheet(); + Assert.assertNotNull(root); + Assert.assertEquals(5, root.getChildren().size()); + Assert.assertTrue(root.getChildren().get(0) instanceof CommentNode); + Assert.assertTrue(root.getChildren().get(2) instanceof CommentNode); + } + + @Test + public void testCompiler() throws CSSException, URISyntaxException, + IOException { + testCompiler(scss, css); + Assert.assertEquals("Original CSS and parsed CSS doesn't match", + comparisonCss, parsedScss); + } +} |