use of com.intellij.psi.JavaDirectoryService in project android by JetBrains.
the class JavaSourceAction method isAvailable.
protected static boolean isAvailable(DataContext dataContext) {
final Module module = LangDataKeys.MODULE.getData(dataContext);
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (module == null || view == null || view.getDirectories().length == 0 || AndroidFacet.getInstance(module) == null) {
return false;
}
final ProjectFileIndex projectIndex = ProjectRootManager.getInstance(module.getProject()).getFileIndex();
final JavaDirectoryService dirService = JavaDirectoryService.getInstance();
for (PsiDirectory dir : view.getDirectories()) {
if (projectIndex.isUnderSourceRootOfType(dir.getVirtualFile(), JavaModuleSourceRootTypes.SOURCES) && dirService.getPackage(dir) != null && !dirService.getPackage(dir).getQualifiedName().isEmpty()) {
return true;
}
}
return false;
}
use of com.intellij.psi.JavaDirectoryService in project android by JetBrains.
the class LegacyNewAndroidComponentAction method isAvailable.
private static boolean isAvailable(DataContext dataContext) {
final Module module = LangDataKeys.MODULE.getData(dataContext);
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (module == null || view == null || view.getDirectories().length == 0) {
return false;
}
final AndroidFacet facet = AndroidFacet.getInstance(module);
if (facet == null || facet.requiresAndroidModel()) {
return false;
}
final ProjectFileIndex projectIndex = ProjectRootManager.getInstance(module.getProject()).getFileIndex();
final JavaDirectoryService dirService = JavaDirectoryService.getInstance();
for (PsiDirectory dir : view.getDirectories()) {
if (projectIndex.isUnderSourceRootOfType(dir.getVirtualFile(), JavaModuleSourceRootTypes.SOURCES) && dirService.getPackage(dir) != null) {
return true;
}
}
return false;
}
use of com.intellij.psi.JavaDirectoryService in project intellij-community by JetBrains.
the class CreatePackageInfoAction method isAvailable.
private static boolean isAvailable(DataContext dataContext) {
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (project == null || view == null) {
return false;
}
final PsiDirectory[] directories = view.getDirectories();
if (directories.length == 0) {
return false;
}
final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
final JavaDirectoryService directoryService = JavaDirectoryService.getInstance();
final PsiNameHelper nameHelper = PsiNameHelper.getInstance(project);
for (PsiDirectory directory : directories) {
if (projectFileIndex.isUnderSourceRootOfType(directory.getVirtualFile(), JavaModuleSourceRootTypes.SOURCES) && PsiUtil.isLanguageLevel5OrHigher(directory)) {
final PsiPackage aPackage = directoryService.getPackage(directory);
if (aPackage != null) {
final String qualifiedName = aPackage.getQualifiedName();
if (StringUtil.isEmpty(qualifiedName) || nameHelper.isQualifiedName(qualifiedName)) {
return true;
}
}
}
}
return false;
}
use of com.intellij.psi.JavaDirectoryService in project qi4j-sdk by Qi4j.
the class CreateConcernOfInPackageAction method doCheckCreate.
protected final void doCheckCreate(final PsiDirectory dir, final String className) throws IncorrectOperationException {
JavaDirectoryService javaDirectoryService = JavaDirectoryService.getInstance();
javaDirectoryService.checkCreateClass(dir, className);
}
Aggregations