use of com.intellij.psi.PsiDirectory in project intellij-community by JetBrains.
the class AbstractFolderNode method containsImpl.
@Override
protected boolean containsImpl(@NotNull final VirtualFile file) {
final PsiElement psiElement = extractPsiFromValue();
if (psiElement == null || !psiElement.isValid()) {
return false;
}
final VirtualFile valueFile = ((PsiDirectory) psiElement).getVirtualFile();
if (!VfsUtil.isAncestor(valueFile, file, false)) {
return false;
}
final Project project = psiElement.getProject();
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
final Module module = fileIndex.getModuleForFile(valueFile);
if (module == null) {
return fileIndex.getModuleForFile(file) == null;
}
return ModuleRootManager.getInstance(module).getFileIndex().isInContent(file);
}
use of com.intellij.psi.PsiDirectory in project intellij-community by JetBrains.
the class AbstractFolderNode method getChildrenImpl.
@Override
@Nullable
protected Collection<AbstractTreeNode> getChildrenImpl() {
final PsiDirectory directory = getPsiDirectory();
if (!directory.isValid()) {
return Collections.emptyList();
}
// scan folder's children
final List<AbstractTreeNode> children = Arrays.stream(directory.getSubdirectories()).map(this::createFolderNode).collect(Collectors.toList());
for (PsiFile file : directory.getFiles()) {
processNotDirectoryFile(children, file);
}
return children;
}
use of com.intellij.psi.PsiDirectory in project intellij-community by JetBrains.
the class AbstractFolderNode method createFolderNode.
private AbstractFolderNode createFolderNode(PsiDirectory directory) {
PsiDirectory realDirectory = directory;
StringBuilder textBuilder = null;
if (getSettings().isHideEmptyMiddlePackages()) {
do {
if (realDirectory.getFiles().length > 0)
break;
PsiDirectory[] subdirectories = realDirectory.getSubdirectories();
if (subdirectories.length != 1)
break;
if (textBuilder == null) {
textBuilder = new StringBuilder();
textBuilder.append(realDirectory.getName());
}
realDirectory = subdirectories[0];
textBuilder.append('.').append(realDirectory.getName());
} while (true);
}
String presentableText = textBuilder == null ? directory.getName() : textBuilder.toString();
return new AbstractFolderNode(getModule(), realDirectory, presentableText, getSettings(), FOLDER) {
@Override
protected void processNotDirectoryFile(List<AbstractTreeNode> nodes, PsiFile file) {
AbstractFolderNode.this.processNotDirectoryFile(nodes, file);
}
@Override
protected AbstractTreeNode createClassNode(GrTypeDefinition typeDefinition) {
return AbstractFolderNode.this.createClassNode(typeDefinition);
}
};
}
use of com.intellij.psi.PsiDirectory in project intellij-community by JetBrains.
the class MavenFilteredPropertiesCompletionAndResolutionTest method testReferencesInXml.
public void testReferencesInXml() throws Exception {
createProjectSubDir("res");
importProject("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<build>" + " <resources>" + " <resource>" + " <directory>res</directory>" + " <filtering>true</filtering>" + " </resource>" + " </resources>" + "</build>");
VirtualFile f = createProjectSubFile("res/foo.xml", "<root attr='${based<caret>ir}'>" + "</root>");
myFixture.configureFromExistingVirtualFile(f);
XmlAttribute attribute = PsiTreeUtil.getParentOfType(myFixture.getFile().findElementAt(myFixture.getCaretOffset()), XmlAttribute.class);
PsiReference[] references = attribute.getReferences();
for (PsiReference ref : references) {
if (ref.resolve() instanceof PsiDirectory) {
// Maven references was added.
return;
}
}
assertTrue("Maven filter reference was not added", false);
}
use of com.intellij.psi.PsiDirectory in project intellij-community by JetBrains.
the class MavenFilteredPropertiesCompletionAndResolutionTest method testCorrectlyCalculatingBaseDir.
public void testCorrectlyCalculatingBaseDir() throws Exception {
createProjectSubDir("res");
importProject("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<build>" + " <resources>" + " <resource>" + " <directory>res</directory>" + " <filtering>true</filtering>" + " </resource>" + " </resources>" + "</build>");
VirtualFile f = createProjectSubFile("res/foo.properties", "foo=abc${basedir<caret>}abc");
PsiDirectory baseDir = PsiManager.getInstance(myProject).findDirectory(myProjectPom.getParent());
assertResolved(f, baseDir);
}
Aggregations