-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic support for import: place import declarations on top of input file
- Loading branch information
meri
committed
Jan 10, 2013
1 parent
a448013
commit 6014a78
Showing
13 changed files
with
287 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/com/github/sommeri/less4j/core/ast/ASTCssNodeType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package com.github.sommeri.less4j.core.ast; | ||
|
||
public enum ASTCssNodeType { | ||
UNKNOWN, CSS_CLASS, DECLARATION, STYLE_SHEET, RULE_SET, SELECTOR, SIMPLE_SELECTOR, PSEUDO_CLASS, PSEUDO_ELEMENT, SELECTOR_ATTRIBUTE, ID_SELECTOR, CHARSET_DECLARATION, FONT_FACE, IDENTIFIER_EXPRESSION, COMPOSED_EXPRESSION, STRING_EXPRESSION, NUMBER, COLOR_EXPRESSION, FUNCTION, MEDIA, COMMENT, DECLARATIONS_BODY, SELECTOR_OPERATOR, SELECTOR_COMBINATOR, EXPRESSION_OPERATOR, NTH, NAMED_EXPRESSION, MEDIA_QUERY, MEDIA_EXPRESSION, MEDIUM, MEDIUM_MODIFIER, MEDIUM_TYPE, MEDIUM_EX_FEATURE, VARIABLE_DECLARATION, VARIABLE, INDIRECT_VARIABLE, PARENTHESES_EXPRESSION, SIGNED_EXPRESSION, ARGUMENT_DECLARATION, MIXIN_REFERENCE, GUARD_CONDITION, COMPARISON_EXPRESSION, GUARD, NESTED_SELECTOR_APPENDER, REUSABLE_STRUCTURE, FAULTY_EXPRESSION, ESCAPED_SELECTOR, ESCAPED_VALUE, INTERPOLABLE_NAME, FIXED_NAME_PART, VARIABLE_NAME_PART, KEYFRAMES, KEYFRAMES_NAME, KEYFRAMES_BODY, REUSABLE_STRUCTURE_NAME, VIEWPORT, GENERAL_BODY, PAGE, NAME, PAGE_MA, PAGE_MARGIN_BOX | ||
UNKNOWN, CSS_CLASS, DECLARATION, STYLE_SHEET, RULE_SET, SELECTOR, SIMPLE_SELECTOR, PSEUDO_CLASS, PSEUDO_ELEMENT, SELECTOR_ATTRIBUTE, ID_SELECTOR, CHARSET_DECLARATION, FONT_FACE, IDENTIFIER_EXPRESSION, COMPOSED_EXPRESSION, STRING_EXPRESSION, NUMBER, COLOR_EXPRESSION, FUNCTION, MEDIA, COMMENT, DECLARATIONS_BODY, SELECTOR_OPERATOR, SELECTOR_COMBINATOR, EXPRESSION_OPERATOR, NTH, NAMED_EXPRESSION, MEDIA_QUERY, MEDIA_EXPRESSION, MEDIUM, MEDIUM_MODIFIER, MEDIUM_TYPE, MEDIUM_EX_FEATURE, VARIABLE_DECLARATION, VARIABLE, INDIRECT_VARIABLE, PARENTHESES_EXPRESSION, SIGNED_EXPRESSION, ARGUMENT_DECLARATION, MIXIN_REFERENCE, GUARD_CONDITION, COMPARISON_EXPRESSION, GUARD, NESTED_SELECTOR_APPENDER, REUSABLE_STRUCTURE, FAULTY_EXPRESSION, ESCAPED_SELECTOR, ESCAPED_VALUE, INTERPOLABLE_NAME, FIXED_NAME_PART, VARIABLE_NAME_PART, KEYFRAMES, KEYFRAMES_NAME, KEYFRAMES_BODY, REUSABLE_STRUCTURE_NAME, VIEWPORT, GENERAL_BODY, PAGE, NAME, PAGE_MA, PAGE_MARGIN_BOX, IMPORT | ||
} |
76 changes: 76 additions & 0 deletions
76
src/main/java/com/github/sommeri/less4j/core/ast/Import.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package com.github.sommeri.less4j.core.ast; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.github.sommeri.less4j.core.parser.HiddenTokenAwareTree; | ||
import com.github.sommeri.less4j.utils.ArraysUtils; | ||
|
||
public class Import extends ASTCssNode { | ||
|
||
private ImportKind kind = ImportKind.IMPORT; | ||
private Expression urlExpression; | ||
private List<MediaQuery> mediums = new ArrayList<MediaQuery>(); | ||
|
||
public Import(HiddenTokenAwareTree underlyingStructure) { | ||
super(underlyingStructure); | ||
} | ||
|
||
public ImportKind getKind() { | ||
return kind; | ||
} | ||
|
||
public void setKind(ImportKind kind) { | ||
this.kind = kind; | ||
} | ||
|
||
public Expression getUrlExpression() { | ||
return urlExpression; | ||
} | ||
|
||
public void setUrlExpression(Expression urlExpression) { | ||
this.urlExpression = urlExpression; | ||
} | ||
|
||
public List<MediaQuery> getMediums() { | ||
return mediums; | ||
} | ||
|
||
public void setMediums(List<MediaQuery> mediums) { | ||
this.mediums = mediums; | ||
} | ||
|
||
public void add(MediaQuery medium) { | ||
mediums.add(medium); | ||
} | ||
|
||
@Override | ||
public List<? extends ASTCssNode> getChilds() { | ||
List<ASTCssNode> result = ArraysUtils.asNonNullList((ASTCssNode)urlExpression); | ||
result.addAll(mediums); | ||
return result; | ||
} | ||
|
||
@Override | ||
public Import clone() { | ||
Import result = (Import) super.clone(); | ||
result.urlExpression = urlExpression==null? null : urlExpression.clone(); | ||
result.mediums = ArraysUtils.deeplyClonedList(mediums); | ||
result.configureParentToAllChilds(); | ||
return result; | ||
} | ||
|
||
//@Override | ||
//public String toString() { | ||
//} | ||
|
||
@Override | ||
public ASTCssNodeType getType() { | ||
return ASTCssNodeType.IMPORT; | ||
} | ||
|
||
public enum ImportKind { | ||
IMPORT, IMPORT_ONCE, IMPORT_MULTIPLE | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.