Skip to content

Commit e9fcb67

Browse files
committed
JS: Provide source locations for JSDocTypeExpr
1 parent cf8c327 commit e9fcb67

File tree

6 files changed

+204
-206
lines changed

6 files changed

+204
-206
lines changed

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();

javascript/ql/src/semmle/javascript/JSDoc.qll

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,16 @@ abstract class Documentable extends ASTNode {
3939
* A syntactic element that a JSDoc type expression may be nested in, that is,
4040
* either a JSDoc tag or another JSDoc type expression.
4141
*/
42-
class JSDocTypeExprParent extends @jsdoc_type_expr_parent {
43-
/** Gets a textual representation of this element. */
44-
string toString() { none() }
42+
class JSDocTypeExprParent extends @jsdoc_type_expr_parent, Locatable {
43+
override Location getLocation() { hasLocation(this, result) }
4544

4645
JSDoc getJSDocComment() { none() }
4746
}
4847

4948
/**
5049
* A JSDoc tag such as `@param Object options An object literal with options.`
5150
*/
52-
class JSDocTag extends @jsdoc_tag, JSDocTypeExprParent, Locatable {
53-
override Location getLocation() { hasLocation(this, result) }
54-
51+
class JSDocTag extends @jsdoc_tag, JSDocTypeExprParent {
5552
/** Gets the tag title; for instance, the title of a `@param` tag is `"param"`. */
5653
string getTitle() { jsdoc_tags(this, result, _, _, _) }
5754

0 commit comments

Comments
 (0)