Files
RedBear-OS/local/recipes/kde/kf6-syntaxhighlighting/source/autotests/folding/highlight.jsonnet.fold
T

103 lines
4.7 KiB
Plaintext

local utils = import <beginfold id='1'>'</beginfold id='1'>utils.libsonnet<endfold id='1'>'</endfold id='1'>;
<beginfold id='2'>/*</beginfold id='2'> A C-style
comment.
<endfold id='2'>*/</endfold id='2'>
# A Python-style comment.
// Define a "local" function.
// Default arguments are like Python:
local my_function(x, y=10) = x + y;
local object = <beginfold id='3'>{</beginfold id='3'>
// A method
my_method(x): x * x,
<endfold id='3'>}</endfold id='3'>;
local string1 = <beginfold id='1'>'</beginfold id='1'>Farmer\'s Gin<endfold id='1'>'</endfold id='1'>;
local string_newline1 = <beginfold id='1'>'</beginfold id='1'>this is
a valid string
with newlines<endfold id='1'>'</endfold id='1'>;
local string_newline2 = <beginfold id='4'>"</beginfold id='4'>this is
also
a valid string<endfold id='4'>"</endfold id='4'>;
local timcollins = <beginfold id='5'>|||</beginfold id='5'>
The Tom Collins is essentially gin and
lemonade. The bitters add complexity.
<endfold id='5'>|||</endfold id='5'>;
local obj = <beginfold id='3'>{</beginfold id='3'>
<beginfold id='4'>"</beginfold id='4'>foo<endfold id='4'>"</endfold id='4'>: 1,
<beginfold id='4'>"</beginfold id='4'>bar<endfold id='4'>"</endfold id='4'>: <beginfold id='3'>{</beginfold id='3'>
<beginfold id='4'>"</beginfold id='4'>arr<endfold id='4'>"</endfold id='4'>: <beginfold id='6'>[</beginfold id='6'>1, 2, 3<endfold id='6'>]</endfold id='6'>,
<beginfold id='4'>"</beginfold id='4'>number<endfold id='4'>"</endfold id='4'>: 10 + 7,
<endfold id='3'>}</endfold id='3'>,
<endfold id='3'>}</endfold id='3'>;
// Define a local function.
// Default arguments are like Python:
local my_function(x, y=10) = x + y;
// Define a local multiline function.
local multiline_function(x) =
// One can nest locals.
local temp = x * 2;
// Every local ends with a semi-colon.
<beginfold id='6'>[</beginfold id='6'>temp, temp + 1<endfold id='6'>]</endfold id='6'>;
local object = <beginfold id='3'>{</beginfold id='3'>
// A method
my_method(x): x * x,
<endfold id='3'>}</endfold id='3'>;
local large = true;
<beginfold id='3'>{</beginfold id='3'>
// Functions are first class citizens.
call_inline_function:
(function(x) x * x)(5),
call_multiline_function: multiline_function(4),
// Using the variable fetches the function,
// the parens call the function.
call: my_function(2),
// Like python, parameters can be named at
// call time.
named_params: my_function(x=2),
// This allows changing their order
named_params2: my_function(y=3, x=2),
// object.my_method returns the function,
// which is then called like any other.
call_method1: object.my_method(3),
standard_lib:
std.join(<beginfold id='1'>'</beginfold id='1'> <endfold id='1'>'</endfold id='1'>, std.split(<beginfold id='4'>"</beginfold id='4'>foo/bar<endfold id='4'>"</endfold id='4'>, <beginfold id='1'>'</beginfold id='1'>/<endfold id='1'>'</endfold id='1'>)),
len: <beginfold id='6'>[</beginfold id='6'>
std.length(<beginfold id='1'>'</beginfold id='1'>hello<endfold id='1'>'</endfold id='1'>),
std.length(<beginfold id='6'>[</beginfold id='6'>1, 2, 3<endfold id='6'>]</endfold id='6'>),
<endfold id='6'>]</endfold id='6'>,
cocktails: <beginfold id='3'>{</beginfold id='3'>
local factor = if large then 2 else 1,
// Ingredient quantities are in fl oz.
<beginfold id='1'>'</beginfold id='1'>Tom Collins<endfold id='1'>'</endfold id='1'>: <beginfold id='3'>{</beginfold id='3'>
ingredients: <beginfold id='6'>[</beginfold id='6'>
<beginfold id='3'>{</beginfold id='3'> kind: string1, qty: 1.5*factor <endfold id='3'>}</endfold id='3'>,
<beginfold id='3'>{</beginfold id='3'> kind: <beginfold id='1'>'</beginfold id='1'>Lemon<endfold id='1'>'</endfold id='1'>, qty: 1 <endfold id='3'>}</endfold id='3'>,
<beginfold id='3'>{</beginfold id='3'> kind: <beginfold id='1'>'</beginfold id='1'>Simple Syrup<endfold id='1'>'</endfold id='1'>, qty: 0.5E+1 <endfold id='3'>}</endfold id='3'>,
<beginfold id='3'>{</beginfold id='3'> kind: <beginfold id='1'>'</beginfold id='1'>Soda<endfold id='1'>'</endfold id='1'>, qty: 2 <endfold id='3'>}</endfold id='3'>,
<beginfold id='3'>{</beginfold id='3'> kind: <beginfold id='1'>'</beginfold id='1'>Angostura<endfold id='1'>'</endfold id='1'>, qty: <beginfold id='1'>'</beginfold id='1'>dash<endfold id='1'>'</endfold id='1'> <endfold id='3'>}</endfold id='3'>,
<endfold id='6'>]</endfold id='6'>,
garnish: <beginfold id='1'>'</beginfold id='1'>Maraschino Cherry<endfold id='1'>'</endfold id='1'>,
served: <beginfold id='1'>'</beginfold id='1'>Tall<endfold id='1'>'</endfold id='1'>,
description: timcollins,
<endfold id='3'>}</endfold id='3'>,
<endfold id='3'>}</endfold id='3'>,
<endfold id='3'>}</endfold id='3'>