Search in sources :

Example 1 with PyPsiUtils

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

the class ScopeImpl method getNamedElements.

@NotNull
@Override
public Collection<PsiNamedElement> getNamedElements(String name, boolean includeNestedGlobals) {
    if (myNamedElements == null) {
        collectDeclarations();
    }
    if (myNamedElements.containsKey(name)) {
        final Collection<PsiNamedElement> elements = myNamedElements.get(name);
        elements.forEach(PyPsiUtils::assertValid);
        return elements;
    }
    if (includeNestedGlobals && isGlobal(name)) {
        for (Scope scope : myNestedScopes) {
            final Collection<PsiNamedElement> globals = scope.getNamedElements(name, true);
            if (!globals.isEmpty()) {
                globals.forEach(PyPsiUtils::assertValid);
                return globals;
            }
        }
    }
    return Collections.emptyList();
}
Also used : PyPsiUtils(com.jetbrains.python.psi.impl.PyPsiUtils) Scope(com.jetbrains.python.codeInsight.dataflow.scope.Scope) PsiNamedElement(com.intellij.psi.PsiNamedElement) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

PsiNamedElement (com.intellij.psi.PsiNamedElement)1 Scope (com.jetbrains.python.codeInsight.dataflow.scope.Scope)1 PyPsiUtils (com.jetbrains.python.psi.impl.PyPsiUtils)1 NotNull (org.jetbrains.annotations.NotNull)1