package com.jetbrains.python.psi.impl;

import com.intellij.lang.ASTNode;
import com.jetbrains.python.PyElementTypes;
import com.jetbrains.python.psi.PyDecoratorList;
import com.jetbrains.python.psi.PyExpression;
import com.jetbrains.python.psi.stubs.PyDecoratorListStub;
import com.jetbrains.python.psi.PyDecorator;
import com.jetbrains.python.psi.PyElementVisitor;
import org.jetbrains.annotations.NotNull;

/**
 * @author dcheryasov
 */
public class PyDecoratorListImpl extends PyBaseElementImpl<PyDecoratorListStub> implements PyDecoratorList{
  
  public PyDecoratorListImpl(ASTNode astNode) {
    super(astNode);
  }

  @Override
  protected void acceptPyVisitor(PyElementVisitor pyVisitor) {
    pyVisitor.visitPyDecoratorList(this);
  }

  public PyDecoratorListImpl(final PyDecoratorListStub stub) {
    super(stub, PyElementTypes.DECORATOR_LIST);
  }

  @NotNull
  public PyDecorator[] getDecorators() {
    final PyDecorator[] decoarray = new PyDecorator[0];
    return getStubOrPsiChildren(PyElementTypes.DECORATOR_CALL, decoarray);
    //return decoarray;
  }

  @Override
  public PyDecorator findDecorator(String name) {
    final PyDecorator[] decorators = getDecorators();
    for (PyDecorator decorator : decorators) {
      final PyExpression callee = decorator.getCallee();
      if (callee != null && name.equals(callee.getText())) {
        return decorator;
      }
    }
    return null;
  }
}

@@ -154,20 +154,16 @@
 ecorator
-List
 ;%0Aimport
@@ -192,60 +192,8 @@
 psi.
-PyExpression;%0Aimport com.jetbrains.python.psi.stubs.
 PyDe
@@ -203,20 +203,16 @@
 atorList
-Stub
 ;%0Aimport
@@ -231,38 +231,43 @@
 ns.python.psi.Py
-Decora
+ElementVisi
 tor;%0Aimport com.
@@ -287,32 +287,41 @@
 hon.psi.
-PyElementVisitor
+stubs.PyDecoratorListStub
 ;%0Aimport
@@ -1202,24 +1202,26 @@
 l Py
-Expression calle
+QualifiedName qNam
 e = 
@@ -1237,13 +1237,20 @@
 .get
-Calle
+QualifiedNam
 e();
@@ -1260,21 +1260,20 @@
     if (
-calle
+qNam
 e != nul
@@ -1293,22 +1293,22 @@
 als(
-callee.getText
+qName.toString
 ()))

Use information from stub for finding decorator in decorators list