use of com.intellij.psi.PsiFileSystemItem in project intellij-community by JetBrains.
the class FileIncludeManagerImpl method doResolve.
@Nullable
private PsiFileSystemItem doResolve(@NotNull final FileIncludeInfo info, @NotNull final PsiFile context) {
if (info instanceof FileIncludeInfoImpl) {
String id = ((FileIncludeInfoImpl) info).providerId;
FileIncludeProvider provider = id == null ? null : myProviderMap.get(id);
final PsiFileSystemItem resolvedByProvider = provider == null ? null : provider.resolveIncludedFile(info, context);
if (resolvedByProvider != null) {
return resolvedByProvider;
}
}
PsiFileImpl psiFile = (PsiFileImpl) myPsiFileFactory.createFileFromText("dummy.txt", FileTypes.PLAIN_TEXT, info.path);
psiFile.setOriginalFile(context);
return new FileReferenceSet(psiFile) {
@Override
protected boolean useIncludingFileAsContext() {
return false;
}
}.resolve();
}
use of com.intellij.psi.PsiFileSystemItem in project intellij-community by JetBrains.
the class FileIncludeManagerImpl method processIncludingFiles.
@Override
public void processIncludingFiles(PsiFile context, Processor<Pair<VirtualFile, FileIncludeInfo>> processor) {
context = context.getOriginalFile();
VirtualFile contextFile = context.getVirtualFile();
if (contextFile == null)
return;
MultiMap<VirtualFile, FileIncludeInfoImpl> infoList = FileIncludeIndex.getIncludingFileCandidates(context.getName(), GlobalSearchScope.allScope(myProject));
for (VirtualFile candidate : infoList.keySet()) {
PsiFile psiFile = myPsiManager.findFile(candidate);
if (psiFile == null || context.equals(psiFile))
continue;
for (FileIncludeInfo info : infoList.get(candidate)) {
PsiFileSystemItem item = resolveFileInclude(info, psiFile);
if (item != null && contextFile.equals(item.getVirtualFile())) {
if (!processor.process(Pair.create(candidate, info))) {
return;
}
}
}
}
}
use of com.intellij.psi.PsiFileSystemItem in project intellij-community by JetBrains.
the class GotoFileCellRenderer method getContainerText.
@Override
protected String getContainerText(PsiFileSystemItem element, String name) {
PsiFileSystemItem parent = element.getParent();
final PsiDirectory psiDirectory = parent instanceof PsiDirectory ? (PsiDirectory) parent : null;
if (psiDirectory == null)
return null;
final VirtualFile virtualFile = psiDirectory.getVirtualFile();
final String relativePath = getRelativePath(virtualFile, element.getProject());
if (relativePath == null)
return "( " + File.separator + " )";
String path = FilePathSplittingPolicy.SPLIT_BY_SEPARATOR.getOptimalTextForComponent(name + " ", new File(relativePath), this, myMaxWidth);
return "(" + path + ")";
}
use of com.intellij.psi.PsiFileSystemItem in project intellij-community by JetBrains.
the class GotoFileModel method getFullName.
@Override
@Nullable
public String getFullName(final Object element) {
if (element instanceof PsiFileSystemItem) {
VirtualFile file = ((PsiFileSystemItem) element).getVirtualFile();
VirtualFile root = getTopLevelRoot(file);
return root != null ? GotoFileCellRenderer.getRelativePathFromRoot(file, root) : GotoFileCellRenderer.getRelativePath(file, myProject);
}
return getElementName(element);
}
use of com.intellij.psi.PsiFileSystemItem in project intellij-community by JetBrains.
the class ScopePaneSelectInTarget method isSubIdSelectable.
@Override
public boolean isSubIdSelectable(@NotNull String subId, @NotNull SelectInContext context) {
PsiFileSystemItem file = getContextPsiFile(context);
if (!(file instanceof PsiFile))
return false;
final NamedScope scope = NamedScopesHolder.getScope(myProject, subId);
PackageSet packageSet = scope != null ? scope.getValue() : null;
if (packageSet == null)
return false;
NamedScopesHolder holder = NamedScopesHolder.getHolder(myProject, subId, DependencyValidationManager.getInstance(myProject));
return packageSet.contains((PsiFile) file, holder);
}
Aggregations