mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
JS: Support postfix "!" operator in templates
This commit is contained in:
@@ -9,6 +9,7 @@ import com.semmle.js.ast.Expression;
|
||||
import com.semmle.js.ast.Identifier;
|
||||
import com.semmle.js.ast.Position;
|
||||
import com.semmle.js.ast.SourceLocation;
|
||||
import com.semmle.ts.ast.NonNullAssertion;
|
||||
|
||||
/**
|
||||
* Parser for Angular template expressions, based on the JS parser with
|
||||
@@ -47,4 +48,16 @@ public class AngularExpressionParser extends CustomParser {
|
||||
}
|
||||
return super.buildBinary(startPos, startLoc, left, right, op, logical);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Expression parseExprAtom(DestructuringErrors refDestructuringErrors) {
|
||||
// Parse postfix "!" operator
|
||||
Position startLoc = this.startLoc;
|
||||
Expression expr = super.parseExprAtom(refDestructuringErrors);
|
||||
if (this.type == TokenType.prefix && "!".equals(this.value)) {
|
||||
this.next(); // consume "!" token
|
||||
return finishNode(new NonNullAssertion(new SourceLocation(startLoc), expr));
|
||||
}
|
||||
return expr;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user