private void validate(
      File file,
      Collection<Exception> exceptions,
      Collection<MavenProjectProblem> problems,
      Collection<MavenId> unresolvedArtifacts)
      throws RemoteException {
    for (Exception each : exceptions) {
      Maven3ServerGlobals.getLogger().info(each);

      if (each instanceof InvalidProjectModelException) {
        ModelValidationResult modelValidationResult =
            ((InvalidProjectModelException) each).getValidationResult();
        if (modelValidationResult != null) {
          for (Object eachValidationProblem : modelValidationResult.getMessages()) {
            problems.add(
                MavenProjectProblem.createStructureProblem(
                    file.getPath(), (String) eachValidationProblem));
          }
        } else {
          problems.add(
              MavenProjectProblem.createStructureProblem(
                  file.getPath(), each.getCause().getMessage()));
        }
      } else if (each instanceof ProjectBuildingException) {
        String causeMessage =
            each.getCause() != null ? each.getCause().getMessage() : each.getMessage();
        problems.add(MavenProjectProblem.createStructureProblem(file.getPath(), causeMessage));
      } else {
        problems.add(MavenProjectProblem.createStructureProblem(file.getPath(), each.getMessage()));
      }
    }
    unresolvedArtifacts.addAll(retrieveUnresolvedArtifactIds());
  }
 public void getNodeValues(
     ResolvedDependency node,
     Collection<ResolvedArtifact> values,
     Collection<ResolvedDependency> connectedNodes) {
   values.addAll(node.getModuleArtifacts());
   connectedNodes.addAll(node.getChildren());
 }
Пример #3
0
 /**
  * This method is similar to {@link #getAffectedUsers(Group)} except that it receives some group
  * properties. The group properties are passed as parameters since the called of this method may
  * want to obtain the related users of the group based in some properties values.
  *
  * <p>This is useful when the group is being edited and some properties has changed and we need to
  * obtain the related users of the group based on the previous group state.
  */
 private Collection<String> getAffectedUsers(Group group, String showInRoster, String groupNames) {
   // Answer an empty collection if the group is not being shown in users' rosters
   if (!"onlyGroup".equals(showInRoster) && !"everybody".equals(showInRoster)) {
     return new ArrayList<String>();
   }
   // Add the users of the group
   Collection<String> users = new HashSet<String>(group.getMembers());
   users.addAll(group.getAdmins());
   // Check if anyone can see this shared group
   if ("everybody".equals(showInRoster)) {
     // Add all users in the system
     for (User user : UserManager.getInstance().getUsers()) {
       users.add(user.getUsername());
     }
     // Add all logged users. We don't need to add all users in the system since only the
     // logged ones will be affected.
     // users.addAll(SessionManager.getInstance().getSessionUsers());
   } else {
     // Add the users that may see the group
     Collection<Group> groupList = parseGroups(groupNames);
     for (Group groupInList : groupList) {
       users.addAll(groupInList.getMembers());
       users.addAll(groupInList.getAdmins());
     }
   }
   return users;
 }
Пример #4
0
  private X509Certificate[] doBuild(X509Certificate[] chain, Collection otherCerts)
      throws CertificateException {
    try {
      PKIXBuilderParameters params = (PKIXBuilderParameters) parameterTemplate.clone();
      setDate(params);

      // setup target constraints
      X509CertSelector selector = new X509CertSelector();
      selector.setCertificate(chain[0]);
      params.setTargetCertConstraints(selector);

      // setup CertStores
      Collection certs = new ArrayList();
      certs.addAll(Arrays.asList(chain));
      if (otherCerts != null) {
        certs.addAll(otherCerts);
      }
      CertStore store =
          CertStore.getInstance("Collection", new CollectionCertStoreParameters(certs));
      params.addCertStore(store);

      // do the build
      CertPathBuilder builder = CertPathBuilder.getInstance("PKIX");
      PKIXCertPathBuilderResult result = (PKIXCertPathBuilderResult) builder.build(params);

      return toArray(result.getCertPath(), result.getTrustAnchor());
    } catch (GeneralSecurityException e) {
      throw new ValidatorException("PKIX path building failed: " + e.toString(), e);
    }
  }
