@@ -976,8 +976,9 @@ private Node convertClass(JsonObject node, String kind, SourceLocation loc) thro
976
976
hasDeclareKeyword ,
977
977
hasAbstractKeyword );
978
978
attachSymbolInformation (classDecl .getClassDef (), node );
979
- if (node .has ("decorators" )) {
980
- classDecl .addDecorators (convertChildren (node , "decorators" ));
979
+ List <Decorator > decorators = getDecorators (node );
980
+ if (!decorators .isEmpty ()) {
981
+ classDecl .addDecorators (decorators );
981
982
advanceUntilAfter (loc , classDecl .getDecorators ());
982
983
}
983
984
Node exportedDecl = fixExports (loc , classDecl );
@@ -989,6 +990,17 @@ private Node convertClass(JsonObject node, String kind, SourceLocation loc) thro
989
990
return exportedDecl ;
990
991
}
991
992
993
+ List <Decorator > getDecorators (JsonObject node ) throws ParseError {
994
+ List <Decorator > result = new ArrayList <>();
995
+ for (JsonElement elt : getChildIterable (node , "modifiers" )) {
996
+ JsonObject modifier = elt .getAsJsonObject ();
997
+ if (hasKind (modifier , "Decorator" )) {
998
+ result .add ((Decorator ) convertNode (modifier ));
999
+ }
1000
+ }
1001
+ return result ;
1002
+ }
1003
+
992
1004
private Node convertCommaListExpression (JsonObject node , SourceLocation loc ) throws ParseError {
993
1005
return new SequenceExpression (loc , convertChildren (node , "elements" ));
994
1006
}
@@ -1041,7 +1053,7 @@ private DecoratorList makeDecoratorList(JsonElement decorators) throws ParseErro
1041
1053
private List <DecoratorList > convertParameterDecorators (JsonObject function ) throws ParseError {
1042
1054
List <DecoratorList > decoratorLists = new ArrayList <>();
1043
1055
for (JsonElement parameter : getProperParameters (function )) {
1044
- decoratorLists .add (makeDecoratorList (parameter .getAsJsonObject ().get ("decorators " )));
1056
+ decoratorLists .add (makeDecoratorList (parameter .getAsJsonObject ().get ("modifiers " )));
1045
1057
}
1046
1058
return decoratorLists ;
1047
1059
}
@@ -1139,7 +1151,7 @@ private Node convertEnumDeclaration(JsonObject node, SourceLocation loc) throws
1139
1151
loc ,
1140
1152
hasModifier (node , "ConstKeyword" ),
1141
1153
hasModifier (node , "DeclareKeyword" ),
1142
- convertChildrenNotNull (node , "decorators " ),
1154
+ convertChildrenNotNull (node , "illegalDecorators " ), // as of https://github.com/microsoft/TypeScript/pull/50343/ the property is called `illegalDecorators` instead of `decorators`
1143
1155
convertChild (node , "name" ),
1144
1156
convertChildren (node , "members" ));
1145
1157
attachSymbolInformation (enumDeclaration , node );
@@ -1664,8 +1676,9 @@ private Node convertMethodDeclaration(JsonObject node, String kind, SourceLocati
1664
1676
FunctionExpression method = convertImplicitFunction (node , loc );
1665
1677
MethodDefinition methodDefinition =
1666
1678
new MethodDefinition (loc , flags , methodKind , convertChild (node , "name" ), method );
1667
- if (node .has ("decorators" )) {
1668
- methodDefinition .addDecorators (convertChildren (node , "decorators" ));
1679
+ List <Decorator > decorators = getDecorators (node );
1680
+ if (!decorators .isEmpty ()) {
1681
+ methodDefinition .addDecorators (decorators );
1669
1682
advanceUntilAfter (loc , methodDefinition .getDecorators ());
1670
1683
}
1671
1684
return methodDefinition ;
@@ -2079,8 +2092,9 @@ private Node convertPropertyDeclaration(JsonObject node, String kind, SourceLoca
2079
2092
convertChild (node , "name" ),
2080
2093
convertChild (node , "initializer" ),
2081
2094
convertChildAsType (node , "type" ));
2082
- if (node .has ("decorators" )) {
2083
- fieldDefinition .addDecorators (convertChildren (node , "decorators" ));
2095
+ List <Decorator > decorators = getDecorators (node );
2096
+ if (!decorators .isEmpty ()) {
2097
+ fieldDefinition .addDecorators (decorators );
2084
2098
advanceUntilAfter (loc , fieldDefinition .getDecorators ());
2085
2099
}
2086
2100
return fieldDefinition ;
0 commit comments