use of com.intellij.psi.impl.file.PsiDirectoryFactory in project intellij-community by JetBrains.
the class CreateDirectoryOrPackageAction method update.
@Override
public void update(AnActionEvent event) {
Presentation presentation = event.getPresentation();
Project project = event.getData(CommonDataKeys.PROJECT);
if (project == null) {
presentation.setVisible(false);
presentation.setEnabled(false);
return;
}
IdeView view = event.getData(LangDataKeys.IDE_VIEW);
if (view == null) {
presentation.setVisible(false);
presentation.setEnabled(false);
return;
}
final PsiDirectory[] directories = view.getDirectories();
if (directories.length == 0) {
presentation.setVisible(false);
presentation.setEnabled(false);
return;
}
presentation.setVisible(true);
presentation.setEnabled(true);
boolean isPackage = false;
final PsiDirectoryFactory factory = PsiDirectoryFactory.getInstance(project);
for (PsiDirectory directory : directories) {
if (factory.isPackage(directory)) {
isPackage = true;
break;
}
}
if (isPackage) {
presentation.setText(IdeBundle.message("action.package"));
presentation.setIcon(PlatformIcons.PACKAGE_ICON);
} else {
presentation.setText(IdeBundle.message("action.directory"));
presentation.setIcon(PlatformIcons.DIRECTORY_CLOSED_ICON);
}
}
use of com.intellij.psi.impl.file.PsiDirectoryFactory in project intellij-community by JetBrains.
the class WrongPackageStatementInspectionBase method isValidPackageName.
private static boolean isValidPackageName(String packageName, final Project project) {
PsiDirectoryFactory factory = PsiDirectoryFactory.getInstance(project);
Iterable<String> shortNames = StringUtil.tokenize(packageName, ".");
for (String shortName : shortNames) {
if (!factory.isValidPackageName(shortName))
return false;
}
return true;
}
Aggregations