Visits the specified statement. If the statement's visit method calls
replaceVisitedMethodWith(), the statement will be replaced.
481688
public Statement replace(Statement stat) {
    replacement = null;
    stat.visit(this);
    Statement result = replacement == null ? stat : replacement;
    replacement = null;
    return result;
  }
16227
@Override
    public Object visit(Object context, ForVarDeclStatement statement, boolean strict) {
        Scope scope = (Scope) context;
        List<VariableDeclaration> decls = statement.getDeclarationList();
        for (VariableDeclaration each : decls) {
            each.accept(context, this, strict);
        }

        final Label startLabel = scope.getNewLabel();
        final Label doneLabel = scope.getNewLabel();

        scope.addInstruction(new LabelInstr(startLabel));
        // TEST
        scope.addInstruction(new BEQ((Operand) statement.getTest().accept(context, this, strict),
                BooleanLiteral.FALSE, doneLabel));

        // BODY
        statement.getBlock().accept(context, this, strict);

        // INCREMENT
        statement.getIncrement().accept(context, this, strict);

        scope.addInstruction(new Jump(startLabel));

        // END
        scope.addInstruction(new LabelInstr(doneLabel));

        return Undefined.UNDEFINED;
    }
1189685
public static void checkedUpdate (
        Statement stmt, String query, int expectedCount)
        throws SQLException, PersistenceException
    {
        int modified = stmt.executeUpdate(query);
        if (modified != expectedCount) {
            String err = "Statement did not modify expected number of rows [stmt=" + stmt +
                ", expected=" + expectedCount + ", modified=" + modified + "]";
            throw new PersistenceException(err);
        }
    }
379011
def _Execute(statements, context, callback, trace):
    
    # Every time we call _Execute, increase this depth
    if trace:
        trace.exec_depth += 1
    for i, statement in enumerate(statements):
        if isinstance(statement, six.string_types):
            callback(statement)
        else:
            # In the case of a substitution, args is a pair (name, formatters).
            # In the case of a section, it's a _Section instance.
            try:
                func, args = statement
                func(args, context, callback, trace)
            except UndefinedVariable as e:
                # Show context for statements
                start = max(0, i - 3)
                end = i + 3
                e.near = statements[start:end]
                e.trace = trace  # Attach caller's trace (could be None)
                raise
31620
@Override
    public void visitMethod(Method obj) {
        suspectLocals.clear();
        int[] parmRegs = RegisterUtils.getParameterRegisters(obj);
        for (int pr : parmRegs) {
            suspectLocals.put(Integer.valueOf(pr), new RegisterInfo(RegisterUtils.getLocalVariableEndRange(obj.getLocalVariableTable(), pr, 0)));
        }
    }
120167
@Override
    public boolean visitTree(VisitContext visitContext, VisitCallback callback) {

        // First check to see whether we are visitable. If not
        // short-circuit out of this subtree, though allow the
        // visit to proceed through to other subtrees.
        if (!isVisitable(visitContext)) {
            return false;
        }

        // Clear out the row index is one is set so that
        // we start from a clean slate.
        FacesContext facesContext = visitContext.getFacesContext();

        // NOTE: that the visitRows local will be obsolete once the
        // appropriate visit hints have been added to the API
        boolean visitRows = requiresRowIteration(visitContext);

        Integer oldRowKey = null;
        if (visitRows) {
            oldRowKey = getRowKey();
            setRowKey(facesContext, null);
        }

        // Push ourselves to EL
        pushComponentToEL(facesContext, null);

        try {

            // Visit ourselves. Note that we delegate to the
            // VisitContext to actually perform the visit.
            VisitResult result = visitContext.invokeVisitCallback(this, callback);

            // If the visit is complete, short-circuit out and end the visit
            if (result == VisitResult.COMPLETE) {
                return true;
            }

            // Visit children, short-circuiting as necessary
            if ((result == VisitResult.ACCEPT)) {
                if (visitDataChildren(visitContext, callback, visitRows)) {
                    return true;
                }
            }
        } catch (IOException e) {
            // TODO handle exception
            LOG.log(Level.SEVERE, e.getMessage(), e);
        } finally {

            // Clean up - pop EL and restore old row index
            popComponentFromEL(facesContext);

            if (visitRows) {
                try {
                    setRowKey(facesContext, oldRowKey);
                    restoreOrigValue(facesContext);
                } catch (Exception e) {

                    // TODO: handle exception
                    LOG.log(Level.SEVERE, e.getMessage(), e);
                }
            }
        }

        // Return false to allow the visit to continue
        return false;
    }
