本文整理汇总了Java中com.intellij.util.CommonProcessors.CollectProcessor方法的典型用法代码示例。如果您正苦于以下问题:Java CommonProcessors.CollectProcessor方法的具体用法?Java CommonProcessors.CollectProcessor怎么用?Java CommonProcessors.CollectProcessor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.util.CommonProcessors
的用法示例。
在下文中一共展示了CommonProcessors.CollectProcessor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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();
}
}
示例3: 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());
}
示例4: getFilesWithText
import com.intellij.util.CommonProcessors; //导入方法依赖的package包/类
@NotNull
private List<VirtualFile> getFilesWithText(@NotNull GlobalSearchScope scope,
final short searchContext,
final boolean caseSensitively,
@NotNull String text,
final ProgressIndicator progress) {
myManager.startBatchFilesProcessingMode();
try {
final List<VirtualFile> result = new ArrayList<VirtualFile>();
Processor<VirtualFile> processor = new CommonProcessors.CollectProcessor<VirtualFile>(result){
@Override
public boolean process(VirtualFile file) {
if (progress != null) progress.checkCanceled();
return super.process(file);
}
};
boolean success = processFilesWithText(scope, searchContext, caseSensitively, text, processor);
LOG.assertTrue(success);
return result;
}
finally {
myManager.finishBatchFilesProcessingMode();
}
}
示例5: processFilesWithText
import com.intellij.util.CommonProcessors; //导入方法依赖的package包/类
public boolean processFilesWithText(@NotNull final GlobalSearchScope scope,
final short searchContext,
final boolean caseSensitively,
@NotNull String text,
@NotNull final Processor<VirtualFile> processor) {
List<IdIndexEntry> entries = getWordEntries(text, caseSensitively);
if (entries.isEmpty()) return true;
final CommonProcessors.CollectProcessor<VirtualFile> collectProcessor = new CommonProcessors.CollectProcessor<VirtualFile>();
processFilesContainingAllKeys(scope, new Condition<Integer>() {
@Override
public boolean value(Integer integer) {
return (integer.intValue() & searchContext) != 0;
}
}, collectProcessor, entries);
final FileIndexFacade index = FileIndexFacade.getInstance(myManager.getProject());
return ContainerUtil.process(collectProcessor.getResults(), new ReadActionProcessor<VirtualFile>() {
@Override
public boolean processInReadAction(VirtualFile virtualFile) {
return !index.shouldBeFound(scope, virtualFile) || processor.process(virtualFile);
}
});
}
示例6: getClassesByName
import com.intellij.util.CommonProcessors; //导入方法依赖的package包/类
@NotNull
@Override
@RequiredReadAction
public PsiClass[] getClassesByName(@NotNull @NonNls String s, @NotNull GlobalSearchScope globalSearchScope)
{
CommonProcessors.CollectProcessor<DotNetTypeDeclaration> collectProcessor = new CommonProcessors.CollectProcessor<DotNetTypeDeclaration>();
DotNetShortNameSearcher.getInstance(myProject).collectTypes(s, globalSearchScope, IdFilter.getProjectIdFilter(myProject, false),
collectProcessor);
Collection<DotNetTypeDeclaration> results = collectProcessor.getResults();
List<PsiClass> classes = new ArrayList<PsiClass>(results.size());
for(DotNetTypeDeclaration dotNetTypeDeclaration : results)
{
JavaClassStubBuilder javaClassStubBuilder = StubBuilder.build(dotNetTypeDeclaration);
if(javaClassStubBuilder == null)
{
continue;
}
classes.add(javaClassStubBuilder.buildToPsi(null));
}
return ContainerUtil.toArray(classes, PsiClass.ARRAY_FACTORY);
}
示例7: getFilesWithFunctionalExpressionsScope
import com.intellij.util.CommonProcessors; //导入方法依赖的package包/类
@NotNull
private static Set<VirtualFile> getFilesWithFunctionalExpressionsScope(Project project, GlobalSearchScope useScope) {
final Set<VirtualFile> files = newLinkedHashSet();
final PsiSearchHelperImpl helper = (PsiSearchHelperImpl)PsiSearchHelper.SERVICE.getInstance(project);
final CommonProcessors.CollectProcessor<VirtualFile> processor = new CommonProcessors.CollectProcessor<VirtualFile>(files);
helper.processFilesWithText(useScope, UsageSearchContext.IN_CODE, true, "::", processor);
helper.processFilesWithText(useScope, UsageSearchContext.IN_CODE, true, "->", processor);
return files;
}
示例8: getAllFileNames
import com.intellij.util.CommonProcessors; //导入方法依赖的package包/类
private static Collection<String> getAllFileNames(final String testName, final GotoFileModel model) {
CommonProcessors.CollectProcessor<String> processor = new CommonProcessors.CollectProcessor<String>() {
@Override
public boolean accept(String name) {
ProgressManager.checkCanceled();
return StringUtil.containsIgnoreCase(name, testName);
}
};
model.processNames(processor, false);
return processor.getResults();
}
示例9: getNames
import com.intellij.util.CommonProcessors; //导入方法依赖的package包/类
@Override
@NotNull
public String[] getNames(Project project, boolean includeNonProjectItems) {
if (FileBasedIndex.ourEnableTracingOfKeyHashToVirtualFileMapping) {
GlobalSearchScope scope = includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project);
CommonProcessors.CollectProcessor<String> processor = new CommonProcessors.CollectProcessor<String>();
processNames(processor, scope, IdFilter.getProjectIdFilter(project, includeNonProjectItems));
return ArrayUtil.toStringArray(processor.getResults());
}
return PsiShortNamesCache.getInstance(project).getAllClassNames();
}
示例10: getItemsByName
import com.intellij.util.CommonProcessors; //导入方法依赖的package包/类
@Override
@NotNull
public NavigationItem[] getItemsByName(String name, final String pattern, Project project, boolean includeNonProjectItems) {
CommonProcessors.CollectProcessor<NavigationItem> processor = new CommonProcessors.CollectProcessor<NavigationItem>();
processElementsWithName(name, processor, FindSymbolParameters.wrap(pattern, project, includeNonProjectItems));
return processor.toArray(new NavigationItem[processor.getResults().size()]);
}
示例11: test
import com.intellij.util.CommonProcessors; //导入方法依赖的package包/类
public void test() throws Exception {
ModuleManager moduleManager = ModuleManager.getInstance(getProject());
Module[] modules = moduleManager.getModules();
assertEquals(3, modules.length);
Module module1 = moduleManager.findModuleByName("test1");
Module module2 = moduleManager.findModuleByName("test2");
Module module3 = moduleManager.findModuleByName("test3");
final GlobalSearchScope moduleScope = GlobalSearchScope.moduleScope(module1);
PsiClass test1 = myJavaFacade.findClass("com.test.TestI", moduleScope);
PsiClass test2 = myJavaFacade.findClass("com.test.TestI", GlobalSearchScope.moduleScope(module2));
PsiClass test3 = myJavaFacade.findClass("com.test.TestI", GlobalSearchScope.moduleScope(module3));
HashSet<PsiElement> expectedImpls1 = new HashSet<PsiElement>(Arrays.asList(
myJavaFacade.findClass("com.test.TestIImpl1", moduleScope),
myJavaFacade.findClass("com.test.TestIImpl2", moduleScope)
));
assertEquals(expectedImpls1, new HashSet<PsiElement>(getClassImplementations(test1)));
PsiMethod psiMethod = test1.findMethodsByName("test", false)[0];
Set<PsiElement> expectedMethodImpl1 = new HashSet<PsiElement>(Arrays.asList(
myJavaFacade.findClass("com.test.TestIImpl1", moduleScope).findMethodsByName("test",false)[0],
myJavaFacade.findClass("com.test.TestIImpl2", moduleScope).findMethodsByName("test",false)[0]
));
CommonProcessors.CollectProcessor<PsiElement> processor = new CommonProcessors.CollectProcessor<PsiElement>();
MethodImplementationsSearch.processImplementations(psiMethod, processor, moduleScope);
assertEquals(expectedMethodImpl1, new HashSet<PsiElement>(processor.getResults()));
HashSet<PsiElement> expectedImpls2 = new HashSet<PsiElement>(Arrays.asList(
myJavaFacade.findClass("com.test.TestIImpl1", GlobalSearchScope.moduleScope(module2)),
myJavaFacade.findClass("com.test.TestIImpl3", GlobalSearchScope.moduleScope(module2))
));
assertEquals(expectedImpls2, new HashSet<PsiElement>(getClassImplementations(test2)));
HashSet<PsiElement> expectedImpls3 = new HashSet<PsiElement>(Arrays.asList(
myJavaFacade.findClass("com.test.TestIImpl1", GlobalSearchScope.moduleScope(module3))
));
assertEquals(expectedImpls3, new HashSet<PsiElement>(getClassImplementations(test3)));
}
示例12: getAllHighlighters
import com.intellij.util.CommonProcessors; //导入方法依赖的package包/类
@Override
@NotNull
public RangeHighlighter[] getAllHighlighters() {
ApplicationManager.getApplication().assertIsDispatchThread();
if (myCachedHighlighters == null) {
int size = myHighlighterTree.size() + myHighlighterTreeForLines.size();
if (size == 0) return RangeHighlighter.EMPTY_ARRAY;
List<RangeHighlighterEx> list = new ArrayList<RangeHighlighterEx>(size);
CommonProcessors.CollectProcessor<RangeHighlighterEx> collectProcessor = new CommonProcessors.CollectProcessor<RangeHighlighterEx>(list);
myHighlighterTree.process(collectProcessor);
myHighlighterTreeForLines.process(collectProcessor);
myCachedHighlighters = list.toArray(new RangeHighlighter[list.size()]);
}
return myCachedHighlighters;
}
示例13: getFilesWithWord
import com.intellij.util.CommonProcessors; //导入方法依赖的package包/类
@Override
@NotNull
public PsiFile[] getFilesWithWord(@NotNull final String word, final short occurenceMask, @NotNull final GlobalSearchScope scope, final boolean caseSensitively) {
if (myProject.isDefault()) {
return PsiFile.EMPTY_ARRAY;
}
CommonProcessors.CollectProcessor<PsiFile> processor = new CommonProcessors.CollectProcessor<PsiFile>();
processFilesWithWord(processor, word, occurenceMask, scope, caseSensitively);
return processor.getResults().isEmpty() ? PsiFile.EMPTY_ARRAY : processor.toArray(PsiFile.EMPTY_ARRAY);
}
示例14: getImplementations
import com.intellij.util.CommonProcessors; //导入方法依赖的package包/类
@NotNull
public static <T, V> Collection<V> getImplementations(final T element, final Class<V> clazz) {
if (element == null) return Collections.emptyList();
CommonProcessors.CollectProcessor<T> processor = new CommonProcessors.CollectProcessor<T>() {
@Override
public boolean process(final T t) {
return !ReflectionUtil.isAssignable(clazz, t.getClass()) || super.process(t);
}
};
new ImplementationProcessor<T>(processor, true).process(element);
return (Collection<V>)processor.getResults();
}
示例15: browse
import com.intellij.util.CommonProcessors; //导入方法依赖的package包/类
@Override
public void browse(MouseEvent e, PsiElement element) {
PsiElement parent = element.getParent();
if (!(parent instanceof GrField)) return;
if (DumbService.isDumb(element.getProject())) {
DumbService.getInstance(element.getProject()).showDumbModeNotification("Navigation to overriding classes is not possible during index update");
return;
}
final GrField field = (GrField)parent;
final CommonProcessors.CollectProcessor<PsiMethod> collectProcessor = new CommonProcessors.CollectProcessor<PsiMethod>(new THashSet<PsiMethod>());
if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
@Override
public void run() {
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
for (GrAccessorMethod method : GroovyPropertyUtils.getFieldAccessors(field)) {
OverridingMethodsSearch.search(method, true).forEach(collectProcessor);
}
}
});
}
}, "Searching for overriding methods", true, field.getProject(), (JComponent)e.getComponent())) {
return;
}
PsiMethod[] overridings = collectProcessor.toArray(PsiMethod.EMPTY_ARRAY);
if (overridings.length == 0) return;
String title = DaemonBundle.message("navigation.title.overrider.method", field.getName(), overridings.length);
boolean showMethodNames = !PsiUtil.allMethodsHaveSameSignature(overridings);
MethodCellRenderer renderer = new MethodCellRenderer(showMethodNames);
Arrays.sort(overridings, renderer.getComparator());
PsiElementListNavigator.openTargets(e, overridings, title, "Overriding Methods of " + field.getName(), renderer);
}