Пример #5
0
  Collection<String> getSharedUsersForRoster(Group group, Roster roster) {
    String showInRoster = group.getProperties().get("sharedRoster.showInRoster");
    String groupNames = group.getProperties().get("sharedRoster.groupList");

    // Answer an empty collection if the group is not being shown in users' rosters
    if (!"onlyGroup".equals(showInRoster) && !"everybody".equals(showInRoster)) {
      return new ArrayList<String>();
    }

    // Add the users of the group
    Collection<String> users = new HashSet<String>(group.getMembers());
    users.addAll(group.getAdmins());

    // Check if anyone can see this shared group
    if ("everybody".equals(showInRoster)) {
      // If the user of the roster belongs to the public group then we should return all users
      // in the system since they all need to be in the roster with subscription "from"
      if (group.isUser(roster.getUsername())) {
        // Add all users in the system
        for (User user : UserManager.getInstance().getUsers()) {
          users.add(user.getUsername());
        }
      }
    } else {
      // Add the users that may see the group
      Collection<Group> groupList = parseGroups(groupNames);
      for (Group groupInList : groupList) {
        users.addAll(groupInList.getMembers());
        users.addAll(groupInList.getAdmins());
      }
    }
    return users;
  }
  private void doPostponedFormattingInner(final FileViewProvider key) {

    final List<ASTNode> astNodes = myReformatElements.remove(key);
    final Document document = key.getDocument();
    // Sort ranges by end offsets so that we won't need any offset adjustment after reformat or
    // reindent
    if (document == null) return;

    final VirtualFile virtualFile = key.getVirtualFile();
    if (!virtualFile.isValid()) return;

    final TreeSet<PostprocessFormattingTask> postProcessTasks =
        new TreeSet<PostprocessFormattingTask>();
    Collection<Disposable> toDispose = ContainerUtilRt.newArrayList();
    try {
      // process all roots in viewProvider to find marked for reformat before elements and create
      // appropriate range markers
      handleReformatMarkers(key, postProcessTasks);
      toDispose.addAll(postProcessTasks);

      // then we create ranges by changed nodes. One per node. There ranges can intersect. Ranges
      // are sorted by end offset.
      if (astNodes != null) createActionsMap(astNodes, key, postProcessTasks);

      if ("true".equals(System.getProperty("check.psi.is.valid"))
          && ApplicationManager.getApplication().isUnitTestMode()) {
        checkPsiIsCorrect(key);
      }

      while (!postProcessTasks.isEmpty()) {
        // now we have to normalize actions so that they not intersect and ordered in most
        // appropriate way
        // (free reformatting -> reindent -> formatting under reindent)
        final List<PostponedAction> normalizedActions =
            normalizeAndReorderPostponedActions(postProcessTasks, document);
        toDispose.addAll(normalizedActions);

        // only in following loop real changes in document are made
        for (final PostponedAction normalizedAction : normalizedActions) {
          CodeStyleSettings settings =
              CodeStyleSettingsManager.getSettings(myPsiManager.getProject());
          boolean old = settings.ENABLE_JAVADOC_FORMATTING;
          settings.ENABLE_JAVADOC_FORMATTING = false;
          try {
            normalizedAction.execute(key);
          } finally {
            settings.ENABLE_JAVADOC_FORMATTING = old;
          }
        }
      }
    } finally {
      for (Disposable disposable : toDispose) {
        //noinspection SSBasedInspection
        disposable.dispose();
      }
    }
  }
