11package org .luapp .language .handlers ;
22
33import org .antlr .v4 .runtime .ParserRuleContext ;
4+ import org .antlr .v4 .runtime .tree .ParseTree ;
45import org .luapp .language .generator .luappParser ;
56import org .luapp .language .listeners .LuaPPListener ;
67
@@ -10,27 +11,41 @@ public ClassBodyHandler() {
1011 this .setTarget (luappParser .RULE_classbody );
1112 }
1213
13- public boolean isClassFunction (ParserRuleContext context ){
14- return context . getRuleIndex () == luappParser .RULE_classfunction ;
14+ public boolean isClassFunction (ParseTree context ){
15+ return context instanceof luappParser .ClassfunctionContext ;
1516 }
1617
17- public boolean isClassGetSet (ParserRuleContext context ){
18- return context . getRuleIndex () == luappParser .RULE_classgetset ;
18+ public boolean isClassGetSet (ParseTree context ){
19+ return context instanceof luappParser .ClassgetsetContext ;
1920 }
2021
21- public boolean isClassConstructor (ParserRuleContext context ){
22- return context . getRuleIndex () == luappParser .RULE_constructor ;
22+ public boolean isClassConstructor (ParseTree context ){
23+ return context instanceof luappParser .ConstructorContext ;
2324 }
2425
2526
2627 @ Override
2728 public void onSetManager () {
28-
2929 this .listenerManager .RegisterIgnoredContext (this .getTarget ());
3030 }
3131
3232 @ Override
3333 public void onEnterContext (ParserRuleContext enterContext ) {
34+ System .out .println ("Being called?" + enterContext .getRuleIndex ());
35+
36+ if (this .getLuaPP ().currentClass .isEmpty ()) {
37+ System .out .println ("No class name, not completing body." );
38+ return ;
39+ }
40+ for (ParseTree child : enterContext .children ) {
41+ if (isClassFunction (child )){
42+ System .out .println ("Class function" );
43+ }else if (isClassConstructor (child )){
44+ System .out .println ("Constructor" );
45+ }else if (isClassGetSet (child )){
46+ System .out .println ("Get/Set" );
47+ }
48+ }
3449
3550 }
3651
0 commit comments