mirror of
https://github.com/github/codeql.git
synced 2026-05-01 19:55:15 +02:00
TypeScript: test case for tokenization of template literals
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
| templateLiteralsJS.js:2 | console . log ( ` template~without~placeholders ` ) ; |
|
||||
| templateLiteralsJS.js:3 | console . log ( ` template~with~placeholder~ ${ x } . ` ) ; |
|
||||
| templateLiteralsTS.ts:2 | console . log ( `template~without~placeholders` ) ; |
|
||||
| templateLiteralsTS.ts:3 | console . log ( `template~with~placeholder~${ x }.` ) ; |
|
||||
@@ -0,0 +1,15 @@
|
||||
import javascript
|
||||
|
||||
Token getATokenAtLine(File file, int line) {
|
||||
result.getFile() = file and
|
||||
result.getLocation().getStartLine() = line
|
||||
}
|
||||
|
||||
bindingset[line]
|
||||
string getTokenStringAtLine(File file, int line) {
|
||||
result = concat(Token tok | tok = getATokenAtLine(file, line) | tok.toString().replaceAll(" ", "~") + " " order by tok.getLocation().getStartColumn())
|
||||
}
|
||||
|
||||
from File file, int line
|
||||
where exists(CallExpr call | call.getFile() = file and call.getLocation().getStartLine() = line)
|
||||
select file.getBaseName() + ":" + line, getTokenStringAtLine(file, line)
|
||||
@@ -0,0 +1,4 @@
|
||||
function f(x) {
|
||||
console.log(`template without placeholders`);
|
||||
console.log(`template with placeholder ${x}.`);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
function f(x) {
|
||||
console.log(`template without placeholders`);
|
||||
console.log(`template with placeholder ${x}.`);
|
||||
}
|
||||
Reference in New Issue
Block a user