當前位置: 首頁>>代碼示例>>Java>>正文


Java Consumer.consume方法代碼示例

本文整理匯總了Java中com.intellij.util.Consumer.consume方法的典型用法代碼示例。如果您正苦於以下問題:Java Consumer.consume方法的具體用法?Java Consumer.consume怎麽用?Java Consumer.consume使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.util.Consumer的用法示例。


在下文中一共展示了Consumer.consume方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: scanLibraryForDeclaredPackages

import com.intellij.util.Consumer; //導入方法依賴的package包/類
@Override
protected void scanLibraryForDeclaredPackages(File file, Consumer<String> result) throws IOException {
  final ZipFile zip = new ZipFile(file);
  try {
    final Enumeration<? extends ZipEntry> entries = zip.entries();
    while (entries.hasMoreElements()) {
      final String entryName = entries.nextElement().getName();
      if (StringUtil.endsWithIgnoreCase(entryName, ".class")) {
        final int index = entryName.lastIndexOf('/');
        if (index > 0) {
          final String packageName = entryName.substring(0, index).replace('/', '.');
          result.consume(packageName);
        }
      }
    }
  }
  finally {
    zip.close();
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:JavaModuleInsight.java

示例2: createRunOrContinuation

import com.intellij.util.Consumer; //導入方法依賴的package包/類
private RunOrContinuation<Out,E> createRunOrContinuation(final In in, final Consumer<TransparentlyFailedValueI<Out, E>> resultConsumer,
                                                         final Class<E> clazzE) {
  return new RunOrContinuation<Out,E>(myProject, myTaskTitle, clazzE) {
    @Override
    protected Out calculate() {
      return myCache.getValue(in);
    }
    @Override
    protected Out calculateLong() throws E {
      final Out result = myLive.convert(in);
      if (result != null) {
        myCache.setValue(result, in);
      }
      return result;
    }

    @Override
    protected void processResult(TransparentlyFailedValueI<Out, E> t) {
      resultConsumer.consume(t);
    }
  };
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:FactsCalculator.java

示例3: readAllHashes

import com.intellij.util.Consumer; //導入方法依賴的package包/類
@NotNull
@Override
public LogData readAllHashes(@NotNull VirtualFile root, @NotNull Consumer<TimedVcsCommit> commitConsumer) throws VcsException {
  LOG.debug("readAllHashes");
  try {
    myFullLogSemaphore.acquire();
  }
  catch (InterruptedException e) {
    throw new RuntimeException(e);
  }
  LOG.debug("readAllHashes passed the semaphore");
  assertRoot(root);
  for (TimedVcsCommit commit : myCommits) {
    commitConsumer.consume(commit);
  }
  return new LogDataImpl(myRefs, Collections.<VcsUser>emptySet());
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:TestVcsLogProvider.java

示例4: consume

import com.intellij.util.Consumer; //導入方法依賴的package包/類
@Override
public void consume(T t) {
  List<Consumer<T>> list;
  synchronized (this) {
    list = consumers;
    consumers = null;
  }

  if (list != null) {
    for (Consumer<T> consumer : list) {
      if (!isObsolete(consumer)) {
        consumer.consume(t);
      }
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:AsyncPromise.java

示例5: findDeclarationsAt

import com.intellij.util.Consumer; //導入方法依賴的package包/類
@Override
public void findDeclarationsAt(@NotNull PsiElement element, int offsetInElement, Consumer<PomTarget> consumer) {
  if (element instanceof AppleScriptSelectorId) {
    AppleScriptHandlerInterleavedParameters handler;
    final PsiElement contextElement = element.getContext() != null ? element.getContext().getContext() : null;
    if (contextElement instanceof AppleScriptHandlerInterleavedParameters) {
      handler = (AppleScriptHandlerInterleavedParameters) contextElement;
      consumer.consume(handler);
    }
  }
}
 
開發者ID:ant-druha,項目名稱:AppleScript-IDEA,代碼行數:12,代碼來源:AppleScriptHandlerDeclarationSearcher.java

示例6: submit

import com.intellij.util.Consumer; //導入方法依賴的package包/類
@Override
public boolean submit(@NotNull IdeaLoggingEvent[] events, @Nullable String additionalInfo,
    @NotNull Component parentComponent, @NotNull Consumer<SubmittedReportInfo> consumer) {
  log(events, additionalInfo);
  consumer.consume(new SubmittedReportInfo(null, null, NEW_ISSUE));
  Messages.showInfoMessage(parentComponent, DEFAULT_RESPONSE, DEFAULT_RESPONSE_TITLE);
  return true;
}
 
開發者ID:google,項目名稱:bamboo-soy,代碼行數:9,代碼來源:RollbarErrorReportSubmitter.java

示例7: belongsTo

import com.intellij.util.Consumer; //導入方法依賴的package包/類
@Override
public boolean belongsTo(final FilePath path, final Consumer<AbstractVcs> vcsConsumer) {
  if (myProject.isDisposed()) return false;
  final VcsRoot rootObject = myVcsManager.getVcsRootObjectFor(path);
  if (vcsConsumer != null && rootObject != null) {
    vcsConsumer.consume(rootObject.getVcs());
  }
  if (rootObject == null || rootObject.getVcs() != myVcs) {
    return false;
  }

  final VirtualFile vcsRoot = rootObject.getPath();
  if (vcsRoot != null) {
    for (VirtualFile contentRoot : myAffectedContentRoots) {
      // since we don't know exact dirty mechanics, maybe we have 3 nested mappings like:
      // /root -> vcs1, /root/child -> vcs2, /root/child/inner -> vcs1, and we have file /root/child/inner/file,
      // mapping is detected as vcs1 with root /root/child/inner, but we could possibly have in scope
      // "affected root" -> /root with scope = /root recursively
      if (VfsUtilCore.isAncestor(contentRoot, vcsRoot, false)) {
        THashSet<FilePath> dirsByRoot = myDirtyDirectoriesRecursively.get(contentRoot);
        if (dirsByRoot != null) {
          for (FilePath filePath : dirsByRoot) {
            if (path.isUnder(filePath, false)) return true;
          }
        }
      }
    }
  }

  if (!myDirtyFiles.isEmpty()) {
    FilePath parent = path.getParentPath();
    return isInDirtyFiles(path) || isInDirtyFiles(parent);
  }

  return false;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:37,代碼來源:VcsDirtyScopeImpl.java

示例8: showNotePopup

import com.intellij.util.Consumer; //導入方法依賴的package包/類
private void showNotePopup(Project project,
                           final DnDAwareTree tree,
                           final Consumer<String> after, final String initText) {
  final JTextArea textArea = new JTextArea(3, 50);
  textArea.setFont(UIUtil.getTreeFont());
  textArea.setText(initText);
  final JBScrollPane pane = new JBScrollPane(textArea);
  final ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(pane, textArea)
    .setCancelOnClickOutside(true)
    .setAdText(KeymapUtil.getShortcutsText(CommonShortcuts.CTRL_ENTER.getShortcuts()) + " to finish")
    .setTitle("Comment")
    .setMovable(true)
    .setRequestFocus(true).setResizable(true).setMayBeParent(true);
  final JBPopup popup = builder.createPopup();
  final JComponent content = popup.getContent();
  final AnAction action = new AnAction() {
    @Override
    public void actionPerformed(AnActionEvent e) {
      popup.closeOk(e.getInputEvent());
      unregisterCustomShortcutSet(content);
      after.consume(textArea.getText());
    }
  };
  action.registerCustomShortcutSet(CommonShortcuts.CTRL_ENTER, content);
  ApplicationManager.getApplication().invokeLater(new Runnable() {
    @Override
    public void run() {
      popup.showInCenterOf(tree);
    }
  }, ModalityState.NON_MODAL, project.getDisposed());
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:32,代碼來源:TaskDefaultFavoriteListProvider.java

示例9: sendError

import com.intellij.util.Consumer; //導入方法依賴的package包/類
public static void sendError(Project project,
                             final String login,
                             final String password,
                             final ErrorBean error,
                             final Consumer<Integer> callback,
                             final Consumer<Exception> errback) {
  if (StringUtil.isEmpty(login)) {
    return;
  }

  Task.Backgroundable task = new Task.Backgroundable(project, DiagnosticBundle.message("title.submitting.error.report")) {
    @Override
    public void run(@NotNull ProgressIndicator indicator) {
      try {
        int threadId = postNewThread(login, password, error);
        callback.consume(threadId);
      }
      catch (Exception ex) {
        errback.consume(ex);
      }
    }
  };

  if (project == null) {
    task.run(new EmptyProgressIndicator());
  }
  else {
    ProgressManager.getInstance().run(task);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:31,代碼來源:ITNProxy.java

示例10: consumeTopHits

import com.intellij.util.Consumer; //導入方法依賴的package包/類
@Override
public void consumeTopHits(String pattern, Consumer<Object> collector, Project project) {
  final ActionManager actionManager = ActionManager.getInstance();
  for (String[] strings : getActionsMatrix()) {
    if (StringUtil.isBetween(pattern, strings[0], strings[1])) {
      for (int i = 2; i < strings.length; i++) {
        collector.consume(actionManager.getAction(strings[i]));
      }
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:12,代碼來源:ActionsTopHitProvider.java

示例11: addConversionsToArray

import com.intellij.util.Consumer; //導入方法依賴的package包/類
private static void addConversionsToArray(final PsiElement element,
                                          final String prefix,
                                          final PsiType itemType,
                                          final Consumer<LookupElement> result,
                                          @Nullable PsiElement qualifier,
                                          final PsiType expectedType) throws IncorrectOperationException {
  final String methodName = getArraysConversionMethod(itemType, expectedType);
  if (methodName == null) return;
  
  final String qualifierText = getQualifierText(qualifier);
  final PsiExpression conversion = createExpression("java.util.Arrays." + methodName + "(" + qualifierText + prefix + ")", element);
  final String presentable = "Arrays." + methodName + "(" + qualifierText + prefix + ")";
  String[] lookupStrings = {StringUtil.isEmpty(qualifierText) ? presentable : prefix, prefix, presentable, methodName + "(" + prefix + ")"};
  result.consume(new ExpressionLookupItem(conversion, PlatformIcons.METHOD_ICON, presentable, lookupStrings) {
    @Override
    public void handleInsert(InsertionContext context) {
      FeatureUsageTracker.getInstance().triggerFeatureUsed(JavaCompletionFeatures.SECOND_SMART_COMPLETION_ASLIST);

      int startOffset = context.getStartOffset() - qualifierText.length();
      final Project project = element.getProject();
      final String callSpace = getSpace(CodeStyleSettingsManager.getSettings(project).SPACE_WITHIN_METHOD_CALL_PARENTHESES);
      final String newText = "java.util.Arrays." + methodName + "(" + callSpace + qualifierText + prefix + callSpace + ")";
      context.getDocument().replaceString(startOffset, context.getTailOffset(), newText);

      context.commitDocument();
      JavaCodeStyleManager.getInstance(project).shortenClassReferences(context.getFile(), startOffset, startOffset + CommonClassNames.JAVA_UTIL_ARRAYS.length());
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:30,代碼來源:ReferenceExpressionCompletionContributor.java

示例12: loadIncomingChangesAsync

import com.intellij.util.Consumer; //導入方法依賴的package包/類
public void loadIncomingChangesAsync(@Nullable final Consumer<List<CommittedChangeList>> consumer, final boolean inBackground) {
  debug("Loading incoming changes");
  final Runnable task = new Runnable() {
    @Override
    public void run() {
      final List<CommittedChangeList> list = loadIncomingChanges(inBackground);
      if (consumer != null) {
        consumer.consume(new ArrayList<CommittedChangeList>(list));
      }
    }
  };
  myTaskQueue.run(task);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:14,代碼來源:CommittedChangesCache.java

示例13: addStatementKeywords

import com.intellij.util.Consumer; //導入方法依賴的package包/類
private static void addStatementKeywords(Consumer<LookupElement> variant, PsiElement position, @Nullable PsiElement prevLeaf) {
  variant.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.SWITCH), TailTypes.SWITCH_LPARENTH));
  variant.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.WHILE), TailTypes.WHILE_LPARENTH));
  variant.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.DO), TailTypes.DO_LBRACE));
  variant.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.FOR), TailTypes.FOR_LPARENTH));
  variant.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.IF), TailTypes.IF_LPARENTH));
  variant.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.TRY), TailTypes.TRY_LBRACE));
  variant.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.THROW), TailType.INSERT_SPACE));
  variant.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.NEW), TailType.INSERT_SPACE));
  variant.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.SYNCHRONIZED), TailTypes.SYNCHRONIZED_LPARENTH));

  if (PsiUtil.getLanguageLevel(position).isAtLeast(LanguageLevel.JDK_1_4)) {
    variant.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.ASSERT), TailType.INSERT_SPACE));
  }

  TailType returnTail = getReturnTail(position);
  LookupElement ret = createKeyword(position, PsiKeyword.RETURN);
  if (returnTail != TailType.NONE) {
    ret = new OverrideableSpace(ret, returnTail);
  }
  variant.consume(ret);

  if (psiElement().withText(";").withSuperParent(2, PsiIfStatement.class).accepts(prevLeaf) ||
      psiElement().withText("}").withSuperParent(3, PsiIfStatement.class).accepts(prevLeaf)) {
    variant.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.ELSE), TailType.HUMBLE_SPACE_BEFORE_WORD));
  }

  if (psiElement().withText("}").withParent(psiElement(PsiCodeBlock.class).withParent(or(psiElement(PsiTryStatement.class), psiElement(PsiCatchSection.class)))).accepts(prevLeaf)) {
    variant.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.CATCH), TailTypes.CATCH_LPARENTH));
    variant.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.FINALLY), TailTypes.FINALLY_LBRACE));
  }

}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:34,代碼來源:JavaKeywordCompletion.java

