本文整理汇总了Java中com.intellij.find.findUsages.FindUsagesHandler类的典型用法代码示例。如果您正苦于以下问题:Java FindUsagesHandler类的具体用法?Java FindUsagesHandler怎么用?Java FindUsagesHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FindUsagesHandler类属于com.intellij.find.findUsages包,在下文中一共展示了FindUsagesHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findTagUsage
import com.intellij.find.findUsages.FindUsagesHandler; //导入依赖的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: findUsages
import com.intellij.find.findUsages.FindUsagesHandler; //导入依赖的package包/类
@NotNull
public Collection<UsageInfo> findUsages(@NotNull final PsiElement targetElement, @Nullable SearchScope scope) {
final Project project = getProject();
final FindUsagesHandler handler =
((FindManagerImpl)FindManager.getInstance(project)).getFindUsagesManager().getFindUsagesHandler(targetElement, false);
final CommonProcessors.CollectProcessor<UsageInfo> processor = new CommonProcessors.CollectProcessor<UsageInfo>();
Assert.assertNotNull("Cannot find handler for: " + targetElement, handler);
final PsiElement[] psiElements = ArrayUtil.mergeArrays(handler.getPrimaryElements(), handler.getSecondaryElements());
final FindUsagesOptions options = handler.getFindUsagesOptions(null);
if (scope != null) options.searchScope = scope;
for (PsiElement psiElement : psiElements) {
handler.processElementUsages(psiElement, processor, options);
}
return processor.getResults();
}
示例3: createFindUsageHandler
import com.intellij.find.findUsages.FindUsagesHandler; //导入依赖的package包/类
/**
* @see {@link com.jetbrains.python.findUsages.PyFindUsagesHandlerFactory#createFindUsagesHandler(com.intellij.psi.PsiElement, boolean) createFindUsagesHandler}
*/
@Nullable
private static FindUsagesHandler createFindUsageHandler(@NotNull final PsiElement element) {
if (element instanceof PyFunction) {
final TypeEvalContext context = TypeEvalContext.userInitiated(element.getProject(), null);
final Collection<PsiElement> superMethods = PySuperMethodsSearch.search((PyFunction)element, true, context).findAll();
if (superMethods.size() > 0) {
final PsiElement next = superMethods.iterator().next();
if (next instanceof PyFunction && !isInObject((PyFunction)next)) {
List<PsiElement> allMethods = Lists.newArrayList();
allMethods.add(element);
allMethods.addAll(superMethods);
return new PyFunctionFindUsagesHandler(element, allMethods);
}
}
return new PyFunctionFindUsagesHandler(element);
}
if (element instanceof PyClass) {
return new PyClassFindUsagesHandler((PyClass)element);
}
return null;
}
示例4: createSettingsButton
import com.intellij.find.findUsages.FindUsagesHandler; //导入依赖的package包/类
@NotNull
private InplaceButton createSettingsButton(@NotNull final FindUsagesHandler handler,
@NotNull final RelativePoint popupPosition, final Editor editor, final int maxUsages,
@NotNull final Runnable cancelAction) {
String shortcutText = "";
KeyboardShortcut shortcut = UsageViewImpl.getShowUsagesWithSettingsShortcut();
if (shortcut != null) {
shortcutText = "(" + KeymapUtil.getShortcutText(shortcut) + ")";
}
return new InplaceButton("Settings..." + shortcutText, AllIcons.General.Settings,
new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
showDialogAndFindUsages(handler, popupPosition, editor, maxUsages);
}
});
cancelAction.run();
}
}
);
}
示例5: createSettingsButton
import com.intellij.find.findUsages.FindUsagesHandler; //导入依赖的package包/类
@NotNull
private InplaceButton createSettingsButton(@NotNull final FindUsagesHandler handler,
@NotNull final RelativePoint popupPosition,
final Editor editor,
final int maxUsages,
@NotNull final Runnable cancelAction) {
String shortcutText = "";
KeyboardShortcut shortcut = UsageViewImpl.getShowUsagesWithSettingsShortcut();
if (shortcut != null) {
shortcutText = "(" + KeymapUtil.getShortcutText(shortcut) + ")";
}
return new InplaceButton("Settings..." + shortcutText, AllIcons.General.Settings, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
showDialogAndFindUsages(handler, popupPosition, editor, maxUsages);
}
});
cancelAction.run();
}
});
}
示例6: createFindUsagesHandler
import com.intellij.find.findUsages.FindUsagesHandler; //导入依赖的package包/类
@Nullable
@Override
public FindUsagesHandler createFindUsagesHandler(
@NotNull final PsiElement element, final boolean forHighlightUsages
) {
if (canFindUsages(element)) {
return new FindUsagesHandler(element) {
};
}
return null;
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:14,代码来源:MacrosFindUsagesHandlerFactory.java
示例7: createFindUsagesHandler
import com.intellij.find.findUsages.FindUsagesHandler; //导入依赖的package包/类
@Nullable
@Override
public FindUsagesHandler createFindUsagesHandler( @NotNull PsiElement element, boolean forHighlightUsages )
{
List<PsiElement> javaElements = ResourceToManifoldUtil.findJavaElementsFor( element );
if( javaElements.isEmpty() )
{
return null;
}
if( element instanceof PsiDirectory )
{
final PsiPackage psiPackage = JavaDirectoryService.getInstance().getPackage( (PsiDirectory)element );
return psiPackage == null ? null : new JavaFindUsagesHandler( psiPackage, this );
}
if( element instanceof PsiMethod && !forHighlightUsages )
{
final PsiMethod[] methods = SuperMethodWarningUtil.checkSuperMethods( (PsiMethod)element, ACTION_STRING );
if( methods.length > 1 )
{
return new JavaFindUsagesHandler( element, methods, this );
}
if( methods.length == 1 )
{
return new JavaFindUsagesHandler( methods[0], this );
}
return FindUsagesHandler.NULL_HANDLER;
}
return new JavaFindUsagesHandler( element, this ) {
@NotNull
@Override
public PsiElement[] getPrimaryElements()
{
return javaElements.toArray( new PsiElement[javaElements.size()] );
}
};
}
示例8: getHighlightUsages
import com.intellij.find.findUsages.FindUsagesHandler; //导入依赖的package包/类
/**
* Returns read and write usages of psi element inside a single element
*
* @param target target psi element
* @param psiElement psi element to search in
* @return a pair where first element is read usages and second is write usages
*/
public static Couple<Collection<TextRange>> getHighlightUsages(@NotNull PsiElement target, PsiElement psiElement, boolean withDeclarations) {
Collection<TextRange> readRanges = new ArrayList<TextRange>();
Collection<TextRange> writeRanges = new ArrayList<TextRange>();
final ReadWriteAccessDetector detector = ReadWriteAccessDetector.findDetector(target);
final FindUsagesManager findUsagesManager = ((FindManagerImpl)FindManager.getInstance(target.getProject())).getFindUsagesManager();
final FindUsagesHandler findUsagesHandler = findUsagesManager.getFindUsagesHandler(target, true);
final LocalSearchScope scope = new LocalSearchScope(psiElement);
Collection<PsiReference> refs = findUsagesHandler != null
? findUsagesHandler.findReferencesToHighlight(target, scope)
: ReferencesSearch.search(target, scope).findAll();
for (PsiReference psiReference : refs) {
if (psiReference == null) {
LOG.error("Null reference returned, findUsagesHandler=" + findUsagesHandler + "; target=" + target + " of " + target.getClass());
continue;
}
final List<TextRange> textRanges = HighlightUsagesHandler.getRangesToHighlight(psiReference);
if (detector == null || detector.getReferenceAccess(target, psiReference) == ReadWriteAccessDetector.Access.Read) {
readRanges.addAll(textRanges);
}
else {
writeRanges.addAll(textRanges);
}
}
if (withDeclarations) {
final TextRange declRange = HighlightUsagesHandler.getNameIdentifierRange(psiElement.getContainingFile(), target);
if (declRange != null) {
if (detector != null && detector.isDeclarationWriteAccess(target)) {
writeRanges.add(declRange);
}
else {
readRanges.add(declRange);
}
}
}
return Couple.of(readRanges, writeRanges);
}
示例9: findUsages
import com.intellij.find.findUsages.FindUsagesHandler; //导入依赖的package包/类
private static Collection<UsageInfo> findUsages(@NotNull final PsiElement element) {
final FindUsagesHandler handler = createFindUsageHandler(element);
if (handler == null) {
return Lists.newArrayList();
}
final CommonProcessors.CollectProcessor<UsageInfo> processor = new CommonProcessors.CollectProcessor<UsageInfo>();
final PsiElement[] psiElements = ArrayUtil.mergeArrays(handler.getPrimaryElements(), handler.getSecondaryElements());
final FindUsagesOptions options = handler.getFindUsagesOptions(null);
for (PsiElement psiElement : psiElements) {
handler.processElementUsages(psiElement, processor, options);
}
return processor.getResults();
}
示例10: createFindUsagesHandler
import com.intellij.find.findUsages.FindUsagesHandler; //导入依赖的package包/类
@Override
public FindUsagesHandler createFindUsagesHandler(@NotNull PsiElement element, boolean forHighlightUsages) {
return new JavaFindUsagesHandler(element, this) {
@NotNull
@Override
public PsiElement[] getSecondaryElements() {
// final PsiField psiField = (PsiField) getPsiElement();
// final PsiClass containingClass = psiField.getContainingClass();
// if (containingClass != null) {
// final AccessorsInfo accessorsInfo = AccessorsInfo.build(psiField);
// final String psiFieldName = psiField.getName();
//
// final String fieldName = accessorsInfo.removePrefix(psiFieldName);
// if (!fieldName.equals(psiFieldName)) {
// final boolean isBoolean = PsiType.BOOLEAN.equals(psiField.getType());
//
// final String getterName = LombokUtils.toGetterName(accessorsInfo, psiFieldName, isBoolean);
// final String setterName = LombokUtils.toSetterName(accessorsInfo, psiFieldName, isBoolean);
//
// final PsiMethod[] psiGetterMethods = containingClass.findMethodsByName(getterName, false);
// final PsiMethod[] psiSetterMethods = containingClass.findMethodsByName(setterName, false);
//
// final Set<PsiElement> elements = new THashSet<PsiElement>(psiGetterMethods.length + psiSetterMethods.length);
// for (PsiMethod accessor : psiGetterMethods) {
// ContainerUtil.addAll(elements, SuperMethodWarningUtil.checkSuperMethods(accessor, ACTION_STRING));
// }
// for (PsiMethod accessor : psiSetterMethods) {
// ContainerUtil.addAll(elements, SuperMethodWarningUtil.checkSuperMethods(accessor, ACTION_STRING));
// }
// return PsiUtilCore.toPsiElementArray(elements);
// }
// }
return super.getSecondaryElements();
}
};
}
示例11: createFindUsagesHandler
import com.intellij.find.findUsages.FindUsagesHandler; //导入依赖的package包/类
@Nullable
@Override
public FindUsagesHandler createFindUsagesHandler(@NotNull PsiElement element, boolean forHighlightUsages) {
if (canFindUsages(element)) {
return new FindUsagesHandler(element) {};
}
return null;
}
开发者ID:jimkyndemeyer,项目名称:js-graphql-intellij-plugin,代码行数:12,代码来源:JSGraphQLEndpointFindUsagesHandlerFactory.java
示例12: highlightTargetUsages
import com.intellij.find.findUsages.FindUsagesHandler; //导入依赖的package包/类
private void highlightTargetUsages(@NotNull PsiElement target) {
final ReadWriteAccessDetector detector = ReadWriteAccessDetector.findDetector(target);
final FindUsagesManager findUsagesManager = ((FindManagerImpl)FindManager.getInstance(target.getProject())).getFindUsagesManager();
final FindUsagesHandler findUsagesHandler = findUsagesManager.getFindUsagesHandler(target, true);
final LocalSearchScope scope = new LocalSearchScope(myFile);
Collection<PsiReference> refs = findUsagesHandler != null
? findUsagesHandler.findReferencesToHighlight(target, scope)
: ReferencesSearch.search(target, scope).findAll();
for (PsiReference psiReference : refs) {
final List<TextRange> textRanges = HighlightUsagesHandler.getRangesToHighlight(psiReference);
if (detector == null || detector.getReferenceAccess(target, psiReference) == ReadWriteAccessDetector.Access.Read) {
myReadAccessRanges.addAll(textRanges);
}
else {
myWriteAccessRanges.addAll(textRanges);
}
}
final TextRange declRange = HighlightUsagesHandler.getNameIdentifierRange(myFile, target);
if (declRange != null) {
if (detector != null && detector.isDeclarationWriteAccess(target)) {
myWriteAccessRanges.add(declRange);
}
else {
myReadAccessRanges.add(declRange);
}
}
}
示例13: createFindUsagesHandler
import com.intellij.find.findUsages.FindUsagesHandler; //导入依赖的package包/类
@Override
public FindUsagesHandler createFindUsagesHandler(@NotNull final PsiElement element, final boolean forHighlightUsages) {
if (canFindUsages(element)) {
PsiElement target = HaxeFindUsagesUtil.getTargetElement(element);
if (!forHighlightUsages) {
if (target instanceof PsiReference) {
PsiElement resolved = ((PsiReference)target).resolve();
if (null != resolved && resolved instanceof HaxeMethod) {
target = resolved;
}
}
if (target instanceof HaxeMethod) {
PsiMethod[] supers = ((HaxeMethod)target).findSuperMethods();
if (supers.length != 0) {
String chosen = askWhetherToSearchForOverridingMethods(target);
if (CURRENT_CLASS == chosen) { return new HaxeFindUsagesHandler(target); }
else if (BASE_CLASS == chosen) { return new HaxeFindUsagesHandler(supers[supers.length - 1]); }
else /* ANCESTOR_CLASSES */ { return new HaxeFindUsagesHandler(target, supers); }
}
}
}
return new HaxeFindUsagesHandler(target != null ? target : element);
}
return FindUsagesHandler.NULL_HANDLER;
}
示例14: createFindUsagesHandler
import com.intellij.find.findUsages.FindUsagesHandler; //导入依赖的package包/类
@Override
public FindUsagesHandler createFindUsagesHandler(@NotNull PsiElement element, boolean forHighlightUsages) {
return new FindUsagesHandler(element) {
@NotNull
@Override
public PsiElement[] getSecondaryElements() {
final PsiField psiField = (PsiField) getPsiElement();
final PsiClass containingClass = psiField.getContainingClass();
if (containingClass != null) {
final AccessorsInfo accessorsInfo = AccessorsInfo.build(psiField);
final String psiFieldName = psiField.getName();
final String fieldName = accessorsInfo.removePrefix(psiFieldName);
if (!fieldName.equals(psiFieldName)) {
final boolean isBoolean = PsiType.BOOLEAN.equals(psiField.getType());
final String getterName = LombokUtils.toGetterName(accessorsInfo, psiFieldName, isBoolean);
final String setterName = LombokUtils.toSetterName(accessorsInfo, psiFieldName, isBoolean);
final PsiMethod[] psiGetterMethods = containingClass.findMethodsByName(getterName, false);
final PsiMethod[] psiSetterMethods = containingClass.findMethodsByName(setterName, false);
final Set<PsiElement> elements = new THashSet<PsiElement>(psiGetterMethods.length + psiSetterMethods.length);
ContainerUtil.addAll(elements, psiGetterMethods);
ContainerUtil.addAll(elements, psiSetterMethods);
return PsiUtilCore.toPsiElementArray(elements);
}
}
return PsiElement.EMPTY_ARRAY;
}
};
}
示例15: createFindUsagesHandler
import com.intellij.find.findUsages.FindUsagesHandler; //导入依赖的package包/类
@Override
public FindUsagesHandler createFindUsagesHandler(@NotNull final PsiElement element,
final boolean forHighlightUsages) {
if (canFindUsages(element)) {
return new XQueryFindUsagesHandler(element);
}
return null;
}