Пример #7
0
  public Collection<String> getArguments() {
    Collection<String> args = new ArrayList<>();
    Optional.ofNullable(username).ifPresent(s -> args.addAll(Arrays.asList("-u", s)));
    Optional.ofNullable(password).ifPresent(s -> args.addAll(Arrays.asList("-p", s)));
    Optional.ofNullable(from)
        .ifPresent(d -> args.addAll(Arrays.asList("-f", d.format(DateTimeFormatter.ISO_DATE))));

    return args;
  }
  protected Collection<String> generateSuggestedNames(PyExpression expression) {
    Collection<String> candidates =
        new LinkedHashSet<String>() {
          @Override
          public boolean add(String s) {
            if (PyNames.isReserved(s)) {
              return false;
            }
            return super.add(s);
          }
        };
    String text = expression.getText();
    final Pair<PsiElement, TextRange> selection =
        expression.getUserData(PyReplaceExpressionUtil.SELECTION_BREAKS_AST_NODE);
    if (selection != null) {
      text = selection.getSecond().substring(text);
    }
    if (expression instanceof PyCallExpression) {
      final PyExpression callee = ((PyCallExpression) expression).getCallee();
      if (callee != null) {
        text = callee.getText();
      }
    }
    if (text != null) {
      candidates.addAll(NameSuggesterUtil.generateNames(text));
    }
    final TypeEvalContext context = TypeEvalContext.userInitiated(expression.getContainingFile());
    PyType type = context.getType(expression);
    if (type != null && type != PyNoneType.INSTANCE) {
      String typeName = type.getName();
      if (typeName != null) {
        if (type.isBuiltin()) {
          typeName = typeName.substring(0, 1);
        }
        candidates.addAll(NameSuggesterUtil.generateNamesByType(typeName));
      }
    }
    final PyKeywordArgument kwArg =
        PsiTreeUtil.getParentOfType(expression, PyKeywordArgument.class);
    if (kwArg != null && kwArg.getValueExpression() == expression) {
      candidates.add(kwArg.getKeyword());
    }

    final PyArgumentList argList = PsiTreeUtil.getParentOfType(expression, PyArgumentList.class);
    if (argList != null) {
      final CallArgumentsMapping result = argList.analyzeCall(PyResolveContext.noImplicits());
      if (result.getMarkedCallee() != null) {
        final PyNamedParameter namedParameter = result.getPlainMappedParams().get(expression);
        if (namedParameter != null) {
          candidates.add(namedParameter.getName());
        }
      }
    }
    return candidates;
  }
Пример #9
0
 private static Collection<DeclarationDescriptor> getAllVariables(LexicalScope scope) {
   Collection<DeclarationDescriptor> result = ContainerUtil.newArrayList();
   result.addAll(
       ScopeUtilsKt.collectDescriptorsFiltered(
           scope, DescriptorKindFilter.VARIABLES, MemberScope.Companion.getALL_NAME_FILTER()));
   for (ReceiverParameterDescriptor implicitReceiver :
       ScopeUtilsKt.getImplicitReceiversHierarchy(scope)) {
     result.addAll(DescriptorUtils.getAllDescriptors(implicitReceiver.getType().getMemberScope()));
   }
   return result;
 }
 @SuppressWarnings("unchecked")
 private Collection<KnowledgePackage> convertCollectionItemsToKnowledgePackages(
     Collection loadedObjects) {
   Collection<KnowledgePackage> knowledgePackages = new ArrayList<KnowledgePackage>();
   knowledgePackages.addAll(loadedObjects);
   return knowledgePackages;
 }
Пример #11
0
 /**
  * This method extracts a collection of tests for a given audit
  *
  * @return
  */
 private void extractTestSet(boolean extractThemeAndCriterion) {
   testSet = new HashSet<Test>();
   testSet.addAll(auditDataService.getAuditWithTest(this.audit.getId()).getTestList());
   if (extractThemeAndCriterion) {
     extractThemeAndCriterionSet();
   }
 }
  /** @throws Exception If failed. */
  public void testClientAffinity() throws Exception {
    GridClientData partitioned = client.data(PARTITIONED_CACHE_NAME);

    Collection<Object> keys = new ArrayList<>();

    keys.addAll(Arrays.asList(Boolean.TRUE, Boolean.FALSE, 1, Integer.MAX_VALUE));

    Random rnd = new Random();
    StringBuilder sb = new StringBuilder();

    // Generate some random strings.
    for (int i = 0; i < 100; i++) {
      sb.setLength(0);

      for (int j = 0; j < 255; j++)
        // Only printable ASCII symbols for test.
        sb.append((char) (rnd.nextInt(0x7f - 0x20) + 0x20));

      keys.add(sb.toString());
    }

    // Generate some more keys to achieve better coverage.
    for (int i = 0; i < 100; i++) keys.add(UUID.randomUUID());

    for (Object key : keys) {
      UUID nodeId = grid(0).mapKeyToNode(PARTITIONED_CACHE_NAME, key).id();

      UUID clientNodeId = partitioned.affinity(key);

      assertEquals(
          "Invalid affinity mapping for REST response for key: " + key, nodeId, clientNodeId);
    }
  }
