mirror of
https://github.com/github/codeql.git
synced 2026-02-11 20:51:06 +01:00
Rust: Apply Black formatter to annotations.py
This commit is contained in:
@@ -6,6 +6,7 @@ class LabelableExpr(Expr):
|
||||
"""
|
||||
The base class for expressions that can be labeled (`LoopExpr`, `ForExpr`, `WhileExpr` or `BlockExpr`).
|
||||
"""
|
||||
|
||||
label: optional[Label] | child
|
||||
|
||||
|
||||
@@ -13,6 +14,7 @@ class LoopingExpr(LabelableExpr):
|
||||
"""
|
||||
The base class for expressions that loop (`LoopExpr`, `ForExpr` or `WhileExpr`).
|
||||
"""
|
||||
|
||||
loop_body: optional["BlockExpr"] | child
|
||||
|
||||
|
||||
@@ -21,6 +23,7 @@ class _:
|
||||
"""
|
||||
An ADT (Abstract Data Type) definition, such as `Struct`, `Enum`, or `Union`.
|
||||
"""
|
||||
|
||||
derive_macro_expansions: list[MacroItems] | child | rust.detach
|
||||
|
||||
|
||||
@@ -95,8 +98,8 @@ class _:
|
||||
foo::bar;
|
||||
```
|
||||
"""
|
||||
segment: _ | ql.db_table_name("path_segments_") | doc(
|
||||
"last segment of this path")
|
||||
|
||||
segment: _ | ql.db_table_name("path_segments_") | doc("last segment of this path")
|
||||
|
||||
|
||||
@annotate(GenericArgList)
|
||||
@@ -132,7 +135,9 @@ class PathExprBase(Expr):
|
||||
"""
|
||||
|
||||
|
||||
@annotate(PathExpr, replace_bases={Expr: PathExprBase}, add_bases=(PathAstNode,), cfg=True)
|
||||
@annotate(
|
||||
PathExpr, replace_bases={Expr: PathExprBase}, add_bases=(PathAstNode,), cfg=True
|
||||
)
|
||||
@qltest.test_with(Path)
|
||||
class _:
|
||||
"""
|
||||
@@ -144,6 +149,7 @@ class _:
|
||||
let z = <TypeRepr as Trait>::foo;
|
||||
```
|
||||
"""
|
||||
|
||||
path: drop
|
||||
|
||||
|
||||
@@ -195,6 +201,7 @@ class _:
|
||||
}
|
||||
```
|
||||
"""
|
||||
|
||||
label: drop
|
||||
|
||||
|
||||
@@ -224,6 +231,7 @@ class _:
|
||||
};
|
||||
```
|
||||
"""
|
||||
|
||||
label: drop
|
||||
loop_body: drop
|
||||
|
||||
@@ -297,8 +305,10 @@ class _:
|
||||
}
|
||||
```
|
||||
"""
|
||||
|
||||
scrutinee: _ | doc(
|
||||
"scrutinee (the expression being matched) of this match expression")
|
||||
"scrutinee (the expression being matched) of this match expression"
|
||||
)
|
||||
|
||||
|
||||
@annotate(ContinueExpr, cfg=True)
|
||||
@@ -348,7 +358,7 @@ class _:
|
||||
0;
|
||||
};
|
||||
```
|
||||
"""
|
||||
"""
|
||||
|
||||
|
||||
@annotate(ReturnExpr, cfg=True)
|
||||
@@ -432,6 +442,7 @@ class _:
|
||||
Foo { a: m, .. } = second;
|
||||
```
|
||||
"""
|
||||
|
||||
path: drop
|
||||
|
||||
|
||||
@@ -579,6 +590,7 @@ class ArrayExpr(Expr):
|
||||
[1; 10];
|
||||
```
|
||||
"""
|
||||
|
||||
exprs: list[Expr] | child
|
||||
attrs: list[Attr] | child
|
||||
|
||||
@@ -591,6 +603,7 @@ class ArrayListExpr(ArrayExpr):
|
||||
[1, 2, 3];
|
||||
```
|
||||
"""
|
||||
|
||||
__cfg__ = True
|
||||
|
||||
|
||||
@@ -602,6 +615,7 @@ class ArrayRepeatExpr(ArrayExpr):
|
||||
[1; 10];
|
||||
```
|
||||
"""
|
||||
|
||||
__cfg__ = True
|
||||
|
||||
repeat_operand: Expr | child
|
||||
@@ -741,6 +755,7 @@ class _:
|
||||
}
|
||||
```
|
||||
"""
|
||||
|
||||
path: drop
|
||||
|
||||
|
||||
@@ -784,6 +799,7 @@ class _:
|
||||
}
|
||||
```
|
||||
"""
|
||||
|
||||
path: drop
|
||||
|
||||
|
||||
@@ -831,6 +847,7 @@ class _:
|
||||
};
|
||||
```
|
||||
"""
|
||||
|
||||
path: drop
|
||||
|
||||
|
||||
@@ -993,10 +1010,18 @@ class _:
|
||||
const X: i32 = 42;
|
||||
```
|
||||
"""
|
||||
has_implementation: predicate | doc("this constant has an implementation") | desc("""
|
||||
|
||||
has_implementation: (
|
||||
predicate
|
||||
| doc("this constant has an implementation")
|
||||
| desc(
|
||||
"""
|
||||
This is the same as `hasBody` for source code, but for library code (for which we always skip
|
||||
the body), this will hold when the body was present in the original code.
|
||||
""") | rust.detach
|
||||
"""
|
||||
)
|
||||
| rust.detach
|
||||
)
|
||||
|
||||
|
||||
@annotate(ConstArg)
|
||||
@@ -1146,6 +1171,7 @@ class _:
|
||||
}
|
||||
```
|
||||
"""
|
||||
|
||||
label: drop
|
||||
loop_body: drop
|
||||
|
||||
@@ -1162,6 +1188,7 @@ class _:
|
||||
```
|
||||
"""
|
||||
|
||||
|
||||
@annotate(FormatArgsArg, cfg=True)
|
||||
@qltest.test_with(FormatArgsExpr)
|
||||
class _:
|
||||
@@ -1185,6 +1212,7 @@ class _:
|
||||
format_args!("{x}, {y}");
|
||||
```
|
||||
"""
|
||||
|
||||
formats: list["Format"] | child | synth
|
||||
|
||||
|
||||
@@ -1279,6 +1307,7 @@ class _:
|
||||
enum E {}
|
||||
```
|
||||
"""
|
||||
|
||||
attribute_macro_expansion: optional[MacroItems] | child | rust.detach
|
||||
|
||||
|
||||
@@ -1361,6 +1390,7 @@ class _:
|
||||
println!("Hello, world!");
|
||||
```
|
||||
"""
|
||||
|
||||
macro_call_expansion: optional[AstNode] | child | rust.detach
|
||||
|
||||
|
||||
@@ -1414,6 +1444,7 @@ class MacroBlockExpr(Expr):
|
||||
my_macro!(); // this macro expands to a sequence of statements (and an expression)
|
||||
```
|
||||
"""
|
||||
|
||||
__cfg__ = True
|
||||
|
||||
statements: list[Stmt] | child
|
||||
@@ -1530,6 +1561,7 @@ class ParamBase(AstNode):
|
||||
"""
|
||||
A normal parameter, `Param`, or a self parameter `SelfParam`.
|
||||
"""
|
||||
|
||||
attrs: list["Attr"] | child
|
||||
type_repr: optional["TypeRepr"] | child
|
||||
|
||||
@@ -1549,6 +1581,7 @@ class _:
|
||||
}
|
||||
```
|
||||
"""
|
||||
|
||||
attrs: drop
|
||||
type_repr: drop
|
||||
|
||||
@@ -1603,6 +1636,7 @@ class _:
|
||||
- `widgets(..)`
|
||||
- `<T as Iterator>`
|
||||
"""
|
||||
|
||||
type_repr: optional["TypeRepr"] | child | rust.detach
|
||||
trait_type_repr: optional["PathTypeRepr"] | child | rust.detach
|
||||
|
||||
@@ -1777,6 +1811,7 @@ class _:
|
||||
}
|
||||
```
|
||||
"""
|
||||
|
||||
attrs: drop
|
||||
type_repr: drop
|
||||
|
||||
@@ -1835,14 +1870,28 @@ class _:
|
||||
// ^^^^^^^^^
|
||||
```
|
||||
"""
|
||||
statements: _ | doc("statements of this statement list") | desc("""
|
||||
|
||||
statements: (
|
||||
_
|
||||
| doc("statements of this statement list")
|
||||
| desc(
|
||||
"""
|
||||
The statements of a `StmtList` do not include any tail expression, which
|
||||
can be accessed with predicates such as `getTailExpr`.
|
||||
""")
|
||||
tail_expr: _ | doc("tail expression of this statement list") | desc("""
|
||||
"""
|
||||
)
|
||||
)
|
||||
tail_expr: (
|
||||
_
|
||||
| doc("tail expression of this statement list")
|
||||
| desc(
|
||||
"""
|
||||
The tail expression is the expression at the end of a block, that
|
||||
determines the block's value.
|
||||
""")
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@annotate(Struct, replace_bases={Item: None}) # still an Item via Adt
|
||||
class _:
|
||||
@@ -1855,6 +1904,7 @@ class _:
|
||||
}
|
||||
```
|
||||
"""
|
||||
|
||||
field_list: _ | ql.db_table_name("struct_field_lists_")
|
||||
|
||||
|
||||
@@ -2152,6 +2202,7 @@ class _:
|
||||
}
|
||||
```
|
||||
"""
|
||||
|
||||
label: drop
|
||||
loop_body: drop
|
||||
|
||||
@@ -2160,10 +2211,17 @@ class _:
|
||||
class _:
|
||||
param_list: drop
|
||||
attrs: drop
|
||||
has_implementation: predicate | doc("this function has an implementation") | desc("""
|
||||
has_implementation: (
|
||||
predicate
|
||||
| doc("this function has an implementation")
|
||||
| desc(
|
||||
"""
|
||||
This is the same as `hasBody` for source code, but for library code (for which we always skip
|
||||
the body), this will hold when the body was present in the original code.
|
||||
""") | rust.detach
|
||||
"""
|
||||
)
|
||||
| rust.detach
|
||||
)
|
||||
|
||||
|
||||
@annotate(ClosureExpr, add_bases=[Callable])
|
||||
@@ -2191,35 +2249,61 @@ class Format(Locatable):
|
||||
println!("Value {value:#width$.precision$}");
|
||||
```
|
||||
"""
|
||||
|
||||
parent: FormatArgsExpr
|
||||
index: int
|
||||
argument_ref: optional["FormatArgument"] | child | desc("""
|
||||
argument_ref: (
|
||||
optional["FormatArgument"]
|
||||
| child
|
||||
| desc(
|
||||
"""
|
||||
For example `name` and `0` in:
|
||||
```rust
|
||||
let name = "Alice";
|
||||
println!("{name} in wonderland");
|
||||
println!("{0} in wonderland", name);
|
||||
```
|
||||
""")
|
||||
width_argument: optional["FormatArgument"] | child | desc("""
|
||||
"""
|
||||
)
|
||||
)
|
||||
width_argument: (
|
||||
optional["FormatArgument"]
|
||||
| child
|
||||
| desc(
|
||||
"""
|
||||
For example `width` and `1` in:
|
||||
```rust
|
||||
let width = 6;
|
||||
println!("{:width$}", PI);
|
||||
println!("{:1$}", PI, width);
|
||||
```
|
||||
""")
|
||||
precision_argument: optional["FormatArgument"] | child | desc("""
|
||||
"""
|
||||
)
|
||||
)
|
||||
precision_argument: (
|
||||
optional["FormatArgument"]
|
||||
| child
|
||||
| desc(
|
||||
"""
|
||||
For example `prec` and `1` in:
|
||||
```rust
|
||||
let prec = 6;
|
||||
println!("{:.prec$}", PI);
|
||||
println!("{:.1$}", PI, prec);
|
||||
```
|
||||
""")
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@synth.on_arguments(parent=FormatArgsExpr, index=int, kind=int, name=string, positional=boolean, offset=int)
|
||||
@synth.on_arguments(
|
||||
parent=FormatArgsExpr,
|
||||
index=int,
|
||||
kind=int,
|
||||
name=string,
|
||||
positional=boolean,
|
||||
offset=int,
|
||||
)
|
||||
@qltest.test_with(FormatArgsExpr)
|
||||
class FormatArgument(Locatable):
|
||||
"""
|
||||
@@ -2232,6 +2316,7 @@ class FormatArgument(Locatable):
|
||||
println!("Value {0:#1$.2$}", value, width, precision);
|
||||
```
|
||||
"""
|
||||
|
||||
parent: Format
|
||||
variable: optional[FormatTemplateVariableAccess] | child
|
||||
|
||||
|
||||
Reference in New Issue
Block a user