use of com.jetbrains.python.psi.resolve.ImportedResolveResult in project intellij-community by JetBrains.
the class DocStringTypeReference method multiResolve.
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
PsiElement result = null;
final ResolveResultList results = new ResolveResultList();
if (myType instanceof PyClassType) {
result = ((PyClassType) myType).getPyClass();
} else if (myType instanceof PyImportedModuleType) {
result = ((PyImportedModuleType) myType).getImportedModule().resolve();
} else if (myType instanceof PyModuleType) {
result = ((PyModuleType) myType).getModule();
}
if (result != null) {
if (myImportElement != null) {
results.add(new ImportedResolveResult(result, RatedResolveResult.RATE_NORMAL, myImportElement));
} else {
results.poke(result, RatedResolveResult.RATE_NORMAL);
}
}
return results.toArray(ResolveResult.EMPTY_ARRAY);
}
use of com.jetbrains.python.psi.resolve.ImportedResolveResult in project intellij-community by JetBrains.
the class PyResolveTest method testUnresolvedImport.
public void testUnresolvedImport() {
final ResolveResult[] results = multiResolve();
assertEquals(1, results.length);
UsefulTestCase.assertInstanceOf(results[0], ImportedResolveResult.class);
ImportedResolveResult result = (ImportedResolveResult) results[0];
assertNull(result.getElement());
}
use of com.jetbrains.python.psi.resolve.ImportedResolveResult in project intellij by bazelbuild.
the class BlazePyBuiltinReferenceResolveProvider method resolveName.
@Override
public List<RatedResolveResult> resolveName(PyQualifiedExpression element, TypeEvalContext context) {
if (!Blaze.isBlazeProject(element.getProject())) {
return ImmutableList.of();
}
PyBuiltinCache cache = getBuiltInCache(element);
if (cache == null) {
return ImmutableList.of();
}
String referencedName = element.getReferencedName();
if (referencedName == null) {
return ImmutableList.of();
}
List<RatedResolveResult> result = Lists.newArrayList();
PyFile bfile = cache.getBuiltinsFile();
if (bfile != null && !PyUtil.isClassPrivateName(referencedName)) {
PsiElement resultElement = bfile.getElementNamed(referencedName);
if (resultElement == null && "__builtins__".equals(referencedName)) {
// resolve __builtins__ reference
resultElement = bfile;
}
if (resultElement != null) {
result.add(new ImportedResolveResult(resultElement, PyReferenceImpl.getRate(resultElement, context), null));
}
}
return result;
}
Aggregations