@Override
 public Icon getIcon(int flags) {
   if (isValid()) {
     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;
     }
   }
   return PlatformIcons.METHOD_ICON;
 }
 @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;
 }
Exemplo n.º 3
0
  public EventPropertyGetter getGetter(
      BeanEventType eventType, EventAdapterService eventAdapterService) {
    List<EventPropertyGetter> getters = new LinkedList<EventPropertyGetter>();

    Property lastProperty = null;
    for (Iterator<Property> it = properties.iterator(); it.hasNext(); ) {
      Property property = it.next();
      lastProperty = property;
      EventPropertyGetter getter = property.getGetter(eventType, eventAdapterService);
      if (getter == null) {
        return null;
      }

      if (it.hasNext()) {
        Class clazz = property.getPropertyType(eventType, eventAdapterService);
        if (clazz == null) {
          // if the property is not valid, return null
          return null;
        }
        // Map cannot be used to further nest as the type cannot be determined
        if (clazz == Map.class) {
          return null;
        }
        if (clazz.isArray()) {
          return null;
        }
        eventType =
            eventAdapterService
                .getBeanEventTypeFactory()
                .createBeanType(clazz.getName(), clazz, false, false, false);
      }
      getters.add(getter);
    }

    GenericPropertyDesc finalPropertyType =
        lastProperty.getPropertyTypeGeneric(eventType, eventAdapterService);
    return new NestedPropertyGetter(
        getters, eventAdapterService, finalPropertyType.getType(), finalPropertyType.getGeneric());
  }