@Nullable
 public QualifiedName asQualifiedName() {
   if (myQualifiedName == null) {
     myQualifiedName = PyPsiUtils.asQualifiedName(this);
   }
   return myQualifiedName;
 }
 @NotNull
 public static List<RatedResolveResult> multiResolveImportElement(
     PyImportElement importElement, @NotNull final QualifiedName qName) {
   if (ApplicationManager.getApplication().isUnitTestMode()) {
     PyPsiUtils.assertValid(importElement);
   }
   final PyStatement importStatement = importElement.getContainingImportStatement();
   if (importStatement instanceof PyFromImportStatement) {
     return resolveNameInFromImport((PyFromImportStatement) importStatement, qName);
   } else {
     return resolveNameInImportStatement(importElement, qName);
   }
 }
 @Override
 public Icon getIcon(int flags) {
   PyPsiUtils.assertValid(this);
   final Property property = getProperty();
   if (property != null) {
     if (property.getGetter().valueOrNull() == this) {
       return PythonIcons.Python.PropertyGetter;
     }
     if (property.getSetter().valueOrNull() == this) {
       return PythonIcons.Python.PropertySetter;
     }
     if (property.getDeleter().valueOrNull() == this) {
       return PythonIcons.Python.PropertyDeleter;
     }
     return PlatformIcons.PROPERTY_ICON;
   }
   if (getContainingClass() != null) {
     return PlatformIcons.METHOD_ICON;
   }
   return PythonIcons.Python.Function;
 }
Ejemplo n.º 4
0
 @Nullable
 public static String extractDeprecationMessage(List<PyStatement> statements) {
   for (PyStatement statement : statements) {
     if (statement instanceof PyExpressionStatement) {
       PyExpressionStatement expressionStatement = (PyExpressionStatement) statement;
       if (expressionStatement.getExpression() instanceof PyCallExpression) {
         PyCallExpression callExpression = (PyCallExpression) expressionStatement.getExpression();
         if (callExpression.isCalleeText(PyNames.WARN)) {
           PyReferenceExpression warningClass =
               callExpression.getArgument(1, PyReferenceExpression.class);
           if (warningClass != null
               && (PyNames.DEPRECATION_WARNING.equals(warningClass.getReferencedName())
                   || PyNames.PENDING_DEPRECATION_WARNING.equals(
                       warningClass.getReferencedName()))) {
             return PyPsiUtils.strValue(callExpression.getArguments()[0]);
           }
         }
       }
     }
   }
   return null;
 }