Search in sources :

Example 26 with PsiFileSystemItem

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();
}
Also used : PsiFileImpl(com.intellij.psi.impl.source.PsiFileImpl) FileReferenceSet(com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet) PsiFileSystemItem(com.intellij.psi.PsiFileSystemItem) Nullable(org.jetbrains.annotations.Nullable)

Example 27 with PsiFileSystemItem

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;
                }
            }
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiFile(com.intellij.psi.PsiFile) PsiFileSystemItem(com.intellij.psi.PsiFileSystemItem)

Example 28 with PsiFileSystemItem

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 + ")";
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiDirectory(com.intellij.psi.PsiDirectory) PsiFileSystemItem(com.intellij.psi.PsiFileSystemItem) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 29 with PsiFileSystemItem

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);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiFileSystemItem(com.intellij.psi.PsiFileSystemItem) Nullable(org.jetbrains.annotations.Nullable)

Example 30 with PsiFileSystemItem

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);
}
Also used : NamedScope(com.intellij.psi.search.scope.packageSet.NamedScope) NamedScopesHolder(com.intellij.psi.search.scope.packageSet.NamedScopesHolder) PsiFile(com.intellij.psi.PsiFile) PsiFileSystemItem(com.intellij.psi.PsiFileSystemItem) PackageSet(com.intellij.psi.search.scope.packageSet.PackageSet)

Aggregations

PsiFileSystemItem (com.intellij.psi.PsiFileSystemItem)60 VirtualFile (com.intellij.openapi.vfs.VirtualFile)31 Nullable (org.jetbrains.annotations.Nullable)20 PsiElement (com.intellij.psi.PsiElement)18 PsiFile (com.intellij.psi.PsiFile)18 Project (com.intellij.openapi.project.Project)14 PsiDirectory (com.intellij.psi.PsiDirectory)14 NotNull (org.jetbrains.annotations.NotNull)8 Module (com.intellij.openapi.module.Module)7 File (java.io.File)6 PropertiesFile (com.intellij.lang.properties.psi.PropertiesFile)5 ArrayList (java.util.ArrayList)5 PsiManager (com.intellij.psi.PsiManager)4 IProperty (com.intellij.lang.properties.IProperty)3 LookupElement (com.intellij.codeInsight.lookup.LookupElement)2 Sdk (com.intellij.openapi.projectRoots.Sdk)2 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)2 SearchScope (com.intellij.psi.search.SearchScope)2 QualifiedName (com.intellij.psi.util.QualifiedName)2 XmlFile (com.intellij.psi.xml.XmlFile)2