|
10 | 10 | import com.semmle.js.ast.jsdoc.JSDocComment; |
11 | 11 | import com.semmle.js.ast.jsdoc.JSDocTag; |
12 | 12 | import com.semmle.js.ast.jsdoc.JSDocTypeExpression; |
13 | | -import com.semmle.js.ast.jsdoc.NameExpression; |
| 13 | +import com.semmle.js.ast.jsdoc.Identifier; |
14 | 14 | import com.semmle.js.ast.jsdoc.NonNullableType; |
15 | 15 | import com.semmle.js.ast.jsdoc.NullLiteral; |
16 | 16 | import com.semmle.js.ast.jsdoc.NullableLiteral; |
17 | 17 | import com.semmle.js.ast.jsdoc.NullableType; |
18 | 18 | import com.semmle.js.ast.jsdoc.OptionalType; |
19 | 19 | import com.semmle.js.ast.jsdoc.ParameterType; |
| 20 | +import com.semmle.js.ast.jsdoc.QualifiedNameExpression; |
20 | 21 | import com.semmle.js.ast.jsdoc.RecordType; |
21 | 22 | import com.semmle.js.ast.jsdoc.RestType; |
22 | 23 | import com.semmle.js.ast.jsdoc.TypeApplication; |
@@ -827,10 +828,16 @@ private JSDocTypeExpression parseRecordType() throws ParseError { |
827 | 828 | } |
828 | 829 |
|
829 | 830 | private JSDocTypeExpression parseNameExpression() throws ParseError { |
830 | | - Object name = value; |
831 | 831 | SourceLocation loc = loc(); |
832 | 832 | expect(Token.NAME); |
833 | | - return finishNode(new NameExpression(loc, name.toString())); |
| 833 | + // Hacky initial implementation with wrong locations |
| 834 | + String[] parts = value.toString().split("\\."); |
| 835 | + JSDocTypeExpression node = finishNode(new Identifier(loc, parts[0])); |
| 836 | + for (int i = 1; i < parts.length; i++) { |
| 837 | + Identifier memberName = finishNode(new Identifier(loc, parts[i])); |
| 838 | + node = finishNode(new QualifiedNameExpression(loc, node, memberName)); |
| 839 | + } |
| 840 | + return node; |
834 | 841 | } |
835 | 842 |
|
836 | 843 | // TypeExpressionList := |
@@ -923,14 +930,14 @@ private List<JSDocTypeExpression> parseParametersType() throws ParseError { |
923 | 930 |
|
924 | 931 | SourceLocation loc = loc(); |
925 | 932 | expr = parseTypeExpression(); |
926 | | - if (expr instanceof NameExpression && token == Token.COLON) { |
| 933 | + if (expr instanceof Identifier && token == Token.COLON) { |
927 | 934 | // Identifier ':' TypeExpression |
928 | 935 | consume(Token.COLON); |
929 | 936 | expr = |
930 | 937 | finishNode( |
931 | 938 | new ParameterType( |
932 | 939 | new SourceLocation(loc), |
933 | | - ((NameExpression) expr).getName(), |
| 940 | + ((Identifier) expr).getName(), |
934 | 941 | parseTypeExpression())); |
935 | 942 | } |
936 | 943 | if (token == Token.EQUAL) { |
@@ -1106,7 +1113,7 @@ private JSDocTypeExpression parseTypeExpression() throws ParseError { |
1106 | 1113 | consume(Token.RBRACK, "expected an array-style type declaration (' + value + '[])"); |
1107 | 1114 | List<JSDocTypeExpression> expressions = new ArrayList<>(); |
1108 | 1115 | expressions.add(expr); |
1109 | | - NameExpression nameExpr = finishNode(new NameExpression(new SourceLocation(loc), "Array")); |
| 1116 | + Identifier nameExpr = finishNode(new Identifier(new SourceLocation(loc), "Array")); |
1110 | 1117 | return finishNode(new TypeApplication(loc, nameExpr, expressions)); |
1111 | 1118 | } |
1112 | 1119 |
|
@@ -1527,9 +1534,9 @@ public boolean parseName() { |
1527 | 1534 | // fixed at the end |
1528 | 1535 | if (isParamTitle(this._title) |
1529 | 1536 | && this._tag.type != null |
1530 | | - && this._tag.type instanceof NameExpression) { |
1531 | | - this._extra_name = ((NameExpression) this._tag.type).getName(); |
1532 | | - this._tag.name = ((NameExpression) this._tag.type).getName(); |
| 1537 | + && this._tag.type instanceof Identifier) { |
| 1538 | + this._extra_name = ((Identifier) this._tag.type).getName(); |
| 1539 | + this._tag.name = ((Identifier) this._tag.type).getName(); |
1533 | 1540 | this._tag.type = null; |
1534 | 1541 | } else { |
1535 | 1542 | if (!this.addError("Missing or invalid tag name")) { |
@@ -1645,7 +1652,7 @@ private boolean epilogue() { |
1645 | 1652 | Position start = new Position(_tag.startLine, _tag.startColumn, _tag.startColumn); |
1646 | 1653 | Position end = new Position(_tag.startLine, _tag.startColumn, _tag.startColumn); |
1647 | 1654 | SourceLocation loc = new SourceLocation(_extra_name, start, end); |
1648 | | - this._tag.type = new NameExpression(loc, _extra_name); |
| 1655 | + this._tag.type = new Identifier(loc, _extra_name); |
1649 | 1656 | } |
1650 | 1657 | this._tag.name = null; |
1651 | 1658 |
|
|
0 commit comments