/*
(non-Javadoc)

@see
edu.umd.cs.findbugs.visitclass.BetterVisitor#visitMethod(org.apache.bcel
.classfile.Method)
347180
@Override
    public void visitMethod(Method obj) {
        if (sawDateClass) {
            try {
                super.visitMethod(obj);
                currentMethod = obj;
                currentLockDataFlow = getClassContext().getLockDataflow(currentMethod);
                currentCFG = getClassContext().getCFG(currentMethod);
            } catch (CFGBuilderException e) {
                reporter.logError("Synchronization check in Static Calendar Detector caught an error.", e);
            } catch (DataflowAnalysisException e) {
                reporter.logError("Synchronization check in Static Calendar Detector caught an error.", e);
            }
        }
    }
1132071
public void visitClass(ClassNode classNode) {
        referencedClasses.clear();
        WriterControllerFactory factory = classNode.getNodeMetaData(WriterControllerFactory.class);
        WriterController normalController = new WriterController();
        if (factory!=null) {
            this.controller = factory.makeController(normalController);
        } else {
            this.controller = normalController;
        }
        this.controller.init(this, context, cv, classNode);
        this.cv = this.controller.getClassVisitor();

        if (controller.shouldOptimizeForInt() || factory!=null) {
            OptimizingStatementWriter.setNodeMeta(controller.getTypeChooser(),classNode);
        }

        try {
            int bytecodeVersion = controller.getBytecodeVersion();
            Object min = classNode.getNodeMetaData(MINIMUM_BYTECODE_VERSION);
            if (min instanceof Integer) {
                int minVersion = (int) min;
                if ((bytecodeVersion ^ Opcodes.V_PREVIEW) < minVersion) {
                    bytecodeVersion = minVersion;
                }
            }
            cv.visit(
                    bytecodeVersion,
                    adjustedClassModifiersForClassWriting(classNode),
                    controller.getInternalClassName(),
                    BytecodeHelper.getGenericsSignature(classNode),
                    controller.getInternalBaseClassName(),
                    BytecodeHelper.getClassInternalNames(classNode.getInterfaces())
            );
            cv.visitSource(sourceFile, null);
            if (classNode instanceof InnerClassNode) {
                InnerClassNode innerClass = (InnerClassNode) classNode;
                MethodNode enclosingMethod = innerClass.getEnclosingMethod();
                if (enclosingMethod != null) {
                    String outerClassName = BytecodeHelper.getClassInternalName(innerClass.getOuterClass().getName());
                    cv.visitOuterClass(outerClassName, enclosingMethod.getName(), BytecodeHelper.getMethodDescriptor(enclosingMethod));
                }
            }
            if (classNode.getName().endsWith("package-info")) {
                PackageNode packageNode = classNode.getPackage();
                if (packageNode != null) {
                    // pull them out of package node but treat them like they were on class node
                    visitAnnotations(classNode, packageNode, cv);
                }
                cv.visitEnd();
                return;
            } else {
                visitAnnotations(classNode, cv);
            }

            if (classNode.isInterface()) {
                ClassNode owner = classNode;
                if (owner instanceof InnerClassNode) {
                    owner = owner.getOuterClass();
                }
                String outerClassName = classNode.getName();
                String name = outerClassName + "$" + context.getNextInnerClassIdx();
                controller.setInterfaceClassLoadingClass(
                        new InterfaceHelperClassNode (
                                owner, name, ACC_SUPER | ACC_SYNTHETIC | ACC_STATIC, ClassHelper.OBJECT_TYPE,
                                controller.getCallSiteWriter().getCallSites()));
                super.visitClass(classNode);
                createInterfaceSyntheticStaticFields();
            } else {
                super.visitClass(classNode);
                MopWriter.Factory mopWriterFactory = classNode.getNodeMetaData(MopWriter.Factory.class);
                if (mopWriterFactory==null) {
                    mopWriterFactory = MopWriter.FACTORY;
                }
                MopWriter mopWriter = mopWriterFactory.create(controller);
                mopWriter.createMopMethods();
                controller.getCallSiteWriter().generateCallSiteArray();
                createSyntheticStaticFields();
            }

            // GROOVY-6750 and GROOVY-6808
            for (Iterator<InnerClassNode> iter = classNode.getInnerClasses(); iter.hasNext();) {
                InnerClassNode innerClass = iter.next();
                makeInnerClassEntry(innerClass);
            }
            makeInnerClassEntry(classNode);

            cv.visitEnd();
        } catch (GroovyRuntimeException e) {
            e.setModule(classNode.getModule());
            throw e;
        } catch (NegativeArraySizeException nase) {
            throw new GroovyRuntimeException("NegativeArraySizeException while processing "+sourceFile, nase);
        } catch (NullPointerException npe) {
            throw new GroovyRuntimeException("NPE while processing "+sourceFile, npe);
        }
    }
1053558
protected void checkProducerMethod(EnhancedAnnotatedMethod<T, ? super X> method) {
        if (method.getEnhancedParameters(Observes.class).size() > 0) {
            throw BeanLogger.LOG.inconsistentAnnotationsOnMethod(PRODUCER_ANNOTATION, "@Observes", this.method,
                    Formats.formatAsStackTraceElement(method.getJavaMember()));
        } else if (method.getEnhancedParameters(ObservesAsync.class).size() > 0) {
            throw BeanLogger.LOG.inconsistentAnnotationsOnMethod(PRODUCER_ANNOTATION, "@ObservesAsync", this.method,
                    Formats.formatAsStackTraceElement(method.getJavaMember()));
        } else if (method.getEnhancedParameters(Disposes.class).size() > 0) {
            throw BeanLogger.LOG.inconsistentAnnotationsOnMethod(PRODUCER_ANNOTATION, "@Disposes", this.method,
                    Formats.formatAsStackTraceElement(method.getJavaMember()));
        } else if (getDeclaringBean() instanceof SessionBean<?> && !Modifier.isStatic(method.slim().getJavaMember().getModifiers())) {
            boolean methodDeclaredOnTypes = false;
            for (Type type : getDeclaringBean().getTypes()) {
                Class<?> clazz = Reflections.getRawType(type);
                try {
                    AccessController.doPrivileged(new GetMethodAction(clazz, method.getName(), method.getParameterTypesAsArray()));
                    methodDeclaredOnTypes = true;
                    break;
                } catch (PrivilegedActionException ignored) {
                }
            }
            if (!methodDeclaredOnTypes) {
                throw BeanLogger.LOG.methodNotBusinessMethod("Producer", this, getDeclaringBean(), Formats.formatAsStackTraceElement(method.getJavaMember()));
            }
        }
    }
1211648
@Override
	public void visitMethod(Method obj) {
		try {
			if (obj.isSynthetic()) {
				return;
			}

			if (Values.CONSTRUCTOR.equals(getMethodName()) && javaClass.getClassName().contains("$")) {
				return;
			}

			List<String> types = SignatureUtils.getParameterSignatures(obj.getSignature());
			if ((types.isEmpty()) || (types.size() > 2)) {
				return;
			}

			if ((obj.getAccessFlags() & Const.ACC_VARARGS) != 0) {
				return;
			}

			String lastParmSig = types.get(types.size() - 1);
			if (!lastParmSig.startsWith(Values.SIG_ARRAY_PREFIX)
					|| lastParmSig.startsWith(Values.SIG_ARRAY_OF_ARRAYS_PREFIX)) {
				return;
			}

			if (SignatureBuilder.SIG_BYTE_ARRAY.equals(lastParmSig)
					|| SignatureBuilder.SIG_CHAR_ARRAY.equals(lastParmSig)) {
				return;
			}

			if (hasSimilarParms(types)) {
				return;
			}

			if (obj.isStatic() && "main".equals(obj.getName()) && SIG_STRING_ARRAY_TO_VOID.equals(obj.getSignature())) {
				return;
			}

			if (!obj.isPrivate() && !obj.isStatic() && isInherited(obj)) {
				return;
			}

			super.visitMethod(obj);
			bugReporter.reportBug(new BugInstance(this, BugType.UVA_USE_VAR_ARGS.name(), LOW_PRIORITY).addClass(this)
					.addMethod(this));

		} catch (ClassNotFoundException cnfe) {
			bugReporter.reportMissingClass(cnfe);
		}
	}
735142
@Override
  public MethodVisitor visitMethod(
      final int access,
      final String name,
      final String desc,
      final String signature,
      final String[] exceptions) {
    MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
    return new CodeSizeEvaluator(mv) {
      @Override
      public void visitEnd() {
        super.visitEnd();
        if (getMaxSize() > 64 * 1024) {
          state = State.FAIL_TOO_LONG;
          message = "the method " + name + " was too long.";
        }
      }
    };
  }
535273
@Override
    public void visitMethod(Method obj) {
        LocalVariableTable lvt = obj.getLocalVariableTable();
        if (lvt != null) {
            LocalVariable[] lvs = lvt.getLocalVariableTable();
            for (LocalVariable lv : lvs) {
                if (checkConfusedName(lv.getName(), lv.getSignature())) {
                    bugReporter.reportBug(new BugInstance(this, BugType.CNC_COLLECTION_NAMING_CONFUSION.name(), NORMAL_PRIORITY).addClass(this)
                            .addString(lv.getName()).addSourceLine(this.clsContext, this, lv.getStartPC()));
                }
            }
        }
    }
1372387
static Method getMethod(Class<?> cls, String name) throws NoSuchMethodException {
    NoSuchMethodException firstExc = null;
    for (Class<?> c = cls; c != null; c = c.getSuperclass()) {
      try {
        return c.getDeclaredMethod(name);
      } catch (NoSuchMethodException e) {
        if (firstExc == null) {
          firstExc = e;
        }
      }
    }
    throw firstExc;
  }
1022712
public void traverseMethod(String methodID) {
    MethodReferenceNode node = (MethodReferenceNode) elementReferenceMap.get(methodID);
    if (node == null) {
      //TODO(malvania): This might never be reached, because we create a node for every method,
      //                both invoked and declared.
      ErrorUtil.warning("Encountered .class method while accessing: " + methodID);
      return;
    }
    if (node.reachable) {
      return;
    }
    node.reachable = true;
    markParentClasses(ElementUtil.getDeclaringClass(node.methodElement));

    for (String invokedMethodID : node.invokedMethods) {
      traverseMethod(invokedMethodID);
    }
    for (String overrideMethodID : node.overridingMethods) {
      traverseMethod(overrideMethodID);
    }
  }
714711
public final void writeMethod(int access, Method method, ClassVisitor visitor) {
    writeMethodTo(new CodeBuilder(access, method, null, visitor));
  }
993801
@Override
    public void visitMethod(final Method obj) {
        methodName = obj.getName();
        if (Values.STATIC_INITIALIZER.equals(methodName) || Values.CONSTRUCTOR.equals(methodName)) {
            return;
        }

        List<String> parms = SignatureUtils.getParameterSignatures(obj.getSignature());

        if (!parms.isEmpty()) {
            boolean isStatic = obj.isStatic();
            isAbstract = obj.isAbstract();

            firstLocalReg = isStatic ? 0 : 1;
            for (String parmSig : parms) {
                firstLocalReg += SignatureUtils.getSignatureSize(parmSig);
            }

            sourceLines = getSourceLines(obj);
        }
    }
1228639
public final void writeIOExceptionMethod(int access, Method method, ClassVisitor visitor) {
    writeMethodTo(new CodeBuilder(access, method, IO_EXCEPTION_ARRAY, visitor));
  }
17628
public static MethodAnnotation fromVisitedMethod(PreorderVisitor visitor) {
        String className = visitor.getDottedClassName();
        MethodAnnotation result = new MethodAnnotation(className, visitor.getMethodName(), visitor.getMethodSig(), visitor
                .getMethod().isStatic());

        // Try to find the source lines for the method
        SourceLineAnnotation srcLines = SourceLineAnnotation.fromVisitedMethod(visitor);
        result.setSourceLines(srcLines);

        return result;
    }
328554
@Override
    public void sawOpcode(int seen) {
        if (seen == Const.INVOKEVIRTUAL) {
            String className = getClassConstantOperand();
            String methodName = getNameConstantOperand();
            String methodSig = getSigConstantOperand();

            FQMethod methodInfo = new FQMethod(className, methodName, methodSig);
            if (oldMethods.contains(methodInfo)) {
                bugReporter.reportBug(new BugInstance(this, BugType.NCMU_NON_COLLECTION_METHOD_USE.name(), NORMAL_PRIORITY).addClass(this).addMethod(this)
                        .addSourceLine(this));
            }
        }
    }
932718
@Override
    public void visit(JavaClass someObj) {
        currentClass = someObj.getClassName();
        currentMethod = null;
        currentCFG = null;
        currentLockDataFlow = null;
        sawDateClass = false;

    }
848100
@Override
    public void visitCode(Code obj) {
        try {
            Method method = getMethod();
            if (method.isSynthetic()) {
                return;
            }

            isBooleanMethod = Type.BOOLEAN.equals(method.getReturnType());
            if (isBooleanMethod || prescreen(method)) {
                catchHandlerPCs = collectExceptions(obj.getExceptionTable());
                if (!catchHandlerPCs.isEmpty()) {
                    stack.resetForMethodEntry(this);
                    catchInfos = new ArrayList<>();
                    lvt = method.getLocalVariableTable();
                    constrainingInfo = null;
                    hasValidFalseReturn = false;
                    catchFalseReturnPC = -1;
                    super.visitCode(obj);

                    if (!hasValidFalseReturn && (catchFalseReturnPC >= 0) && !method.getName().startsWith("is")) {
                        bugReporter.reportBug(new BugInstance(this, BugType.EXS_EXCEPTION_SOFTENING_RETURN_FALSE.name(),
                                NORMAL_PRIORITY).addClass(this).addMethod(this).addSourceLine(this,
                                        catchFalseReturnPC));
                    }
                }
            }
        } finally {
            catchInfos = null;
            catchHandlerPCs = null;
            lvt = null;
            constrainingInfo = null;
        }
    }
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);
            }
        }
    }
1239650
protected function visitMethod(Node\Stmt\ClassMethod $method)
    {
        if ($this->testClass) {
            if (strpos($method->name, 'test') === 0) {
                $this->metrics['testMethods']++;
            } elseif (strpos($method->getDocComment(), '@test')) {
                $this->metrics['testMethods']++;
            }
            return;
        }
        $this->metrics['methods']++;

        if ($method->isPrivate()) {
            $this->metrics['privateMethods']++;
        } elseif ($method->isProtected()) {
            $this->metrics['protectedMethods']++;
        } else {
            $this->metrics['publicMethods']++;
        }

        if ($method->isStatic()) {
            $this->metrics['staticMethods']++;
        } else {
            $this->metrics['nonStaticMethods']++;
        }
    }