File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change
1
+ import { ParseTreeWalker } from 'antlr4ts/tree/ParseTreeWalker' ;
1
2
import { parse } from './index' ;
3
+ import { ExpressionContext } from './parser/JavaParser' ;
4
+ import { JavaParserListener } from './parser/JavaParserListener' ;
2
5
3
6
describe ( 'Java AST parser' , ( ) => {
4
7
it ( 'should parse the given Java code and return the AST' , ( ) => {
@@ -8,4 +11,26 @@ describe('Java AST parser', () => {
8
11
` ) ;
9
12
expect ( tree . children [ 0 ] . getChild ( 0 ) . getChild ( 1 ) . text ) . toEqual ( 'TestClass' ) ;
10
13
} ) ;
14
+
15
+ it ( 'should handle super invocation with arguments' , ( ) => {
16
+ const tree = parse ( `
17
+ class B extends A {
18
+ public B() {
19
+ super(1);
20
+ }
21
+ }
22
+ ` ) ;
23
+
24
+ const expressions = [ ] ;
25
+ ParseTreeWalker . DEFAULT . walk (
26
+ {
27
+ enterExpression ( context : ExpressionContext ) {
28
+ expressions . push ( context . text ) ;
29
+ } ,
30
+ } as JavaParserListener ,
31
+ tree ,
32
+ ) ;
33
+
34
+ expect ( expressions ) . toContain ( 'super(1)' ) ;
35
+ } ) ;
11
36
} ) ;
Original file line number Diff line number Diff line change @@ -524,7 +524,7 @@ lambdaBody
524
524
primary
525
525
: ' (' expression ' )'
526
526
| THIS
527
- | SUPER
527
+ | SUPER superSuffix
528
528
| literal
529
529
| IDENTIFIER
530
530
| typeTypeOrVoid ' .' CLASS
You can’t perform that action at this time.
0 commit comments