Search in sources :

Example 1 with PyImportedNameDefiner

use of com.jetbrains.python.psi.PyImportedNameDefiner in project intellij-community by JetBrains.

the class PyResolveProcessor method execute.

@Override
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
    final PsiNamedElement namedElement = PyUtil.as(element, PsiNamedElement.class);
    if (namedElement != null && myName.equals(namedElement.getName())) {
        return tryAddResult(element, null);
    }
    final PyImportedNameDefiner importedNameDefiner = PyUtil.as(element, PyImportedNameDefiner.class);
    if (importedNameDefiner != null) {
        final List<RatedResolveResult> results = resolveInImportedNameDefiner(importedNameDefiner);
        if (!results.isEmpty()) {
            boolean cont = true;
            for (RatedResolveResult result : results) {
                final PsiElement resolved = result.getElement();
                if (resolved != null) {
                    cont = tryAddResult(resolved, importedNameDefiner) && cont;
                }
            }
            return cont;
        }
        final PyImportElement importElement = PyUtil.as(element, PyImportElement.class);
        if (importElement != null) {
            final String importName = importElement.getVisibleName();
            if (myName.equals(importName)) {
                return tryAddResult(null, importElement);
            }
        }
    }
    return myOwner == null || myOwner == ScopeUtil.getScopeOwner(element);
}
Also used : PsiNamedElement(com.intellij.psi.PsiNamedElement) PyImportElement(com.jetbrains.python.psi.PyImportElement) PyImportedNameDefiner(com.jetbrains.python.psi.PyImportedNameDefiner) PsiElement(com.intellij.psi.PsiElement)

Aggregations

PsiElement (com.intellij.psi.PsiElement)1 PsiNamedElement (com.intellij.psi.PsiNamedElement)1 PyImportElement (com.jetbrains.python.psi.PyImportElement)1 PyImportedNameDefiner (com.jetbrains.python.psi.PyImportedNameDefiner)1