public void saveInCache(@NotNull TIntObjectHashMap<T> details) {
   UIUtil.invokeAndWaitIfNeeded(
       (Runnable)
           () ->
               details.forEachEntry(
                   (key, value) -> {
                     myCache.put(key, value);
                     return true;
                   }));
 }
 public ContextRelevantStaticMethod(
     final PsiMethod psiMethod, @Nullable final TIntObjectHashMap<PsiVariable> parameters) {
   this.psiMethod = psiMethod;
   if (parameters == null) {
     this.parameters = null;
   } else {
     this.parameters = new TIntObjectHashMap<>(parameters.size());
     parameters.forEachEntry(
         new TIntObjectProcedure<PsiVariable>() {
           @SuppressWarnings("ConstantConditions")
           @Override
           public boolean execute(final int pos, final PsiVariable var) {
             ContextRelevantStaticMethod.this.parameters.put(
                 pos, new VariableSubLookupElement(var));
             return true;
           }
         });
   }
 }
  private void checkForCycles() {
    final TIntObjectHashMap<TIntHashSet> transitivePredecessors =
        new TIntObjectHashMap<TIntHashSet>();

    myRegisteredPassFactories.forEachEntry(
        new TIntObjectProcedure<PassConfig>() {
          @Override
          public boolean execute(int passId, PassConfig config) {
            TIntHashSet allPredecessors = new TIntHashSet(config.completionPredecessorIds);
            allPredecessors.addAll(config.startingPredecessorIds);
            transitivePredecessors.put(passId, allPredecessors);
            allPredecessors.forEach(
                new TIntProcedure() {
                  @Override
                  public boolean execute(int predecessorId) {
                    PassConfig predecessor = myRegisteredPassFactories.get(predecessorId);
                    if (predecessor == null) return true;
                    TIntHashSet transitives = transitivePredecessors.get(predecessorId);
                    if (transitives == null) {
                      transitives = new TIntHashSet();
                      transitivePredecessors.put(predecessorId, transitives);
                    }
                    transitives.addAll(predecessor.completionPredecessorIds);
                    transitives.addAll(predecessor.startingPredecessorIds);
                    return true;
                  }
                });
            return true;
          }
        });
    transitivePredecessors.forEachKey(
        new TIntProcedure() {
          @Override
          public boolean execute(int passId) {
            if (transitivePredecessors.get(passId).contains(passId)) {
              throw new IllegalArgumentException(
                  "There is a cycle introduced involving pass "
                      + myRegisteredPassFactories.get(passId).passFactory);
            }
            return true;
          }
        });
  }
  private void storeIds(@NotNull ConcurrentIntObjectMap<int[]> fileToForwardIds) {
    int forwardSize = 0;
    int backwardSize = 0;
    final TIntObjectHashMap<TIntArrayList> fileToBackwardIds =
        new TIntObjectHashMap<TIntArrayList>(fileToForwardIds.size());
    for (ConcurrentIntObjectMap.IntEntry<int[]> entry : fileToForwardIds.entries()) {
      int fileId = entry.getKey();
      int[] forwardIds = entry.getValue();
      forwardSize += forwardIds.length;
      for (int forwardId : forwardIds) {
        TIntArrayList backIds = fileToBackwardIds.get(forwardId);
        if (backIds == null) {
          backIds = new TIntArrayList();
          fileToBackwardIds.put(forwardId, backIds);
        }
        backIds.add(fileId);
        backwardSize++;
      }
    }
    log("backwardSize = " + backwardSize);
    log("forwardSize = " + forwardSize);
    log("fileToForwardIds.size() = " + fileToForwardIds.size());
    log("fileToBackwardIds.size() = " + fileToBackwardIds.size());
    assert forwardSize == backwardSize;

    // wrap in read action so that sudden quit (in write action) would not interrupt us
    myApplication.runReadAction(
        () -> {
          if (!myApplication.isDisposed()) {
            fileToBackwardIds.forEachEntry(
                new TIntObjectProcedure<TIntArrayList>() {
                  @Override
                  public boolean execute(int fileId, TIntArrayList backIds) {
                    storage.addAll(fileId, backIds.toNativeArray());
                    return true;
                  }
                });
          }
        });
  }
Ejemplo n.º 5
0
 @Override
 public String toString() {
   @NonNls final StringBuilder s = new StringBuilder();
   s.append("defensivelyMarked = ").append(defensivelyMarked);
   s.append("; wolfPassFinfished = ").append(wolfPassFinished);
   s.append("; errorFound = ").append(errorFound);
   s.append("; dirtyScopes: (");
   dirtyScopes.forEachEntry(
       new TIntObjectProcedure<RangeMarker>() {
         @Override
         public boolean execute(int passId, RangeMarker rangeMarker) {
           s.append(" pass: "******" -> ")
               .append(rangeMarker == WHOLE_FILE_DIRTY_MARKER ? "Whole file" : rangeMarker)
               .append(";");
           return true;
         }
       });
   s.append(")");
   return s.toString();
 }
 public void putAll(final TIntObjectHashMap<V> map) {
   map.forEachEntry(this.PUT_ALL_PROC);
 }