Kotlin: Add support for string templates

This commit is contained in:
Ian Lynagh
2021-11-01 16:34:26 +00:00
parent 168786ae71
commit 976cc31c7a
3 changed files with 33 additions and 0 deletions

View File

@@ -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. */

View File

@@ -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" }
}