本文整理汇总了Java中com.intellij.usages.UsageInfoToUsageConverter类的典型用法代码示例。如果您正苦于以下问题:Java UsageInfoToUsageConverter类的具体用法?Java UsageInfoToUsageConverter怎么用?Java UsageInfoToUsageConverter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UsageInfoToUsageConverter类属于com.intellij.usages包,在下文中一共展示了UsageInfoToUsageConverter类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: showObjectUpcastedUsageView
import com.intellij.usages.UsageInfoToUsageConverter; //导入依赖的package包/类
private void showObjectUpcastedUsageView(final ObjectUpcastedUsageInfo[] usages) {
UsageViewPresentation presentation = new UsageViewPresentation();
presentation.setTargetsNodeText(RefactoringBundle.message("replacing.inheritance.with.delegation"));
presentation.setCodeUsagesString(RefactoringBundle.message("instances.casted.to.java.lang.object"));
final String upcastedString = RefactoringBundle.message("instances.upcasted.to.object");
presentation.setUsagesString(upcastedString);
presentation.setTabText(upcastedString);
UsageViewManager manager = UsageViewManager.getInstance(myProject);
manager.showUsages(
new UsageTarget[]{new PsiElement2UsageTargetAdapter(myClass)},
UsageInfoToUsageConverter.convert(new PsiElement[]{myClass}, usages),
presentation
);
WindowManager.getInstance().getStatusBar(myProject).setInfo(RefactoringBundle.message("instances.upcasted.to.java.lang.object.found"));
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:InheritanceToDelegationProcessor.java
示例2: showRootUsages
import com.intellij.usages.UsageInfoToUsageConverter; //导入依赖的package包/类
public void showRootUsages(UsageInfo root, UsageInfo migration, final TypeMigrationLabeler labeler) {
final PsiElement rootElement = root.getElement();
if (rootElement == null) return;
final UsageInfoToUsageConverter.TargetElementsDescriptor targetElementsDescriptor =
new UsageInfoToUsageConverter.TargetElementsDescriptor(rootElement);
final Set<PsiElement> usages = labeler.getTypeUsages((TypeMigrationUsageInfo)migration, ((TypeMigrationUsageInfo)root));
if (usages != null) {
final List<UsageInfo> infos = new ArrayList<UsageInfo>(usages.size());
for (PsiElement usage : usages) {
if (usage != null && usage.isValid()) {
infos.add(new UsageInfo(usage));
}
}
showUsages(targetElementsDescriptor, infos.toArray(new UsageInfo[infos.size()]));
} else {
showUsages(targetElementsDescriptor, new UsageInfo[] {migration});
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:MigrationUsagesPanel.java
示例3: selectionChanged
import com.intellij.usages.UsageInfoToUsageConverter; //导入依赖的package包/类
private void selectionChanged() {
myConflictsPanel.setToInitialPosition();
myUsagesPanel.setToInitialPosition();
final DefaultMutableTreeNode[] migrationNodes = myRootsTree.getSelectedNodes(DefaultMutableTreeNode.class, null);
if (migrationNodes == null || migrationNodes.length == 0) return;
final Object userObject = migrationNodes[0].getUserObject();
if (userObject instanceof MigrationNode) {
final MigrationNode migrationNode = (MigrationNode)userObject;
final UsageInfo[] failedUsages = myLabeler.getFailedUsages();
if (failedUsages.length > 0) {
myConflictsPanel.showUsages(new UsageInfoToUsageConverter.TargetElementsDescriptor(new PsiElement[0]), failedUsages);
}
final AbstractTreeNode rootNode = migrationNode.getParent();
if (rootNode instanceof MigrationNode) {
myUsagesPanel.showRootUsages(((MigrationNode)rootNode).getInfo(), migrationNode.getInfo(), myLabeler);
}
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:MigrationPanel.java
示例4: showObjectUpcastedUsageView
import com.intellij.usages.UsageInfoToUsageConverter; //导入依赖的package包/类
private void showObjectUpcastedUsageView(final ObjectUpcastedUsageInfo[] usages) {
UsageViewPresentation presentation = new UsageViewPresentation();
presentation.setTargetsNodeText(RefactoringBundle.message("replacing.inheritance.with.delegation"));
presentation.setCodeUsagesString(RefactoringBundle.message("instances.casted.to.java.lang.object"));
final String upcastedString = RefactoringBundle.message("instances.upcasted.to.object");
presentation.setUsagesString(upcastedString);
presentation.setTabText(upcastedString);
UsageViewManager manager = UsageViewManager.getInstance(myProject);
manager.showUsages(
new UsageTarget[]{new PsiElement2UsageTargetAdapter(myClass)},
UsageInfoToUsageConverter.convert(new UsageInfoToUsageConverter.TargetElementsDescriptor(myClass), usages),
presentation
);
WindowManager.getInstance().getStatusBar(myProject).setInfo(RefactoringBundle.message("instances.upcasted.to.java.lang.object.found"));
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:InheritanceToDelegationProcessor.java
示例5: createUsageSearcher
import com.intellij.usages.UsageInfoToUsageConverter; //导入依赖的package包/类
@NotNull
public static UsageSearcher createUsageSearcher(@NotNull final PsiElement[] primaryElements, @NotNull final PsiElement[] secondaryElements, @NotNull final FindUsagesHandler handler, @NotNull FindUsagesOptions options, final PsiFile scopeFile) {
final FindUsagesOptions optionsClone = options.clone();
return new UsageSearcher() {
public void generate(@NotNull final Processor<Usage> processor) {
Project project = (Project) ApplicationManager.getApplication().runReadAction(new Computable() {
public Project compute() {
return scopeFile != null?scopeFile.getProject():primaryElements[0].getProject();
}
});
dropResolveCacheRegularly(ProgressManager.getInstance().getProgressIndicator(), project);
if(scopeFile != null) {
optionsClone.searchScope = new LocalSearchScope(scopeFile);
}
final CommonProcessors.UniqueProcessor usageInfoProcessor = new CommonProcessors.UniqueProcessor(new Processor<UsageInfo>() {
@Override
public boolean process(final UsageInfo usageInfo) {
Usage usage = (Usage)ApplicationManager.getApplication().runReadAction(new Computable() {
public Usage compute() {
return UsageInfoToUsageConverter.convert(primaryElements, usageInfo);
}
});
return processor.process(usage);
}
});
Iterable elements = ContainerUtil.concat(new PsiElement[][]{primaryElements, secondaryElements});
optionsClone.fastTrack = new SearchRequestCollector(new SearchSession());
if(optionsClone.searchScope instanceof GlobalSearchScope) {
optionsClone.searchScope = optionsClone.searchScope.union(GlobalSearchScope.projectScope(project));
}
try {
Iterator i$ = elements.iterator();
while(i$.hasNext()) {
final PsiElement element = (PsiElement)i$.next();
ApplicationManager.getApplication().runReadAction(new Runnable() {
public void run() {
}
});
handler.processElementUsages(element, usageInfoProcessor, optionsClone);
CustomUsageSearcher[] arr$ = (CustomUsageSearcher[])Extensions.getExtensions(CustomUsageSearcher.EP_NAME);
int len$ = arr$.length;
for(int i$1 = 0; i$1 < len$; ++i$1) {
CustomUsageSearcher searcher = arr$[i$1];
try {
searcher.processElementUsages(element, processor, optionsClone);
} catch (IndexNotReadyException var17) {
DumbService.getInstance(element.getProject()).showDumbModeNotification("Find usages is not available during indexing");
} catch (ProcessCanceledException var18) {
throw var18;
} catch (Exception var19) {
}
}
}
PsiSearchHelper.SERVICE.getInstance(project).processRequests(optionsClone.fastTrack, new Processor<PsiReference>() {
public boolean process(final PsiReference ref) {
UsageInfo info = (UsageInfo)ApplicationManager.getApplication().runReadAction(new Computable() {
public UsageInfo compute() {
return !ref.getElement().isValid()?null:new UsageInfo(ref);
}
});
return info == null || usageInfoProcessor.process(info);
}
});
} finally {
optionsClone.fastTrack = null;
}
}
};
}
开发者ID:niorgai,项目名称:Android-Resource-Usage-Count,代码行数:79,代码来源:FindUsageUtils.java
示例6: customizeCellRenderer
import com.intellij.usages.UsageInfoToUsageConverter; //导入依赖的package包/类
public void customizeCellRenderer(@NotNull final JTree tree,
final Object value,
final boolean selected,
final boolean expanded,
final boolean leaf,
final int row,
final boolean hasFocus) {
final Object userObject = ((DefaultMutableTreeNode)value).getUserObject();
if (!(userObject instanceof MigrationNode)) return;
final TypeMigrationUsageInfo usageInfo = ((MigrationNode)userObject).getInfo();
if (usageInfo != null) {
final PsiElement element = usageInfo.getElement();
if (element != null) {
PsiElement typeElement = null;
if (element instanceof PsiVariable) {
typeElement = ((PsiVariable)element).getTypeElement();
} else if (element instanceof PsiMethod) {
typeElement = ((PsiMethod)element).getReturnTypeElement();
}
if (typeElement == null) typeElement = element;
PsiDocumentManager.getInstance(element.getProject()).commitAllDocuments();
final UsagePresentation presentation = UsageInfoToUsageConverter.convert(new PsiElement[]{typeElement}, new UsageInfo(typeElement)).getPresentation();
boolean isPrefix = true; //skip usage position
for (TextChunk chunk : presentation.getText()) {
if (!isPrefix) append(chunk.getText(), patchAttrs(usageInfo, chunk.getSimpleAttributesIgnoreBackground()));
isPrefix = false;
}
setIcon(presentation.getIcon());
String location;
if (element instanceof PsiMember) {
location = SymbolPresentationUtil.getSymbolContainerText(element);
}
else {
final PsiMember member = PsiTreeUtil.getParentOfType(element, PsiMember.class);
if (member instanceof PsiField) {
location = PsiFormatUtil.formatVariable((PsiVariable)member, PsiFormatUtilBase.SHOW_NAME |
PsiFormatUtilBase.SHOW_CONTAINING_CLASS |
PsiFormatUtilBase.SHOW_FQ_NAME, PsiSubstitutor.EMPTY);
}
else if (member instanceof PsiMethod) {
location = PsiFormatUtil.formatMethod((PsiMethod)member, PsiSubstitutor.EMPTY, PsiFormatUtilBase.SHOW_NAME |
PsiFormatUtilBase.SHOW_CONTAINING_CLASS |
PsiFormatUtilBase.SHOW_FQ_NAME,
PsiFormatUtilBase.SHOW_TYPE);
}
else if (member instanceof PsiClass) {
location = PsiFormatUtil.formatClass((PsiClass)member, PsiFormatUtilBase.SHOW_NAME |
PsiFormatUtilBase.SHOW_FQ_NAME);
}
else {
location = null;
}
if (location != null) location = PsiBundle.message("aux.context.display", location);
}
if (location != null) {
append(location, SimpleTextAttributes.GRAYED_ATTRIBUTES);
}
} else {
append(UsageViewBundle.message("node.invalid"), SimpleTextAttributes.ERROR_ATTRIBUTES);
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:64,代码来源:MigrationPanel.java
示例7: PsiElement2UsageTargetComposite
import com.intellij.usages.UsageInfoToUsageConverter; //导入依赖的package包/类
public PsiElement2UsageTargetComposite(@NotNull PsiElement[] primaryElements,
@NotNull PsiElement[] secondaryElements,
@NotNull FindUsagesOptions options) {
super(primaryElements[0], options);
myDescriptor = new UsageInfoToUsageConverter.TargetElementsDescriptor(primaryElements, secondaryElements);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:PsiElement2UsageTargetComposite.java
示例8: showUsages
import com.intellij.usages.UsageInfoToUsageConverter; //导入依赖的package包/类
@Override
public void showUsages(@NotNull final UsageInfoToUsageConverter.TargetElementsDescriptor descriptor, @NotNull final UsageInfo[] usageInfos) {
super.showUsages(descriptor, usageInfos);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:5,代码来源:MigrationConflictsPanel.java
示例9: customizeCellRenderer
import com.intellij.usages.UsageInfoToUsageConverter; //导入依赖的package包/类
public void customizeCellRenderer(final JTree tree,
final Object value,
final boolean selected,
final boolean expanded,
final boolean leaf,
final int row,
final boolean hasFocus) {
final Object userObject = ((DefaultMutableTreeNode)value).getUserObject();
if (!(userObject instanceof MigrationNode)) return;
final TypeMigrationUsageInfo usageInfo = ((MigrationNode)userObject).getInfo();
if (usageInfo != null) {
final PsiElement element = usageInfo.getElement();
if (element != null) {
PsiElement typeElement = null;
if (element instanceof PsiVariable) {
typeElement = ((PsiVariable)element).getTypeElement();
} else if (element instanceof PsiMethod) {
typeElement = ((PsiMethod)element).getReturnTypeElement();
}
if (typeElement == null) typeElement = element;
PsiDocumentManager.getInstance(element.getProject()).commitAllDocuments();
final UsagePresentation presentation = UsageInfoToUsageConverter.convert(new UsageInfoToUsageConverter.TargetElementsDescriptor(typeElement), new UsageInfo(typeElement)).getPresentation();
boolean isPrefix = true; //skip usage position
for (TextChunk chunk : presentation.getText()) {
if (!isPrefix) append(chunk.getText(), patchAttrs(usageInfo, chunk.getSimpleAttributesIgnoreBackground()));
isPrefix = false;
}
setIcon(presentation.getIcon());
String location;
if (element instanceof PsiMember) {
location = SymbolPresentationUtil.getSymbolContainerText(element);
}
else {
final PsiMember member = PsiTreeUtil.getParentOfType(element, PsiMember.class);
if (member instanceof PsiField) {
location = PsiFormatUtil.formatVariable((PsiVariable)member, PsiFormatUtilBase.SHOW_NAME |
PsiFormatUtilBase.SHOW_CONTAINING_CLASS |
PsiFormatUtilBase.SHOW_FQ_NAME, PsiSubstitutor.EMPTY);
}
else if (member instanceof PsiMethod) {
location = PsiFormatUtil.formatMethod((PsiMethod)member, PsiSubstitutor.EMPTY, PsiFormatUtilBase.SHOW_NAME |
PsiFormatUtilBase.SHOW_CONTAINING_CLASS |
PsiFormatUtilBase.SHOW_FQ_NAME,
PsiFormatUtilBase.SHOW_TYPE);
}
else if (member instanceof PsiClass) {
location = PsiFormatUtil.formatClass((PsiClass)member, PsiFormatUtilBase.SHOW_NAME |
PsiFormatUtilBase.SHOW_FQ_NAME);
}
else {
location = null;
}
if (location != null) location = PsiBundle.message("aux.context.display", location);
}
if (location != null) {
append(location, SimpleTextAttributes.GRAYED_ATTRIBUTES);
}
} else {
append(UsageViewBundle.message("node.invalid"), SimpleTextAttributes.ERROR_ATTRIBUTES);
}
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:64,代码来源:MigrationPanel.java
示例10: PsiElement2UsageTargetComposite
import com.intellij.usages.UsageInfoToUsageConverter; //导入依赖的package包/类
public PsiElement2UsageTargetComposite(@Nonnull PsiElement[] primaryElements,
@Nonnull PsiElement[] secondaryElements,
@Nonnull FindUsagesOptions options) {
super(primaryElements[0], options);
myDescriptor = new UsageInfoToUsageConverter.TargetElementsDescriptor(primaryElements, secondaryElements);
}
开发者ID:consulo,项目名称:consulo,代码行数:7,代码来源:PsiElement2UsageTargetComposite.java
示例11: customizeCellRenderer
import com.intellij.usages.UsageInfoToUsageConverter; //导入依赖的package包/类
public void customizeCellRenderer(@NotNull final JTree tree, final Object value, final boolean selected, final boolean expanded, final boolean leaf, final int row, final boolean hasFocus)
{
final Object userObject = ((DefaultMutableTreeNode) value).getUserObject();
if(!(userObject instanceof MigrationNode))
{
return;
}
final TypeMigrationUsageInfo usageInfo = ((MigrationNode) userObject).getInfo();
if(usageInfo != null)
{
final PsiElement element = usageInfo.getElement();
if(element != null)
{
PsiElement typeElement = null;
if(element instanceof PsiVariable)
{
typeElement = ((PsiVariable) element).getTypeElement();
}
else if(element instanceof PsiMethod)
{
typeElement = ((PsiMethod) element).getReturnTypeElement();
}
if(typeElement == null)
{
typeElement = element;
}
final UsagePresentation presentation = UsageInfoToUsageConverter.convert(new PsiElement[]{typeElement}, new UsageInfo(typeElement)).getPresentation();
boolean isPrefix = true; //skip usage position
for(TextChunk chunk : presentation.getText())
{
if(!isPrefix)
{
append(chunk.getText(), patchAttrs(usageInfo, chunk.getSimpleAttributesIgnoreBackground()));
}
isPrefix = false;
}
setIcon(presentation.getIcon());
String location;
if(element instanceof PsiMember)
{
location = SymbolPresentationUtil.getSymbolContainerText(element);
}
else
{
final PsiMember member = PsiTreeUtil.getParentOfType(element, PsiMember.class);
if(member instanceof PsiField)
{
location = PsiFormatUtil.formatVariable((PsiVariable) member, PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_CONTAINING_CLASS | PsiFormatUtilBase.SHOW_FQ_NAME,
PsiSubstitutor.EMPTY);
}
else if(member instanceof PsiMethod)
{
location = PsiFormatUtil.formatMethod((PsiMethod) member, PsiSubstitutor.EMPTY, PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_CONTAINING_CLASS | PsiFormatUtilBase
.SHOW_FQ_NAME, PsiFormatUtilBase.SHOW_TYPE);
}
else if(member instanceof PsiClass)
{
location = PsiFormatUtil.formatClass((PsiClass) member, PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_FQ_NAME);
}
else
{
location = null;
}
if(location != null)
{
location = PsiBundle.message("aux.context.display", location);
}
}
if(location != null)
{
append(location, SimpleTextAttributes.GRAYED_ATTRIBUTES);
}
}
else
{
append(UsageViewBundle.message("node.invalid"), SimpleTextAttributes.ERROR_ATTRIBUTES);
}
}
}
开发者ID:consulo,项目名称:consulo-java,代码行数:82,代码来源:MigrationPanel.java
示例12: performSearch
import com.intellij.usages.UsageInfoToUsageConverter; //导入依赖的package包/类
private void performSearch(final SearchScope searchScope, final String subscribeClassName) {
JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(myProject);
PsiClass subscribePsiClass = javaPsiFacade.findClass(subscribeClassName,
GlobalSearchScope.allScope(myProject));
if (subscribePsiClass == null) {
// the guava or otto library isn't available in this project so do nothing
return;
}
FindUsagesHandler handler = findUsagesManager.getNewFindUsagesHandler(subscribePsiClass, false);
if (handler != null) {
UsageInfoToUsageConverter.TargetElementsDescriptor descriptor =
new UsageInfoToUsageConverter.TargetElementsDescriptor(handler.getPrimaryElements(),
handler.getSecondaryElements());
final long startTime = System.currentTimeMillis();
Processor<Usage> processor = new Processor<Usage>() {
@Override public boolean process(Usage usage) {
if (usage instanceof UsageInfo2UsageAdapter) {
PsiElement element = ((UsageInfo2UsageAdapter) usage).getElement();
if ((element = element.getContext()) instanceof PsiAnnotation) {
if ((element = element.getContext()) instanceof PsiModifierList) {
if ((element = element.getContext()) instanceof PsiMethod) {
if (PsiConsultantImpl.hasAnnotation((PsiMethod) element, subscribeClassName)) {
maybeAddSubscriberMethod((PsiMethod) element);
}
}
}
}
}
return true;
}
};
JavaClassFindUsagesOptions options = new JavaClassFindUsagesOptions(myProject);
options.searchScope = searchScope;
FindUsagesManager.startProcessUsages(handler, handler.getPrimaryElements(), handler.getSecondaryElements(), processor, options, new Runnable() {
@Override public void run() {
int eventClassCount = optimizeEventClassIndex();
if (eventClassCount > 0) {
scheduleRefreshOfEventFiles();
} else {
maybeScheduleAnotherSearch();
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(String.format("Searched for @Subscribe in %s in %dms",
searchScope, System.currentTimeMillis() - startTime));
}
}
});
}
}
开发者ID:square,项目名称:otto-intellij-plugin,代码行数:53,代码来源:OttoProjectHandler.java
注:本文中的com.intellij.usages.UsageInfoToUsageConverter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论