1075266
private static void replaceThis(Node expectedGetprop, Node replacement) {
    Node leftChild = expectedGetprop.getFirstChild();
    if (leftChild.isThis()) {
      expectedGetprop.replaceChild(leftChild, replacement);
    } else {
      replaceThis(leftChild, replacement);
    }
  }
605669
@Override
    public void visitCode() {
        if (injectedTraceAnnotationVisitor == null && classAdapter.isInjectedTraceAnnotationRequired()) {
            AnnotationVisitor av = visitAnnotation(INJECTED_TRACE_TYPE.getDescriptor(), true);
            av.visitEnd();
        }

        super.visitCode();

        // Label the entry to the method so we can update the local var
        // debug data and indicate that we're referencing them during
        // method entry
        methodEntryLabel = new Label();
        visitLabel(methodEntryLabel);

        if (!waitingForSuper) {
            // This must be done before all instruction callbacks, but it must
            // also be done before the visitLabel() callback, which might have
            // an associated UNINITIALIZED entry in the stack map frame that is
            // supposed to be pointing at a NEW opcode.
            processMethodEntry();
        }
    }
238769
public static SuggestedFix renameMethodInvocation(
      MethodInvocationTree tree, String replacement, VisitorState state) {
    Tree methodSelect = tree.getMethodSelect();
    int startPos;
    String extra = "";
    if (methodSelect instanceof MemberSelectTree) {
      startPos = state.getEndPosition(((MemberSelectTree) methodSelect).getExpression());
      extra = ".";
    } else if (methodSelect instanceof IdentifierTree) {
      startPos = ((JCTree) tree).getStartPosition();
    } else {
      return SuggestedFix.builder().build();
    }
    int endPos = state.getEndPosition(methodSelect);
    return SuggestedFix.replace(startPos, endPos, extra + replacement);
  }
596742
public static SuggestedFix renameMethod(
      MethodTree tree, final String replacement, VisitorState state) {
    // Search tokens from beginning of method tree to beginning of method body.
    int basePos = ((JCTree) tree).getStartPosition();
    int endPos =
        tree.getBody() != null
            ? ((JCTree) tree.getBody()).getStartPosition()
            : state.getEndPosition(tree);
    List<ErrorProneToken> methodTokens =
        ErrorProneTokens.getTokens(
            state.getSourceCode().subSequence(basePos, endPos).toString(), state.context);
    for (ErrorProneToken token : methodTokens) {
      if (token.kind() == TokenKind.IDENTIFIER && token.name().equals(tree.getName())) {
        int nameStartPosition = basePos + token.pos();
        int nameEndPosition = basePos + token.endPos();
        return SuggestedFix.builder()
            .replace(nameStartPosition, nameEndPosition, replacement)
            .build();
      }
    }
    // Method name not found.
    throw new AssertionError();
  }
164996
@Override
    public void visitMethod(Method obj) {
        stack.resetForMethodEntry(this);
        jdbcLocals.clear();

        int[] parmRegs = RegisterUtils.getParameterRegisters(obj);
        Type[] argTypes = obj.getArgumentTypes();

        for (int t = 0; t < argTypes.length; t++) {
            String sig = argTypes[t].getSignature();
            if (isJDBCClass(sig)) {
                jdbcLocals.put(Integer.valueOf(parmRegs[t]),
                        Integer.valueOf(RegisterUtils.getLocalVariableEndRange(obj.getLocalVariableTable(), parmRegs[t], 0)));
            }
        }
    }
1136748
private int afterHookInsertLine(TestMethod method, int codeLineIndex) {
        // if multiple statements exist in one line, afterHook is inserted only after the last statement,
        // since when multi-line statements are like:
        // method(1);method(
        //         2);
        // insertion to the middle of the statement causes problem
        if (!isLineLastStament(method, codeLineIndex)) {
            return -1;
        }
        // insert hook to the next line of the codeLine
        // since insertAt method inserts code just before the specified line
        CodeLine codeLine = method.getCodeBody().get(codeLineIndex);
        return codeLine.getEndLine() + 1;
    }
261497
protected void executeUpdateSilently(String statement) {
        logger.trace(statement);
        try (Statement alter = conn.createStatement()) {
            alter.execute(statement);
        } catch (final SQLException e) {
            logger.debug("Could not execute {}.", statement, e);
        }
    }
