UIDefaultsLoader: added if() function (inspired by Less CSS)

This commit is contained in:
Karl Tauber
2021-09-26 23:54:06 +02:00
parent 36d5747fbf
commit a4ea88f4be
4 changed files with 83 additions and 3 deletions

View File

@@ -405,6 +405,13 @@ class FlatCompletionProvider
setParameterizedCompletionParams( '(', ",", ')' );
setParameterChoicesProvider( this );
addFunction( "if",
"condition", "evaluates to true if: is not \"null\" and is not \"false\" and is not an integer with zero value",
"trueValue", "used if condition is true",
"falseValue", "used if condition is false" );
addFunction( "lazy",
"uiKey", "UI key (without leading '$')" );
addFunction( "rgb",
"red", "0-255 or 0-100%",
"green", "0-255 or 0-100%",

View File

@@ -51,7 +51,11 @@ public class FlatThemeTokenMaker
tokenMap.put( "false", Token.LITERAL_BOOLEAN );
tokenMap.put( "true", Token.LITERAL_BOOLEAN );
// functions
// general functions
tokenMap.put( "if", TOKEN_FUNCTION );
tokenMap.put( "lazy", TOKEN_FUNCTION );
// color functions
tokenMap.put( "rgb", TOKEN_FUNCTION );
tokenMap.put( "rgba", TOKEN_FUNCTION );
tokenMap.put( "hsl", TOKEN_FUNCTION );
@@ -72,7 +76,6 @@ public class FlatThemeTokenMaker
tokenMap.put( "tint", TOKEN_FUNCTION );
tokenMap.put( "shade", TOKEN_FUNCTION );
tokenMap.put( "contrast", TOKEN_FUNCTION );
tokenMap.put( "lazy", TOKEN_FUNCTION );
// function options
tokenMap.put( "relative", Token.RESERVED_WORD );