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);
}
}
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()]);
}
Aggregations