JS: Add test and fix bug in pipe parser

This commit is contained in:
Asger Feldthaus
2020-12-11 14:47:21 +00:00
parent 16a2a60b9a
commit ed27c8b13f
5 changed files with 41 additions and 2 deletions

View File

@@ -0,0 +1,4 @@
<other-component
[prop]="foo | bar"
[prop2]="foo | bar:'baz'"
></other-component>

View File

@@ -0,0 +1,13 @@
import { Component } from "@angular/core";
@Component({
selector: "foo-component",
templateUrl: "./foo.component.html"
})
export class Foo {
foo: string;
constructor() {
this.foo = "hello";
}
}

View File

@@ -0,0 +1,10 @@
pipeRef
| foo.component.html:2:19:2:21 | bar |
| foo.component.html:3:20:3:28 | bar:'baz' |
pipeCall
| foo.component.html:2:13:2:21 | foo \| bar |
| foo.component.html:3:14:3:28 | foo \| bar:'baz' |
pipeCallArg
| 0 | foo.component.html:2:13:2:15 | foo | foo.component.html:2:13:2:21 | foo \| bar |
| 0 | foo.component.html:3:14:3:16 | foo | foo.component.html:3:14:3:28 | foo \| bar:'baz' |
| 1 | foo.component.html:3:24:3:28 | 'baz' | foo.component.html:3:14:3:28 | foo \| bar:'baz' |

View File

@@ -0,0 +1,12 @@
import javascript
query Angular2::PipeRefExpr pipeRef() { any() }
query CallExpr pipeCall() {
result.getCallee() instanceof Angular2::PipeRefExpr
}
query CallExpr pipeCallArg(int i, Expr arg) {
result.getCallee() instanceof Angular2::PipeRefExpr and
result.getArgument(i) = arg
}