当前位置: 首页>>代码示例>>Java>>正文


Java PairConsumer类代码示例

本文整理汇总了Java中com.intellij.util.PairConsumer的典型用法代码示例。如果您正苦于以下问题:Java PairConsumer类的具体用法?Java PairConsumer怎么用?Java PairConsumer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PairConsumer类属于com.intellij.util包,在下文中一共展示了PairConsumer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processMembersOfRegisteredClasses

import com.intellij.util.PairConsumer; //导入依赖的package包/类
public List<PsiMember> processMembersOfRegisteredClasses(final PrefixMatcher matcher, PairConsumer<PsiMember, PsiClass> consumer) {
  final ArrayList<PsiMember> result = ContainerUtil.newArrayList();
  for (final PsiClass psiClass : myStaticImportedClasses) {
    for (final PsiMethod method : psiClass.getAllMethods()) {
      if (matcher.prefixMatches(method.getName())) {
        if (isStaticallyImportable(method)) {
          consumer.consume(method, psiClass);
        }
      }
    }
    for (final PsiField field : psiClass.getAllFields()) {
      if (matcher.prefixMatches(field. getName())) {
        if (isStaticallyImportable(field)) {
          consumer.consume(field, psiClass);
        }
      }
    }
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:StaticMemberProcessor.java

示例2: MembersGetter

import com.intellij.util.PairConsumer; //导入依赖的package包/类
protected MembersGetter(StaticMemberProcessor processor, @NotNull final PsiElement place) {
  myPlace = place;
  processor.processMembersOfRegisteredClasses(PrefixMatcher.ALWAYS_TRUE, new PairConsumer<PsiMember, PsiClass>() {
    @Override
    public void consume(PsiMember member, PsiClass psiClass) {
      myImportedStatically.add(member);
    }
  });

  PsiClass current = PsiTreeUtil.getContextOfType(place, PsiClass.class);
  while (current != null) {
    current = CompletionUtil.getOriginalOrSelf(current);
    myPlaceClasses.add(current);
    current = PsiTreeUtil.getContextOfType(current, PsiClass.class);
  }

  PsiMethod eachMethod = PsiTreeUtil.getContextOfType(place, PsiMethod.class);
  while (eachMethod != null) {
    eachMethod = CompletionUtil.getOriginalOrSelf(eachMethod);
    myPlaceMethods.add(eachMethod);
    eachMethod = PsiTreeUtil.getContextOfType(eachMethod, PsiMethod.class);
  }

}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:MembersGetter.java

示例3: BackgroundTaskQueue

import com.intellij.util.PairConsumer; //导入依赖的package包/类
public BackgroundTaskQueue(@Nullable final Project project, @NotNull String title, final Boolean forcedHeadlessMode) {
  myMonitor = Boolean.TRUE.equals(Boolean.getBoolean(ourMonitorFlag)) ? new BackgroundTasksMonitor(title) : new PlusMinus.Empty<String>();
  final boolean headless = forcedHeadlessMode != null ? forcedHeadlessMode : ApplicationManager.getApplication().isHeadlessEnvironment();

  final QueueProcessor.ThreadToUse threadToUse = headless ? QueueProcessor.ThreadToUse.POOLED : QueueProcessor.ThreadToUse.AWT;
  final PairConsumer<Pair<Task.Backgroundable, Getter<ProgressIndicator>>, Runnable> consumer
    = headless ? new BackgroundableHeadlessRunner() : new BackgroundableUnderProgressRunner(title, project, myMonitor);

  myProcessor = new QueueProcessor<Pair<Task.Backgroundable, Getter<ProgressIndicator>>>(consumer, true,
                                                                                         threadToUse, new Condition<Object>() {
      @Override public boolean value(Object o) {
        if (project == null) return ApplicationManager.getApplication().isDisposed();
        if (project.isDefault()) {
          return project.isDisposed();
        } else {
          return !ApplicationManager.getApplication().isUnitTestMode() && !project.isOpen() || project.isDisposed();
        }
      }
    });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:BackgroundTaskQueue.java

示例4: AbstractRefreshablePanel

import com.intellij.util.PairConsumer; //导入依赖的package包/类
protected AbstractRefreshablePanel(final Project project, final String loadingTitle, final BackgroundTaskQueue queue) {
  myQueue = queue;
  myTicket = new Ticket();
  myDetailsPanel = new DetailsPanel();
  myDetailsPanel.loading();
  myDetailsPanel.layout();
  
  myDetailsLoader = new GenericDetailsLoader<Ticket, T>(new Consumer<Ticket>() {
    @Override
    public void consume(Ticket ticket) {
      final Loader loader = new Loader(project, loadingTitle, myTicket.copy());
      loader.runSteadily(new Consumer<Task.Backgroundable>() {
        @Override
        public void consume(Task.Backgroundable backgroundable) {
          myQueue.run(backgroundable);
        }
      });
    }
  }, new PairConsumer<Ticket, T>() {
    @Override
    public void consume(Ticket ticket, T t) {
      acceptData(t);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:AbstractRefreshablePanel.java

示例5: completeReference

import com.intellij.util.PairConsumer; //导入依赖的package包/类
public static boolean completeReference(final CompletionParameters parameters, final CompletionResultSet result) {
  final CompletionData completionData = getCompletionData(parameters);
  if (completionData == null) {
    return false;
  }

  final Ref<Boolean> hasVariants = Ref.create(false);
  processReferences(parameters, result, new PairConsumer<PsiReference, CompletionResultSet>() {
    @Override
    public void consume(final PsiReference reference, final CompletionResultSet resultSet) {
      final Set<LookupElement> lookupSet = new LinkedHashSet<LookupElement>();
      completionData.completeReference(reference, lookupSet, parameters.getPosition(), parameters.getOriginalFile());
      for (final LookupElement item : lookupSet) {
        if (resultSet.getPrefixMatcher().prefixMatches(item)) {
          if (!item.isValid()) {
            LOG.error(completionData + " has returned an invalid lookup element " + item + " of " + item.getClass() +
                      " in " + parameters.getOriginalFile() + " of " + parameters.getOriginalFile().getClass());
          }
          hasVariants.set(true);
          resultSet.addElement(item);
        }
      }
    }
  });
  return hasVariants.get().booleanValue();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:LegacyCompletionContributor.java

示例6: processReference

import com.intellij.util.PairConsumer; //导入依赖的package包/类
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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:LegacyCompletionContributor.java

示例7: ScratchFileServiceImpl

import com.intellij.util.PairConsumer; //导入依赖的package包/类
protected ScratchFileServiceImpl(MessageBus messageBus) {
  myIndex = new LightDirectoryIndex<RootType>(messageBus.connect(), NULL_TYPE) {

    @Override
    protected void collectRoots(@NotNull PairConsumer<VirtualFile, RootType> consumer) {
      LocalFileSystem fileSystem = LocalFileSystem.getInstance();
      for (RootType r : RootType.getAllRootIds()) {
        String root = getRootPath(r);
        VirtualFile rootFile = fileSystem.findFileByPath(root);
        if (rootFile != null) {
          consumer.consume(rootFile, r);
        }
      }
    }
  };
  initFileOpenedListener(messageBus);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ScratchFileServiceImpl.java

示例8: addCompletions

import com.intellij.util.PairConsumer; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
                              ProcessingContext context,
                              @NotNull final CompletionResultSet result) {
  LegacyCompletionContributor.processReferences(parameters, result, new PairConsumer<PsiReference, CompletionResultSet>() {
    @Override
    public void consume(PsiReference reference, CompletionResultSet set) {
      if (reference instanceof TagNameReference) {
        collectCompletionVariants((TagNameReference)reference, set);
      }
      else if (reference instanceof SchemaPrefixReference) {
        TagNameReference tagNameReference = ((SchemaPrefixReference)reference).getTagNameReference();
        if (tagNameReference != null && !tagNameReference.isStartTagFlag()) {
          set.consume(createClosingTagLookupElement((XmlTag)tagNameReference.getElement(), true, tagNameReference.getNameElement()));
        }
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:TagNameReferenceCompletionProvider.java

示例9: beforeCheckin

import com.intellij.util.PairConsumer; //导入依赖的package包/类
@Override
public ReturnResult beforeCheckin(@Nullable CommitExecutor executor, PairConsumer<Object, Object> additionalDataConsumer) {
  if (emptyCommitMessage()) {
    return ReturnResult.CANCEL;
  }

  if (commitOrCommitAndPush(executor)) {
    ReturnResult result = checkUserName();
    if (result != ReturnResult.COMMIT) {
      return result;
    }
    result = warnAboutCrlfIfNeeded();
    if (result != ReturnResult.COMMIT) {
      return result;
    }
    return warnAboutDetachedHeadIfNeeded();
  }
  return ReturnResult.COMMIT;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:GitCheckinHandlerFactory.java

示例10: showRecentListsForSelection

import com.intellij.util.PairConsumer; //导入依赖的package包/类
@Override
public List<CommittedChangeList> showRecentListsForSelection(@NotNull List<CommittedChangeList> list,
                                                             @NotNull String mergeTitle,
                                                             @NotNull MergeChecker mergeChecker,
                                                             @NotNull PairConsumer<Long, MergeDialogI> loader,
                                                             boolean everyThingLoaded) {
  final ToBeMergedDialog dialog = new ToBeMergedDialog(myProject, list, mergeTitle, mergeChecker, loader);
  if (everyThingLoaded) {
    dialog.setEverythingLoaded(true);
  }
  dialog.show();
  if (DialogWrapper.OK_EXIT_CODE == dialog.getExitCode()) {
    return dialog.getSelected();
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:QuickMergeInteractionImpl.java

示例11: createMoreChangeListsLoader

import com.intellij.util.PairConsumer; //导入依赖的package包/类
@NotNull
private PairConsumer<Long, MergeDialogI> createMoreChangeListsLoader() {
  return new PairConsumer<Long, MergeDialogI>() {

    @Override
    public void consume(@NotNull Long bunchSize, @NotNull MergeDialogI dialog) {
      LoadRecentBranchRevisions loader = new LoadRecentBranchRevisions(myMergeContext, dialog.getLastNumber(), bunchSize.intValue());
      TaskDescriptor updater = createUpdateDialogTask(dialog, loader);

      Continuation fragmented = Continuation.createFragmented(myMergeContext.getProject(), true);
      fragmented.addExceptionHandler(VcsException.class, new Consumer<VcsException>() {
        @Override
        public void consume(VcsException e) {
          PopupUtil.showBalloonForActiveComponent(e.getMessage() == null ? e.getClass().getName() : e.getMessage(), MessageType.ERROR);
        }
      });
      fragmented.run(loader, updater);
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:ShowRecentInDialogTask.java

示例12: getChangeListsBefore

import com.intellij.util.PairConsumer; //导入依赖的package包/类
@NotNull
private List<Pair<SvnChangeList, LogHierarchyNode>> getChangeListsBefore(long revision) throws VcsException {
  ChangeBrowserSettings settings = new ChangeBrowserSettings();
  if (revision > 0) {
    settings.CHANGE_BEFORE = String.valueOf(revision);
    settings.USE_CHANGE_BEFORE_FILTER = true;
  }

  final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
  ProgressManager.progress2(
    SvnBundle.message("progress.text2.collecting.history", myMergeContext.getSourceUrl() + (revision > 0 ? ("@" + revision) : "")));
  final List<Pair<SvnChangeList, LogHierarchyNode>> result = ContainerUtil.newArrayList();

  ((SvnCommittedChangesProvider)myMergeContext.getVcs().getCommittedChangesProvider())
    .getCommittedChangesWithMergedRevisons(settings, new SvnRepositoryLocation(myMergeContext.getSourceUrl()),
                                           myBunchSize + (revision > 0 ? 2 : 1),
                                           new PairConsumer<SvnChangeList, LogHierarchyNode>() {
                                             public void consume(SvnChangeList svnList, LogHierarchyNode tree) {
                                               indicator.setText2(
                                                 SvnBundle.message("progress.text2.processing.revision", svnList.getNumber()));
                                               result.add(Pair.create(svnList, tree));
                                             }
                                           });

  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:LoadRecentBranchRevisions.java

示例13: getKeyVariants

import com.intellij.util.PairConsumer; //导入依赖的package包/类
@Override
protected Collection<String> getKeyVariants(@NotNull GrExpression qualifier, @Nullable PsiElement resolve) {
  Pair<ConfigSlurperSupport.PropertiesProvider, List<String>> info = getInfo(qualifier, resolve);
  if (info == null) return Collections.emptyList();

  final Set<String> res = new HashSet<String>();

  info.first.collectVariants(info.second, new PairConsumer<String, Boolean>() {
    @Override
    public void consume(String variant, Boolean isFinal) {
      res.add(variant);
    }
  });

  return res;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ConfigSlurperMapContentProvider.java

示例14: getValueType

import com.intellij.util.PairConsumer; //导入依赖的package包/类
@Override
public PsiType getValueType(@NotNull GrExpression qualifier, @Nullable PsiElement resolve, @NotNull final String key) {
  Pair<ConfigSlurperSupport.PropertiesProvider, List<String>> info = getInfo(qualifier, resolve);
  if (info == null) return null;

  final Ref<Boolean> res = new Ref<Boolean>();

  info.first.collectVariants(info.second, new PairConsumer<String, Boolean>() {
    @Override
    public void consume(String variant, Boolean isFinal) {
      if (variant.equals(key)) {
        res.set(isFinal);
      }
      else if (variant.startsWith(key) && variant.length() > key.length() && variant.charAt(key.length()) == '.') {
        res.set(false);
      }
    }
  });

  if (res.get() != null && !res.get()) {
    return JavaPsiFacade.getElementFactory(qualifier.getProject()).createTypeByFQClassName(GroovyCommonClassNames.GROOVY_UTIL_CONFIG_OBJECT, qualifier.getResolveScope());
  }

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:ConfigSlurperMapContentProvider.java

示例15: completeReference

import com.intellij.util.PairConsumer; //导入依赖的package包/类
public static boolean completeReference(final CompletionParameters parameters, final CompletionResultSet result) {
  final CompletionData completionData = getCompletionData(parameters);
  if (completionData == null) {
    return false;
  }

  final Ref<Boolean> hasVariants = Ref.create(false);
  processReferences(parameters, result, new PairConsumer<PsiReference, CompletionResultSet>() {
    @Override
    public void consume(final PsiReference reference, final CompletionResultSet resultSet) {
      final Set<LookupElement> lookupSet = new LinkedHashSet<LookupElement>();
      completionData
        .completeReference(reference, lookupSet, parameters.getPosition(), parameters.getOriginalFile(), parameters.getOffset());
      for (final LookupElement item : lookupSet) {
        if (resultSet.getPrefixMatcher().prefixMatches(item)) {
          hasVariants.set(true);
          resultSet.addElement(item);
        }
      }
    }
  });
  return hasVariants.get().booleanValue();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:LegacyCompletionContributor.java


注:本文中的com.intellij.util.PairConsumer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。