use of com.intellij.psi.util.PsiUtil in project intellij-community by JetBrains.
the class CreateModuleInfoAction method update.
@Override
public void update(@NotNull AnActionEvent e) {
DataContext ctx = e.getDataContext();
boolean available = Optional.ofNullable(LangDataKeys.IDE_VIEW.getData(ctx)).map(view -> getTargetDirectory(ctx, view)).filter(PsiUtil::isLanguageLevel9OrHigher).map(ModuleUtilCore::findModuleForPsiElement).map(module -> FilenameIndex.getVirtualFilesByName(module.getProject(), MODULE_INFO_FILE, module.getModuleScope(false)).isEmpty()).orElse(false);
e.getPresentation().setEnabledAndVisible(available);
}
use of com.intellij.psi.util.PsiUtil in project intellij-community by JetBrains.
the class JavaAllOverridingMethodsSearcher method execute.
@Override
public boolean execute(@NotNull final AllOverridingMethodsSearch.SearchParameters p, @NotNull final Processor<Pair<PsiMethod, PsiMethod>> consumer) {
final PsiClass psiClass = p.getPsiClass();
final List<PsiMethod> potentials = ReadAction.compute(() -> ContainerUtil.filter(psiClass.getMethods(), PsiUtil::canBeOverriden));
final SearchScope scope = p.getScope();
Processor<PsiClass> inheritorsProcessor = inheritor -> {
Project project = psiClass.getProject();
for (PsiMethod superMethod : potentials) {
ProgressManager.checkCanceled();
if (superMethod.hasModifierProperty(PsiModifier.PACKAGE_LOCAL) && !JavaPsiFacade.getInstance(project).arePackagesTheSame(psiClass, inheritor))
continue;
PsiMethod inInheritor = JavaOverridingMethodsSearcher.findOverridingMethod(project, inheritor, superMethod, psiClass);
if (inInheritor != null && !consumer.process(Pair.create(superMethod, inInheritor)))
return false;
}
return true;
};
return ClassInheritorsSearch.search(psiClass, scope, true).forEach(inheritorsProcessor);
}
Aggregations