@Override
 public List<Task> getIssues(
     @Nullable String query,
     int max,
     long since,
     boolean forceRequest,
     final boolean withClosed,
     @NotNull final ProgressIndicator cancelled) {
   List<Task> tasks = getIssuesFromRepositories(query, max, since, forceRequest, cancelled);
   if (tasks == null) return getCachedIssues(withClosed);
   myIssueCache.putAll(ContainerUtil.newMapFromValues(tasks.iterator(), KEY_CONVERTOR));
   return ContainerUtil.filter(
       tasks,
       new Condition<Task>() {
         @Override
         public boolean value(final Task task) {
           return withClosed || !task.isClosed();
         }
       });
 }
/** @author Mikhail Golubev */
public enum JqlStandardField {
  AFFECTED_VERSION("affectedVersion", JqlFieldType.VERSION),
  ASSIGNEE("assignee", JqlFieldType.USER),
  CATEGORY("category", JqlFieldType.CATEGORY),
  COMMENT("comment", JqlFieldType.TEXT),
  COMPONENT("component", JqlFieldType.COMPONENT),
  CREATED("created", JqlFieldType.DATE),
  CREATED_DATE("createdDate", JqlFieldType.DATE),
  DESCRIPTION("description", JqlFieldType.TEXT),
  DUE("due", JqlFieldType.DATE),
  DUE_DATE("dueDate", JqlFieldType.DATE),
  ENVIRONMENT("environment", JqlFieldType.TEXT),
  FILTER("filter", JqlFieldType.FILTER),
  REQUEST("request", JqlFieldType.FILTER),
  SAVED_FILTER("savedFilter", JqlFieldType.FILTER),
  SEARCH_REQUEST("searchRequest", JqlFieldType.FILTER),
  FIX_VERSION("fixVersion", JqlFieldType.VERSION),
  ISSUE_KEY("issueKey", JqlFieldType.ISSUE),
  ID("id", JqlFieldType.ISSUE),
  ISSUE("issue", JqlFieldType.ISSUE),
  KEY("key", JqlFieldType.ISSUE),
  LAST_VIEWED("lastViewed", JqlFieldType.DATE),
  LEVEL("level", JqlFieldType.SECURITY_LEVEL),
  ORIGINAL_ESTIMATE("originalEstimate", JqlFieldType.DURATION),
  TIME_ORIGINAL_ESTIMATE("timeOriginalEstimate", JqlFieldType.DURATION),
  PARENT("parent", JqlFieldType.ISSUE),
  PRIORITY("priority", JqlFieldType.PRIORITY),
  PROJECT("project", JqlFieldType.PROJECT),
  REMAINING_ESTIMATE("remainingEstimate", JqlFieldType.DURATION),
  TIME_ESTIMATE("timeEstimate", JqlFieldType.DURATION),
  REPORTER("reporter", JqlFieldType.USER),
  RESOLUTION("resolution", JqlFieldType.RESOLUTION),
  RESOLVED("resolved", JqlFieldType.DATE),
  RESOLUTION_DATE("resolutionDate", JqlFieldType.DATE),
  STATUS("status", JqlFieldType.STATUS),
  SUMMARY("summary", JqlFieldType.TEXT),
  // So called "master-field". Search in summary, description, environment,
  // comments and custom fields
  TEXT("text", JqlFieldType.TEXT),
  TYPE("type", JqlFieldType.ISSUE_TYPE),
  ISSUE_TYPE("issueType", JqlFieldType.ISSUE_TYPE),
  TIME_SPENT("timeSpent", JqlFieldType.DURATION),
  UPDATED("updated", JqlFieldType.DATE),
  UPDATED_DATE("updatedDate", JqlFieldType.DATE),
  VOTER("voter", JqlFieldType.USER),
  VOTES("votes", JqlFieldType.NUMBER),
  WATCHER("watcher", JqlFieldType.USER),
  WATCHERS("watchers", JqlFieldType.NUMBER),
  WORK_RATION("workRatio", JqlFieldType.NUMBER);

