use of com.intellij.psi.PsiDirectory in project intellij-community by JetBrains.
the class AntDomFileReferenceSet method computeDefaultContexts.
@NotNull
@Override
public Collection<PsiFileSystemItem> computeDefaultContexts() {
final AntDomElement element = myValue.getParentOfType(AntDomElement.class, false);
final AntDomProject containingProject = element != null ? element.getAntProject() : null;
if (containingProject != null) {
if (isAbsolutePathReference()) {
return toFileSystemItems(ManagingFS.getInstance().getLocalRoots());
} else {
VirtualFile root = null;
if (element instanceof AntDomAnt) {
final PsiFileSystemItem dirValue = ((AntDomAnt) element).getAntFileDir().getValue();
if (dirValue instanceof PsiDirectory) {
root = dirValue.getVirtualFile();
}
}
if (root == null) {
final String basedir;
if (element instanceof AntDomIncludingDirective) {
basedir = containingProject.getContainingFileDir();
} else {
basedir = containingProject.getContextAntProject().getProjectBasedirPath();
}
if (basedir != null) {
root = LocalFileSystem.getInstance().findFileByPath(basedir);
}
}
if (root != null) {
return toFileSystemItems(root);
}
}
}
return super.computeDefaultContexts();
}
use of com.intellij.psi.PsiDirectory in project intellij-community by JetBrains.
the class DirectoryCoverageViewExtension method getChildrenNodes.
@Override
public List<AbstractTreeNode> getChildrenNodes(AbstractTreeNode node) {
List<AbstractTreeNode> children = new ArrayList<>();
if (node instanceof CoverageListNode) {
final Object val = node.getValue();
if (val instanceof PsiFile || val == null)
return Collections.emptyList();
final PsiDirectory psiDirectory = (PsiDirectory) val;
final PsiDirectory[] subdirectories = ApplicationManager.getApplication().runReadAction(new Computable<PsiDirectory[]>() {
@Override
public PsiDirectory[] compute() {
return psiDirectory.getSubdirectories();
}
});
for (PsiDirectory subdirectory : subdirectories) {
children.add(new CoverageListNode(myProject, subdirectory, mySuitesBundle, myStateBean));
}
final PsiFile[] psiFiles = ApplicationManager.getApplication().runReadAction(new Computable<PsiFile[]>() {
@Override
public PsiFile[] compute() {
return psiDirectory.getFiles();
}
});
for (PsiFile psiFile : psiFiles) {
children.add(new CoverageListNode(myProject, psiFile, mySuitesBundle, myStateBean));
}
for (AbstractTreeNode childNode : children) {
childNode.setParent(node);
}
}
return children;
}
use of com.intellij.psi.PsiDirectory in project intellij-community by JetBrains.
the class CoverageProjectViewDirectoryNodeDecorator method decorate.
public void decorate(PackageDependenciesNode node, ColoredTreeCellRenderer cellRenderer) {
final PsiElement element = node.getPsiElement();
if (element == null || !element.isValid()) {
return;
}
final CoverageDataManager manager = getCoverageDataManager();
final CoverageSuitesBundle currentSuite = manager.getCurrentSuitesBundle();
final CoverageAnnotator coverageAnnotator = currentSuite != null ? currentSuite.getAnnotator(element.getProject()) : null;
if (coverageAnnotator == null) {
// N/A
return;
}
String informationString = null;
if (element instanceof PsiDirectory) {
informationString = coverageAnnotator.getDirCoverageInformationString((PsiDirectory) element, currentSuite, manager);
} else if (element instanceof PsiFile) {
informationString = coverageAnnotator.getFileCoverageInformationString((PsiFile) element, currentSuite, manager);
}
if (informationString != null) {
appendCoverageInfo(cellRenderer, informationString);
}
}
use of com.intellij.psi.PsiDirectory in project intellij-community by JetBrains.
the class CoverageProjectViewDirectoryNodeDecorator method decorate.
public void decorate(ProjectViewNode node, PresentationData data) {
final CoverageDataManager manager = getCoverageDataManager();
final CoverageSuitesBundle currentSuite = manager.getCurrentSuitesBundle();
final CoverageAnnotator coverageAnnotator = currentSuite != null ? currentSuite.getAnnotator(node.getProject()) : null;
if (coverageAnnotator == null) {
// N/A
return;
}
final Object value = node.getValue();
PsiElement element = null;
if (value instanceof PsiElement) {
element = (PsiElement) value;
} else if (value instanceof SmartPsiElementPointer) {
element = ((SmartPsiElementPointer) value).getElement();
}
String informationString = null;
if (element instanceof PsiDirectory) {
informationString = coverageAnnotator.getDirCoverageInformationString((PsiDirectory) element, currentSuite, manager);
} else if (element instanceof PsiFile) {
informationString = coverageAnnotator.getFileCoverageInformationString((PsiFile) element, currentSuite, manager);
}
if (informationString != null) {
data.setLocationString(informationString);
}
}
use of com.intellij.psi.PsiDirectory in project intellij-community by JetBrains.
the class DescriptionCheckerUtil method allDescriptionDirs.
/**
* Unlike getDescriptionsDirs this includes dirs in dependent modules and even project dirs ordered by
* search scopes (first dirs in current module, then dirs in module dependencies, then dirs in
* dependent modules, finally other project dirs).
*
* @param module module to search description directories for
* @param descriptionType type of description directory to search
* @return lazily populated stream of candidate directories
*/
public static StreamEx<PsiDirectory> allDescriptionDirs(Module module, DescriptionType descriptionType) {
final JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(module.getProject());
final PsiPackage psiPackage = javaPsiFacade.findPackage(descriptionType.getDescriptionFolder());
if (psiPackage == null)
return StreamEx.empty();
return searchScopes(module).flatMap(scope -> StreamEx.of(psiPackage.getDirectories(scope))).distinct();
}
Aggregations