@@ -88,7 +88,6 @@ class DNObjectiveCParserListener extends ObjectiveCParserListener {
88
88
}
89
89
// Enter a parse tree produced by ObjectiveCParser#genericTypeSpecifier.
90
90
enterGenericTypeSpecifier ( ctx ) {
91
-
92
91
}
93
92
// Exit a parse tree produced by ObjectiveCParser#genericTypeSpecifier.
94
93
exitGenericTypeSpecifier ( ctx ) {
@@ -312,6 +311,22 @@ class DNObjectiveCParserListener extends ObjectiveCParserListener {
312
311
}
313
312
// Enter a parse tree produced by ObjectiveCParser#blockType.
314
313
enterBlockType ( ctx ) {
314
+ if ( this . currentContext instanceof DNArgumentContext ) {
315
+ for ( var i = 0 ; i < ctx . children . length ; i ++ ) {
316
+ var subChild = ctx . children [ i ]
317
+ if ( subChild instanceof ObjectiveCParser . BlockParametersContext ) {
318
+ var blockArgs = ''
319
+ subChild . children . forEach ( element => {
320
+ if ( element instanceof ObjectiveCParser . TypeVariableDeclaratorOrNameContext ) {
321
+ blockArgs += element . start . text + ' ' + element . stop . text + ', '
322
+ }
323
+ } )
324
+ blockArgs = '(' + blockArgs . substring ( 0 , blockArgs . length - 2 ) + ')'
325
+ this . currentContext . anonDef = this . currentContext . type + ' ' + this . currentContext . name + blockArgs
326
+ break
327
+ }
328
+ }
329
+ }
315
330
}
316
331
// Exit a parse tree produced by ObjectiveCParser#blockType.
317
332
exitBlockType ( ctx ) {
@@ -324,6 +339,11 @@ class DNObjectiveCParserListener extends ObjectiveCParserListener {
324
339
}
325
340
// Enter a parse tree produced by ObjectiveCParser#typeSpecifierWithPrefixes.
326
341
enterTypeSpecifierWithPrefixes ( ctx ) {
342
+ if ( this . currentContext instanceof DNMethodContext || this . currentContext instanceof DNBlockDefContext ) {
343
+ this . currentContext . returnType = this . currentContext . returnType + '<' + TC . convert ( ctx . start . text ) + '>'
344
+ } else if ( this . currentContext instanceof DNArgumentContext ) {
345
+ this . currentContext . type = this . currentContext . type + '<' + TC . convert ( ctx . start . text ) + '>'
346
+ }
327
347
}
328
348
// Exit a parse tree produced by ObjectiveCParser#typeSpecifierWithPrefixes.
329
349
exitTypeSpecifierWithPrefixes ( ctx ) {
@@ -367,10 +387,15 @@ class DNObjectiveCParserListener extends ObjectiveCParserListener {
367
387
if ( argument . type != 'void' ) {
368
388
this . currentContext . args . push ( argument )
369
389
}
390
+ this . currentContext . addChild ( argument )
391
+ this . currentContext = argument
370
392
}
371
393
}
372
394
// Exit a parse tree produced by ObjectiveCParser#typeVariableDeclaratorOrName.
373
395
exitTypeVariableDeclaratorOrName ( ctx ) {
396
+ if ( this . currentContext instanceof DNArgumentContext ) {
397
+ this . currentContext = this . currentContext . parent
398
+ }
374
399
}
375
400
// Enter a parse tree produced by ObjectiveCParser#blockExpression.
376
401
enterBlockExpression ( ctx ) {
@@ -536,11 +561,9 @@ class DNObjectiveCParserListener extends ObjectiveCParserListener {
536
561
}
537
562
// Enter a parse tree produced by ObjectiveCParser#enumDeclaration.
538
563
enterEnumDeclaration ( ctx ) {
539
- if ( this . currentContext instanceof DNRootContext ) {
540
- var enumDef = new DNEnumDefContext ( ctx )
541
- this . currentContext . addChild ( enumDef )
542
- this . currentContext = enumDef
543
- }
564
+ var enumDef = new DNEnumDefContext ( ctx )
565
+ this . currentContext . addChild ( enumDef )
566
+ this . currentContext = enumDef
544
567
}
545
568
// Exit a parse tree produced by ObjectiveCParser#enumDeclaration.
546
569
exitEnumDeclaration ( ctx ) {
@@ -554,12 +577,10 @@ class DNObjectiveCParserListener extends ObjectiveCParserListener {
554
577
}
555
578
// Enter a parse tree produced by ObjectiveCParser#typedefDeclaration.
556
579
enterTypedefDeclaration ( ctx ) {
557
- if ( this . currentContext instanceof DNRootContext ) {
558
- var blockDef = new DNBlockDefContext ( ctx )
559
- blockDef . returnType = TC . convert ( ctx . children [ 1 ] . start . text )
560
- this . currentContext . addChild ( blockDef )
561
- this . currentContext = blockDef
562
- }
580
+ var blockDef = new DNBlockDefContext ( ctx )
581
+ blockDef . returnType = TC . convert ( ctx . children [ 1 ] . start . text )
582
+ this . currentContext . addChild ( blockDef )
583
+ this . currentContext = blockDef
563
584
}
564
585
// Exit a parse tree produced by ObjectiveCParser#typedefDeclaration.
565
586
exitTypedefDeclaration ( ctx ) {
@@ -782,9 +803,9 @@ class DNObjectiveCParserListener extends ObjectiveCParserListener {
782
803
// Enter a parse tree produced by ObjectiveCParser#typeName.
783
804
enterTypeName ( ctx ) {
784
805
if ( this . currentContext instanceof DNMethodContext ) {
785
- this . currentContext . returnType = TC . convert ( ctx . start . text == 'instancetype' ? this . currentContext . parent . name : ctx . start . text )
806
+ this . currentContext . returnType = TC . convert ( ctx . start . text == 'instancetype' ? this . currentContext . parent . name : ctx . start . text , true )
786
807
} else if ( this . currentContext instanceof DNArgumentContext ) {
787
- this . currentContext . type = TC . convert ( ctx . start . text )
808
+ this . currentContext . type = TC . convert ( ctx . start . text , true )
788
809
}
789
810
}
790
811
// Exit a parse tree produced by ObjectiveCParser#typeName.
0 commit comments