本文整理汇总了Java中com.intellij.openapi.util.Factory类的典型用法代码示例。如果您正苦于以下问题:Java Factory类的具体用法?Java Factory怎么用?Java Factory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Factory类属于com.intellij.openapi.util包,在下文中一共展示了Factory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findTagUsage
import com.intellij.openapi.util.Factory; //导入依赖的package包/类
private int findTagUsage(XmlTag element) {
final FindUsagesHandler handler = FindUsageUtils.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 FindUsageUtils.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;
}
示例2: JavaConstantExpressionEvaluator
import com.intellij.openapi.util.Factory; //导入依赖的package包/类
private JavaConstantExpressionEvaluator(Set<PsiVariable> visitedVars,
final boolean throwExceptionOnOverflow,
@NotNull Project project,
final PsiConstantEvaluationHelper.AuxEvaluator auxEvaluator) {
myMapFactory = auxEvaluator == null ? new Factory<ConcurrentMap<PsiElement, Object>>() {
@Override
public ConcurrentMap<PsiElement, Object> create() {
final Key<CachedValue<ConcurrentMap<PsiElement, Object>>> key =
throwExceptionOnOverflow ? CONSTANT_VALUE_WITH_OVERFLOW_MAP_KEY : CONSTANT_VALUE_WO_OVERFLOW_MAP_KEY;
return CachedValuesManager.getManager(myProject).getCachedValue(myProject, key, PROVIDER, false);
}
} : new Factory<ConcurrentMap<PsiElement, Object>>() {
@Override
public ConcurrentMap<PsiElement, Object> create() {
return auxEvaluator.getCacheMap(throwExceptionOnOverflow);
}
};
myProject = project;
myConstantExpressionVisitor = new ConstantExpressionVisitor(visitedVars, throwExceptionOnOverflow, auxEvaluator);
}
示例3: rerunFactory
import com.intellij.openapi.util.Factory; //导入依赖的package包/类
@NotNull
private Factory<UsageSearcher> rerunFactory(@NotNull final Project project, @NotNull final AnalysisScope scope) {
return new Factory<UsageSearcher>() {
@Override
public UsageSearcher create() {
return new UsageInfoSearcherAdapter() {
@Override
protected UsageInfo[] findUsages() {
return InferNullityAnnotationsAction.this.findUsages(project, scope, scope.getFileCount());
}
@Override
public void generate(@NotNull Processor<Usage> processor) {
processUsages(processor, project);
}
};
}
};
}
示例4: SearchForUsagesRunnable
import com.intellij.openapi.util.Factory; //导入依赖的package包/类
SearchForUsagesRunnable(@NotNull UsageViewManagerImpl usageViewManager,
@NotNull Project project,
@NotNull AtomicReference<UsageViewImpl> usageViewRef,
@NotNull UsageViewPresentation presentation,
@NotNull UsageTarget[] searchFor,
@NotNull Factory<UsageSearcher> searcherFactory,
@NotNull FindUsagesProcessPresentation processPresentation,
@NotNull SearchScope searchScopeToWarnOfFallingOutOf,
@Nullable UsageViewManager.UsageViewStateListener listener) {
myProject = project;
myUsageViewRef = usageViewRef;
myPresentation = presentation;
mySearchFor = searchFor;
mySearcherFactory = searcherFactory;
myProcessPresentation = processPresentation;
mySearchScopeToWarnOfFallingOutOf = searchScopeToWarnOfFallingOutOf;
myListener = listener;
myUsageViewManager = usageViewManager;
}
示例5: doSearchAndShow
import com.intellij.openapi.util.Factory; //导入依赖的package包/类
private UsageView doSearchAndShow(@NotNull final UsageTarget[] searchFor,
@NotNull final Factory<UsageSearcher> searcherFactory,
@NotNull final UsageViewPresentation presentation,
@NotNull final FindUsagesProcessPresentation processPresentation,
@Nullable final UsageViewStateListener listener) {
final SearchScope searchScopeToWarnOfFallingOutOf = getMaxSearchScopeToWarnOfFallingOutOf(searchFor);
final AtomicReference<UsageViewImpl> usageViewRef = new AtomicReference<UsageViewImpl>();
Task.Backgroundable task = new Task.Backgroundable(myProject, getProgressTitle(presentation), true, new SearchInBackgroundOption()) {
@Override
public void run(@NotNull final ProgressIndicator indicator) {
new SearchForUsagesRunnable(UsageViewManagerImpl.this, UsageViewManagerImpl.this.myProject, usageViewRef, presentation, searchFor, searcherFactory,
processPresentation, searchScopeToWarnOfFallingOutOf, listener).run();
}
@Override
@Nullable
public NotificationInfo getNotificationInfo() {
String notification = usageViewRef.get() != null ? usageViewRef.get().getUsagesCount() + " Usage(s) Found" : "No Usages Found";
return new NotificationInfo("Find Usages", "Find Usages Finished", notification);
}
};
ProgressManager.getInstance().run(task);
return usageViewRef.get();
}
示例6: findUsages
import com.intellij.openapi.util.Factory; //导入依赖的package包/类
public void findUsages(@NotNull final PsiElement[] primaryElements,
@NotNull final PsiElement[] secondaryElements,
@NotNull final FindUsagesHandler handler,
@NotNull final FindUsagesOptions findUsagesOptions,
final boolean toSkipUsagePanelWhenOneUsage) {
if (primaryElements.length == 0) {
throw new AssertionError(handler + " " + findUsagesOptions);
}
Iterable<PsiElement> allElements = ContainerUtil.concat(primaryElements, secondaryElements);
final PsiElement2UsageTargetAdapter[] targets = convertToUsageTargets(allElements, findUsagesOptions);
myAnotherManager.searchAndShowUsages(targets, new Factory<UsageSearcher>() {
@Override
public UsageSearcher create() {
return createUsageSearcher(primaryElements, secondaryElements, handler, findUsagesOptions, null);
}
}, !toSkipUsagePanelWhenOneUsage, true, createPresentation(primaryElements[0], findUsagesOptions, shouldOpenInNewTab()), null);
myHistory.add(targets[0]);
}
示例7: setupProcessPresentation
import com.intellij.openapi.util.Factory; //导入依赖的package包/类
@NotNull
public static FindUsagesProcessPresentation setupProcessPresentation(@NotNull final Project project,
final boolean showPanelIfOnlyOneUsage,
@NotNull final UsageViewPresentation presentation) {
FindUsagesProcessPresentation processPresentation = new FindUsagesProcessPresentation(presentation);
processPresentation.setShowNotFoundMessage(true);
processPresentation.setShowPanelIfOnlyOneUsage(showPanelIfOnlyOneUsage);
processPresentation.setProgressIndicatorFactory(
new Factory<ProgressIndicator>() {
@NotNull
@Override
public ProgressIndicator create() {
return new FindProgressIndicator(project, presentation.getScopeText());
}
}
);
return processPresentation;
}
示例8: createPointersThunk
import com.intellij.openapi.util.Factory; //导入依赖的package包/类
private static <T> NotNullLazyValue<List<SmartPsiElementPointer>> createPointersThunk(boolean lazy,
final Project project,
final Factory<Collection<T>> targets,
final NotNullFunction<T, Collection<? extends PsiElement>> converter) {
if (!lazy) {
return NotNullLazyValue.createConstantValue(calcPsiTargets(project, targets.create(), converter));
}
return new NotNullLazyValue<List<SmartPsiElementPointer>>() {
@Override
@NotNull
public List<SmartPsiElementPointer> compute() {
return calcPsiTargets(project, targets.create(), converter);
}
};
}
示例9: getStableValues
import com.intellij.openapi.util.Factory; //导入依赖的package包/类
@Override
@NotNull
public final List<? extends DomElement> getStableValues(@NotNull final DomElement parent) {
final List<? extends DomElement> list = getValues(parent);
final ArrayList<DomElement> result = new ArrayList<DomElement>(list.size());
final DomManager domManager = parent.getManager();
for (int i = 0; i < list.size(); i++) {
final int i1 = i;
result.add(domManager.createStableValue(new Factory<DomElement>() {
@Override
@Nullable
public DomElement create() {
if (!parent.isValid()) return null;
final List<? extends DomElement> domElements = getValues(parent);
return domElements.size() > i1 ? domElements.get(i1) : null;
}
}));
}
return result;
}
示例10: createDomFileEditor
import com.intellij.openapi.util.Factory; //导入依赖的package包/类
public static DomFileEditor createDomFileEditor(final String name,
@Nullable final Icon icon,
final DomElement element,
final Factory<? extends CommittablePanel> committablePanel) {
final XmlFile file = DomUtil.getFile(element);
final Factory<BasicDomElementComponent> factory = new Factory<BasicDomElementComponent>() {
@Override
public BasicDomElementComponent create() {
CaptionComponent captionComponent = new CaptionComponent(name, icon);
captionComponent.initErrorPanel(element);
BasicDomElementComponent component = createComponentWithCaption(committablePanel.create(), captionComponent, element);
Disposer.register(component, captionComponent);
return component;
}
};
return new DomFileEditor<BasicDomElementComponent>(file.getProject(), file.getVirtualFile(), name, factory) {
@Override
public JComponent getPreferredFocusedComponent() {
return null;
}
};
}
示例11: testStable_Revalidate
import com.intellij.openapi.util.Factory; //导入依赖的package包/类
public void testStable_Revalidate() throws Throwable {
final MyElement[] element = new MyElement[]{createElement("")};
final MyElement stable = getDomManager().createStableValue(new Factory<MyElement>() {
@Override
public MyElement create() {
return element[0];
}
});
MyElement oldElement = element[0];
((StableElement) stable).revalidate();
assertSame(oldElement, ((StableElement) stable).getWrappedElement());
element[0] = createElement("");
assertTrue(oldElement.isValid());
((StableElement) stable).revalidate();
assertTrue(oldElement.isValid());
assertNotSame(oldElement, ((StableElement) stable).getWrappedElement());
assertSame(element[0], ((StableElement) stable).getWrappedElement());
}
示例12: rerunFactory
import com.intellij.openapi.util.Factory; //导入依赖的package包/类
@NotNull
private static Factory<UsageSearcher> rerunFactory(@NotNull final Project project, @NotNull final AnalysisScope scope) {
return new Factory<UsageSearcher>() {
@Override
public UsageSearcher create() {
return new UsageInfoSearcherAdapter() {
@Override
protected UsageInfo[] findUsages() {
return AndroidInferNullityAnnotationAction.findUsages(project, scope, scope.getFileCount());
}
@Override
public void generate(@NotNull Processor<Usage> processor) {
processUsages(processor, project);
}
};
}
};
}
示例13: addAddManyFacility
import com.intellij.openapi.util.Factory; //导入依赖的package包/类
public void addAddManyFacility(JButton button, final Factory<List<T>> factory) {
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
List<T> items = factory.create();
getList().requestFocusInWindow();
if (items == null || items.size() == 0) {
return;
}
for (final T item : items) {
getModel().addElement(item);
ScrollingUtil.selectItem(getList(), item);
}
}
});
addComponent(button);
}
示例14: checkList
import com.intellij.openapi.util.Factory; //导入依赖的package包/类
@NotNull
public SvnMergeInfoCache.MergeCheckResult checkList(@NotNull final SvnChangeList list, final String branchPath) {
synchronized (myCalculatedLock) {
SvnMergeInfoCache.MergeCheckResult result;
final long revision = calculateCopyRevision(branchPath);
if (revision != -1 && revision >= list.getNumber()) {
result = SvnMergeInfoCache.MergeCheckResult.COMMON;
}
else {
result = ContainerUtil.getOrCreate(myAlreadyCalculatedMap, list.getNumber(), new Factory<SvnMergeInfoCache.MergeCheckResult>() {
@Override
public SvnMergeInfoCache.MergeCheckResult create() {
return checkAlive(list, branchPath);
}
});
}
return result;
}
}
示例15: createEditAction
import com.intellij.openapi.util.Factory; //导入依赖的package包/类
@Override
public AnAction createEditAction(final Project project, final Factory<BaseInjection> producer) {
return new AnAction() {
@Override
public void actionPerformed(final AnActionEvent e) {
final BaseInjection originalInjection = producer.create();
final MethodParameterInjection injection = createFrom(project, originalInjection, null, false);
if (injection != null) {
final boolean mergeEnabled = !project.isInitialized() ||
JavaPsiFacade.getInstance(project).findClass(injection.getClassName(), GlobalSearchScope.allScope(project)) == null;
final BaseInjection newInjection = showInjectionUI(project, injection);
if (newInjection != null) {
newInjection.mergeOriginalPlacesFrom(originalInjection, mergeEnabled);
originalInjection.copyFrom(newInjection);
}
}
else {
createDefaultEditAction(project, producer).actionPerformed(null);
}
}
};
}