forked from Wilfred/difftastic
-
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.
feat: Improve highlights (Wilfred#18)
* refactor: replace (expr) with more specific names * chore: make generate * feat: add/improve queries * docs: add syntax.jsonnet example
- Loading branch information
Showing
16 changed files
with
16,861 additions
and
11,157 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Example file with all(?) possible components from the syntax | ||
|
||
local object = { | ||
'null': null, | ||
'true': true, | ||
'false': false, | ||
string: 'string', | ||
number: 5, | ||
array: [ | ||
null, | ||
true, | ||
false, | ||
'string', | ||
1.5, | ||
], | ||
|
||
forloop: [ | ||
i | ||
for i in std.range(0, 9) | ||
], | ||
|
||
objforloop: { | ||
['index' + i]: i | ||
for i in std.range(0, 9) | ||
if (i % 2) == 0 // binaryop: multiplicative and equality | ||
}, | ||
|
||
fieldaccess: self.string, | ||
indexing: self.forloop[self.number], | ||
indexing_obj: self.objforloop['index' + '0'], | ||
indexing_slice: self.forloop[2:8:2], | ||
|
||
binaryop_equality: self.string == 'string', | ||
conditional_in_parenthesis: | ||
(if self.binaryop_equality && true // binaryop: AND | ||
then 'condition true' | ||
else 'condition false'), | ||
|
||
local objlocal = false || true, // binaryop: OR | ||
unaryop: !objlocal, | ||
|
||
anonymous_function:: function(arg, default='v') arg + default, | ||
regular_func(arg):: $.string + ' ' + arg, | ||
|
||
assert true : 'assert instide object', | ||
|
||
'import':: import 'file.json', | ||
'importstr':: import 'file.txt', | ||
err:: error 'message', | ||
}; | ||
|
||
assert true : 'assert outside object'; | ||
|
||
object + { | ||
fieldaccess_super: super.number, | ||
indexing_super: super.array[2 * 2], // binaryop: multiplicative | ||
|
||
functioncall_1: super.anonymous_function('echo 1'), | ||
|
||
functioncall_2: self.regular_func(arg='echo 2') tailstrict, | ||
|
||
local localfunc(arg) = { | ||
local notarg = 'value', | ||
a: notarg, // not a parameter reference | ||
b: arg, // parameter reference | ||
[arg]: arg, // parameter reference in fieldname | ||
}, | ||
functioncall_3: localfunc('echo 3'), // function reference | ||
|
||
in_super: 'keynotfound' in super, | ||
|
||
array+: ['another item'], | ||
objforloop+: { another: 'item' }, | ||
|
||
['fieldname_expr' + (5 - object.objforloop.index2)]: 'value', | ||
[if object.string == 'string' then 'conditional_key']: 'value', | ||
} |
Oops, something went wrong.