use of com.intellij.psi.PsiFileSystemItem in project intellij-plugins by JetBrains.
the class FileReferenceSetHelper method addWebDirectoryAndCurrentNamespaceAsRoots.
/**
* Adds all {@link WebDirectoryElement}s as well as web-directory with name of given current namespace
* (if not "root" namespace) as possible content roots.
*
* @param psiElement Current element.
* @param namespace Current namespace.
* @param webFacet Module.
* @param set FRS to patch.
*/
public static void addWebDirectoryAndCurrentNamespaceAsRoots(final PsiElement psiElement, final String namespace, final WebFacet webFacet, final FileReferenceSet set) {
final WebDirectoryUtil directoryUtil = WebDirectoryUtil.getWebDirectoryUtil(psiElement.getProject());
set.addCustomization(FileReferenceSet.DEFAULT_PATH_EVALUATOR_OPTION, file -> {
final List<PsiFileSystemItem> basePathRoots = new ArrayList<>();
final List<WebRoot> webRoots = webFacet.getWebRoots(true);
for (final WebRoot webRoot : webRoots) {
final String webRootPath = webRoot.getRelativePath();
final WebDirectoryElement webRootBase = directoryUtil.findWebDirectoryElementByPath(webRootPath, webFacet);
ContainerUtil.addIfNotNull(basePathRoots, webRootBase);
}
if (!Comparing.equal(namespace, StrutsPackage.DEFAULT_NAMESPACE)) {
final WebDirectoryElement packageBase = directoryUtil.findWebDirectoryElementByPath(namespace, webFacet);
ContainerUtil.addIfNotNull(basePathRoots, packageBase);
}
return basePathRoots;
});
}
use of com.intellij.psi.PsiFileSystemItem in project intellij-plugins by JetBrains.
the class SendToMayaAction method getPythonFile.
@Nullable
private static PyFile getPythonFile(AnActionEvent e) {
VirtualFile vFile = e.getData(CommonDataKeys.VIRTUAL_FILE);
Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
if (project != null && vFile != null) {
final PsiManager psiManager = PsiManager.getInstance(project);
PsiFileSystemItem fsItem = vFile.isDirectory() ? psiManager.findDirectory(vFile) : psiManager.findFile(vFile);
if (fsItem instanceof PyFile) {
return (PyFile) fsItem;
}
}
return null;
}
use of com.intellij.psi.PsiFileSystemItem in project intellij-plugins by JetBrains.
the class KarmaRunConfigurationProducer method setup.
@Nullable
private static Pair<KarmaRunSettings, PsiElement> setup(@Nullable PsiElement element, @NotNull KarmaRunSettings templateSettings) {
JSFile file = ObjectUtils.tryCast(element != null ? element.getContainingFile() : null, JSFile.class);
VirtualFile virtualFile = PsiUtilCore.getVirtualFile(file);
if (virtualFile == null) {
return null;
}
if (!(element instanceof PsiFileSystemItem)) {
Pair<KarmaRunSettings, PsiElement> suiteOrTestConfiguration = setupAsSuiteOrTest(file, virtualFile, element, templateSettings);
if (suiteOrTestConfiguration != null) {
return suiteOrTestConfiguration;
}
}
if (KarmaUtil.isKarmaConfigFile(virtualFile.getNameSequence(), false)) {
return Pair.create(templateSettings.toBuilder().setScopeKind(KarmaScopeKind.ALL).setConfigPath(virtualFile.getPath()).build(), file);
}
if (file.getTestFileType() != null) {
KarmaRunSettings settings = guessConfigFileIfNeeded(templateSettings, virtualFile, element.getProject());
return Pair.create(settings.toBuilder().setScopeKind(KarmaScopeKind.TEST_FILE).setTestFilePath(virtualFile.getPath()).build(), file);
}
return null;
}
use of com.intellij.psi.PsiFileSystemItem in project intellij-plugins by StepicOrg.
the class ProjectPsiFilesUtils method isNotMovableOrRenameElement.
public static boolean isNotMovableOrRenameElement(@NotNull PsiElement element, @NotNull Set<Class<? extends PsiElement>> acceptableClasses) {
Project project = element.getProject();
StudyNode root = StepikProjectManager.getProjectRoot(project);
if (root == null) {
return false;
}
if (notAccept(element, acceptableClasses)) {
return false;
}
PsiFileSystemItem file = getFile(element);
if (file == null) {
return false;
}
String path = getRelativePath(file);
return ProjectFilesUtils.isNotMovableOrRenameElement(root, path);
}
use of com.intellij.psi.PsiFileSystemItem in project intellij-plugins by StepicOrg.
the class ProjectPsiFilesUtils method isCanNotBeTarget.
public static boolean isCanNotBeTarget(@Nullable PsiElement target, @NotNull Set<Class<? extends PsiElement>> acceptableClasses) {
if (target == null) {
return false;
}
Project project = target.getProject();
if (!StepikProjectManager.isStepikProject(project)) {
return false;
}
if (notAccept(target, acceptableClasses)) {
return false;
}
PsiFileSystemItem item = getFile(target);
if (item == null) {
return false;
}
String targetPath = getRelativePath(item);
return ProjectFilesUtils.isCanNotBeTarget(targetPath);
}
Aggregations