use of com.intellij.codeInspection.reference.RefEntity in project intellij-community by JetBrains.
the class QuickFixAction method getSelectedElements.
@NotNull
private static RefEntity[] getSelectedElements(InspectionResultsView view) {
if (view == null)
return new RefElement[0];
List<RefEntity> selection = new ArrayList<>(Arrays.asList(view.getTree().getSelectedElements()));
PsiDocumentManager.getInstance(view.getProject()).commitAllDocuments();
Collections.sort(selection, (o1, o2) -> {
if (o1 instanceof RefElement && o2 instanceof RefElement) {
RefElement r1 = (RefElement) o1;
RefElement r2 = (RefElement) o2;
final PsiElement element1 = r1.getElement();
final PsiElement element2 = r2.getElement();
final PsiFile containingFile1 = element1.getContainingFile();
final PsiFile containingFile2 = element2.getContainingFile();
if (containingFile1 == containingFile2) {
int i1 = element1.getTextOffset();
int i2 = element2.getTextOffset();
if (i1 < i2) {
return 1;
}
if (i1 > i2) {
return -1;
}
return 0;
}
return containingFile1.getName().compareTo(containingFile2.getName());
}
if (o1 instanceof RefElement) {
return 1;
}
if (o2 instanceof RefElement) {
return -1;
}
return o1.getName().compareTo(o2.getName());
});
return selection.toArray(new RefEntity[selection.size()]);
}
use of com.intellij.codeInspection.reference.RefEntity in project intellij-community by JetBrains.
the class QuickFixAction method removeElements.
public static void removeElements(@NotNull RefEntity[] refElements, @NotNull Project project, @NotNull InspectionToolWrapper toolWrapper) {
refreshViews(project, refElements, toolWrapper);
final ArrayList<RefElement> deletedRefs = new ArrayList<>(1);
for (RefEntity refElement : refElements) {
if (!(refElement instanceof RefElement))
continue;
refElement.getRefManager().removeRefElement((RefElement) refElement, deletedRefs);
}
}
use of com.intellij.codeInspection.reference.RefEntity in project intellij-community by JetBrains.
the class QuickFixAction method refreshViews.
protected static void refreshViews(@NotNull Project project, @NotNull RefEntity[] refElements, @NotNull InspectionToolWrapper toolWrapper) {
final Set<PsiElement> ignoredElements = new HashSet<>();
for (RefEntity element : refElements) {
final PsiElement psiElement = element instanceof RefElement ? ((RefElement) element).getElement() : null;
if (psiElement != null && psiElement.isValid()) {
ignoredElements.add(psiElement);
}
}
refreshViews(project, ignoredElements, toolWrapper);
}
use of com.intellij.codeInspection.reference.RefEntity in project intellij-community by JetBrains.
the class OfflineDescriptorResolveResult method resolve.
@NotNull
static OfflineDescriptorResolveResult resolve(@NotNull OfflineProblemDescriptor descriptor, @NotNull InspectionToolWrapper wrapper, @NotNull InspectionToolPresentation presentation) {
final RefEntity element = descriptor.getRefElement(presentation.getContext().getRefManager());
final CommonProblemDescriptor resolvedDescriptor = ReadAction.compute(() -> createDescriptor(element, descriptor, wrapper, presentation));
return new OfflineDescriptorResolveResult(element, resolvedDescriptor);
}
use of com.intellij.codeInspection.reference.RefEntity in project intellij-community by JetBrains.
the class OfflineInspectionRVContentProvider method getFilteredContent.
@Nullable
@SuppressWarnings({ "UnusedAssignment" })
private Map<String, Set<OfflineProblemDescriptor>> getFilteredContent(@NotNull GlobalInspectionContextImpl context, @NotNull InspectionToolWrapper toolWrapper) {
Map<String, Set<OfflineProblemDescriptor>> content = myContent.get(toolWrapper.getShortName());
if (content == null)
return null;
if (context.getUIOptions().FILTER_RESOLVED_ITEMS) {
final Map<String, Set<OfflineProblemDescriptor>> current = new HashMap<>(content);
//GC it
content = null;
InspectionToolPresentation presentation = context.getPresentation(toolWrapper);
for (RefEntity refEntity : presentation.getIgnoredRefElements()) {
if (refEntity instanceof RefElement) {
excludeProblem(refEntity.getExternalName(), current);
}
}
return current;
}
return content;
}
Aggregations