mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fixed resolve in sub injected fragments of doctests
This commit is contained in:
@@ -3,6 +3,8 @@ package com.jetbrains.python.documentation.doctest;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.codeInsight.completion.CompletionUtil;
|
||||
import com.intellij.lang.injection.InjectedLanguageManager;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.*;
|
||||
import com.jetbrains.python.codeInsight.controlflow.ScopeOwner;
|
||||
import com.jetbrains.python.psi.PyQualifiedExpression;
|
||||
@@ -12,6 +14,7 @@ import com.jetbrains.python.psi.resolve.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* User : ktisha
|
||||
@@ -32,9 +35,25 @@ public class PyDocReference extends PyReferenceImpl {
|
||||
final InjectedLanguageManager languageManager = InjectedLanguageManager.getInstance(myElement.getProject());
|
||||
final PsiLanguageInjectionHost host = languageManager.getInjectionHost(myElement);
|
||||
if (host != null) file = host.getContainingFile();
|
||||
|
||||
final String referencedName = myElement.getReferencedName();
|
||||
if (referencedName == null) return ResolveResult.EMPTY_ARRAY;
|
||||
|
||||
if (host != null) {
|
||||
final List<Pair<PsiElement,TextRange>> files = languageManager.getInjectedPsiFiles(host);
|
||||
if (files != null) {
|
||||
for (Pair<PsiElement, TextRange> pair : files) {
|
||||
ResolveProcessor processor = new ResolveProcessor(referencedName);
|
||||
|
||||
PyResolveUtil.scopeCrawlUp(processor, (ScopeOwner)pair.getFirst(), referencedName, pair.getFirst());
|
||||
PsiElement uexpr = processor.getResult();
|
||||
if (uexpr != null) ret.add(new RatedResolveResult(RatedResolveResult.RATE_NORMAL, uexpr));
|
||||
if (ret.size() > 0) {
|
||||
return ret.toArray(new RatedResolveResult[ret.size()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ResolveProcessor processor = new ResolveProcessor(referencedName);
|
||||
|
||||
PyResolveUtil.scopeCrawlUp(processor, (ScopeOwner)file, referencedName, file);
|
||||
|
||||
Reference in New Issue
Block a user