Java Code Examples for com.intellij.util.PairConsumer#consume()

The following examples show how to use com.intellij.util.PairConsumer#consume() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LegacyCompletionContributor.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static void processReference(final CompletionResultSet result,
                                     final int startOffset,
                                     final PairConsumer<PsiReference, CompletionResultSet> consumer,
                                     final PsiReference reference) {
  PsiElement element = reference.getElement();
  final int offsetInElement = startOffset - element.getTextRange().getStartOffset();
  if (!ReferenceRange.containsOffsetInElement(reference, offsetInElement)) {
    return;
  }

  TextRange range = reference.getRangeInElement();
  try {
    final String prefix = element.getText().substring(range.getStartOffset(), offsetInElement);
    consumer.consume(reference, result.withPrefixMatcher(prefix));
  }
  catch (StringIndexOutOfBoundsException e) {
    LOG.error("Reference=" + reference +
              "; element=" + element + " of " + element.getClass() +
              "; range=" + range +
              "; offset=" + offsetInElement,
              e);
  }
}
 
Example 2
Source File: TabLabel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void doTranslate(PairConsumer<Integer, Integer> consumer) {
  final JBTabsPosition pos = myTabs.getTabsPosition();

  int dX = 0;
  int dXs = 0;
  int dY = 0;
  int dYs = 0;
  int selected = getSelectedOffset();
  int plain = getNonSelectedOffset();

  switch (pos) {
    case bottom:
      dY = -plain;
      dYs = -selected;
      break;
    case left:
      dX = plain;
      dXs = selected;
      break;
    case right:
      dX = -plain;
      dXs = -selected;
      break;
    case top:
      dY = plain;
      dYs = selected;
      break;
  }

  if (!myTabs.isDropTarget(myInfo)) {
    if (myTabs.getSelectedInfo() != myInfo) {
      consumer.consume(dX, dY);
    }
    else {
      consumer.consume(dXs, dYs);
    }
  }
}
 
Example 3
Source File: TreeModelAdapter.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static TreeModelListener create(@Nonnull final PairConsumer<? super TreeModelEvent, ? super EventType> consumer) {
  return new TreeModelAdapter() {
    @Override
    protected void process(@Nonnull TreeModelEvent event, @Nonnull EventType type) {
      consumer.consume(event, type);
    }
  };
}
 
Example 4
Source File: StartupUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static void prepareAndStart(String[] args, BiFunction<String, String, ImportantFolderLocker> lockFactory, PairConsumer<Boolean, CommandLineArgs> appStarter) {
  boolean newConfigFolder;
  CommandLineArgs commandLineArgs = CommandLineArgs.parse(args);

  if (commandLineArgs.isShowHelp()) {
    CommandLineArgs.printUsage();
    System.exit(ExitCodes.USAGE_INFO);
  }

  if (commandLineArgs.isShowVersion()) {
    ApplicationInfo infoEx = ApplicationInfo.getInstance();
    System.out.println(infoEx.getFullApplicationName());
    System.exit(ExitCodes.VERSION_INFO);
  }

  AppUIUtil.updateFrameClass();
  newConfigFolder = !new File(ContainerPathManager.get().getConfigPath()).exists();

  ActivationResult result = lockSystemFolders(lockFactory, args);
  if (result == ActivationResult.ACTIVATED) {
    System.exit(0);
  }
  else if (result != ActivationResult.STARTED) {
    System.exit(ExitCodes.INSTANCE_CHECK_FAILED);
  }

  Logger log = Logger.getInstance(StartupUtil.class);
  logStartupInfo(log);
  loadSystemLibraries(log);
  fixProcessEnvironment(log);

  appStarter.consume(newConfigFolder, commandLineArgs);
}
 
Example 5
Source File: PsiEquivalenceUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void addRangeDuplicates(final PsiElement scope,
                                       final PsiElement first,
                                       final PsiElement last,
                                       final PairConsumer<PsiElement, PsiElement> result) {
  final PsiElement[] children = getFilteredChildren(scope, null, true);
  NextChild:
  for (int i = 0; i < children.length;) {
    PsiElement child = children[i];
    if (child != first) {
      int j = i;
      PsiElement next = first;
      do {
        if (!areElementsEquivalent(children[j], next)) break;
        j++;
        if (next == last) {
          result.consume(child, children[j - 1]);
          i = j + 1;
          continue NextChild;
        }
        next = PsiTreeUtil.skipSiblingsForward(next, PsiWhiteSpace.class);
      }
      while (true);

      if (i == j) {
        addRangeDuplicates(child, first, last, result);
      }
    }

    i++;
  }
}
 
Example 6
Source File: StepIntersection.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void process(final Iterable<Data> data, final PairConsumer<Data, Area> consumer) {
  myDataIterator = data.iterator();

  if (! myDataIterator.hasNext() || noMoreAreas()) return;
  dataStep();
  initArea();
  while (! noMoreAreas()) {
    final boolean intersects = myAreaRange.intersects(myDataRange);
    if (intersects) {
      consumer.consume(myCurData, myCurArea);
    }
    // take next
    if (! myDataIterator.hasNext() && noMoreAreas()) break;
    if (! myDataIterator.hasNext()) {
      areaStep();
      continue;
    }
    if (noMoreAreas()) {
      dataStep();
      continue;
    }
    if (myDataRange.getEndOffset() < myAreaRange.getEndOffset()) {
      dataStep();
    } else {
      areaStep();
    }
  }
}
 
Example 7
Source File: SubmitModel.java    From p4ic4idea with Apache License 2.0 4 votes vote down vote up
public void saveState(@NotNull PairConsumer<Object, Object> dataConsumer) {
    dataConsumer.consume("jobIds", jobs);
    dataConsumer.consume("jobStatus", status);
}