Skip to content

Commit 3880d9f

Browse files
committed
PS: More consistent lower casing in the AST classes.
1 parent 71fec26 commit 3880d9f

File tree

6 files changed

+41
-14
lines changed

6 files changed

+41
-14
lines changed
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
private import AstImport
22

33
class AutomaticVariable extends Expr, TAutomaticVariable {
4-
final override string toString() { result = this.getName() }
4+
final override string toString() { result = this.getLowerCaseName() }
55

6-
string getName() { any(Synthesis s).automaticVariableName(this, result) }
6+
string getLowerCaseName() { any(Synthesis s).automaticVariableName(this, result) }
7+
8+
bindingset[result]
9+
pragma[inline_late]
10+
string getAName() { result.toLowerCase() = this.getLowerCaseName() }
711
}
812

913
class MyInvocation extends AutomaticVariable {
10-
MyInvocation() { this.getName() = "myinvocation" }
14+
MyInvocation() { this.getLowerCaseName() = "myinvocation" }
1115
}

powershell/ql/lib/semmle/code/powershell/ast/internal/InvokeMemberExpression.qll

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,13 @@ class ConstructorCall extends InvokeMemberExpr {
7171
this.isStatic() and typename = this.getQualifier() and this.getLowerCaseName() = "new"
7272
}
7373

74+
/** Gets a name of the type being constructed by this constructor call. */
75+
bindingset[result]
76+
pragma[inline_late]
77+
string getAConstructedTypeName() { result = typename.getAName() }
78+
7479
/** Gets the name of the type being constructed by this constructor call. */
75-
string getConstructedTypeName() { result = typename.getName() }
80+
string getLowerCaseConstructedTypeName() { result = typename.getLowerCaseName() }
7681
}
7782

7883
/**

powershell/ql/lib/semmle/code/powershell/ast/internal/ObjectCreation.qll

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import powershell
22

33
abstract private class AbstractObjectCreation extends CallExpr {
44
/** The name of the type of the object being constructed. */
5-
abstract string getConstructedTypeName();
5+
bindingset[result]
6+
pragma[inline_late]
7+
string getAConstructedTypeName() { result.toLowerCase() = this.getLowerCaseConstructedTypeName() }
8+
9+
abstract string getLowerCaseConstructedTypeName();
610

711
abstract Expr getConstructedTypeExpr();
812
}
@@ -14,8 +18,14 @@ abstract private class AbstractObjectCreation extends CallExpr {
1418
* ```
1519
*/
1620
class NewObjectCreation extends AbstractObjectCreation, ConstructorCall {
17-
final override string getConstructedTypeName() {
18-
result = ConstructorCall.super.getConstructedTypeName()
21+
final override string getLowerCaseConstructedTypeName() {
22+
result = ConstructorCall.super.getLowerCaseConstructedTypeName()
23+
}
24+
25+
bindingset[result]
26+
pragma[inline_late]
27+
final override string getAConstructedTypeName() {
28+
result = ConstructorCall.super.getAConstructedTypeName()
1929
}
2030

2131
final override Expr getConstructedTypeExpr() { result = typename }
@@ -30,7 +40,7 @@ class NewObjectCreation extends AbstractObjectCreation, ConstructorCall {
3040
class DotNetObjectCreation extends AbstractObjectCreation, CmdCall {
3141
DotNetObjectCreation() { this.getLowerCaseName() = "new-object" }
3242

33-
final override string getConstructedTypeName() {
43+
final override string getLowerCaseConstructedTypeName() {
3444
result = this.getConstructedTypeExpr().(StringConstExpr).getValueString().toLowerCase()
3545
}
3646

powershell/ql/lib/semmle/code/powershell/ast/internal/Raw/NamedAttributeArgument.qll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ class NamedAttributeArgument extends @named_attribute_argument, Ast {
1515
}
1616

1717
class ValueFromPipelineAttribute extends NamedAttributeArgument {
18-
ValueFromPipelineAttribute() { this.getName() = "ValueFromPipeline" }
18+
ValueFromPipelineAttribute() { this.getName().toLowerCase() = "valuefrompipeline" }
1919
}
2020

2121
class ValueFromPipelineByPropertyName extends NamedAttributeArgument {
22-
ValueFromPipelineByPropertyName() { this.getName() = "ValueFromPipelineByPropertyName" }
22+
ValueFromPipelineByPropertyName() {
23+
this.getName().toLowerCase() = "valuefrompipelinebypropertyname"
24+
}
2325
}

powershell/ql/lib/semmle/code/powershell/ast/internal/Synthesis.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ private module TypeSynth {
530530
override predicate typeName(Type t, string name) {
531531
exists(Raw::TypeStmt typeStmt |
532532
t = TTypeSynth(typeStmt, _) and
533-
typeStmt.getName() = name
533+
typeStmt.getName().toLowerCase() = name
534534
)
535535
}
536536

powershell/ql/lib/semmle/code/powershell/ast/internal/TypeExpression.qll

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,21 @@ class TypeNameExpr extends Expr, TTypeNameExpr {
1414
)
1515
}
1616

17-
string getName() { this.parseName(_, result) }
17+
string getLowerCaseName() { this.parseName(_, result) }
18+
19+
bindingset[result]
20+
pragma[inline_late]
21+
string getAName() { this.parseName(_, result.toLowerCase()) }
1822

1923
/** If any */
20-
string getPossiblyQualifiedName() { result = getRawAst(this).(Raw::TypeNameExpr).getName().toLowerCase() }
24+
string getPossiblyQualifiedName() {
25+
result = getRawAst(this).(Raw::TypeNameExpr).getName().toLowerCase()
26+
}
2127

2228
// TODO: What to do when System is omitted?
2329
string getNamespace() { this.parseName(result, _) }
2430

25-
override string toString() { result = this.getName() }
31+
override string toString() { result = this.getLowerCaseName() }
2632

2733
predicate isQualified() { this.getNamespace() != "" }
2834

0 commit comments

Comments
 (0)