  private final String myName;
  private final JqlFieldType myType;

  JqlStandardField(String name, JqlFieldType type) {
    myName = name;
    myType = type;
  }

  public String getName() {
    return myName;
  }

  public JqlFieldType getType() {
    return myType;
  }

  private static final JqlStandardField[] VALUES = values();
  private static final Map<String, JqlStandardField> NAME_LOOKUP =
      ContainerUtil.newMapFromValues(
          ContainerUtil.iterate(VALUES),
          new Convertor<JqlStandardField, String>() {
            @Override
            public String convert(JqlStandardField field) {
              return field.getName();
            }
          });

  public static JqlStandardField byName(String name) {
    return NAME_LOOKUP.get(name);
  }

  private static final MultiMap<JqlFieldType, String> TYPE_LOOKUP =
      new MultiMap<JqlFieldType, String>();

  static {
    for (JqlStandardField field : VALUES) {
      TYPE_LOOKUP.putValue(field.getType(), field.getName());
    }
  }

  public static Collection<String> allOfType(JqlFieldType type) {
    return type == JqlFieldType.UNKNOWN
        ? ALL_FIELD_NAMES
        : new ArrayList<String>(TYPE_LOOKUP.get(type));
  }

  public static final List<String> ALL_FIELD_NAMES =
      ContainerUtil.map2List(VALUES, field -> field.myName);

  public static JqlFieldType typeOf(String name) {
    for (Map.Entry<JqlFieldType, Collection<String>> entry : TYPE_LOOKUP.entrySet()) {
      if (entry.getValue().contains(name)) {
        return entry.getKey();
      }
    }
    return JqlFieldType.UNKNOWN;
  }
}
Пример #3
0
  // new TemplatesGroup selected
  public void projectTypeChanged() {
    TemplatesGroup group = getSelectedGroup();
    if (group == null || group == myLastSelectedGroup) return;
    myLastSelectedGroup = group;
    PropertiesComponent.getInstance().setValue(PROJECT_WIZARD_GROUP, group.getId());
    ModuleBuilder groupModuleBuilder = group.getModuleBuilder();

    mySettingsStep = null;
    myHeaderPanel.removeAll();
    if (groupModuleBuilder != null && groupModuleBuilder.getModuleType() != null) {
      mySettingsStep = groupModuleBuilder.modifyProjectTypeStep(this);
    }

    if (groupModuleBuilder == null || groupModuleBuilder.isTemplateBased()) {
      showTemplates(group);
    } else if (!showCustomOptions(groupModuleBuilder)) {
      List<FrameworkSupportInModuleProvider> providers =
          FrameworkSupportUtil.getProviders(groupModuleBuilder);
      final ProjectCategory category = group.getProjectCategory();
      if (category != null) {
        List<FrameworkSupportInModuleProvider> filtered =
            ContainerUtil.filter(
                providers,
                new Condition<FrameworkSupportInModuleProvider>() {
                  @Override
                  public boolean value(FrameworkSupportInModuleProvider provider) {
                    return matchFramework(category, provider);
                  }
                });
        // add associated
        Map<String, FrameworkSupportInModuleProvider> map =
            ContainerUtil.newMapFromValues(providers.iterator(), PROVIDER_STRING_CONVERTOR);
        Set<FrameworkSupportInModuleProvider> set =
            new HashSet<FrameworkSupportInModuleProvider>(filtered);
        for (FrameworkSupportInModuleProvider provider : filtered) {
          for (FrameworkSupportInModuleProvider.FrameworkDependency depId :
              provider.getDependenciesFrameworkIds()) {
            FrameworkSupportInModuleProvider dependency = map.get(depId.getFrameworkId());
            set.add(dependency);
          }
        }

        myFrameworksPanel.setProviders(
            new ArrayList<FrameworkSupportInModuleProvider>(set),
            new HashSet<String>(Arrays.asList(category.getAssociatedFrameworkIds())),
            new HashSet<String>(Arrays.asList(category.getPreselectedFrameworkIds())));
      } else {
        myFrameworksPanel.setProviders(providers);
      }
      getSelectedBuilder().addModuleConfigurationUpdater(myConfigurationUpdater);

      showCard(FRAMEWORKS_CARD);
    }

    myHeaderPanel.setVisible(myHeaderPanel.getComponentCount() > 0);
    // align header labels
    List<JLabel> labels = UIUtil.findComponentsOfType(myHeaderPanel, JLabel.class);
    int width = 0;
    for (JLabel label : labels) {
      int width1 = label.getPreferredSize().width;
      width = Math.max(width, width1);
    }
    for (JLabel label : labels) {
      label.setPreferredSize(new Dimension(width, label.getPreferredSize().height));
    }
    myHeaderPanel.revalidate();
    myHeaderPanel.repaint();

    updateSelection();
  }
