22
33import org .antlr .v4 .runtime .ParserRuleContext ;
44import org .antlr .v4 .runtime .tree .ParseTree ;
5+ import org .antlr .v4 .runtime .tree .TerminalNodeImpl ;
56import org .luapp .language .generator .luappParser ;
67import org .luapp .language .listeners .LuaPPListener ;
78
@@ -12,15 +13,15 @@ public ClassBodyHandler() {
1213 }
1314
1415 public boolean isClassFunction (ParseTree context ){
15- return context instanceof luappParser .ClassfunctionContext ;
16+ return (( ParserRuleContext ) context ). getRuleIndex () == luappParser .RULE_classfunction ;
1617 }
1718
1819 public boolean isClassGetSet (ParseTree context ){
19- return context instanceof luappParser .ClassgetsetContext ;
20+ return (( ParserRuleContext ) context ). getRuleIndex () == luappParser .RULE_classgetset ;
2021 }
2122
2223 public boolean isClassConstructor (ParseTree context ){
23- return context instanceof luappParser .ConstructorContext ;
24+ return (( ParserRuleContext ) context ). getRuleIndex () == luappParser .RULE_constructor ;
2425 }
2526
2627
@@ -38,10 +39,14 @@ public void onEnterContext(ParserRuleContext enterContext) {
3839 return ;
3940 }
4041 for (ParseTree child : enterContext .children ) {
42+ if (child instanceof TerminalNodeImpl ) continue ;
4143 if (isClassFunction (child )){
4244 System .out .println ("Class function" );
4345 }else if (isClassConstructor (child )){
44- System .out .println ("Constructor" );
46+ System .out .println ("Constructor!" );
47+ this .listenerManager
48+ .GetInstangeByTarget (luappParser .RULE_constructor )
49+ .handleEnterContext ((ParserRuleContext )child );
4550 }else if (isClassGetSet (child )){
4651 System .out .println ("Get/Set" );
4752 }
0 commit comments