@Override public void ignoreProblem(RefEntity refEntity, CommonProblemDescriptor problem, int idx) { if (refEntity == null) return; final Set<QuickFix> localQuickFixes = getQuickFixActions().get(refEntity); final QuickFix[] fixes = problem.getFixes(); if (isIgnoreProblem(fixes, localQuickFixes, idx)) { getProblemToElements().remove(problem); Map<RefEntity, CommonProblemDescriptor[]> problemElements = getProblemElements(); synchronized (lock) { CommonProblemDescriptor[] descriptors = problemElements.get(refEntity); if (descriptors != null) { ArrayList<CommonProblemDescriptor> newDescriptors = new ArrayList<CommonProblemDescriptor>(Arrays.asList(descriptors)); newDescriptors.remove(problem); getQuickFixActions().put(refEntity, null); if (!newDescriptors.isEmpty()) { problemElements.put( refEntity, newDescriptors.toArray(new CommonProblemDescriptor[newDescriptors.size()])); for (CommonProblemDescriptor descriptor : newDescriptors) { collectQuickFixes(descriptor.getFixes(), refEntity); } } else { ignoreProblemElement(refEntity); } } } } }
@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); }