Пример #13
0
 private static void appendAnnotationAttributeValues(
     final Map<String, Collection<String>> results,
     final PsiAnnotation annotation,
     final PsiDocCommentOwner commentOwner) {
   for (String parameter : results.keySet()) {
     final Collection<String> values = results.get(parameter);
     if (annotation != null) {
       final PsiAnnotationMemberValue value = annotation.findDeclaredAttributeValue(parameter);
       if (value != null) {
         values.addAll(extractValuesFromParameter(value));
       }
     } else {
       values.addAll(extractAnnotationValuesFromJavaDoc(getTextJavaDoc(commentOwner), parameter));
     }
   }
 }
 @Override
 public Collection<String> findConflicts(
     PsiElement element, PsiElement[] elements, UsageInfo[] usages) {
   String methodRefFound = null;
   if (!ApplicationManager.getApplication().isUnitTestMode()
       && (element instanceof PsiMethod || element instanceof PsiParameter)) {
     for (UsageInfo usage : usages) {
       final PsiElement refElement = usage.getElement();
       if (refElement instanceof PsiMethodReferenceExpression) {
         methodRefFound = RefactoringBundle.message("expand.method.reference.warning");
         break;
       }
     }
   }
   if (methodRefFound != null) {
     Collection<String> result = new ArrayList<>();
     result.add(methodRefFound);
     final Collection<String> conflicts = super.findConflicts(element, elements, usages);
     if (conflicts != null) {
       result.addAll(conflicts);
     }
     return result;
   }
   return super.findConflicts(element, elements, usages);
 }
Пример #15
0
  @NotNull
  public static Collection<ClassDescriptor> getClassOrObjectDescriptorsByFqName(
      @NotNull ResolveSession resolveSession,
      @NotNull FqName fqName,
      boolean includeObjectDeclarations) {
    if (fqName.isRoot()) {
      return Collections.emptyList();
    }

    Collection<ClassDescriptor> classDescriptors = Lists.newArrayList();

    FqName packageFqName = fqName.parent();
    while (true) {
      NamespaceDescriptor packageDescriptor =
          resolveSession.getPackageDescriptorByFqName(packageFqName);
      if (packageDescriptor != null) {
        FqName classInPackagePath = new FqName(QualifiedNamesUtil.tail(packageFqName, fqName));
        Collection<ClassDescriptor> descriptors =
            getClassOrObjectDescriptorsByFqName(
                packageDescriptor, classInPackagePath, includeObjectDeclarations);
        classDescriptors.addAll(descriptors);
      }

      if (packageFqName.isRoot()) {
        break;
      } else {
        packageFqName = packageFqName.parent();
      }
    }

    return classDescriptors;
  }
Пример #16
0
  // 删除
  @RequestMapping(value = "/delete", method = RequestMethod.POST)
  @ResponseBody
  public Object del(String ids) {
    Map map = new HashMap();
    int result = 0;
    Collection collection = new ArrayList();
    for (String id : ids.split("&")) {
      List<ControlBaseInfo> controlBaseInfos =
          controlBaseInfoService.selectByBaseMer(Long.valueOf(id));

      if (controlBaseInfos.size() == 0) {
        result = baseMerService.deleteByPrimaryKey(Long.valueOf(id));
      } else {
        collection.addAll(controlBaseInfos);
      }
    }

    map.put("state", result);
    if (!collection.isEmpty()) {
      map.put(
          "controlBaseInfos",
          BeanUtil.getCollection2JSON(collection, "controlBaseInfos", "controlmername", true));
    }

    return map;
  }
