@@ -1599,7 +1599,7 @@ private Node convertMappedType(JsonObject node, SourceLocation loc) throws Parse
15991599 private Node convertMetaProperty (JsonObject node , SourceLocation loc ) throws ParseError {
16001600 Position metaStart = loc .getStart ();
16011601 String keywordKind =
1602- metadata .getSyntaxKinds (). get ( node .getAsJsonPrimitive ("keywordToken" ).getAsInt () + "" ). getAsString ( );
1602+ metadata .getSyntaxKindName ( node .getAsJsonPrimitive ("keywordToken" ).getAsInt ());
16031603 String identifier = keywordKind .equals ("ImportKeyword" ) ? "import" : "new" ;
16041604 Position metaEnd =
16051605 new Position (
@@ -1977,7 +1977,7 @@ private Node convertPrefixUnaryExpression(JsonObject node, SourceLocation loc) t
19771977
19781978 private String getOperator (JsonObject node ) throws ParseError {
19791979 int operatorId = node .get ("operator" ).getAsInt ();
1980- switch (metadata .getSyntaxKindMap (). get (operatorId )) {
1980+ switch (metadata .getSyntaxKindName (operatorId )) {
19811981 case "PlusPlusToken" :
19821982 return "++" ;
19831983 case "MinusMinusToken" :
@@ -2201,7 +2201,7 @@ private Node convertTypeOfExpression(JsonObject node, SourceLocation loc) throws
22012201 }
22022202
22032203 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 ());
22052205 if (operator .equals ("KeyOfKeyword" )) {
22062206 return new UnaryTypeExpr (loc , UnaryTypeExpr .Kind .Keyof , convertChildAsType (node , "type" ));
22072207 }
@@ -2519,12 +2519,7 @@ private int getMemberModifierKeywords(JsonObject node) {
25192519 * <tt>ts.NodeFlags</tt> in enum.
25202520 */
25212521 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 );
25282523 JsonElement flags = node .get ("flags" );
25292524 if (flags instanceof JsonPrimitive ) {
25302525 return (flags .getAsInt () & flagId ) != 0 ;
@@ -2534,12 +2529,7 @@ private boolean hasFlag(JsonObject node, String flagName) {
25342529
25352530 /** Gets the numeric value of the syntax kind enum with the given name. */
25362531 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 );
25432533 }
25442534
25452535 /** Check whether a node has a child with a given name. */
@@ -2563,7 +2553,7 @@ private String getKind(JsonElement node) {
25632553 if (node instanceof JsonObject ) {
25642554 JsonElement kind = ((JsonObject ) node ).get ("kind" );
25652555 if (kind instanceof JsonPrimitive && ((JsonPrimitive ) kind ).isNumber ())
2566- return metadata .getSyntaxKindMap (). get (kind .getAsInt ());
2556+ return metadata .getSyntaxKindName (kind .getAsInt ());
25672557 }
25682558 return null ;
25692559 }
0 commit comments