final ContextStackEntry topmost_stack_entry = contextStack.peek(); final ContextStackEntry cse = contextStack.peek(cie); if(cse==null) { throw new IllegalStateException("Named class [" + this.declaredName + "] w/o appropriate context"); final ContextStackEntry cse = contextStack.peek(pcie); if(cse!=null) context = (JavaId)cse.getConstructId(); final ContextStackEntry cse = contextStack.peek(cie); if(cse==null) { throw new IllegalStateException("Anonnymous class [" + this.declaredName + "] w/o appropriate context");
/** * 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 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 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)); }