public abstract class ErlangExpressionType {
  public String getName() {
    return myName;
  }

  private final String myName;

  protected ErlangExpressionType(String name) {
    myName = name;
  }

  @Override
  public String toString() {
    return "ErlangExpressionType{'" + myName + "'}";
  }

  public boolean accept(ErlangExpressionType type) {
    return equals(type);
  }

  public static class ErlangPrimitiveType extends ErlangExpressionType {
    public ErlangPrimitiveType(@NotNull String name) {
      super(name);
    }
  }

  private static final ErlangExpressionType FLOAT = new ErlangPrimitiveType("FLOAT");
  private static final ErlangExpressionType FUN = new ErlangPrimitiveType("FUN");
  private static final ErlangExpressionType INTEGER = new ErlangPrimitiveType("INTEGER");
  private static final ErlangExpressionType CHAR = new ErlangPrimitiveType("CHAR");
  private static final ErlangExpressionType IOLIST = new ErlangPrimitiveType("IOLIST");
  private static final ErlangExpressionType TUPLE = new ErlangPrimitiveType("TUPLE");
  private static final ErlangExpressionType ATOM = new ErlangPrimitiveType("ATOM");
  private static final ErlangExpressionType BINARY = new ErlangPrimitiveType("BINARY");
  private static final ErlangExpressionType BITSTRING = new ErlangPrimitiveType("BITSTRING");
  private static final ErlangExpressionType STRING = new ErlangPrimitiveType("STRING");
  private static final ErlangExpressionType PID = new ErlangPrimitiveType("PID");
  private static final ErlangExpressionType PORT = new ErlangPrimitiveType("PORT");
  private static final ErlangExpressionType REF = new ErlangPrimitiveType("REF");
  private static final ErlangExpressionType TERM = new ErlangPrimitiveType("TERM");
  private static final ErlangExpressionType BOOLEAN = new ErlangPrimitiveType("BOOLEAN");
  public static final ErlangExpressionType UNKNOWN = new ErlangPrimitiveType("UNKNOWN");
  private static final ErlangExpressionType LIST =
      new ErlangPrimitiveType("LIST") {
        @Override
        public boolean accept(ErlangExpressionType type) {
          return super.accept(type) || type.equals(STRING);
        }
      };

  public static final Map<String, ErlangExpressionType> TYPE_MAP =
      ContainerUtil.newMapFromValues(
          ContainerUtil.list(
                  FLOAT, FUN, INTEGER, LIST, IOLIST, TUPLE, ATOM, BINARY, BITSTRING, STRING, PID,
                  PORT, REF, TERM, BOOLEAN)
              .iterator(),
          erlangExpressionType -> erlangExpressionType.myName.toLowerCase());

