Java Code Examples for com.intellij.openapi.util.Factory#create()
The following examples show how to use
com.intellij.openapi.util.Factory#create() .
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: FindUsagesImpl171.java From Android-Resource-Usage-Count with MIT License | 6 votes |
int findUsage(XmlTag element) { final FindUsagesHandler handler = FindUsagesImpl171.getFindUsagesHandler(element, element.getProject()); if (handler != null) { final FindUsagesOptions findUsagesOptions = handler.getFindUsagesOptions(); final PsiElement[] primaryElements = handler.getPrimaryElements(); final PsiElement[] secondaryElements = handler.getSecondaryElements(); Factory factory = new Factory() { public UsageSearcher create() { return FindUsagesImpl171.createUsageSearcher(primaryElements, secondaryElements, handler, findUsagesOptions, (PsiFile) null); } }; UsageSearcher usageSearcher = (UsageSearcher)factory.create(); final AtomicInteger mCount = new AtomicInteger(0); usageSearcher.generate(new Processor<Usage>() { @Override public boolean process(Usage usage) { if (ResourceUsageCountUtils.isUsefulUsageToCount(usage)) { mCount.incrementAndGet(); } return true; } }); return mCount.get(); } return 0; }
Example 2
Source File: InspectionToolRegistrar.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull @TestOnly public List<InspectionToolWrapper> createTools() { ensureInitialized(); final List<InspectionToolWrapper> tools = ContainerUtil.newArrayListWithCapacity(myInspectionToolFactories.size()); final Set<Factory<InspectionToolWrapper>> broken = ContainerUtil.newHashSet(); for (final Factory<InspectionToolWrapper> factory : myInspectionToolFactories) { ProgressManager.checkCanceled(); final InspectionToolWrapper toolWrapper = factory.create(); if (toolWrapper != null && checkTool(toolWrapper) == null) { tools.add(toolWrapper); } else { broken.add(factory); } } myInspectionToolFactories.removeAll(broken); return tools; }
Example 3
Source File: FindUsagesImpl.java From Android-Resource-Usage-Count with MIT License | 5 votes |
int findUsage(XmlTag element) { final AtomicInteger mCount = new AtomicInteger(0); try { com.intellij.find.findUsages.FindUsagesHandler handler = this.getFindUsagesHandler(element); if (handler != null) { AbstractFindUsagesDialog dialog = handler.getFindUsagesDialog(false, false, false); dialog.close(0); FindUsagesOptions findUsagesOptions = dialog.calcFindUsagesOptions(); PsiElement[] primaryElements = handler.getPrimaryElements(); PsiElement[] secondaryElements = handler.getSecondaryElements(); PsiElement2UsageTargetAdapter[] primaryTargets = convertToUsageTargets(Arrays.asList(primaryElements), findUsagesOptions); PsiElement2UsageTargetAdapter[] secondaryTargets = convertToUsageTargets(Arrays.asList(secondaryElements), findUsagesOptions); final Factory<UsageSearcher> factory = new Factory<UsageSearcher>() { @Override public UsageSearcher create() { return createUsageSearcher(primaryTargets, secondaryTargets, handler, findUsagesOptions, (PsiFile) null); } }; UsageSearcher usageSearcher = (UsageSearcher)factory.create(); usageSearcher.generate((usage) -> { if (ResourceUsageCountUtils.isUsefulUsageToCount(usage)) { mCount.incrementAndGet(); } return true; }); } } catch (Exception e) { e.printStackTrace(); } return mCount.get(); }