149108
@Override
    public void sawOpcode(int seen) {
        Comparable<?> regOrField = null;
        Comparable<?> uValue;
        boolean sawAlias = false;
        boolean sawLoad = false;

        try {
            stack.precomputation(this);

            int pc = getPC();
            Iterator<LoopInfo> it = loops.values().iterator();
            while (it.hasNext()) {
                LoopInfo loop = it.next();
                int endPC = loop.getEndPC();
                int loopPC = loop.getAddPC();
                if ((endPC - 3) <= pc) {
                    if (loopPC > 0) {
                        bugReporter.reportBug(new BugInstance(this, BugType.UAA_USE_ADD_ALL.name(), NORMAL_PRIORITY).addClass(this).addMethod(this)
                                .addSourceLine(this, loopPC));
                    }
                    it.remove();
                } else if ((endPC > pc) && (loopPC < (pc - 5)) && (loopPC > 0)) {
                    it.remove();
                }
            }

            if (seen == Const.INVOKEINTERFACE) {
                String methodName = getNameConstantOperand();
                String signature = getSigConstantOperand();
                if ("get".equals(methodName) && SignatureBuilder.SIG_INT_TO_OBJECT.equals(signature)) {
                    if (stack.getStackDepth() > 1) {
                        OpcodeStack.Item itm = stack.getStackItem(1);
                        int reg = isLocalCollection(itm);
                        if (reg >= 0) {
                            regOrField = Integer.valueOf(reg);
                            sawAlias = true;
                        } else {
                            String field = isFieldCollection(itm);
                            if (field != null) {
                                regOrField = field;
                                sawAlias = true;
                            }
                        }
                    }
                } else if ("keySet".equals(methodName) || "values".equals(methodName) || "iterator".equals(methodName) || "next".equals(methodName)
                        || "hasNext".equals(methodName)) {
                    if (stack.getStackDepth() > 0) {
                        OpcodeStack.Item itm = stack.getStackItem(0);
                        int reg = isLocalCollection(itm);
                        if (reg >= 0) {
                            regOrField = Integer.valueOf(reg);
                            sawAlias = true;
                        } else {
                            String field = isFieldCollection(itm);
                            if (field != null) {
                                regOrField = field;
                                sawAlias = true;
                            }
                        }
                    }
                } else if ("add".equals(methodName) && SignatureBuilder.SIG_OBJECT_TO_BOOLEAN.equals(signature) && (stack.getStackDepth() > 1)) {
                    OpcodeStack.Item colItem = stack.getStackItem(1);
                    OpcodeStack.Item valueItem = stack.getStackItem(0);
                    int reg = isLocalCollection(colItem);
                    if (reg >= 0) {
                        regOrField = Integer.valueOf(reg);
                        uValue = (Comparable<?>) valueItem.getUserValue();
                        if (uValue != null) {
                            LoopInfo loop = loops.get(uValue);
                            if ((loop != null) && loop.isInLoop(pc) && (this.getCodeByte(getNextPC()) == Const.POP)) {
                                loop.foundAdd(pc);
                            }
                        }
                    } else {
                        String field = isFieldCollection(colItem);
                        if (field != null) {
                            regOrField = field;
                            uValue = (Comparable<?>) valueItem.getUserValue();
                            if (uValue != null) {
                                LoopInfo loop = loops.get(uValue);
                                if ((loop != null) && loop.isInLoop(pc) && (this.getCodeByte(getNextPC()) == Const.POP)) {
                                    loop.foundAdd(pc);
                                }
                            }
                        }
                    }
                }
            } else if (OpcodeUtils.isIStore(seen) || OpcodeUtils.isAStore(seen)) {
                if (stack.getStackDepth() > 0) {
                    uValue = (Comparable<?>) stack.getStackItem(0).getUserValue();
                    userValues.put(Integer.valueOf(RegisterUtils.getStoreReg(this, seen)), uValue);
                }
            } else if (OpcodeUtils.isILoad(seen) || OpcodeUtils.isALoad(seen)) {
                sawLoad = true;
            } else if (seen == Const.IFEQ) {
                boolean loopFound = false;
                if ((stack.getStackDepth() > 0) && (getBranchOffset() > 0)) {
                    int gotoPos = getBranchTarget() - 3;
                    byte[] code = getCode().getCode();
                    if ((0x00FF & code[gotoPos]) == Const.GOTO) {
                        short brOffset = (short) (0x0FF & code[gotoPos + 1]);
                        brOffset <<= 8;
                        brOffset |= (0x0FF & code[gotoPos + 2]);
                        gotoPos += brOffset;
                        if (gotoPos < pc) {
                            OpcodeStack.Item itm = stack.getStackItem(0);
                            uValue = (Comparable<?>) itm.getUserValue();
                            if (uValue != null) {
                                loops.put(uValue, new LoopInfo(pc, getBranchTarget()));
                            }
                            loopFound = true;
                        }
                    }

                    if (!loopFound) {
                        removeLoop(pc);
                    }
                }
            } else if (isInstanceMethod && (seen == Const.PUTFIELD)) {
                if (stack.getStackDepth() > 1) {
                    OpcodeStack.Item item = stack.getStackItem(1);
                    if (item.getRegisterNumber() == 0) {
                        uValue = (Comparable<?>) stack.getStackItem(0).getUserValue();
                        userValues.put(getNameConstantOperand(), uValue);
                    }
                }
            } else if (isInstanceMethod && (seen == Const.GETFIELD)) {
                if (stack.getStackDepth() > 0) {
                    OpcodeStack.Item item = stack.getStackItem(0);
                    if (item.getRegisterNumber() == 0) {
                        sawLoad = true;
                    }
                }
            } else if (((seen > Const.IFEQ) && (seen <= Const.GOTO)) || (seen == Const.IFNULL) || (seen == Const.IFNONNULL)) {
                removeLoop(pc);
            } else if ((seen == Const.CHECKCAST) && (stack.getStackDepth() > 0)) {
                OpcodeStack.Item itm = stack.getStackItem(0);
                uValue = (Comparable<?>) itm.getUserValue();
                if (uValue != null) {
                    regOrField = uValue;
                    sawAlias = true;
                }
            }
        } catch (ClassNotFoundException cnfe) {
            bugReporter.reportMissingClass(cnfe);
        } finally {
            TernaryPatcher.pre(stack, seen);
            stack.sawOpcode(this, seen);
            TernaryPatcher.post(stack, seen);
            if (sawAlias) {
                if (stack.getStackDepth() > 0) {
                    OpcodeStack.Item itm = stack.getStackItem(0);
                    itm.setUserValue(regOrField);
                }
            } else if (sawLoad && (stack.getStackDepth() > 0)) {
                OpcodeStack.Item itm = stack.getStackItem(0);
                int reg = itm.getRegisterNumber();
                if (reg >= 0) {
                    uValue = userValues.get(Integer.valueOf(reg));
                    itm.setUserValue(uValue);
                } else {
                    XField xField = itm.getXField();
                    if (xField != null) {
                        uValue = userValues.get(xField.getName());
                        itm.setUserValue(uValue);
                    }
                }
            }
        }
    }