Пример #17
0
  /**
   * Core sentiment detection method. doNota = none of the above
   *
   * @param captions (null/none = all)
   */
  public Map<String, Collection<Document>> getEmotions(
      Indexer indexer,
      Collection<Document> docs,
      boolean doNota,
      boolean originalContentOnly,
      String... captions) {
    Collection<Lexicon1Lang> lexicons = getRelevantLexicon1Langs(docs);
    Map<String, Collection<Document>> result = new LinkedHashMap<>();
    Set<Document> docs_set = Util.castOrCloneAsSet(docs);
    // aggregate results for each lang into result
    for (Lexicon1Lang lex : lexicons) {
      Map<String, Collection<Document>> resultsForThisLang =
          (doNota
              ? lex.getEmotionsWithNOTA(indexer, docs_set, originalContentOnly)
              : lex.getEmotions(indexer, docs_set, originalContentOnly, captions));
      if (resultsForThisLang == null) continue;

      for (String caption : resultsForThisLang.keySet()) {
        Collection<Document> resultDocsThisLang = resultsForThisLang.get(caption);
        Collection<Document> resultDocs = result.get(caption);
        // if caption doesn't exist already, create a new entry, or else add to the existing set of
        // docs that match this caption
        if (resultDocs == null) result.put(caption, resultDocsThisLang);
        else resultDocs.addAll(resultDocsThisLang);
      }
    }
    // TODO: the result can be cached at server to avoid redundant computation (by concurrent users,
    // which are few for now)
    return result;
  }
  protected Collection<PsiElement> classGoToDeclaration(PsiElement psiElement, String className) {

    Collection<PsiElement> psiElements = new HashSet<PsiElement>();

    // Class::method
    // Class::FooAction
    // Class:Foo
    if (className.contains(":")) {
      String[] split = className.replaceAll("(:)\\1", "$1").split(":");
      if (split.length == 2) {
        for (String append : new String[] {"", "Action"}) {
          Method classMethod =
              PhpElementsUtil.getClassMethod(psiElement.getProject(), split[0], split[1] + append);
          if (classMethod != null) {
            psiElements.add(classMethod);
          }
        }
      }

      return psiElements;
    }

    // ClassName
    psiElements.addAll(PhpElementsUtil.getClassesInterface(psiElement.getProject(), className));
    return psiElements;
  }
Пример #19
0
  private void removeSharedGroupFromRoster(Group group, String username) {
    // Get the group users to remove from the user's roster
    Collection<String> users = new HashSet<String>(group.getMembers());
    users.addAll(group.getAdmins());

    // Get the roster of the user from which we need to remove the shared group users
    Roster userRoster = (Roster) CacheManager.getCache("username2roster").get(username);

    // Iterate on all the group users and update their rosters
    for (String userToRemove : users) {
      // Get the roster to update
      Roster roster = (Roster) CacheManager.getCache("username2roster").get(userToRemove);
      // Only update rosters in memory
      if (roster != null) {
        roster.deleteSharedUser(group, username);
      }
      // Update the roster of the user
      if (userRoster != null) {
        try {
          User user = UserManager.getInstance().getUser(userToRemove);
          Collection<Group> groups = GroupManager.getInstance().getGroups(user);
          userRoster.deleteSharedUser(userToRemove, groups, group);
        } catch (UserNotFoundException e) {
        }
      }
    }
  }
Пример #20
0
 /** @return Not null, read only and of type <tt>String</tt>. */
 public Collection getHiddenTableColumns() throws XavaException {
   if (hiddenTableColumns == null) {
     hiddenTableColumns = getTableColumns(getHiddenPropertiesNames());
     hiddenTableColumns.addAll(getCmpFieldsColumnsInMultipleProperties());
   }
   return hiddenTableColumns;
 }
Пример #21
0
  private void processElements(
      Attribute attribute,
      CssElementType elementType,
      Map<String, Collection<FileObject>> elements2files) {
    CharSequence value = attribute.unquotedValue();
    if (value == null) {
      return;
    }

    if (value.length() == 0) {
      return; // ignore empty value
    }

    // all files containing the id declaration
    Collection<FileObject> filesWithTheId = elements2files.get(value.toString());

    // all referred files with the id declaration
    Collection<FileObject> referredFilesWithTheId = new LinkedList<FileObject>();
    if (filesWithTheId != null) {
      referredFilesWithTheId.addAll(filesWithTheId);
      referredFilesWithTheId.retainAll(referredFiles);
    }

    if (referredFilesWithTheId.isEmpty()) {
      // unknown id
      hints.add(
          new MissingCssElement(
              rule, context, getAttributeValueOffsetRange(attribute, context), filesWithTheId));
    }
  }