  @NotNull
  public static ErlangExpressionType create(@Nullable ErlangExpression e) {
    if (e == null) return UNKNOWN;
    final Ref<ErlangExpressionType> ref = Ref.create(UNKNOWN);
    e.accept(
        new ErlangVisitor() {
          @Override
          public void visitParenthesizedExpression(@NotNull ErlangParenthesizedExpression o) {
            ref.set(create(o.getExpression()));
          }

          @Override
          public void visitMultiplicativeExpression(@NotNull ErlangMultiplicativeExpression o) {
            PsiElement firstChild = o.getFirstChild();
            PsiElement operator = firstChild.getNextSibling();
            if (operator == null) return;
            IElementType operatorElementType = operator.getNode().getElementType();
            if (operatorElementType == ErlangTypes.ERL_OP_AR_DIV) ref.set(FLOAT);
            else if (operatorElementType == ErlangTypes.ERL_OP_AR_MUL) {
              ErlangExpressionType leftType = create(o.getLeft());
              ErlangExpressionType rightType = create(o.getRight());
              if (leftType.equals(rightType)) ref.set(leftType);
              else ref.set(FLOAT);
            }
          }

          @Override
          public void visitFunctionCallExpression(@NotNull ErlangFunctionCallExpression o) {
            PsiReference reference = o.getReference();
            PsiElement element = reference != null ? reference.resolve() : null;
            if (element instanceof ErlangFunction) {
              ref.set(calculateFunctionType((ErlangFunction) element));
            }
          }

          @Override
          public void visitBinaryExpression(@NotNull ErlangBinaryExpression o) {
            ref.set(BINARY);
          }

          @Override
          public void visitTupleExpression(@NotNull ErlangTupleExpression o) {
            ref.set(TUPLE);
          }

          @Override
          public void visitListExpression(@NotNull ErlangListExpression o) {
            ref.set(LIST);
          }

          @Override
          public void visitAdditiveExpression(@NotNull ErlangAdditiveExpression o) {
            ErlangExpressionType leftType = create(o.getLeft());
            ErlangExpressionType rightType = create(o.getRight());
            if (leftType.equals(rightType)) ref.set(leftType);
          }

          @Override
          public void visitMaxExpression(@NotNull ErlangMaxExpression o) {
            if (o.getInteger() != null) ref.set(INTEGER);
            else if (o.getFloat() != null) ref.set(FLOAT);
            else if (o.getQAtom() != null) ref.set(ATOM);
            else if (o.getChar() != null) ref.set(CHAR);
          }

          @Override
          public void visitStringLiteral(@NotNull ErlangStringLiteral o) {
            ref.set(STRING);
          }

          @Override
          public void visitFunExpression(@NotNull ErlangFunExpression o) {
            ref.set(FUN);
          }
        });
    return ref.get();
  }

  @NotNull
  public static ErlangExpressionType calculateFunctionType(@NotNull ErlangFunction function) {
    ErlangSpecification spec = function.findSpecification();
    if (spec == null) return UNKNOWN;
    ErlangFunTypeSigs signature = ErlangPsiImplUtil.getSignature(spec);
    if (signature == null) return UNKNOWN;
    for (ErlangTypeSig typeSig : signature.getTypeSigList()) {
      ErlangFunType funType = typeSig.getFunType();
      ErlangTopTypeClause typeClause = funType.getTopTypeClause();
      ErlangType type = PsiTreeUtil.getChildOfType(typeClause, ErlangType.class);
      ErlangTypeRef typeRef = type != null ? type.getTypeRef() : null;
      String text = typeRef != null ? typeRef.getText() : null;
      ErlangExpressionType expressionType = TYPE_MAP.get(text);
      if (expressionType != null) return expressionType;
    }
    return UNKNOWN;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    ErlangExpressionType that = (ErlangExpressionType) o;
    if (myName != null ? !myName.equals(that.myName) : that.myName != null) return false;
    return true;
  }

  @Override
  public int hashCode() {
    return myName != null ? myName.hashCode() : 0;
  }
}