private void alignSpockTable(List<GrStatement> group) {
    if (group.size() < 2) {
      return;
    }
    GrStatement inner = ((GrLabeledStatement) group.get(0)).getStatement();
    boolean embedded = inner != null && isTablePart(inner);

    GrStatement first = embedded ? inner : group.get(1);
    List<AlignmentProvider.Aligner> alignments =
        ContainerUtil.map2List(
            getSpockTable(first),
            new Function<LeafPsiElement, AlignmentProvider.Aligner>() {
              @Override
              public AlignmentProvider.Aligner fun(LeafPsiElement leaf) {
                return myAlignmentProvider.createAligner(leaf, true, Alignment.Anchor.RIGHT);
              }
            });

    int second = embedded ? 1 : 2;
    for (int i = second; i < group.size(); i++) {
      List<LeafPsiElement> table = getSpockTable(group.get(i));
      for (int j = 0; j < Math.min(table.size(), alignments.size()); j++) {
        alignments.get(j).append(table.get(j));
      }
    }
  }
Пример #2
0
 public static <T, U> List<Pair<T, U>> mapToList(Map<T, U> map) {
   return ContainerUtil.map2List(
       map.entrySet(),
       new Function<Map.Entry<T, U>, Pair<T, U>>() {
         public Pair<T, U> fun(Map.Entry<T, U> tuEntry) {
           return Pair.create(tuEntry.getKey(), tuEntry.getValue());
         }
       });
 }
 public Collection<String> getSDKVersions(Library[] libraries) {
   return ContainerUtil.map2List(
       libraries,
       new Function<Library, String>() {
         @Override
         public String fun(Library library) {
           return getSDKLibVersion(library);
         }
       });
 }
Пример #4
0
 public static List<File> virtualToIoFiles(@NotNull Collection<VirtualFile> scope) {
   return ContainerUtil.map2List(
       scope,
       new Function<VirtualFile, File>() {
         @Override
         public File fun(VirtualFile file) {
           return virtualToIoFile(file);
         }
       });
 }
 @NotNull
 public synchronized List<String> getSuspiciousNames() {
   List<VirtualFile> suspicious =
       new SubList<VirtualFile>(myChildren, getAdoptedChildrenStart(), myChildren.length);
   return ContainerUtil.map2List(
       suspicious,
       new Function<VirtualFile, String>() {
         @Override
         public String fun(VirtualFile file) {
           return file.getName();
         }
       });
 }
Пример #6
0
 public static String toString(Collection<?> collection, String separator) {
   List<String> list =
       ContainerUtil.map2List(
           collection,
           new Function<Object, String>() {
             @Override
             public String fun(final Object o) {
               return String.valueOf(o);
             }
           });
   Collections.sort(list);
   StringBuilder builder = new StringBuilder();
   boolean flag = false;
   for (final String o : list) {
     if (flag) {
       builder.append(separator);
     }
     builder.append(o);
     flag = true;
   }
   return builder.toString();
 }
/** @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;
  }
}