Skip to content

Commit a7c0305

Browse files
committed
PS: Lift StringLiterals to the public AST from the raw AST.
1 parent 64dd13d commit a7c0305

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ module Public {
6666
import ParenExpr
6767
import Pipeline
6868
import StringConstantExpression
69+
import StringLiteral
6970
import MemberExpr
7071
import InvokeMemberExpression
7172
import ObjectCreation
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
private import AstImport
2+
3+
// TODO: A string literal should ideally be the string constants that are
4+
// surrounded by quotes (single or double), but we don't yet extract that
5+
// information. So for now we just use the StringConstExpr class, which is
6+
// a bit more general than we want.
7+
class StringLiteral instanceof StringConstExpr {
8+
/** Get the string representation of this string literal. */
9+
string toString() { result = this.getValue() }
10+
11+
/** Get the value of this string literal. */
12+
string getValue() { result = super.getValueString() }
13+
14+
/** Get the location of this string literal. */
15+
SourceLocation getLocation() { result = super.getLocation() }
16+
}

0 commit comments

Comments
 (0)