Skip to content

Commit 8020040

Browse files
authored
QL: Autoformat
1 parent 9f4c829 commit 8020040

2 files changed

Lines changed: 22 additions & 66 deletions

File tree

ql/src/codeql_ql/ast/Ast.qll

Lines changed: 20 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,7 @@ class TopLevel extends TTopLevel, AstNode {
9595
ModuleMember getAMember() { result = getMember(_) }
9696

9797
/** Gets the `i`'th member of this top-level module. */
98-
ModuleMember getMember(int i) {
99-
toQL(result) = file.getChild(i).(QL::ModuleMember).getChild(_)
100-
}
98+
ModuleMember getMember(int i) { toQL(result) = file.getChild(i).(QL::ModuleMember).getChild(_) }
10199

102100
/** Gets a top-level import in this module. */
103101
Import getAnImport() { result = this.getAMember() }
@@ -171,9 +169,7 @@ class Select extends TSelect, AstNode {
171169
Expr getExpr(int i) { toQL(result) = sel.getChild(_).(QL::AsExprs).getChild(i) }
172170

173171
// TODO: This gets the `i`th order-by, but some expressions might not have an order-by.
174-
Expr getOrderBy(int i) {
175-
toQL(result) = sel.getChild(_).(QL::OrderBys).getChild(i).getChild(0)
176-
}
172+
Expr getOrderBy(int i) { toQL(result) = sel.getChild(_).(QL::OrderBys).getChild(i).getChild(0) }
177173

178174
override AstNode getAChild(string pred) {
179175
result = super.getAChild(pred)
@@ -429,11 +425,7 @@ class ClasslessPredicate extends TClasslessPredicate, Predicate, ModuleDeclarati
429425

430426
override VarDecl getParameter(int i) {
431427
toQL(result) =
432-
rank[i + 1](QL::VarDecl decl, int index |
433-
decl = pred.getChild(index)
434-
|
435-
decl order by index
436-
)
428+
rank[i + 1](QL::VarDecl decl, int index | decl = pred.getChild(index) | decl order by index)
437429
}
438430

439431
override TypeExpr getReturnTypeExpr() { toQL(result) = pred.getReturnType() }
@@ -476,11 +468,7 @@ class ClassPredicate extends TClassPredicate, Predicate {
476468

477469
override VarDecl getParameter(int i) {
478470
toQL(result) =
479-
rank[i + 1](QL::VarDecl decl, int index |
480-
decl = pred.getChild(index)
481-
|
482-
decl order by index
483-
)
471+
rank[i + 1](QL::VarDecl decl, int index | decl = pred.getChild(index) | decl order by index)
484472
}
485473

486474
/**
@@ -654,22 +642,16 @@ class Module extends TModule, ModuleDeclaration {
654642
/**
655643
* Gets a member of the module.
656644
*/
657-
AstNode getAMember() {
658-
toQL(result) = mod.getChild(_).(QL::ModuleMember).getChild(_)
659-
}
645+
AstNode getAMember() { toQL(result) = mod.getChild(_).(QL::ModuleMember).getChild(_) }
660646

661-
AstNode getMember(int i) {
662-
toQL(result) = mod.getChild(i).(QL::ModuleMember).getChild(_)
663-
}
647+
AstNode getMember(int i) { toQL(result) = mod.getChild(i).(QL::ModuleMember).getChild(_) }
664648

665649
QLDoc getQLDocFor(AstNode m) {
666650
exists(int i | result = this.getMember(i) and m = this.getMember(i + 1))
667651
}
668652

669653
/** Gets the module expression that this module is an alias for, if any. */
670-
ModuleExpr getAlias() {
671-
toQL(result) = mod.getAFieldOrChild().(QL::ModuleAliasBody).getChild()
672-
}
654+
ModuleExpr getAlias() { toQL(result) = mod.getAFieldOrChild().(QL::ModuleAliasBody).getChild() }
673655

674656
override AstNode getAChild(string pred) {
675657
result = super.getAChild(pred)
@@ -731,14 +713,11 @@ class Class extends TClass, TypeDeclaration, ModuleDeclaration {
731713
/**
732714
* Gets the charateristic predicate for this class.
733715
*/
734-
CharPred getCharPred() {
735-
toQL(result) = cls.getChild(_).(QL::ClassMember).getChild(_)
736-
}
716+
CharPred getCharPred() { toQL(result) = cls.getChild(_).(QL::ClassMember).getChild(_) }
737717

738718
AstNode getMember(int i) {
739719
toQL(result) = cls.getChild(i).(QL::ClassMember).getChild(_) or
740-
toQL(result) =
741-
cls.getChild(i).(QL::ClassMember).getChild(_).(QL::Field).getChild()
720+
toQL(result) = cls.getChild(i).(QL::ClassMember).getChild(_).(QL::Field).getChild()
742721
}
743722

744723
QLDoc getQLDocFor(AstNode m) {
@@ -764,8 +743,7 @@ class Class extends TClass, TypeDeclaration, ModuleDeclaration {
764743
* Gets a field in this class.
765744
*/
766745
VarDecl getAField() {
767-
toQL(result) =
768-
cls.getChild(_).(QL::ClassMember).getChild(_).(QL::Field).getChild()
746+
toQL(result) = cls.getChild(_).(QL::ClassMember).getChild(_).(QL::Field).getChild()
769747
}
770748

771749
/**
@@ -774,14 +752,10 @@ class Class extends TClass, TypeDeclaration, ModuleDeclaration {
774752
TypeExpr getASuperType() { toQL(result) = cls.getExtends(_) }
775753

776754
/** Gets the type that this class is defined to be an alias of. */
777-
TypeExpr getAliasType() {
778-
toQL(result) = cls.getChild(_).(QL::TypeAliasBody).getChild()
779-
}
755+
TypeExpr getAliasType() { toQL(result) = cls.getChild(_).(QL::TypeAliasBody).getChild() }
780756

781757
/** Gets the type of one of the members that this class is defined to be a union of. */
782-
TypeExpr getUnionMember() {
783-
toQL(result) = cls.getChild(_).(QL::TypeUnionBody).getChild(_)
784-
}
758+
TypeExpr getUnionMember() { toQL(result) = cls.getChild(_).(QL::TypeUnionBody).getChild(_) }
785759

786760
/** Gets the class type defined by this class declaration. */
787761
Type getType() { result.getDeclaration() = this }
@@ -846,11 +820,7 @@ class NewTypeBranch extends TNewTypeBranch, PredicateOrBuiltin, TypeDeclaration
846820
/** Gets a field in this branch. */
847821
VarDecl getField(int i) {
848822
toQL(result) =
849-
rank[i + 1](QL::VarDecl var, int index |
850-
var = branch.getChild(index)
851-
|
852-
var order by index
853-
)
823+
rank[i + 1](QL::VarDecl var, int index | var = branch.getChild(index) | var order by index)
854824
}
855825

856826
/** Gets the body of this branch. */
@@ -922,9 +892,7 @@ class PredicateCall extends TPredicateCall, Call {
922892
PredicateCall() { this = TPredicateCall(expr) }
923893

924894
override Expr getArgument(int i) {
925-
exists(QL::CallBody body | body.getParent() = expr |
926-
toQL(result) = body.getChild(i)
927-
)
895+
exists(QL::CallBody body | body.getParent() = expr | toQL(result) = body.getChild(i))
928896
}
929897

930898
final override ModuleExpr getQualifier() {
@@ -936,9 +904,7 @@ class PredicateCall extends TPredicateCall, Call {
936904

937905
override string getAPrimaryQlClass() { result = "PredicateCall" }
938906

939-
override predicate isClosure(string kind) {
940-
kind = expr.getChild(_).(QL::Closure).getValue()
941-
}
907+
override predicate isClosure(string kind) { kind = expr.getChild(_).(QL::Closure).getValue() }
942908

943909
/**
944910
* Gets the name of the predicate called.
@@ -972,9 +938,7 @@ class MemberCall extends TMemberCall, Call {
972938
* Gets the name of the member called.
973939
* E.g. for `foo.bar()` the result is "bar".
974940
*/
975-
string getMemberName() {
976-
result = expr.getChild(_).(QL::QualifiedRhs).getName().getValue()
977-
}
941+
string getMemberName() { result = expr.getChild(_).(QL::QualifiedRhs).getName().getValue() }
978942

979943
override predicate isClosure(string kind) {
980944
kind = expr.getChild(_).(QL::QualifiedRhs).getChild(_).(QL::Closure).getValue()
@@ -985,9 +949,7 @@ class MemberCall extends TMemberCall, Call {
985949
*
986950
* Only yields a result if this is actually a `super` call.
987951
*/
988-
TypeExpr getSuperType() {
989-
toQL(result) = expr.getChild(_).(QL::SuperRef).getChild(0)
990-
}
952+
TypeExpr getSuperType() { toQL(result) = expr.getChild(_).(QL::SuperRef).getChild(0) }
991953

992954
override Expr getArgument(int i) {
993955
result =
@@ -1053,9 +1015,7 @@ class InlineCast extends TInlineCast, Expr {
10531015
* Gets the type being cast to.
10541016
* E.g. for `foo.(Bar)` the result is `Bar`.
10551017
*/
1056-
TypeExpr getTypeExpr() {
1057-
toQL(result) = expr.getChild(_).(QL::QualifiedRhs).getChild(_)
1058-
}
1018+
TypeExpr getTypeExpr() { toQL(result) = expr.getChild(_).(QL::QualifiedRhs).getChild(_) }
10591019

10601020
override Type getType() { result = this.getTypeExpr().getResolvedType() }
10611021

@@ -2177,8 +2137,8 @@ private class AnnotationArg extends TAnnotationArg, AstNode {
21772137
string getValue() {
21782138
result =
21792139
[
2180-
arg.getChild().(QL::SimpleId).getValue(),
2181-
arg.getChild().(QL::Result).getValue(), arg.getChild().(QL::This).getValue()
2140+
arg.getChild().(QL::SimpleId).getValue(), arg.getChild().(QL::Result).getValue(),
2141+
arg.getChild().(QL::This).getValue()
21822142
]
21832143
}
21842144

ql/src/codeql_ql/ast/internal/AstNodes.qll

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,8 @@ newtype TAstNode =
2323
TComparisonFormula(QL::CompTerm comp) or
2424
TComparisonOp(QL::Compop op) or
2525
TQuantifier(QL::Quantified quant) or
26-
TFullAggregate(QL::Aggregate agg) {
27-
agg.getChild(_) instanceof QL::FullAggregateBody
28-
} or
29-
TExprAggregate(QL::Aggregate agg) {
30-
agg.getChild(_) instanceof QL::ExprAggregateBody
31-
} or
26+
TFullAggregate(QL::Aggregate agg) { agg.getChild(_) instanceof QL::FullAggregateBody } or
27+
TExprAggregate(QL::Aggregate agg) { agg.getChild(_) instanceof QL::ExprAggregateBody } or
3228
TSuper(QL::SuperRef sup) or
3329
TIdentifier(QL::Variable var) or
3430
TAsExpr(QL::AsExpr asExpr) { asExpr.getChild(1) instanceof QL::VarName } or

0 commit comments

Comments
 (0)