</javac>
</target>
+ <target name="compile-sass-parser">
+ <javacc target="${parserDir}/Parser.jj" javacchome="${JavaCChome}">
+ </javacc>
+ </target>
+
<target name="compile-sass" depends="init, preprocess-src">
<!-- TODO also perform javacc compilation of the parser -->
<mkdir dir="${result-classes-sass}" />
<property name="deps.initialized" value="${deps.initialized}"/>
</ant>
</target>
+
</project>
<!-- These are for emacs. -->
import com.vaadin.sass.parser.SelectorListImpl;
import com.vaadin.sass.selector.SelectorUtil;
+import com.vaadin.sass.util.Clonable;
+import com.vaadin.sass.util.DeepCopy;
-public class BlockNode extends Node {
+public class BlockNode extends Node implements Clonable {
private static final long serialVersionUID = 5742962631468325048L;
}
@Override
- protected Object clone() throws CloneNotSupportedException {
- SelectorListImpl clonedSelectorList = new SelectorListImpl();
+ public Object clone() throws CloneNotSupportedException {
+
+ SelectorListImpl clonedSelectorList = null;
+
+ if (selectorList != null) {
+ clonedSelectorList = new SelectorListImpl();
for (int i = 0; i < selectorList.getLength(); i++) {
clonedSelectorList.addSelector(selectorList.item(i));
}
- return null;
- // BlockNode clone = new BlockNode()
}
+ final BlockNode clone = new BlockNode(clonedSelectorList);
+ for (Node child : getChildren()) {
+ clone.getChildren().add((Node) DeepCopy.copy(child));
+ }
+ return clone;
+ }
+
}
--- /dev/null
+package com.vaadin.sass.util;
+
+public interface Clonable {
+
+ public Object clone() throws CloneNotSupportedException;
+
+}
* Returns a copy of the object, or null if the object cannot be serialized.
*/
public static Object copy(Object orig) {
+
Object obj = null;
+ if (!(orig instanceof Clonable)) {
try {
// Write the object out to a byte array
FastByteArrayOutputStream fbos = new FastByteArrayOutputStream();
// Retrieve an input stream from the byte array and read
// a copy of the object back in.
- ObjectInputStream in = new ObjectInputStream(fbos.getInputStream());
+ ObjectInputStream in = new ObjectInputStream(
+ fbos.getInputStream());
obj = in.readObject();
in.close();
} catch (IOException e) {
cnfe.printStackTrace();
}
return obj;
+ } else {
+ try {
+ obj = ((Clonable) orig).clone();
+ } catch (ClassCastException e2) {
+ // Can't clone, return obj as null
+ } catch (CloneNotSupportedException e2) {
+ // Can't clone, return obj as null
+ }
+ return obj;
+ }
}
}
\ No newline at end of file
font-weight: bold;
}
+.main .details {
+ font-size: 14px;
+ font-weight: bold;
+}
+
.footer {
border: 2px solid black;
-webkit-border-radius: 10px;
.main {
@include rounded-borders(1px);
@include font-settings;
+ @include main-details(14px);
}
.footer {
}
@include font-settings;
}
+
+@mixin main-details($size){
+ .details {
+ font: {
+ size : $size;
+ weight: bold;
+ }
+ }
+}
+
@include layout;
\ No newline at end of file
Assert.assertEquals(4, mixinDefNode1.getChildren().size());
BlockNode mainBlockNode = (BlockNode) root.getChildren().get(2);
- Assert.assertEquals(2, mainBlockNode.getChildren().size());
+ Assert.assertEquals(3, mainBlockNode.getChildren().size());
MixinNode mixinNode0MainBlock = (MixinNode) mainBlockNode.getChildren()
.get(0);
Assert.assertEquals("rounded-borders", mixinNode0MainBlock.getName());
Assert.assertEquals("font-settings", mixinNOde1MainBlock.getName());
Assert.assertTrue(mixinNOde1MainBlock.getArglist().isEmpty());
+ MixinNode mixinNOde2MainBlock = (MixinNode) mainBlockNode.getChildren()
+ .get(2);
+ Assert.assertEquals("main-details", mixinNOde2MainBlock.getName());
+ Assert.assertTrue(mixinNOde1MainBlock.getArglist().isEmpty());
+
MixinNode mixinNode1MainBlock = (MixinNode) mainBlockNode.getChildren()
.get(1);
Assert.assertTrue(mixinNode1MainBlock.getArglist().isEmpty());
Assert.assertTrue(root.getChildren().get(4).getChildren().get(3) instanceof MediaNode);
Assert.assertTrue(root.getChildren().get(4).getChildren().get(4) instanceof MixinNode);
- MixinNode topLevelMixin = (MixinNode) root.getChildren().get(5);
- Assert.assertEquals("layout", topLevelMixin.getName());
-
}
@Test