@@ -546,6 +546,10 @@ export class JavaScriptParserVisitor {
546546 return this . mapIdentifier ( node , 'any' ) ;
547547 }
548548
549+ visitIntrinsicKeyword ( node : ts . Node ) {
550+ return this . mapIdentifier ( node , 'intrinsic' ) ;
551+ }
552+
549553 visitObjectKeyword ( node : ts . Node ) {
550554 return this . mapIdentifier ( node , 'object' ) ;
551555 }
@@ -814,6 +818,13 @@ export class JavaScriptParserVisitor {
814818 annotationType = this . convert ( node . expression ) ;
815819 } else if ( ts . isPropertyAccessExpression ( node . expression ) ) {
816820 annotationType = this . convert ( node . expression ) ;
821+ } else if ( ts . isParenthesizedExpression ( node . expression ) ) {
822+ annotationType = new JS . TypeTreeExpression (
823+ randomId ( ) ,
824+ this . prefix ( node . expression ) ,
825+ Markers . EMPTY ,
826+ this . convert ( node . expression )
827+ ) ;
817828 } else {
818829 return this . visitUnknown ( node ) ;
819830 }
@@ -1045,6 +1056,12 @@ export class JavaScriptParserVisitor {
10451056 ) ;
10461057 }
10471058
1059+ const name : J . Identifier = ! node . name
1060+ ? this . mapIdentifier ( node , "" )
1061+ : ts . isStringLiteral ( node . name )
1062+ ? this . mapIdentifier ( node . name , node . name . getText ( ) )
1063+ : this . visit ( node . name ) ;
1064+
10481065 return new J . MethodDeclaration (
10491066 randomId ( ) ,
10501067 this . prefix ( node ) ,
@@ -1054,7 +1071,7 @@ export class JavaScriptParserVisitor {
10541071 this . mapTypeParametersAsObject ( node ) ,
10551072 this . mapTypeInfo ( node ) ,
10561073 new J . MethodDeclaration . IdentifierWithAnnotations (
1057- node . name ? this . visit ( node . name ) : this . mapIdentifier ( node , "" ) ,
1074+ name ,
10581075 [ ]
10591076 ) ,
10601077 this . mapCommaSeparatedList ( this . getParameterListNodes ( node ) ) ,
@@ -1381,7 +1398,10 @@ export class JavaScriptParserVisitor {
13811398 this . mapTypeParametersAsObject ( node ) ,
13821399 new JContainer (
13831400 this . prefix ( node . getChildAt ( node . getChildren ( ) . findIndex ( n => n . pos === node . parameters . pos ) - 1 ) ) ,
1384- node . parameters . map ( p => this . rightPadded ( this . visit ( p ) , this . suffix ( p ) ) ) ,
1401+ node . parameters . length == 0 ?
1402+ [ this . rightPadded ( this . newJEmpty ( ) , this . prefix ( this . findChildNode ( node , ts . SyntaxKind . CloseParenToken ) ! ) ) ]
1403+ : node . parameters . map ( p => this . rightPadded ( this . visit ( p ) , this . suffix ( p ) ) )
1404+ . concat ( node . parameters . hasTrailingComma ? this . rightPadded ( this . newJEmpty ( ) , this . prefix ( this . findChildNode ( node , ts . SyntaxKind . CloseParenToken ) ! ) ) : [ ] ) ,
13851405 Markers . EMPTY ) ,
13861406 this . prefix ( this . findChildNode ( node , ts . SyntaxKind . EqualsGreaterThanToken ) ! ) ,
13871407 this . convert ( node . type ) ,
@@ -2234,6 +2254,9 @@ export class JavaScriptParserVisitor {
22342254 case ts . SyntaxKind . AsteriskAsteriskToken :
22352255 assignmentOperation = JS . JsAssignmentOperation . Type . Power ;
22362256 break ;
2257+ case ts . SyntaxKind . AsteriskAsteriskEqualsToken :
2258+ assignmentOperation = JS . JsAssignmentOperation . Type . Exp ;
2259+ break ;
22372260 }
22382261
22392262 if ( assignmentOperation !== undefined ) {
@@ -2428,7 +2451,7 @@ export class JavaScriptParserVisitor {
24282451 randomId ( ) ,
24292452 this . prefix ( node ) ,
24302453 Markers . EMPTY ,
2431- [ ] , // this.mapDecorators(node),
2454+ this . mapDecorators ( node ) ,
24322455 [ ] , //this.mapModifiers(node),
24332456 new J . ClassDeclaration . Kind (
24342457 randomId ( ) ,
@@ -2558,7 +2581,8 @@ export class JavaScriptParserVisitor {
25582581 }
25592582
25602583 visitVariableStatement ( node : ts . VariableStatement ) {
2561- return this . visitVariableDeclarationList ( node . declarationList ) . withModifiers ( this . mapModifiers ( node ) ) . withPrefix ( this . prefix ( node ) ) ;
2584+ const declaration = this . visitVariableDeclarationList ( node . declarationList ) ;
2585+ return declaration . withModifiers ( this . mapModifiers ( node ) . concat ( declaration . modifiers ) ) . withPrefix ( this . prefix ( node ) ) ;
25622586 }
25632587
25642588 visitExpressionStatement ( node : ts . ExpressionStatement ) : J . Statement {
@@ -2788,6 +2812,10 @@ export class JavaScriptParserVisitor {
27882812 }
27892813
27902814 visitTryStatement ( node : ts . TryStatement ) {
2815+ if ( node . catchClause ?. variableDeclaration ?. name && ! ts . isIdentifier ( node . catchClause ?. variableDeclaration ?. name ) ) {
2816+ this . visitUnknown ( node ) ;
2817+ }
2818+
27912819 return new J . Try (
27922820 randomId ( ) ,
27932821 this . prefix ( node ) ,
@@ -2843,14 +2871,28 @@ export class JavaScriptParserVisitor {
28432871 }
28442872
28452873 visitVariableDeclarationList ( node : ts . VariableDeclarationList ) {
2846- const kind = node . getFirstToken ( this . sourceFile ) ;
2874+ let kind = node . getFirstToken ( ) ;
2875+
2876+ // to parse the declaration case: await using db = ...
2877+ let modifier ;
2878+ if ( kind ?. kind === ts . SyntaxKind . AwaitKeyword ) {
2879+ modifier = new J . Modifier (
2880+ randomId ( ) ,
2881+ this . prefix ( kind ) ,
2882+ Markers . EMPTY ,
2883+ 'await' ,
2884+ J . Modifier . Type . LanguageExtension ,
2885+ [ ]
2886+ ) ;
2887+ kind = node . getChildAt ( 1 ) ;
2888+ }
28472889 return new JS . ScopedVariableDeclarations (
28482890 randomId ( ) ,
28492891 Space . EMPTY ,
28502892 Markers . EMPTY ,
2851- [ ] ,
2893+ modifier ? [ modifier ] : [ ] ,
28522894 this . leftPadded (
2853- this . prefix ( node ) ,
2895+ kind ? this . prefix ( kind ) : this . prefix ( node ) ,
28542896 kind ?. kind === ts . SyntaxKind . LetKeyword
28552897 ? JS . ScopedVariableDeclarations . Scope . Let
28562898 : kind ?. kind === ts . SyntaxKind . ConstKeyword
@@ -3812,7 +3854,7 @@ export class JavaScriptParserVisitor {
38123854 return args ;
38133855 }
38143856
3815- private mapDecorators ( node : ts . ClassDeclaration | ts . FunctionDeclaration | ts . MethodDeclaration | ts . ConstructorDeclaration | ts . ParameterDeclaration | ts . PropertyDeclaration | ts . SetAccessorDeclaration | ts . GetAccessorDeclaration ) : J . Annotation [ ] {
3857+ private mapDecorators ( node : ts . ClassDeclaration | ts . FunctionDeclaration | ts . MethodDeclaration | ts . ConstructorDeclaration | ts . ParameterDeclaration | ts . PropertyDeclaration | ts . SetAccessorDeclaration | ts . GetAccessorDeclaration | ts . ClassExpression ) : J . Annotation [ ] {
38163858 return node . modifiers ?. filter ( ts . isDecorator ) ?. map ( this . convert < J . Annotation > ) ?? [ ] ;
38173859 }
38183860
0 commit comments