use of com.intellij.psi.PsiFileSystemItem in project intellij-community by JetBrains.
the class SearchEverywherePsiRenderer method getContainerText.
@Override
protected String getContainerText(PsiElement element, String name) {
if (element instanceof PsiFileSystemItem) {
PsiFileSystemItem parent = ((PsiFileSystemItem) element).getParent();
final PsiDirectory psiDirectory = parent instanceof PsiDirectory ? (PsiDirectory) parent : null;
VirtualFile virtualFile = psiDirectory == null ? null : psiDirectory.getVirtualFile();
if (virtualFile == null)
return null;
String relativePath = GotoFileCellRenderer.getRelativePath(virtualFile, element.getProject());
if (relativePath == null)
return "( " + File.separator + " )";
int width = myList.getWidth();
if (width == 0)
width += 800;
String path = FilePathSplittingPolicy.SPLIT_BY_SEPARATOR.getOptimalTextForComponent(name, new File(relativePath), this, width - myRightComponentWidth - 16 - 10);
return "(" + path + ")";
}
return getSymbolContainerText(name, element);
}
use of com.intellij.psi.PsiFileSystemItem in project intellij-community by JetBrains.
the class GoToLinkTargetAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
Project project = getEventProject(e);
VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(e.getDataContext());
if (project != null && file != null && file.is(VFileProperty.SYMLINK)) {
VirtualFile target = file.getCanonicalFile();
if (target != null) {
PsiManager psiManager = PsiManager.getInstance(project);
PsiFileSystemItem psiFile = target.isDirectory() ? psiManager.findDirectory(target) : psiManager.findFile(target);
if (psiFile != null) {
ProjectView.getInstance(project).select(psiFile, target, false);
}
}
}
}
use of com.intellij.psi.PsiFileSystemItem in project intellij-community by JetBrains.
the class GotoFileItemProvider method filterElements.
@Override
public boolean filterElements(@NotNull ChooseByNameBase base, @NotNull String pattern, boolean everywhere, @NotNull ProgressIndicator indicator, @NotNull Processor<Object> consumer) {
if (pattern.contains("/") || pattern.contains("\\")) {
String path = FileUtil.toSystemIndependentName(ChooseByNamePopup.getTransformedPattern(pattern, myModel));
VirtualFile vFile = LocalFileSystem.getInstance().findFileByPathIfCached(path);
if (vFile != null) {
ProjectFileIndex index = ProjectFileIndex.SERVICE.getInstance(myProject);
if (index.isInContent(vFile) || index.isInLibraryClasses(vFile) || index.isInLibrarySource(vFile)) {
PsiFileSystemItem fileOrDir = vFile.isDirectory() ? PsiManager.getInstance(myProject).findDirectory(vFile) : PsiManager.getInstance(myProject).findFile(vFile);
if (fileOrDir != null && !consumer.process(fileOrDir)) {
return false;
}
}
}
}
if (pattern.startsWith("./") || pattern.startsWith(".\\")) {
pattern = pattern.substring(1);
}
return super.filterElements(base, pattern, everywhere, indicator, consumer);
}
use of com.intellij.psi.PsiFileSystemItem in project intellij-community by JetBrains.
the class NewElementToolbarAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
if (e.getData(LangDataKeys.IDE_VIEW) == null) {
final Project project = e.getData(CommonDataKeys.PROJECT);
final PsiFileSystemItem psiFile = e.getData(CommonDataKeys.PSI_FILE).getParent();
ProjectViewImpl.getInstance(project).selectCB(psiFile, psiFile.getVirtualFile(), true).doWhenDone(() -> showPopup(DataManager.getInstance().getDataContext()));
} else {
super.actionPerformed(e);
}
}
use of com.intellij.psi.PsiFileSystemItem in project intellij-community by JetBrains.
the class PyStdlibDocumentationLinkProvider method getExternalDocumentationUrl.
@Override
public String getExternalDocumentationUrl(PsiElement element, PsiElement originalElement) {
PsiFileSystemItem file = element instanceof PsiFileSystemItem ? (PsiFileSystemItem) element : element.getContainingFile();
if (PyNames.INIT_DOT_PY.equals(file.getName())) {
file = file.getParent();
assert file != null;
}
Sdk sdk = PyBuiltinCache.findSdkForFile(file);
VirtualFile vFile = file.getVirtualFile();
if (vFile != null && sdk != null && PythonSdkType.isStdLib(vFile, sdk)) {
QualifiedName qName = QualifiedNameFinder.findCanonicalImportPath(element, originalElement);
return getStdlibUrlFor(element, qName, sdk);
}
return null;
}
Aggregations