Пример #22
0
 public void add(NullAnalysisResult duplicate) {
   for (int i = 0; i < groupedByValue.length; i++) {
     Collection<PsiElement> elements = groupedByValue[i];
     Collection<PsiElement> other = duplicate.groupedByValue[i];
     elements.addAll(other);
   }
 }
 public Collection<Change> getAllChanges() {
   final Collection<Change> changes = new HashSet<Change>();
   for (LocalChangeList list : myMap.values()) {
     changes.addAll(list.getChanges());
   }
   return changes;
 }
  @Override
  public void rebuildList() {
    if (myInRebuildList) return;
    try {
      myInRebuildList = true;
      if (myChangesToDisplay == null) {
        // changes set not fixed === local changes
        final ChangeListManager manager = ChangeListManager.getInstance(myProject);
        myChangeListsMap = new HashMap<Change, LocalChangeList>();
        final List<LocalChangeList> lists = manager.getChangeListsCopy();
        Collection<Change> allChanges = new ArrayList<Change>();
        for (LocalChangeList list : lists) {
          final Collection<Change> changes = list.getChanges();
          allChanges.addAll(changes);
          for (Change change : changes) {
            myChangeListsMap.put(change, list);
          }
        }
        myAllChanges = allChanges;
        // refresh selected list also
        updateListsInChooser();
      }

      super.rebuildList();
      if (myRebuildListListener != null) {
        myRebuildListListener.run();
      }
    } finally {
      myInRebuildList = false;
    }
  }
Пример #25
0
 // look up and apply coarts for given rels to each sign in result
 private void applyCoarts(List<String> coartRels, Collection<Sign> result) {
   List<Sign> inputSigns = new ArrayList<Sign>(result);
   result.clear();
   List<Sign> outputSigns = new ArrayList<Sign>(inputSigns.size());
   // for each rel, lookup coarts and apply to input signs, storing results in output signs
   for (Iterator<String> it = coartRels.iterator(); it.hasNext(); ) {
     String rel = it.next();
     Collection<String> preds = (Collection<String>) _coartRelsToPreds.get(rel);
     if (preds == null) continue; // not expected
     Collection<Sign> coartResult = getSignsFromRelAndPreds(rel, preds);
     if (coartResult == null) continue;
     for (Iterator<Sign> it2 = coartResult.iterator(); it2.hasNext(); ) {
       Sign coartSign = it2.next();
       // apply to each input
       for (int j = 0; j < inputSigns.size(); j++) {
         Sign sign = inputSigns.get(j);
         grammar.rules.applyCoart(sign, coartSign, outputSigns);
       }
     }
     // switch output to input for next iteration
     inputSigns.clear();
     inputSigns.addAll(outputSigns);
     outputSigns.clear();
   }
   // add results back
   result.addAll(inputSigns);
 }
