use of com.intellij.psi.PsiManager in project intellij-community by JetBrains.
the class FormInspectionUtil method isComponentClass.
public static boolean isComponentClass(final Module module, final IComponent component, final Class componentClass) {
final GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module);
final PsiManager psiManager = PsiManager.getInstance(module.getProject());
final PsiClass aClass = JavaPsiFacade.getInstance(psiManager.getProject()).findClass(component.getComponentClassName(), scope);
if (aClass != null) {
final PsiClass labelClass = JavaPsiFacade.getInstance(psiManager.getProject()).findClass(componentClass.getName(), scope);
if (labelClass != null && InheritanceUtil.isInheritorOrSelf(aClass, labelClass, true)) {
return true;
}
}
return false;
}
use of com.intellij.psi.PsiManager in project intellij-community by JetBrains.
the class UpdateCopyrightCheckinHandlerFactory method createHandler.
@NotNull
public CheckinHandler createHandler(@NotNull final CheckinProjectPanel panel, @NotNull CommitContext commitContext) {
return new CheckinHandler() {
@Override
public RefreshableOnComponent getBeforeCheckinConfigurationPanel() {
final JCheckBox updateCopyrightCb = new JCheckBox("Update copyright");
return new RefreshableOnComponent() {
public JComponent getComponent() {
return JBUI.Panels.simplePanel().addToLeft(updateCopyrightCb);
}
public void refresh() {
}
public void saveState() {
UpdateCopyrightCheckinHandlerState.getInstance(panel.getProject()).UPDATE_COPYRIGHT = updateCopyrightCb.isSelected();
}
public void restoreState() {
updateCopyrightCb.setSelected(UpdateCopyrightCheckinHandlerState.getInstance(panel.getProject()).UPDATE_COPYRIGHT);
}
};
}
@Override
public ReturnResult beforeCheckin(@Nullable CommitExecutor executor, PairConsumer<Object, Object> additionalDataConsumer) {
if (UpdateCopyrightCheckinHandlerState.getInstance(panel.getProject()).UPDATE_COPYRIGHT) {
new UpdateCopyrightProcessor(panel.getProject(), null, getPsiFiles()).run();
FileDocumentManager.getInstance().saveAllDocuments();
}
return super.beforeCheckin();
}
private PsiFile[] getPsiFiles() {
final Collection<VirtualFile> files = panel.getVirtualFiles();
final List<PsiFile> psiFiles = new ArrayList<>();
final PsiManager manager = PsiManager.getInstance(panel.getProject());
for (final VirtualFile file : files) {
final PsiFile psiFile = manager.findFile(file);
if (psiFile != null) {
psiFiles.add(psiFile);
}
}
return PsiUtilCore.toPsiFileArray(psiFiles);
}
};
}
use of com.intellij.psi.PsiManager in project intellij-community by JetBrains.
the class ExternalLibrariesNode method addLibraryChildren.
public static void addLibraryChildren(final LibraryOrderEntry entry, final List<AbstractTreeNode> children, Project project, ProjectViewNode node) {
final PsiManager psiManager = PsiManager.getInstance(project);
final VirtualFile[] files = entry.getRootFiles(OrderRootType.CLASSES);
for (final VirtualFile file : files) {
final PsiDirectory psiDir = psiManager.findDirectory(file);
if (psiDir == null) {
continue;
}
children.add(new PsiDirectoryNode(project, psiDir, node.getSettings()));
}
}
use of com.intellij.psi.PsiManager in project intellij-community by JetBrains.
the class SyntheticLibraryElementNode method getChildren.
@NotNull
@Override
public Collection<AbstractTreeNode> getChildren() {
List<AbstractTreeNode> children = new ArrayList<>();
SyntheticLibrary library = getLibrary();
Project project = Objects.requireNonNull(getProject());
PsiManager psiManager = PsiManager.getInstance(project);
for (VirtualFile file : library.getSourceRoots()) {
if (!file.isValid())
continue;
if (file.isDirectory()) {
PsiDirectory psiDir = psiManager.findDirectory(file);
if (psiDir != null) {
children.add(new PsiDirectoryNode(project, psiDir, getSettings()));
}
} else {
PsiFile psiFile = psiManager.findFile(file);
if (psiFile != null) {
children.add(new PsiFileNode(project, psiFile, getSettings()));
}
}
}
return children;
}
use of com.intellij.psi.PsiManager in project intellij-community by JetBrains.
the class ProjectViewProjectNode method getChildren.
@Override
@NotNull
public Collection<AbstractTreeNode> getChildren() {
List<VirtualFile> topLevelContentRoots = ProjectViewDirectoryHelper.getInstance(myProject).getTopLevelRoots();
Set<Module> modules = new LinkedHashSet<>(topLevelContentRoots.size());
for (VirtualFile root : topLevelContentRoots) {
final Module module = ModuleUtil.findModuleForFile(root, myProject);
if (module != null) {
// Some people exclude module's content roots...
modules.add(module);
}
}
ArrayList<AbstractTreeNode> nodes = new ArrayList<>();
final PsiManager psiManager = PsiManager.getInstance(getProject());
/*
for (VirtualFile root : reduceRoots(topLevelContentRoots)) {
nodes.add(new PsiDirectoryNode(getProject(), psiManager.findDirectory(root), getSettings()));
}
*/
nodes.addAll(modulesAndGroups(modules.toArray(new Module[modules.size()])));
final VirtualFile baseDir = getProject().getBaseDir();
if (baseDir == null)
return nodes;
final VirtualFile[] files = baseDir.getChildren();
for (VirtualFile file : files) {
if (!file.isDirectory()) {
if (ProjectFileIndex.SERVICE.getInstance(getProject()).getModuleForFile(file, false) == null) {
nodes.add(new PsiFileNode(getProject(), psiManager.findFile(file), getSettings()));
}
}
}
if (getSettings().isShowLibraryContents()) {
nodes.add(new ExternalLibrariesNode(getProject(), getSettings()));
}
return nodes;
}
Aggregations