mirror of
https://github.com/github/codeql.git
synced 2026-04-28 10:15:14 +02:00
Kotlin: Add support for string templates
This commit is contained in:
@@ -670,6 +670,7 @@ case @expr.kind of
|
||||
| 77 = @safecastexpr
|
||||
| 78 = @notinstanceofexpr
|
||||
| 79 = @stmtexpr
|
||||
| 80 = @stringtemplateexpr
|
||||
;
|
||||
|
||||
/** Holds if this `when` expression was written as an `if` expression. */
|
||||
|
||||
@@ -2246,3 +2246,24 @@ class StmtExpr extends Expr, @stmtexpr {
|
||||
|
||||
override string getAPrimaryQlClass() { result = "StmtExpr" }
|
||||
}
|
||||
|
||||
/**
|
||||
* A Kotlin string template expression. For example, `"foo${bar}baz"`.
|
||||
*/
|
||||
class StringTemplateExpr extends Expr, @stringtemplateexpr {
|
||||
/**
|
||||
* Gets the `i`th component of this string template.
|
||||
*
|
||||
* For example, in the string template `"foo${bar}baz"`, the 0th
|
||||
* component is the string literal `"foo"`, the 1st component is
|
||||
* the variable access `bar`, and the 2nd component is the string
|
||||
* literal `"bar"`.
|
||||
*/
|
||||
Expr getComponent(int i) { result.isNthChildOf(this, i) }
|
||||
|
||||
override string toString() { result = "\"...\"" }
|
||||
|
||||
override string getHalsteadID() { result = "StringTemplateExpr" }
|
||||
|
||||
override string getAPrimaryQlClass() { result = "StringTemplateExpr" }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user