Search in sources :

Example 1 with PsiDynaReference

use of com.intellij.openapi.paths.PsiDynaReference in project intellij-community by JetBrains.

the class LegacyCompletionContributor method processReferences.

public static void processReferences(final CompletionParameters parameters, final CompletionResultSet result, final PairConsumer<PsiReference, CompletionResultSet> consumer) {
    final int startOffset = parameters.getOffset();
    final PsiReference ref = parameters.getPosition().getContainingFile().findReferenceAt(startOffset);
    if (ref instanceof PsiMultiReference) {
        for (final PsiReference reference : CompletionData.getReferences((PsiMultiReference) ref)) {
            processReference(result, startOffset, consumer, reference);
        }
    } else if (ref instanceof PsiDynaReference) {
        for (final PsiReference reference : ((PsiDynaReference<?>) ref).getReferences()) {
            processReference(result, startOffset, consumer, reference);
        }
    } else if (ref != null) {
        processReference(result, startOffset, consumer, ref);
    }
}
Also used : PsiDynaReference(com.intellij.openapi.paths.PsiDynaReference) PsiReference(com.intellij.psi.PsiReference) PsiMultiReference(com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference)

Example 2 with PsiDynaReference

use of com.intellij.openapi.paths.PsiDynaReference in project intellij-community by JetBrains.

the class MoveFilesOrDirectoriesProcessor method retargetUsages.

protected void retargetUsages(UsageInfo[] usages, Map<PsiElement, PsiElement> oldToNewMap) {
    final List<NonCodeUsageInfo> nonCodeUsages = new ArrayList<>();
    for (UsageInfo usageInfo : usages) {
        if (usageInfo instanceof MyUsageInfo) {
            final MyUsageInfo info = (MyUsageInfo) usageInfo;
            final PsiElement element = myElementsToMove[info.myIndex];
            if (info.getReference() instanceof FileReference || info.getReference() instanceof PsiDynaReference) {
                final PsiElement usageElement = info.getElement();
                if (usageElement != null) {
                    final PsiFile usageFile = usageElement.getContainingFile();
                    final PsiFile psiFile = usageFile.getViewProvider().getPsi(usageFile.getViewProvider().getBaseLanguage());
                    if (psiFile != null && psiFile.equals(element)) {
                        // already processed in MoveFilesOrDirectoriesUtil.doMoveFile
                        continue;
                    }
                }
            }
            final PsiElement refElement = info.myReference.getElement();
            if (refElement != null && refElement.isValid()) {
                info.myReference.bindToElement(element);
            }
        } else if (usageInfo instanceof NonCodeUsageInfo) {
            nonCodeUsages.add((NonCodeUsageInfo) usageInfo);
        }
    }
    for (PsiFile movedFile : myFoundUsages.keySet()) {
        MoveFileHandler.forElement(movedFile).retargetUsages(myFoundUsages.get(movedFile), oldToNewMap);
    }
    myNonCodeUsages = nonCodeUsages.toArray(new NonCodeUsageInfo[nonCodeUsages.size()]);
}
Also used : PsiDynaReference(com.intellij.openapi.paths.PsiDynaReference) NonCodeUsageInfo(com.intellij.refactoring.util.NonCodeUsageInfo) ArrayList(java.util.ArrayList) PsiFile(com.intellij.psi.PsiFile) FileReference(com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReference) UsageInfo(com.intellij.usageView.UsageInfo) NonCodeUsageInfo(com.intellij.refactoring.util.NonCodeUsageInfo) PsiElement(com.intellij.psi.PsiElement)

Aggregations

PsiDynaReference (com.intellij.openapi.paths.PsiDynaReference)2 PsiElement (com.intellij.psi.PsiElement)1 PsiFile (com.intellij.psi.PsiFile)1 PsiReference (com.intellij.psi.PsiReference)1 PsiMultiReference (com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference)1 FileReference (com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReference)1 NonCodeUsageInfo (com.intellij.refactoring.util.NonCodeUsageInfo)1 UsageInfo (com.intellij.usageView.UsageInfo)1 ArrayList (java.util.ArrayList)1