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


Java CommonProcessors类代码示例

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


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

示例1: getMethodsByNameIfNotMoreThan

import com.intellij.util.CommonProcessors; //导入依赖的package包/类
@Override
@NotNull
public PsiMethod[] getMethodsByNameIfNotMoreThan(@NonNls @NotNull final String name, @NotNull final GlobalSearchScope scope, final int maxCount) {
  final List<PsiMethod> methods = new SmartList<PsiMethod>();
  StubIndex.getInstance().processElements(JavaStubIndexKeys.METHODS, name, myManager.getProject(), scope, PsiMethod.class, new
                                          CommonProcessors.CollectProcessor < PsiMethod > (methods){
  @Override
    public boolean process(PsiMethod method) {
      return methods.size() != maxCount && super.process(method);
    }
  });
  if (methods.isEmpty()) return PsiMethod.EMPTY_ARRAY;

  List<PsiMethod> list = filterMembers(methods, scope);
  return list.toArray(new PsiMethod[list.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:PsiShortNamesCacheImpl.java

示例2: getFieldsByNameIfNotMoreThan

import com.intellij.util.CommonProcessors; //导入依赖的package包/类
@Override
@NotNull
public PsiField[] getFieldsByNameIfNotMoreThan(@NotNull String name, @NotNull final GlobalSearchScope scope, final int maxCount) {
  final List<PsiField> methods = new SmartList<PsiField>();
  StubIndex.getInstance().processElements(JavaStubIndexKeys.FIELDS, name, myManager.getProject(), scope, PsiField.class, new
                                          CommonProcessors.CollectProcessor < PsiField > (methods){
  @Override
    public boolean process(PsiField method) {
      return methods.size() != maxCount && super.process(method);
    }
  });
  if (methods.isEmpty()) return PsiField.EMPTY_ARRAY;

  List<PsiField> list = filterMembers(methods, scope);
  return list.toArray(new PsiField[list.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:PsiShortNamesCacheImpl.java

示例3: getSuperAnnotationOwners

import com.intellij.util.CommonProcessors; //导入依赖的package包/类
public static <T extends PsiModifierListOwner> List<T> getSuperAnnotationOwners(final T element) {
  return CachedValuesManager.getCachedValue(element, new CachedValueProvider<List<T>>() {
    @Nullable
    @Override
    public Result<List<T>> compute() {
      LinkedHashSet<PsiModifierListOwner> result = ContainerUtil.newLinkedHashSet();
      if (element instanceof PsiMethod) {
        collectSuperMethods(result, ((PsiMethod)element).getHierarchicalMethodSignature(), element,
                            JavaPsiFacade.getInstance(element.getProject()).getResolveHelper());
      } else if (element instanceof PsiClass) {
        //noinspection unchecked
        InheritanceUtil.processSupers((PsiClass)element, false, new CommonProcessors.CollectProcessor<PsiClass>((Set)result));
      } else if (element instanceof PsiParameter) {
        collectSuperParameters(result, (PsiParameter)element);
      }

      List<T> list = new ArrayList<T>();
      //noinspection unchecked
      list.addAll((Collection<? extends T>)result);
      
      List<Object> dependencies = ContainerUtil.<Object>newArrayList(result);
      dependencies.add(PsiModificationTracker.MODIFICATION_COUNT);
      return Result.create(list, dependencies);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:AnnotationUtil.java

示例4: getVariants

import com.intellij.util.CommonProcessors; //导入依赖的package包/类
@NotNull
public Collection<? extends PsiMethod> getVariants(final ConvertContext context) {
  LinkedHashSet<PsiMethod> methodList = new LinkedHashSet<PsiMethod>();
  Processor<PsiMethod> processor = CommonProcessors.notNullProcessor(new CommonProcessors.CollectProcessor<PsiMethod>(methodList));
  processMethods(context, processor, new Function<PsiClass, PsiMethod[]>() {
    public PsiMethod[] fun(final PsiClass s) {
      final List<PsiMethod> list = ContainerUtil.findAll(getVariants(s), new Condition<PsiMethod>() {
        public boolean value(final PsiMethod object) {
          return acceptMethod(object, context);
        }
      });
      return list.toArray(new PsiMethod[list.size()]);
    }
  });
  return methodList;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:AbstractMethodResolveConverter.java

示例5: searchMethodCalls

import com.intellij.util.CommonProcessors; //导入依赖的package包/类
@NotNull
public static Set<PsiMethodCallExpression> searchMethodCalls(@NotNull final PsiMethod psiMethod, @NotNull SearchScope searchScope) {
  final Set<PsiMethodCallExpression> callExpressions = new com.intellij.util.containers.HashSet<PsiMethodCallExpression>();
  final CommonProcessors.CollectUniquesProcessor<PsiReference> consumer = new CommonProcessors.CollectUniquesProcessor<PsiReference>();

  MethodReferencesSearch.search(psiMethod, searchScope, true).forEach(consumer);

  for (PsiReference psiReference : consumer.getResults()) {
    final PsiMethodCallExpression methodCallExpression =
      PsiTreeUtil.getParentOfType(psiReference.getElement(), PsiMethodCallExpression.class);

    if (methodCallExpression != null) {
      callExpressions.add(methodCallExpression);
    }
  }


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

示例6: testFindInPathInLibraryDirActuallySearchesInTheirSourcesToo

import com.intellij.util.CommonProcessors; //导入依赖的package包/类
public void testFindInPathInLibraryDirActuallySearchesInTheirSourcesToo() throws Exception {
  FindModel model = new FindModel();
  final PsiClass aClass = myJavaFacade.findClass("LibraryClass1");
  assertNotNull(aClass);
  model.setDirectoryName(aClass.getContainingFile().getContainingDirectory().getVirtualFile().getPath());
  model.setCaseSensitive(true);
  model.setCustomScope(false);
  model.setStringToFind("LibraryClass1");
  model.setProjectScope(false);

  List<UsageInfo> usages = new ArrayList<>();
  FindInProjectUtil.findUsages(model, getProject(),
                               new CommonProcessors.CollectProcessor<>(
                                 usages), FindInProjectUtil
                                 .setupProcessPresentation(getProject(), false, FindInProjectUtil.setupViewPresentation(false, model)));

  assertEquals(2, usages.size());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:SearchInLibsTest.java

示例7: testFindInPathInLibrarySourceDirShouldSearchJustInThisDirectoryOnly

import com.intellij.util.CommonProcessors; //导入依赖的package包/类
public void testFindInPathInLibrarySourceDirShouldSearchJustInThisDirectoryOnly() throws Exception {
  FindModel model = new FindModel();
  final PsiClass aClass = myJavaFacade.findClass("x.X");
  assertNotNull(aClass);
  String classDirPath = aClass.getContainingFile().getContainingDirectory().getVirtualFile().getPath();
  String sourceDirPath = ((PsiFile)aClass.getContainingFile().getNavigationElement()).getContainingDirectory().getVirtualFile().getPath();
  assertFalse(classDirPath.equals(sourceDirPath));
  model.setDirectoryName(sourceDirPath);
  model.setCaseSensitive(true);
  model.setCustomScope(false);
  model.setStringToFind("xxx");
  model.setProjectScope(false);

  List<UsageInfo> usages = new ArrayList<>();
  FindInProjectUtil.findUsages(model, getProject(),
                               new CommonProcessors.CollectProcessor<>(
                                 usages), FindInProjectUtil
                                 .setupProcessPresentation(getProject(), false, FindInProjectUtil.setupViewPresentation(false, model)));

  UsageInfo info = assertOneElement(usages);
  assertEquals("X.java", info.getFile().getName());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:SearchInLibsTest.java

示例8: ModuleCompileScope

import com.intellij.util.CommonProcessors; //导入依赖的package包/类
private ModuleCompileScope(Project project, final Collection<Module> modules, boolean includeDependentModules, boolean includeRuntimeDeps) {
  myProject = project;
  myScopeModules = new HashSet<Module>();
  for (Module module : modules) {
    if (module == null) {
      continue; // prevent NPE
    }
    if (includeDependentModules) {
      OrderEnumerator enumerator = ModuleRootManager.getInstance(module).orderEntries().recursively();
      if (!includeRuntimeDeps) {
        enumerator = enumerator.compileOnly();
      }
      enumerator.forEachModule(new CommonProcessors.CollectProcessor<Module>(myScopeModules));
    }
    else {
      myScopeModules.add(module);
    }
  }
  myModules = ModuleManager.getInstance(myProject).getModules();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:ModuleCompileScope.java

示例9: flashUsageScriptaculously

import com.intellij.util.CommonProcessors; //导入依赖的package包/类
private static void flashUsageScriptaculously(@NotNull final Usage usage) {
  if (!(usage instanceof UsageInfo2UsageAdapter)) {
    return;
  }
  UsageInfo2UsageAdapter usageInfo = (UsageInfo2UsageAdapter)usage;

  Editor editor = usageInfo.openTextEditor(true);
  if (editor == null) return;
  TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.BLINKING_HIGHLIGHTS_ATTRIBUTES);

  RangeBlinker rangeBlinker = new RangeBlinker(editor, attributes, 6);
  List<Segment> segments = new ArrayList<Segment>();
  CommonProcessors.CollectProcessor<Segment> processor = new CommonProcessors.CollectProcessor<Segment>(segments);
  usageInfo.processRangeMarkers(processor);
  rangeBlinker.resetMarkers(segments);
  rangeBlinker.startBlinking();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:SearchForUsagesRunnable.java

示例10: getFilesWithText

import com.intellij.util.CommonProcessors; //导入依赖的package包/类
private void getFilesWithText(@NotNull GlobalSearchScope scope,
                              final short searchContext,
                              final boolean caseSensitively,
                              @NotNull String text,
                              @NotNull final ProgressIndicator progress,
                              @NotNull Collection<VirtualFile> result) {
  myManager.startBatchFilesProcessingMode();
  try {
    Processor<VirtualFile> processor = new CommonProcessors.CollectProcessor<VirtualFile>(result){
      @Override
      public boolean process(VirtualFile file) {
        progress.checkCanceled();
        return super.process(file);
      }
    };
    boolean success = processFilesWithText(scope, searchContext, caseSensitively, text, processor);
    // success == false means exception in index
  }
  finally {
    myManager.finishBatchFilesProcessingMode();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:PsiSearchHelperImpl.java

示例11: HighlighterSweep

import com.intellij.util.CommonProcessors; //导入依赖的package包/类
private HighlighterSweep(@NotNull MarkupModelEx markupModel, int start, int end, final boolean onlyFullLine) {
  // we have to get all highlighters in advance and sort them by affected offsets
  // since these can be different from the real offsets the highlighters are sorted by in the tree.  (See LINES_IN_RANGE perverts)
  final List<RangeHighlighterEx> list = new ArrayList<RangeHighlighterEx>();
  markupModel.processRangeHighlightersOverlappingWith(myReverseIteration ? end : start, 
                                                      myReverseIteration ? start : end,
                                                      new CommonProcessors.CollectProcessor<RangeHighlighterEx>(list) {
                                                        @Override
                                                        protected boolean accept(RangeHighlighterEx ex) {
                                                          return !onlyFullLine || ex.getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE;
                                                        }
                                                      });
  highlighters = list.isEmpty() ? RangeHighlighterEx.EMPTY_ARRAY : list.toArray(new RangeHighlighterEx[list.size()]);
  Arrays.sort(highlighters, myReverseIteration ? BY_AFFECTED_END_OFFSET_REVERSED : RangeHighlighterEx.BY_AFFECTED_START_OFFSET);

  while (i < highlighters.length) {
    RangeHighlighterEx highlighter = highlighters[i++];
    if (!skipHighlighter(highlighter)) {
      myNextHighlighter = highlighter;
      break;
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:IterationState.java

示例12: HighlighterSweep

import com.intellij.util.CommonProcessors; //导入依赖的package包/类
private HighlighterSweep(@NotNull MarkupModelEx markupModel, int start, int end, final boolean onlyFullLine) {
  // we have to get all highlighters in advance and sort them by affected offsets
  // since these can be different from the real offsets the highlighters are sorted by in the tree.  (See LINES_IN_RANGE perverts)
  final List<RangeHighlighterEx> list = new ArrayList<RangeHighlighterEx>();
  markupModel.processRangeHighlightersOverlappingWith(start, end, new CommonProcessors.CollectProcessor<RangeHighlighterEx>(list) {
    @Override
    protected boolean accept(RangeHighlighterEx ex) {
      return !onlyFullLine || ex.getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE;
    }
  });
  highlighters = list.isEmpty() ? RangeHighlighterEx.EMPTY_ARRAY : list.toArray(new RangeHighlighterEx[list.size()]);
  Arrays.sort(highlighters, RangeHighlighterEx.BY_AFFECTED_START_OFFSET);

  while (i < highlighters.length) {
    RangeHighlighterEx highlighter = highlighters[i++];
    if (!skipHighlighter(highlighter)) {
      myNextHighlighter = highlighter;
      break;
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:IterationState.java

示例13: getHyperlinks

import com.intellij.util.CommonProcessors; //导入依赖的package包/类
public static List<RangeHighlighter> getHyperlinks(int startOffset, int endOffset, final Editor editor) {
  final MarkupModelEx markupModel = (MarkupModelEx)editor.getMarkupModel();
  final CommonProcessors.CollectProcessor<RangeHighlighterEx> processor = new CommonProcessors.CollectProcessor<RangeHighlighterEx>();
  markupModel.processRangeHighlightersOverlappingWith(startOffset, endOffset,
                                                      new FilteringProcessor<RangeHighlighterEx>(new Condition<RangeHighlighterEx>() {
                                                        @Override
                                                        public boolean value(RangeHighlighterEx rangeHighlighterEx) {
                                                          return rangeHighlighterEx.getEditorFilter().avaliableIn(editor) &&
                                                                 HYPERLINK_LAYER == rangeHighlighterEx.getLayer() &&
                                                                 rangeHighlighterEx.isValid() &&
                                                                 getHyperlinkInfo(rangeHighlighterEx) != null;
                                                        }
                                                      }, processor)
  );
  return new ArrayList<RangeHighlighter>(processor.getResults());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:EditorHyperlinkSupport.java

示例14: testRangeHighlighterLinesInRangeForLongLinePerformance

import com.intellij.util.CommonProcessors; //导入依赖的package包/类
public void testRangeHighlighterLinesInRangeForLongLinePerformance() throws Exception {
  final int N = 50000;
  Document document = EditorFactory.getInstance().createDocument(StringUtil.repeatSymbol('x', 2 * N));

  final MarkupModelEx markupModel = (MarkupModelEx)DocumentMarkupModel.forDocument(document, ourProject, true);
  for (int i=0; i<N-1;i++) {
    markupModel.addRangeHighlighter(2*i, 2*i+1, 0, null, HighlighterTargetArea.EXACT_RANGE);
  }
  markupModel.addRangeHighlighter(N / 2, N / 2 + 1, 0, null, HighlighterTargetArea.LINES_IN_RANGE);

  PlatformTestUtil.startPerformanceTest("slow highlighters lookup", (int)(N*Math.log(N)/1000), new ThrowableRunnable() {
    @Override
    public void run() {
      List<RangeHighlighterEx> list = new ArrayList<RangeHighlighterEx>();
      CommonProcessors.CollectProcessor<RangeHighlighterEx> coll = new CommonProcessors.CollectProcessor<RangeHighlighterEx>(list);
      for (int i=0; i<N-1;i++) {
        list.clear();
        markupModel.processRangeHighlightersOverlappingWith(2*i, 2*i+1, coll);
        assertEquals(2, list.size());  // 1 line plus one exact range marker
      }
    }
  }).assertTiming();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:RangeMarkerTest.java

示例15: calculateRoot

import com.intellij.util.CommonProcessors; //导入依赖的package包/类
private Object calculateRoot(DataContext dataContext) {
  // Narrow down the root element to the first interesting one
  Object root = LangDataKeys.MODULE.getData(dataContext);
  if (root != null) return root;

  Project project = CommonDataKeys.PROJECT.getData(dataContext);
  if (project == null) return null;

  Object projectChild;
  Object projectGrandChild = null;

  CommonProcessors.FindFirstAndOnlyProcessor<Object> processor = new CommonProcessors.FindFirstAndOnlyProcessor<Object>();
  processChildren(project, processor);
  projectChild = processor.reset();
  if (projectChild != null) {
    processChildren(projectChild, processor);
    projectGrandChild = processor.reset();
  }
  return ObjectUtils.chooseNotNull(projectGrandChild, ObjectUtils.chooseNotNull(projectChild, project));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:NavBarModel.java


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