1004701
@Override
    public void visit(Delete delete) {
        if (enableLimitCheck && delete.getLimit() == null) {
            throw new IllegalStateException("no limit in sql: " + sql);
        }
        this.getStack().push(new FrameContext(StatementType.DELETE));
        visit0(delete);
        afterVisitBaseStatement();
    }
303063
@Override
  public MethodVisitor visitMethod(
      int access, String base, String desc, String signature, String[] exceptions) {
    MethodVisitor mv = cv.visitMethod(access, base, desc, signature, exceptions);

    if (mv != null) {
      // We need to compute stackmaps (see
      // AllocationInstrumenter#instrument).  This can't really be
      // done for old bytecode that contains JSR and RET instructions.
      // So, we remove JSRs and RETs.
      JSRInlinerAdapter jsria =
          new JSRInlinerAdapter(mv, access, base, desc, signature, exceptions);
      AllocationMethodAdapter aimv =
          new AllocationMethodAdapter(jsria, recorderClass, recorderMethod);
      LocalVariablesSorter lvs = new LocalVariablesSorter(access, desc, aimv);
      aimv.lvs = lvs;
      mv = lvs;
    }
    return mv;
  }
392230
@Override
    public void visitMethod(Method obj) {
        Code c = obj.getCode();
        if (c != null) {
            byte[] opcodes = c.getCode();
            if (opcodes != null) {
                trPCPos = opcodes.length - 1;
                if (!obj.getSignature().endsWith(Values.SIG_VOID)) {
                    trPCPos -= 1;
                }
                trPCPos -= TAILRECURSIONFUDGE;
                possibleTailRecursion = true;
                isStatic = obj.isStatic();
                stack.resetForMethodEntry(this);
                super.visitMethod(obj);
            }
        }
    }