Skip to content

Commit 7ca5cc2

Browse files
author
Max Schaefer
authored
Merge pull request #1257 from asger-semmle/jsdoc
JS: Add common interface between TypeExpr and JSDocTypeExpr
2 parents 8a34ea8 + 3e7bac4 commit 7ca5cc2

File tree

26 files changed

+3397
-850
lines changed

26 files changed

+3397
-850
lines changed

change-notes/1.21/analysis-javascript.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@
4242
## Changes to QL libraries
4343

4444
* `RegExpLiteral` is now a `DataFlow::SourceNode`.
45+
* `JSDocTypeExpr` now has source locations and is a subclass of `Locatable` and `TypeAnnotation`.
46+
* Various predicates named `getTypeAnnotation()` now return `TypeAnnotation` instead of `TypeExpr`.
47+
In rare cases, this may cause compilation errors. Cast the result to `TypeExpr` if this happens.

javascript/extractor/src/com/semmle/js/extractor/JSDocExtractor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ private Label visit(JSDocTypeExpression nd) {
7070
Label key = trapwriter.localID(nd);
7171
int kind = jsdocTypeExprKinds.get(nd.getType());
7272
trapwriter.addTuple("jsdoc_type_exprs", key, kind, parent, idx, nd.pp());
73+
locationManager.emitNodeLocation(nd, key);
7374
return key;
7475
}
7576

javascript/extractor/src/com/semmle/js/extractor/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class Main {
3737
* A version identifier that should be updated every time the extractor changes in such a way that
3838
* it may produce different tuples for the same file under the same {@link ExtractorConfig}.
3939
*/
40-
public static final String EXTRACTOR_VERSION = "2019-03-21";
40+
public static final String EXTRACTOR_VERSION = "2019-04-17";
4141

4242
public static final Pattern NEWLINE = Pattern.compile("\n");
4343

javascript/extractor/src/com/semmle/js/parser/JSDocParser.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ private JSDocTypeExpression parseBasicTypeExpression() throws ParseError {
10001000
case STAR:
10011001
loc = loc();
10021002
consume(Token.STAR);
1003-
return new AllLiteral(loc);
1003+
return finishNode(new AllLiteral(loc));
10041004

10051005
case LPAREN:
10061006
return parseUnionType();
@@ -1015,13 +1015,13 @@ private JSDocTypeExpression parseBasicTypeExpression() throws ParseError {
10151015
if (value.equals("null")) {
10161016
loc = loc();
10171017
consume(Token.NAME);
1018-
return new NullLiteral(loc);
1018+
return finishNode(new NullLiteral(loc));
10191019
}
10201020

10211021
if (value.equals("undefined")) {
10221022
loc = loc();
10231023
consume(Token.NAME);
1024-
return new UndefinedLiteral(loc);
1024+
return finishNode(new UndefinedLiteral(loc));
10251025
}
10261026

10271027
context = save();

0 commit comments

Comments
 (0)