@@ -1599,7 +1599,7 @@ private Node convertMappedType(JsonObject node, SourceLocation loc) throws Parse
1599
1599
private Node convertMetaProperty (JsonObject node , SourceLocation loc ) throws ParseError {
1600
1600
Position metaStart = loc .getStart ();
1601
1601
String keywordKind =
1602
- metadata .getSyntaxKinds (). get ( node .getAsJsonPrimitive ("keywordToken" ).getAsInt () + "" ). getAsString ( );
1602
+ metadata .getSyntaxKindName ( node .getAsJsonPrimitive ("keywordToken" ).getAsInt ());
1603
1603
String identifier = keywordKind .equals ("ImportKeyword" ) ? "import" : "new" ;
1604
1604
Position metaEnd =
1605
1605
new Position (
@@ -1977,7 +1977,7 @@ private Node convertPrefixUnaryExpression(JsonObject node, SourceLocation loc) t
1977
1977
1978
1978
private String getOperator (JsonObject node ) throws ParseError {
1979
1979
int operatorId = node .get ("operator" ).getAsInt ();
1980
- switch (metadata .getSyntaxKindMap (). get (operatorId )) {
1980
+ switch (metadata .getSyntaxKindName (operatorId )) {
1981
1981
case "PlusPlusToken" :
1982
1982
return "++" ;
1983
1983
case "MinusMinusToken" :
@@ -2201,7 +2201,7 @@ private Node convertTypeOfExpression(JsonObject node, SourceLocation loc) throws
2201
2201
}
2202
2202
2203
2203
private Node convertTypeOperator (JsonObject node , SourceLocation loc ) throws ParseError {
2204
- String operator = metadata .getSyntaxKinds (). get ( "" + node .get ("operator" ).getAsInt ()). getAsString ( );
2204
+ String operator = metadata .getSyntaxKindName ( node .get ("operator" ).getAsInt ());
2205
2205
if (operator .equals ("KeyOfKeyword" )) {
2206
2206
return new UnaryTypeExpr (loc , UnaryTypeExpr .Kind .Keyof , convertChildAsType (node , "type" ));
2207
2207
}
@@ -2519,12 +2519,7 @@ private int getMemberModifierKeywords(JsonObject node) {
2519
2519
* <tt>ts.NodeFlags</tt> in enum.
2520
2520
*/
2521
2521
private boolean hasFlag (JsonObject node , String flagName ) {
2522
- JsonElement flagDescriptor = this .metadata .getNodeFlags ().get (flagName );
2523
- if (flagDescriptor == null ) {
2524
- throw new RuntimeException (
2525
- "Incompatible version of TypeScript installed. Missing node flag " + flagName );
2526
- }
2527
- int flagId = flagDescriptor .getAsInt ();
2522
+ int flagId = metadata .getNodeFlagId (flagName );
2528
2523
JsonElement flags = node .get ("flags" );
2529
2524
if (flags instanceof JsonPrimitive ) {
2530
2525
return (flags .getAsInt () & flagId ) != 0 ;
@@ -2534,12 +2529,7 @@ private boolean hasFlag(JsonObject node, String flagName) {
2534
2529
2535
2530
/** Gets the numeric value of the syntax kind enum with the given name. */
2536
2531
private int getSyntaxKind (String syntaxKind ) {
2537
- JsonElement descriptor = this .metadata .getSyntaxKinds ().get (syntaxKind );
2538
- if (descriptor == null ) {
2539
- throw new RuntimeException (
2540
- "Incompatible version of TypeScript installed. Missing syntax kind " + syntaxKind );
2541
- }
2542
- return descriptor .getAsInt ();
2532
+ return metadata .getSyntaxKindId (syntaxKind );
2543
2533
}
2544
2534
2545
2535
/** Check whether a node has a child with a given name. */
@@ -2563,7 +2553,7 @@ private String getKind(JsonElement node) {
2563
2553
if (node instanceof JsonObject ) {
2564
2554
JsonElement kind = ((JsonObject ) node ).get ("kind" );
2565
2555
if (kind instanceof JsonPrimitive && ((JsonPrimitive ) kind ).isNumber ())
2566
- return metadata .getSyntaxKindMap (). get (kind .getAsInt ());
2556
+ return metadata .getSyntaxKindName (kind .getAsInt ());
2567
2557
}
2568
2558
return null ;
2569
2559
}
0 commit comments