mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
update-scripts: Add more verbose errors for rust-analyzer
This commit is contained in:
parent
e4484133d6
commit
8e9458eacf
1 changed files with 80 additions and 74 deletions
|
@ -37,85 +37,91 @@ let
|
||||||
) options;
|
) options;
|
||||||
|
|
||||||
mkRustAnalyzerOptionType =
|
mkRustAnalyzerOptionType =
|
||||||
nullable: property_name:
|
nullable: property_name: property:
|
||||||
{
|
let
|
||||||
type,
|
inner =
|
||||||
enum ? null,
|
{
|
||||||
minimum ? null,
|
type,
|
||||||
maximum ? null,
|
enum ? null,
|
||||||
items ? null,
|
minimum ? null,
|
||||||
anyOf ? null,
|
maximum ? null,
|
||||||
properties ? null,
|
items ? null,
|
||||||
# Not used in the function, but anyOf values contain it
|
anyOf ? null,
|
||||||
enumDescriptions ? null,
|
properties ? null,
|
||||||
}@property:
|
# Not used in the function, but anyOf values contain it
|
||||||
if enum != null then
|
enumDescriptions ? null,
|
||||||
{
|
}@property:
|
||||||
kind = "enum";
|
if enum != null then
|
||||||
values = enum;
|
{
|
||||||
}
|
kind = "enum";
|
||||||
else if anyOf != null then
|
values = enum;
|
||||||
let
|
}
|
||||||
possibleTypes = lib.filter (sub: !(sub.type == "null" && nullable)) anyOf;
|
else if anyOf != null then
|
||||||
in
|
|
||||||
{
|
|
||||||
kind = "oneOf";
|
|
||||||
subTypes = builtins.map (
|
|
||||||
t: mkRustAnalyzerOptionType nullable "${property_name}-sub" t
|
|
||||||
) possibleTypes;
|
|
||||||
}
|
|
||||||
else if lib.isList type then
|
|
||||||
(
|
|
||||||
if lib.head type == "null" then
|
|
||||||
assert lib.assertMsg (
|
|
||||||
lib.length type == 2
|
|
||||||
) "Lists starting with null are assumed to mean nullOr, so length 2";
|
|
||||||
let
|
let
|
||||||
innerType = property // {
|
possibleTypes = lib.filter (sub: !(sub.type == "null" && nullable)) anyOf;
|
||||||
type = lib.elemAt type 1;
|
|
||||||
};
|
|
||||||
inner = mkRustAnalyzerOptionType nullable "${property_name}-inner" innerType;
|
|
||||||
in
|
|
||||||
assert lib.assertMsg nullable "nullOr types are not yet handled";
|
|
||||||
inner
|
|
||||||
else
|
|
||||||
let
|
|
||||||
innerTypes = builtins.map (
|
|
||||||
t: mkRustAnalyzerOptionType nullable "${property_name}-inner" (property // { type = t; })
|
|
||||||
) type;
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
kind = "oneOf";
|
kind = "oneOf";
|
||||||
subTypes = innerTypes;
|
subTypes = builtins.map (
|
||||||
|
t: mkRustAnalyzerOptionType nullable "${property_name}-sub" t
|
||||||
|
) possibleTypes;
|
||||||
}
|
}
|
||||||
)
|
else if lib.isList type then
|
||||||
else if type == "array" then
|
(
|
||||||
{
|
if lib.head type == "null" then
|
||||||
kind = "list";
|
assert lib.assertMsg (
|
||||||
item = mkRustAnalyzerOptionType false "${property_name}-item" items;
|
lib.length type == 2
|
||||||
}
|
) "Lists starting with null are assumed to mean nullOr, so length 2";
|
||||||
else if type == "number" || type == "integer" then
|
let
|
||||||
{
|
innerType = property // {
|
||||||
kind = type;
|
type = lib.elemAt type 1;
|
||||||
inherit minimum maximum;
|
};
|
||||||
}
|
inner = mkRustAnalyzerOptionType nullable "${property_name}-inner" innerType;
|
||||||
else if type == "object" && properties != null then
|
in
|
||||||
{
|
assert lib.assertMsg nullable "nullOr types are not yet handled";
|
||||||
kind = "submodule";
|
inner
|
||||||
options = lib.mapAttrs (
|
else
|
||||||
name: value: mkRustAnalyzerOptionType false "${property_name}.${name}" value
|
let
|
||||||
) properties;
|
innerTypes = builtins.map (
|
||||||
}
|
t: mkRustAnalyzerOptionType nullable "${property_name}-inner" (property // { type = t; })
|
||||||
else if
|
) type;
|
||||||
lib.elem type [
|
in
|
||||||
"object"
|
{
|
||||||
"string"
|
kind = "oneOf";
|
||||||
"boolean"
|
subTypes = innerTypes;
|
||||||
]
|
}
|
||||||
then
|
)
|
||||||
{ kind = type; }
|
else if type == "array" then
|
||||||
else
|
{
|
||||||
throw "Unhandled value in ${property_name}: ${lib.generators.toPretty { } property}";
|
kind = "list";
|
||||||
|
item = mkRustAnalyzerOptionType false "${property_name}-item" items;
|
||||||
|
}
|
||||||
|
else if type == "number" || type == "integer" then
|
||||||
|
{
|
||||||
|
kind = type;
|
||||||
|
inherit minimum maximum;
|
||||||
|
}
|
||||||
|
else if type == "object" && properties != null then
|
||||||
|
{
|
||||||
|
kind = "submodule";
|
||||||
|
options = lib.mapAttrs (
|
||||||
|
name: value: mkRustAnalyzerOptionType false "${property_name}.${name}" value
|
||||||
|
) properties;
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
lib.elem type [
|
||||||
|
"object"
|
||||||
|
"string"
|
||||||
|
"boolean"
|
||||||
|
]
|
||||||
|
then
|
||||||
|
{ kind = type; }
|
||||||
|
else
|
||||||
|
throw "Unhandled value in ${property_name}: ${lib.generators.toPretty { } property}";
|
||||||
|
in
|
||||||
|
builtins.addErrorContext "While creating type for ${property_name}:\n${lib.generators.toPretty { } property}" (
|
||||||
|
inner property
|
||||||
|
);
|
||||||
|
|
||||||
mkRustAnalyzerOption =
|
mkRustAnalyzerOption =
|
||||||
property_name:
|
property_name:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue