@NotNull
 private static CommonProblemDescriptor[] mergeDescriptors(
     @NotNull CommonProblemDescriptor[] problems1, @NotNull CommonProblemDescriptor[] problems2) {
   CommonProblemDescriptor[] out =
       new CommonProblemDescriptor[problems1.length + problems2.length];
   int o = problems1.length;
   Equality<CommonProblemDescriptor> equality =
       new Equality<CommonProblemDescriptor>() {
         @Override
         public boolean equals(CommonProblemDescriptor o1, CommonProblemDescriptor o2) {
           if (o1 instanceof ProblemDescriptor) {
             ProblemDescriptorBase p1 = (ProblemDescriptorBase) o1;
             ProblemDescriptorBase p2 = (ProblemDescriptorBase) o2;
             if (!Comparing.equal(p1.getDescriptionTemplate(), p2.getDescriptionTemplate()))
               return false;
             if (!Comparing.equal(p1.getTextRange(), p2.getTextRange())) return false;
             if (!Comparing.equal(p1.getHighlightType(), p2.getHighlightType())) return false;
             if (!Comparing.equal(p1.getProblemGroup(), p2.getProblemGroup())) return false;
             if (!Comparing.equal(p1.getStartElement(), p2.getStartElement())) return false;
             if (!Comparing.equal(p1.getEndElement(), p2.getEndElement())) return false;
           } else {
             if (!o1.toString().equals(o2.toString())) return false;
           }
           return true;
         }
       };
   for (CommonProblemDescriptor descriptor : problems2) {
     if (ArrayUtil.indexOf(problems1, descriptor, equality) == -1) {
       out[o++] = descriptor;
     }
   }
   System.arraycopy(problems1, 0, out, 0, problems1.length);
   return Arrays.copyOfRange(out, 0, o);
 }
  public static ArrayList<RefParameter> getUnusedParameters(RefMethod refMethod) {
    boolean checkDeep = !refMethod.isStatic() && !refMethod.isConstructor();
    ArrayList<RefParameter> res = new ArrayList<RefParameter>();
    RefParameter[] methodParameters = refMethod.getParameters();
    RefParameter[] result = new RefParameter[methodParameters.length];
    System.arraycopy(methodParameters, 0, result, 0, methodParameters.length);

    clearUsedParameters(refMethod, result, checkDeep);

    for (RefParameter parameter : result) {
      if (parameter != null) {
        res.add(parameter);
      }
    }

    return res;
  }