forked from SomMeri/less4j
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Solving js interpolation for SomMeri#22. It is as general as possible…
…, to allow different languages support.
- Loading branch information
Showing
15 changed files
with
171 additions
and
36 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
src/main/java/com/github/sommeri/less4j/EmbeddedScripting.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,9 @@ | ||
package com.github.sommeri.less4j; | ||
|
||
import com.github.sommeri.less4j.core.ast.Expression; | ||
|
||
public interface EmbeddedScripting { | ||
|
||
String toScriptExpression(Expression value, LessProblems problemsHandler); | ||
|
||
} |
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
20 changes: 20 additions & 0 deletions
20
src/main/java/com/github/sommeri/less4j/LessStringsEvaluator.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,20 @@ | ||
package com.github.sommeri.less4j; | ||
|
||
import com.github.sommeri.less4j.core.ast.Expression; | ||
import com.github.sommeri.less4j.utils.InStringCssPrinter; | ||
|
||
public class LessStringsEvaluator implements EmbeddedScripting { | ||
|
||
public LessStringsEvaluator() { | ||
super(); | ||
} | ||
|
||
@Override | ||
public String toScriptExpression(Expression value, LessProblems problemsHandler) { | ||
InStringCssPrinter builder = new InStringCssPrinter(); | ||
builder.append(value); | ||
String replacement = builder.toString(); | ||
return replacement; | ||
} | ||
|
||
} |
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, SELECTOR_OPERATOR, SELECTOR_COMBINATOR, EXPRESSION_OPERATOR, NTH, NAMED_EXPRESSION, MEDIA_QUERY, FIXED_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, REUSABLE_STRUCTURE_NAME, VIEWPORT, GENERAL_BODY, PAGE, NAME, PAGE_MARGIN_BOX, IMPORT, FAULTY_NODE, ANONYMOUS, EMPTY_EXPRESSION, SYNTAX_ONLY_ELEMENT, UNICODE_RANGE_EXPRESSION, INTERPOLATED_MEDIA_EXPRESSION, DOCUMENT, SUPPORTS, SUPPORTS_QUERY, SUPPORTS_CONDITION_NEGATION, SUPPORTS_CONDITION_PARENTHESES, SUPPORTS_CONDITION_LOGICAL, SUPPORTS_LOGICAL_OPERATOR, EXTEND, INLINE_CONTENT | ||
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, SELECTOR_OPERATOR, SELECTOR_COMBINATOR, EXPRESSION_OPERATOR, NTH, NAMED_EXPRESSION, MEDIA_QUERY, FIXED_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, REUSABLE_STRUCTURE_NAME, VIEWPORT, GENERAL_BODY, PAGE, NAME, PAGE_MARGIN_BOX, IMPORT, FAULTY_NODE, ANONYMOUS, EMPTY_EXPRESSION, SYNTAX_ONLY_ELEMENT, UNICODE_RANGE_EXPRESSION, INTERPOLATED_MEDIA_EXPRESSION, DOCUMENT, SUPPORTS, SUPPORTS_QUERY, SUPPORTS_CONDITION_NEGATION, SUPPORTS_CONDITION_PARENTHESES, SUPPORTS_CONDITION_LOGICAL, SUPPORTS_LOGICAL_OPERATOR, EXTEND, INLINE_CONTENT, EMBEDDED_SCRIPT | ||
} |
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
46 changes: 46 additions & 0 deletions
46
src/main/java/com/github/sommeri/less4j/core/ast/EmbeddedScript.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,46 @@ | ||
package com.github.sommeri.less4j.core.ast; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import com.github.sommeri.less4j.core.ast.annotations.NotAstProperty; | ||
import com.github.sommeri.less4j.core.parser.HiddenTokenAwareTree; | ||
|
||
public class EmbeddedScript extends Expression { | ||
|
||
private String value; | ||
|
||
public EmbeddedScript(HiddenTokenAwareTree token, String value) { | ||
super(token); | ||
this.value = value; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
|
||
public void setValue(String value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public ASTCssNodeType getType() { | ||
return ASTCssNodeType.EMBEDDED_SCRIPT; | ||
} | ||
|
||
@Override | ||
@NotAstProperty | ||
public List<? extends ASTCssNode> getChilds() { | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public EmbeddedScript clone() { | ||
return (EmbeddedScript) super.clone(); | ||
} | ||
} |
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
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
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
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
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
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.