use of com.intellij.psi.PsiDirectory in project folding-plugin by dmytrodanylyk.
the class ProjectStructureProvider method modify.
@NotNull
@Override
public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings viewSettings) {
List<AbstractTreeNode> resultList = new ArrayList<>();
if (parent.getValue() instanceof PsiDirectory) {
PsiDirectory directory = (PsiDirectory) parent.getValue();
String path = directory.getVirtualFile().getPath();
if (SettingsManager.isComposed(path)) {
resultList.addAll(createComposedFiles(children, viewSettings));
} else {
resultList.addAll(children);
}
} else {
resultList.addAll(children);
}
return resultList;
}
use of com.intellij.psi.PsiDirectory in project folding-plugin by dmytrodanylyk.
the class ComposeAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent actionEvent) {
Object nav = actionEvent.getData(CommonDataKeys.NAVIGATABLE);
if (nav instanceof PsiDirectory) {
PsiDirectory directory = (PsiDirectory) nav;
String path = directory.getVirtualFile().getPath();
if (SettingsManager.isComposed(path)) {
SettingsManager.removeComposedFolder(path);
} else {
SettingsManager.addComposedFolder(path);
}
Project project = actionEvent.getData(CommonDataKeys.PROJECT);
if (project != null) {
ProjectView.getInstance(project).refresh();
}
}
}
use of com.intellij.psi.PsiDirectory in project buck by facebook.
the class BuckCopyPasteProcessor method referenceNameToBuckFile.
private VirtualFile referenceNameToBuckFile(Project project, String reference) {
// First test if it is a absolute path of a file.
File tryFile = new File(reference);
if (tryFile != null) {
VirtualFile file = VfsUtil.findFileByIoFile(tryFile, true);
if (file != null) {
return BuckBuildUtil.getBuckFileFromDirectory(file.getParent());
}
}
// Try class firstly.
PsiClass classElement = JavaPsiFacade.getInstance(project).findClass(reference, GlobalSearchScope.allScope(project));
if (classElement != null) {
VirtualFile file = PsiUtilCore.getVirtualFile(classElement);
return BuckBuildUtil.getBuckFileFromDirectory(file.getParent());
}
// Then try package.
PsiPackage packageElement = JavaPsiFacade.getInstance(project).findPackage(reference);
if (packageElement != null) {
PsiDirectory directory = packageElement.getDirectories()[0];
return BuckBuildUtil.getBuckFileFromDirectory(directory.getVirtualFile());
}
// Extract the package from the reference.
int index = reference.lastIndexOf(".");
if (index == -1) {
return null;
}
reference = reference.substring(0, index);
// Try to find the package again.
packageElement = JavaPsiFacade.getInstance(project).findPackage(reference);
if (packageElement != null) {
PsiDirectory directory = packageElement.getDirectories()[0];
return BuckBuildUtil.getBuckFileFromDirectory(directory.getVirtualFile());
}
return null;
}
use of com.intellij.psi.PsiDirectory in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoTestRunConfigurationProducerTest method testSameConfigurationOnDirectory.
public void testSameConfigurationOnDirectory() {
PsiFile file = myFixture.configureByText("a.go", "package main");
PsiDirectory directory = file.getParent();
assertNotNull(directory);
ConfigurationContext configurationContext = new ConfigurationContext(directory);
GotestRunConfigurationProducer producer = new GotestRunConfigurationProducer();
GoTestRunConfiguration runConfiguration = createDirectoryConfiguration(GotestFramework.INSTANCE, directory.getVirtualFile().getPath(), directory.getVirtualFile().getPath());
assertTrue(producer.isConfigurationFromContext(runConfiguration, configurationContext));
runConfiguration = createDirectoryConfiguration(GotestFramework.INSTANCE, directory.getVirtualFile().getPath() + "_vl", directory.getVirtualFile().getPath());
assertFalse(producer.isConfigurationFromContext(runConfiguration, configurationContext));
runConfiguration = createDirectoryConfiguration(GobenchFramework.INSTANCE, directory.getVirtualFile().getPath(), directory.getVirtualFile().getPath());
assertFalse(producer.isConfigurationFromContext(runConfiguration, configurationContext));
runConfiguration = createDirectoryConfiguration(GotestFramework.INSTANCE, directory.getVirtualFile().getPath(), directory.getVirtualFile().getPath() + "_vl");
assertFalse(producer.isConfigurationFromContext(runConfiguration, configurationContext));
}
use of com.intellij.psi.PsiDirectory in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoRunConfigurationProducerTest method testSameRunApplicationConfigurationOnDirectory.
public void testSameRunApplicationConfigurationOnDirectory() {
PsiFile file = myFixture.addFileToProject("import/path/a.go", "package main; func main(){}");
PsiDirectory directory = file.getParent();
assertNotNull(directory);
ConfigurationContext configurationContext = new ConfigurationContext(directory);
GoApplicationRunConfigurationProducer producer = new GoApplicationRunConfigurationProducer();
GoApplicationConfiguration runConfiguration = createRunAppPackageConfiguration("import/path");
assertTrue(producer.isConfigurationFromContext(runConfiguration, configurationContext));
runConfiguration = createRunAppPackageConfiguration("import/path/other");
assertFalse(producer.isConfigurationFromContext(runConfiguration, configurationContext));
}
Aggregations