Search in sources :

Example 1 with SyntheticFileSystemItem

use of com.intellij.psi.impl.SyntheticFileSystemItem in project intellij-community by JetBrains.

the class CachesBasedRefSearcher method processQuery.

@Override
public void processQuery(@NotNull ReferencesSearch.SearchParameters p, @NotNull Processor<PsiReference> consumer) {
    final PsiElement refElement = p.getElementToSearch();
    boolean caseSensitive = refElement.getLanguage().isCaseSensitive();
    String text = null;
    if (refElement instanceof PsiFileSystemItem && !(refElement instanceof SyntheticFileSystemItem)) {
        final VirtualFile vFile = ((PsiFileSystemItem) refElement).getVirtualFile();
        if (vFile != null) {
            text = vFile.getNameWithoutExtension();
        }
        // We must not look for file references with the file language's case-sensitivity, 
        // since case-sensitivity of the references themselves depends either on file system 
        // or on the rules of the language of reference
        caseSensitive = false;
    } else if (refElement instanceof PsiNamedElement) {
        text = ((PsiNamedElement) refElement).getName();
        if (refElement instanceof PsiMetaOwner) {
            final PsiMetaData metaData = ((PsiMetaOwner) refElement).getMetaData();
            if (metaData != null)
                text = metaData.getName();
        }
    }
    if (text == null && refElement instanceof PsiMetaOwner) {
        final PsiMetaData metaData = ((PsiMetaOwner) refElement).getMetaData();
        if (metaData != null)
            text = metaData.getName();
    }
    if (StringUtil.isNotEmpty(text)) {
        final SearchScope searchScope = p.getEffectiveSearchScope();
        p.getOptimizer().searchWord(text, searchScope, caseSensitive, refElement);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) SyntheticFileSystemItem(com.intellij.psi.impl.SyntheticFileSystemItem) PsiMetaData(com.intellij.psi.meta.PsiMetaData) PsiNamedElement(com.intellij.psi.PsiNamedElement) SearchScope(com.intellij.psi.search.SearchScope) PsiFileSystemItem(com.intellij.psi.PsiFileSystemItem) PsiMetaOwner(com.intellij.psi.meta.PsiMetaOwner) PsiElement(com.intellij.psi.PsiElement)

Aggregations

VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiElement (com.intellij.psi.PsiElement)1 PsiFileSystemItem (com.intellij.psi.PsiFileSystemItem)1 PsiNamedElement (com.intellij.psi.PsiNamedElement)1 SyntheticFileSystemItem (com.intellij.psi.impl.SyntheticFileSystemItem)1 PsiMetaData (com.intellij.psi.meta.PsiMetaData)1 PsiMetaOwner (com.intellij.psi.meta.PsiMetaOwner)1 SearchScope (com.intellij.psi.search.SearchScope)1