示例14: addExtendsSuperImplements

import com.intellij.util.Consumer; //導入方法依賴的package包/類
private static void addExtendsSuperImplements(Consumer<LookupElement> result, PsiElement position, @Nullable PsiElement prevLeaf) {
  if (JavaMemberNameCompletionContributor.INSIDE_TYPE_PARAMS_PATTERN.accepts(position)) {
    result.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.EXTENDS), TailType.HUMBLE_SPACE_BEFORE_WORD));
    result.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.SUPER), TailType.HUMBLE_SPACE_BEFORE_WORD));
  }

  if (prevLeaf == null || !(prevLeaf instanceof PsiIdentifier || prevLeaf.textMatches(">"))) return;

  PsiClass psiClass = null;
  PsiElement prevParent = prevLeaf.getParent();
  if (prevLeaf instanceof PsiIdentifier && prevParent instanceof PsiClass) {
    psiClass = (PsiClass)prevParent;
  } else {
    PsiReferenceList referenceList = PsiTreeUtil.getParentOfType(prevLeaf, PsiReferenceList.class);
    if (referenceList != null && referenceList.getParent() instanceof PsiClass) {
      psiClass = (PsiClass)referenceList.getParent();
    }
    else if (prevParent instanceof PsiTypeParameterList && prevParent.getParent() instanceof PsiClass) {
      psiClass = (PsiClass)prevParent.getParent();
    }
  }

  if (psiClass != null) {
    result.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.EXTENDS), TailType.HUMBLE_SPACE_BEFORE_WORD));
    if (!psiClass.isInterface()) {
      result.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.IMPLEMENTS), TailType.HUMBLE_SPACE_BEFORE_WORD));
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:30,代碼來源:JavaKeywordCompletion.java

示例15: selectTargets

import com.intellij.util.Consumer; //導入方法依賴的package包/類
@Override
protected void selectTargets(final List<PsiElement> targets, final Consumer<List<PsiElement>> selectionConsumer) {
    selectionConsumer.consume(targets);
}
 
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:5,代碼來源:HighlightMacrosHandler.java


注:本文中的com.intellij.util.Consumer.consume方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。