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' ;
12import { parse } from './index' ;
3+ import { ExpressionContext } from './parser/JavaParser' ;
4+ import { JavaParserListener } from './parser/JavaParserListener' ;
25
36describe ( 'Java AST parser' , ( ) => {
47 it ( 'should parse the given Java code and return the AST' , ( ) => {
@@ -8,4 +11,26 @@ describe('Java AST parser', () => {
811 ` ) ;
912 expect ( tree . children [ 0 ] . getChild ( 0 ) . getChild ( 1 ) . text ) . toEqual ( 'TestClass' ) ;
1013 } ) ;
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+ } ) ;
1136} ) ;
Original file line number Diff line number Diff line change @@ -524,7 +524,7 @@ lambdaBody
524524primary
525525 : ' (' expression ' )'
526526 | THIS
527- | SUPER
527+ | SUPER superSuffix
528528 | literal
529529 | IDENTIFIER
530530 | typeTypeOrVoid ' .' CLASS
You can’t perform that action at this time.
0 commit comments