@Override public void enterClassBody(@NotNull JavaParser.ClassBodyContext ctx) { // Create JavaId and push to the stack final JavaId id = (JavaClassId) this.constructIdBuilder.buildJavaClassId(); this.contextStack.push(id); this.saveConstruct(id, this.getConstructContent(ctx)); // Log anon classes if(this.constructIdBuilder.isAnonymousClass()) JavaFileAnalyzer2.log.debug(this.indent(this.contextStack.size()) + "Enter anon class body " + id.toString() + " " + this.printDeclarationStack()); this.constructIdBuilder.resetCurrentDeclarationContext(); }
@Override public void enterConstructorDeclaration(@NotNull JavaParser.ConstructorDeclarationContext ctx) { // Peek JavaId and ensure it is a class or enum final JavaId class_ctx = (JavaId) this.contextStack.peek().getConstructId(); this.isOfExpectedType(class_ctx, new JavaId.Type[] { JavaId.Type.CLASS, JavaId.Type.ENUM }, true); // Build the identifier final JavaId id = new JavaConstructorId((JavaId)class_ctx, this.getParameters(ctx.formalParameters().formalParameterList())); this.contextStack.push(id); this.saveConstruct(id, this.getConstructContent(ctx)); }
/** * Interfaces are not added to {@link #constructs}. */ @Override public void enterInterfaceDeclaration(@NotNull JavaParser.InterfaceDeclarationContext ctx) { // Create JavaId and push to the stack final ContextStackEntry cse = this.contextStack.peek(); final JavaId decl_ctx = ( cse==null ? JavaPackageId.DEFAULT_PACKAGE : (JavaId)cse.getConstructId() ); final JavaId id = new JavaInterfaceId(decl_ctx, ctx.IDENTIFIER().getText()); this.contextStack.push(id); }
@Override public void enterPackageDeclaration(@NotNull JavaParser.PackageDeclarationContext ctx) { // Create JavaId final JavaPackageId id = new JavaPackageId(ctx.getChild(1).getText()); // Add to the stack this.contextStack.push(id); // Create the construct this.saveConstruct(id, ctx.getParent().getText()); }
/** * Enums are added to {@link #constructs}. */ @Override public void enterEnumDeclaration(@NotNull JavaParser.EnumDeclarationContext ctx) { // Create JavaId and push to the stack final ContextStackEntry cse = this.contextStack.peek(); final JavaId decl_ctx = ( cse==null ? JavaPackageId.DEFAULT_PACKAGE : (JavaId)cse.getConstructId() ); final JavaId id = new JavaEnumId(decl_ctx, ctx.IDENTIFIER().getText()); this.contextStack.push(id); this.saveConstruct(id, this.getConstructContent(ctx)); }
@Override public void enterMethodDeclaration(@NotNull JavaParser.MethodDeclarationContext ctx) { // Peek JavaId and ensure it is a class or enum final JavaId class_ctx = (JavaId) this.contextStack.peek().getConstructId(); this.isOfExpectedType(class_ctx, new JavaId.Type[] { JavaId.Type.CLASS, JavaId.Type.ENUM }, true); // Build the identifier final JavaMethodId id = new JavaMethodId((JavaId) class_ctx, ctx.IDENTIFIER().getText(), this.getParameters(ctx.formalParameters().formalParameterList())); this.contextStack.push(id); this.saveConstruct(id, this.getConstructContent(ctx)); }