use of com.intellij.codeInspection.reference.RefElement 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.RefElement 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.RefElement 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;
}
use of com.intellij.codeInspection.reference.RefElement in project intellij-community by JetBrains.
the class EmptyDirectoryInspection method runInspection.
@Override
public void runInspection(@NotNull final AnalysisScope scope, @NotNull final InspectionManager manager, @NotNull final GlobalInspectionContext context, @NotNull final ProblemDescriptionsProcessor processor) {
final Project project = context.getProject();
final ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();
final SearchScope searchScope = scope.toSearchScope();
if (!(searchScope instanceof GlobalSearchScope)) {
return;
}
final GlobalSearchScope globalSearchScope = (GlobalSearchScope) searchScope;
final PsiManager psiManager = PsiManager.getInstance(project);
index.iterateContent(fileOrDir -> {
if (!fileOrDir.isDirectory()) {
return true;
}
if (!globalSearchScope.contains(fileOrDir)) {
return true;
}
if (onlyReportDirectoriesUnderSourceRoots && !index.isInSourceContent(fileOrDir)) {
return true;
}
final VirtualFile[] children = fileOrDir.getChildren();
if (children.length != 0) {
return true;
}
final PsiDirectory directory = ReadAction.compute(() -> psiManager.findDirectory(fileOrDir));
final RefElement refDirectory = context.getRefManager().getReference(directory);
if (refDirectory == null || context.shouldCheck(refDirectory, this)) {
return true;
}
final String relativePath = getPathRelativeToModule(fileOrDir, project);
if (relativePath == null) {
return true;
}
processor.addProblemElement(refDirectory, manager.createProblemDescriptor(InspectionGadgetsBundle.message("empty.directories.problem.descriptor", relativePath), new EmptyPackageFix(fileOrDir.getUrl(), fileOrDir.getName())));
return true;
});
}
use of com.intellij.codeInspection.reference.RefElement in project intellij-community by JetBrains.
the class InitializationDependencyUtils method tabulateInitializationDependencyClasses.
@SuppressWarnings({ "MethodWithMultipleLoops" })
static void tabulateInitializationDependencyClasses(RefElement element, Set<RefClass> dependencies) {
final Collection<RefElement> references = element.getOutReferences();
final RefJavaUtil refUtil = RefJavaUtil.getInstance();
for (RefElement reference : references) {
final RefClass refClass = refUtil.getTopLevelClass(reference);
if (refClass != null) {
dependencies.add(refClass);
}
}
final List<RefEntity> children = element.getChildren();
for (RefEntity child : children) {
if (child instanceof RefElement) {
tabulateInitializationDependencyClasses((RefElement) child, dependencies);
}
}
}
Aggregations