Пример #26
0
  public void checkRedeclarationsInInnerClassNames(@NotNull TopDownAnalysisContext c) {
    for (ClassDescriptorWithResolutionScopes classDescriptor : c.getDeclaredClasses().values()) {
      if (classDescriptor.getKind() == ClassKind.CLASS_OBJECT) {
        // Class objects should be considered during analysing redeclarations in classes
        continue;
      }

      Collection<DeclarationDescriptor> allDescriptors =
          classDescriptor.getScopeForMemberLookup().getOwnDeclaredDescriptors();

      ClassDescriptorWithResolutionScopes classObj = classDescriptor.getClassObjectDescriptor();
      if (classObj != null) {
        Collection<DeclarationDescriptor> classObjDescriptors =
            classObj.getScopeForMemberLookup().getOwnDeclaredDescriptors();
        if (!classObjDescriptors.isEmpty()) {
          allDescriptors = Lists.newArrayList(allDescriptors);
          allDescriptors.addAll(classObjDescriptors);
        }
      }

      Multimap<Name, DeclarationDescriptor> descriptorMap = HashMultimap.create();
      for (DeclarationDescriptor desc : allDescriptors) {
        if (desc instanceof ClassDescriptor || desc instanceof PropertyDescriptor) {
          descriptorMap.put(desc.getName(), desc);
        }
      }

      reportRedeclarations(descriptorMap);
    }
  }
  @Override
  protected void setInitialSelection(
      List<? extends ChangeList> changeLists,
      List<Change> changes,
      ChangeList initialListSelection) {
    myAllChanges = new ArrayList<Change>();
    mySelectedChangeList = initialListSelection;

    for (ChangeList list : changeLists) {
      if (list instanceof LocalChangeList) {
        myAllChanges.addAll(list.getChanges());
        if (initialListSelection == null) {
          for (Change c : list.getChanges()) {
            if (changes.contains(c)) {
              mySelectedChangeList = list;
              break;
            }
          }
        }
      }
    }

    if (mySelectedChangeList == null) {
      for (ChangeList list : changeLists) {
        if (list instanceof LocalChangeList && ((LocalChangeList) list).isDefault()) {
          mySelectedChangeList = list;
          break;
        }
      }
      if (mySelectedChangeList == null && !changeLists.isEmpty()) {
        mySelectedChangeList = changeLists.get(0);
      }
    }
  }
  @Override
  public void collectMethods(
      @NotNull final GrTypeDefinition clazz, @NotNull Collection<PsiMethod> collector) {
    Set<PsiClass> processed = new HashSet<PsiClass>();

    if (!checkForDelegate(clazz)) return;

    Map<MethodSignature, PsiMethod> signatures =
        new THashMap<MethodSignature, PsiMethod>(
            MethodSignatureUtil.METHOD_PARAMETERS_ERASURE_EQUALITY);
    initializeSignatures(clazz, PsiSubstitutor.EMPTY, signatures, processed);

    List<PsiMethod> methods = new ArrayList<PsiMethod>();
    process(
        clazz,
        PsiSubstitutor.EMPTY,
        true,
        new HashSet<PsiClass>(),
        processed,
        methods,
        clazz,
        false);

    final Set<PsiMethod> result = new LinkedHashSet<PsiMethod>();
    for (PsiMethod method : methods) {
      addMethodChecked(signatures, method, PsiSubstitutor.EMPTY, result);
    }

    collector.addAll(result);
  }
  /**
   * JUnit.
   *
   * @throws Exception If failed.
   */
  public void testGetAndIncrement() throws Exception {
    Collection<Long> res = new HashSet<>();

    String seqName = UUID.randomUUID().toString();

    for (int i = 0; i < GRID_CNT; i++) {
      Set<Long> retVal =
          compute(grid(i).cluster().forLocal()).call(new GetAndIncrementJob(seqName, RETRIES));

      for (Long l : retVal) assert !res.contains(l) : "Value already was used " + l;

      res.addAll(retVal);
    }

    assert res.size() == GRID_CNT * RETRIES;

    int gapSize = 0;

    for (long i = 0; i < GRID_CNT * RETRIES; i++) {
      if (!res.contains(i)) gapSize++;
      else gapSize = 0;

      assert gapSize <= BATCH_SIZE + 1
          : "Gap above id  " + i + " is " + gapSize + " more than batch size: " + (BATCH_SIZE + 1);
    }
  }
Пример #30
0
  public Runnable prepareMergeRunnable() {
    Map<MapContainer, Collection<Record>> recordMap =
        new HashMap<MapContainer, Collection<Record>>(mapContainers.size());
    InternalPartitionService partitionService = nodeEngine.getPartitionService();
    int partitionCount = partitionService.getPartitionCount();
    Address thisAddress = nodeEngine.getClusterService().getThisAddress();

    for (MapContainer mapContainer : mapContainers.values()) {
      for (int i = 0; i < partitionCount; i++) {
        RecordStore recordStore = getPartitionContainer(i).getRecordStore(mapContainer.getName());
        // add your owned entries to the map so they will be merged
        if (thisAddress.equals(partitionService.getPartitionOwner(i))) {
          Collection<Record> records = recordMap.get(mapContainer);
          if (records == null) {
            records = new ArrayList<Record>();
            recordMap.put(mapContainer, records);
          }
          records.addAll(recordStore.getReadonlyRecordMap().values());
        }
        // clear all records either owned or backup
        recordStore.reset();
      }
    }
    return new Merger(recordMap);
  }