• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java UsageInfo2UsageAdapter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.usages.UsageInfo2UsageAdapter的典型用法代码示例。如果您正苦于以下问题:Java UsageInfo2UsageAdapter类的具体用法?Java UsageInfo2UsageAdapter怎么用?Java UsageInfo2UsageAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



UsageInfo2UsageAdapter类属于com.intellij.usages包,在下文中一共展示了UsageInfo2UsageAdapter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: customizeCellRenderer

import com.intellij.usages.UsageInfo2UsageAdapter; //导入依赖的package包/类
@Override
public void customizeCellRenderer(@NotNull SliceUsageCellRendererBase renderer,
                                  @NotNull JTree tree,
                                  Object value,
                                  boolean selected,
                                  boolean expanded,
                                  boolean leaf,
                                  int row,
                                  boolean hasFocus) {
  Usage usage = getValue();
  renderer.append("Value: ", SimpleTextAttributes.REGULAR_ATTRIBUTES);

  if (usage instanceof UsageInfo2UsageAdapter) {
    PsiElement element = ((UsageInfo2UsageAdapter)usage).getElement();
    if (element == null) {
      renderer.append(UsageViewBundle.message("node.invalid") + " ", SliceUsageCellRenderer.ourInvalidAttributes);
    }
    else {
      appendElementText((UsageInfo2UsageAdapter)usage, element, renderer);
    }
  }
  else {
    renderer.append("Other", SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:SliceLeafValueRootNode.java


示例2: testBackwardPackageScope

import com.intellij.usages.UsageInfo2UsageAdapter; //导入依赖的package包/类
public void testBackwardPackageScope(){
   final PsiPackage bPackage = JavaPsiFacade.getInstance(myPsiManager.getProject()).findPackage("com.a");
  final DependenciesBuilder builder = new BackwardDependenciesBuilder(myProject, new JavaAnalysisScope(bPackage, null));
  builder.analyze();
  final Set<PsiFile> searchFor = new HashSet<PsiFile>();
  searchFor.add(myJavaFacade.findClass("com.a.A", GlobalSearchScope.allScope(myProject)).getContainingFile());
  final Set<PsiFile> searchIn = new HashSet<PsiFile>();
  final PsiClass bClass = myJavaFacade.findClass("com.b.B", GlobalSearchScope.allScope(myProject));
  searchIn.add(bClass.getContainingFile());
  final PsiClass cClass = myJavaFacade.findClass("com.a.C", GlobalSearchScope.allScope(myProject));
  searchFor.add(cClass.getContainingFile());
  final UsageInfo[] usagesInfos = FindDependencyUtil.findBackwardDependencies(builder, searchIn, searchFor);
  final UsageInfo2UsageAdapter[] usages = UsageInfo2UsageAdapter.convert(usagesInfos);
  final String [] psiUsages = new String [usagesInfos.length];
  for (int i = 0; i < usagesInfos.length; i++) {
    psiUsages[i] = toString(usages[i]);
  }
  checkResult(new String []{"(4: 3) A myA = new A();", "(4: 15) A myA = new A();", "(5: 3) C myC = new C();", "(5: 15) C myC = new C();", "(7: 9) myA.aa();", "(8: 9) myC.cc();"}, psiUsages);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:UsagesInAnalyzingDependenciesTest.java


示例3: testForwardSimple

import com.intellij.usages.UsageInfo2UsageAdapter; //导入依赖的package包/类
public void testForwardSimple(){
  final DependenciesBuilder builder = new ForwardDependenciesBuilder(myProject, new AnalysisScope(myProject));
  builder.analyze();

  final Set<PsiFile> searchIn = new HashSet<PsiFile>();
  final PsiClass aClass = myJavaFacade.findClass("A", GlobalSearchScope.allScope(myProject));
  searchIn.add(aClass.getContainingFile());
  final Set<PsiFile> searchFor = new HashSet<PsiFile>();
  final PsiClass bClass = myJavaFacade.findClass("B", GlobalSearchScope.allScope(myProject));
  searchFor.add(bClass.getContainingFile());

  final UsageInfo[] usagesInfos = FindDependencyUtil.findDependencies(builder, searchIn, searchFor);
  final UsageInfo2UsageAdapter[] usages = UsageInfo2UsageAdapter.convert(usagesInfos);
  final String [] psiUsages = new String [usagesInfos.length];
  for (int i = 0; i < usagesInfos.length; i++) {
    psiUsages[i] = toString(usages[i]);
  }
  checkResult(new String []{"(2: 3) B myB = new B();", "(2: 15) B myB = new B();", "(4: 9) myB.bb();"}, psiUsages);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:UsagesInAnalyzingDependenciesTest.java


示例4: testForwardJdkClasses

import com.intellij.usages.UsageInfo2UsageAdapter; //导入依赖的package包/类
public void testForwardJdkClasses(){
  final DependenciesBuilder builder = new ForwardDependenciesBuilder(myProject, new AnalysisScope(myProject));
  builder.analyze();

  final Set<PsiFile> searchIn = new HashSet<PsiFile>();
  final PsiClass aClass = myJavaFacade.findClass("A", GlobalSearchScope.allScope(myProject));
  searchIn.add(aClass.getContainingFile());

  final Set<PsiFile> searchFor = new HashSet<PsiFile>();
  final PsiClass stringClass = myJavaFacade.findClass("java.lang.String", GlobalSearchScope.allScope(myProject));
  searchFor.add((PsiFile)stringClass.getContainingFile().getNavigationElement());

  final UsageInfo[] usagesInfos = FindDependencyUtil.findDependencies(builder, searchIn, searchFor);
  final UsageInfo2UsageAdapter[] usages = UsageInfo2UsageAdapter.convert(usagesInfos);
  final String [] psiUsages = new String [usagesInfos.length];
  for (int i = 0; i < usagesInfos.length; i++) {
    psiUsages[i] = toString(usages[i]);
  }
  checkResult(new String []{"(2: 3) String myName;"}, psiUsages);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:UsagesInAnalyzingDependenciesTest.java


示例5: replaceOne

import com.intellij.usages.UsageInfo2UsageAdapter; //导入依赖的package包/类
private void replaceOne(UsageInfo2UsageAdapter info, boolean doConfirm) {
  ReplacementInfo replacementInfo = usage2ReplacementInfo.get(info);
  boolean approved;

  if (doConfirm) {
    ReplacementPreviewDialog wrapper =
      new ReplacementPreviewDialog(mySearchContext.getProject(), info.getUsageInfo(), replacementInfo.getReplacement());

    approved = wrapper.showAndGet();
  }
  else {
    approved = true;
  }

  if (approved) {
    ensureFileWritable(info);
    getUsageView().removeUsage(info);
    getReplacer().replace(replacementInfo);

    if (getUsageView().getUsagesCount() == 0) {
      getUsageView().close();
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:ReplaceUsageViewContext.java


示例6: groupUsage

import com.intellij.usages.UsageInfo2UsageAdapter; //导入依赖的package包/类
@Nullable
public UsageGroup groupUsage(@NotNull Usage usage) {
    if (usage instanceof UsageInfo2UsageAdapter) {
        final UsageInfo2UsageAdapter u = (UsageInfo2UsageAdapter)usage;
        final UsageInfo usageInfo = u.getUsageInfo();
        if (usageInfo instanceof MoveRenameUsageInfo) {
            final MoveRenameUsageInfo info = (MoveRenameUsageInfo)usageInfo;
            return buildGroup(info.getReferencedElement(), usageInfo, true);
        } else {
            final PsiReference[] references = u.getElement().getReferences();
            for (PsiReference reference : references) {
                if (reference.getRangeInElement().equals(usageInfo.getRangeInElement())) {
                    return buildGroup(reference.resolve(), usageInfo, false);
                }
            }
        }
    }
    return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:XsltStuffProvider.java


示例7: customizeCellRenderer

import com.intellij.usages.UsageInfo2UsageAdapter; //导入依赖的package包/类
@Override
public void customizeCellRenderer(SliceUsageCellRenderer renderer,
                                  JTree tree,
                                  Object value,
                                  boolean selected,
                                  boolean expanded,
                                  boolean leaf,
                                  int row,
                                  boolean hasFocus) {
  Usage usage = getValue();
  renderer.append("Value: ", SimpleTextAttributes.REGULAR_ATTRIBUTES);

  if (usage instanceof UsageInfo2UsageAdapter) {
    PsiElement element = ((UsageInfo2UsageAdapter)usage).getElement();
    if (element == null) {
      renderer.append(UsageViewBundle.message("node.invalid") + " ", SliceUsageCellRenderer.ourInvalidAttributes);
    }
    else {
      appendElementText((UsageInfo2UsageAdapter)usage, element, renderer);
    }
  }
  else {
    renderer.append("Other", SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:26,代码来源:SliceLeafValueRootNode.java


示例8: groupUsage

import com.intellij.usages.UsageInfo2UsageAdapter; //导入依赖的package包/类
@Override
public UsageGroup groupUsage(@NotNull Usage usage) {
  if (usage instanceof PsiElementUsage) {
    if (usage instanceof UsageInfo2UsageAdapter) {
      final UsageInfo usageInfo = ((UsageInfo2UsageAdapter)usage).getUsageInfo();
      if (usageInfo.isDynamicUsage()) {
        return DynamicUsageGroup.INSTANCE;
      }
    }
    if (((PsiElementUsage)usage).isNonCodeUsage()) {
      return NonCodeUsageGroup.INSTANCE;
    }
    else {
      return CodeUsageGroup.INSTANCE;
    }
  }
  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:NonCodeUsageGroupingRule.java


示例9: prettyUsageMessage

import com.intellij.usages.UsageInfo2UsageAdapter; //导入依赖的package包/类
public String prettyUsageMessage(UsageInfo usage) {

    UsageInfo2UsageAdapter adapter = new UsageInfo2UsageAdapter(usage);
    StringBuilder builder = new StringBuilder();

    VirtualFile vFile = adapter.getFile();
    builder.append(null != vFile ? vFile.getName() : "<unknown file>");
    builder.append(", line ");
    builder.append(adapter.getLine() + 1);
    builder.append(':');
    builder.append(adapter.getPresentation().getPlainText());

    String tooltip = adapter.getPresentation().getTooltipText();
    if (null != tooltip) {
      builder.append(" {");
      builder.append(tooltip);
      builder.append("} ");
    }

    return builder.toString();
  }
 
开发者ID:HaxeFoundation,项目名称:intellij-haxe,代码行数:22,代码来源:HaxeFindUsagesTest.java


示例10: shouldShow

import com.intellij.usages.UsageInfo2UsageAdapter; //导入依赖的package包/类
@Override public boolean shouldShow(UsageTarget target, Usage usage) {
  PsiElement element = ((UsageInfo2UsageAdapter) usage).getElement();

  PsiField field = PsiConsultantImpl.findField(element);
  if (field != null //
      && PsiConsultantImpl.hasAnnotation(field, CLASS_INJECT) //
      && PsiConsultantImpl.hasQuailifierAnnotations(field, qualifierAnnotations)
      && PsiConsultantImpl.hasTypeParameters(field, typeParameters)) {
    return true;
  }

  PsiMethod method = PsiConsultantImpl.findMethod(element);
  if (method != null && (PsiConsultantImpl.hasAnnotation(method, CLASS_INJECT)
          || PsiConsultantImpl.hasAnnotation(method, CLASS_PROVIDES))) {
    for (PsiParameter parameter : method.getParameterList().getParameters()) {
      PsiClass parameterClass = PsiConsultantImpl.checkForLazyOrProvider(parameter);
      if (parameterClass.equals(returnType) && PsiConsultantImpl.hasQuailifierAnnotations(
          parameter, qualifierAnnotations)
          && PsiConsultantImpl.hasTypeParameters(parameter, typeParameters)) {
        return true;
      }
    }
  }

  return false;
}
 
开发者ID:square,项目名称:dagger-intellij-plugin,代码行数:27,代码来源:Decider.java


示例11: groupUsage

import com.intellij.usages.UsageInfo2UsageAdapter; //导入依赖的package包/类
@Override
public UsageGroup groupUsage(@Nonnull Usage usage) {
  if (usage instanceof UsageInFile) {
    VirtualFile file = ((UsageInFile)usage).getFile();
    if (file != null) {
      if (GeneratedSourcesFilter.isGenerated(myProject, file)) {
        return UsageInGeneratedCodeGroup.INSTANCE;
      }
    }
  }
  if (usage instanceof PsiElementUsage) {
    if (usage instanceof UsageInfo2UsageAdapter) {
      final UsageInfo usageInfo = ((UsageInfo2UsageAdapter)usage).getUsageInfo();
      if (usageInfo.isDynamicUsage()) {
        return DynamicUsageGroup.INSTANCE;
      }
    }
    if (((PsiElementUsage)usage).isNonCodeUsage()) {
      return NonCodeUsageGroup.INSTANCE;
    }
    else {
      return CodeUsageGroup.INSTANCE;
    }
  }
  return null;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:27,代码来源:NonCodeUsageGroupingRule.java


示例12: toString

import com.intellij.usages.UsageInfo2UsageAdapter; //导入依赖的package包/类
@Override
public String toString()
{
	Usage myLeafExpression = getValue();
	String text;
	if(myLeafExpression instanceof UsageInfo2UsageAdapter)
	{
		PsiElement element = ((UsageInfo2UsageAdapter) myLeafExpression).getUsageInfo().getElement();
		text = element == null ? "" : element.getText();
	}
	else
	{
		text = "Other";
	}
	return "Value: " + text;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:17,代码来源:SliceLeafValueRootNode.java


示例13: searchFields

import com.intellij.usages.UsageInfo2UsageAdapter; //导入依赖的package包/类
private static void searchFields(PsiClass allIcons, final UsageView view, ProgressIndicator indicator) {
  indicator.setText("Searching for: " + allIcons.getQualifiedName());
  ReferencesSearch.search(allIcons).forEach(new Processor<PsiReference>() {
    @Override
    public boolean process(PsiReference reference) {
      PsiElement elt = reference.getElement();

      while (elt instanceof PsiExpression) elt = elt.getParent();

      if (elt instanceof PsiField) {
        UsageInfo info = new UsageInfo(elt, false);
        view.appendUsage(new UsageInfo2UsageAdapter(info));
      }

      return true;
    }
  });
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:19,代码来源:StaticIconFieldsAction.java


示例14: testBackwardPackageScope

import com.intellij.usages.UsageInfo2UsageAdapter; //导入依赖的package包/类
public void testBackwardPackageScope(){
   final PsiJavaPackage bPackage = JavaPsiFacade.getInstance(myPsiManager.getProject()).findPackage("com.a");
  final DependenciesBuilder builder = new BackwardDependenciesBuilder(myProject, new JavaAnalysisScope(bPackage, null));
  builder.analyze();
  final Set<PsiFile> searchFor = new HashSet<PsiFile>();
  searchFor.add(myJavaFacade.findClass("com.a.A", GlobalSearchScope.allScope(myProject)).getContainingFile());
  final Set<PsiFile> searchIn = new HashSet<PsiFile>();
  final PsiClass bClass = myJavaFacade.findClass("com.b.B", GlobalSearchScope.allScope(myProject));
  searchIn.add(bClass.getContainingFile());
  final PsiClass cClass = myJavaFacade.findClass("com.a.C", GlobalSearchScope.allScope(myProject));
  searchFor.add(cClass.getContainingFile());
  final UsageInfo[] usagesInfos = FindDependencyUtil.findBackwardDependencies(builder, searchIn, searchFor);
  final UsageInfo2UsageAdapter[] usages = UsageInfo2UsageAdapter.convert(usagesInfos);
  final String [] psiUsages = new String [usagesInfos.length];
  for (int i = 0; i < usagesInfos.length; i++) {
    psiUsages[i] = toString(usages[i]);
  }
  checkResult(new String []{"(4: 3) A myA = new A();", "(4: 15) A myA = new A();", "(5: 3) C myC = new C();", "(5: 15) C myC = new C();", "(7: 9) myA.aa();", "(8: 9) myC.cc();"}, psiUsages);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:20,代码来源:UsagesInAnalyzingDependenciesTest.java


示例15: toString

import com.intellij.usages.UsageInfo2UsageAdapter; //导入依赖的package包/类
@Override
public String toString() {
  Usage myLeafExpression = getValue();
  String text;
  if (myLeafExpression instanceof UsageInfo2UsageAdapter) {
    PsiElement element = ((UsageInfo2UsageAdapter)myLeafExpression).getUsageInfo().getElement();
    text = element == null ? "" : element.getText();
  }
  else {
    text = "Other";
  }
  return "Value: "+ text;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:SliceLeafValueRootNode.java


示例16: appendElementText

import com.intellij.usages.UsageInfo2UsageAdapter; //导入依赖的package包/类
private static void appendElementText(@NotNull UsageInfo2UsageAdapter usage,
                                      @NotNull final PsiElement element,
                                      @NotNull final SliceUsageCellRendererBase renderer) {
  PsiFile file = element.getContainingFile();
  List<TextChunk> result = new ArrayList<TextChunk>();
  ChunkExtractor.getExtractor(element.getContainingFile())
    .createTextChunks(usage, file.getText(), element.getTextRange().getStartOffset(), element.getTextRange().getEndOffset(),
                      false, result);

  for (TextChunk chunk : result) {
    renderer.append(chunk.getText(), chunk.getSimpleAttributesIgnoreBackground());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:SliceLeafValueRootNode.java


示例17: testForwardPackageScope

import com.intellij.usages.UsageInfo2UsageAdapter; //导入依赖的package包/类
public void testForwardPackageScope(){
  final PsiPackage bPackage = JavaPsiFacade.getInstance(myPsiManager.getProject()).findPackage("com.b");
  final DependenciesBuilder builder = new ForwardDependenciesBuilder(myProject, new JavaAnalysisScope(bPackage, null));
  builder.analyze();
  final Set<PsiFile> searchFor = new HashSet<PsiFile>();
  searchFor.add(myJavaFacade.findClass("com.a.A", GlobalSearchScope.allScope(myProject)).getContainingFile());
  final Set<PsiFile> searchIn = new HashSet<PsiFile>();
  final PsiClass bClass = myJavaFacade.findClass("com.b.B", GlobalSearchScope.allScope(myProject));
  searchIn.add(bClass.getContainingFile());
  final PsiClass cClass = myJavaFacade.findClass("com.b.C", GlobalSearchScope.allScope(myProject));
  searchIn.add(cClass.getContainingFile());
  final UsageInfo[] usagesInfos = FindDependencyUtil.findDependencies(builder, searchIn, searchFor);
  final UsageInfo2UsageAdapter[] usages = UsageInfo2UsageAdapter.convert(usagesInfos);
  final String [] psiUsages = new String [usagesInfos.length];
  for (int i = 0; i < usagesInfos.length; i++) {
    psiUsages[i] = toString(usages[i]);
  }
  checkResult(new String []{
    "(2: 14) import com.a.A;",
    "(4: 3) A myA = new A();",
    "(4: 15) A myA = new A();",
    "(6: 9) myA.aa();",

    "(2: 14) import com.a.A;",
    "(4: 3) A myA = new A();",
    "(4: 15) A myA = new A();",
    "(6: 9) myA.aa();"}, psiUsages);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:UsagesInAnalyzingDependenciesTest.java


示例18: groupUsage

import com.intellij.usages.UsageInfo2UsageAdapter; //导入依赖的package包/类
@Override
public UsageGroup groupUsage(@NotNull Usage usage) {
  if (usage instanceof UsageInFile) {
    VirtualFile file = ((UsageInFile)usage).getFile();
    if (file != null) {
      for (GeneratedSourcesFilter filter : myGeneratedSourcesFilters) {
        if (filter.isGeneratedSource(file, myProject)) {
          return UsageInGeneratedCodeGroup.INSTANCE;
        }
      }
    }
  }
  if (usage instanceof PsiElementUsage) {
    if (usage instanceof UsageInfo2UsageAdapter) {
      final UsageInfo usageInfo = ((UsageInfo2UsageAdapter)usage).getUsageInfo();
      if (usageInfo.isDynamicUsage()) {
        return DynamicUsageGroup.INSTANCE;
      }
    }
    if (((PsiElementUsage)usage).isNonCodeUsage()) {
      return NonCodeUsageGroup.INSTANCE;
    }
    else {
      return CodeUsageGroup.INSTANCE;
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:NonCodeUsageGroupingRule.java


示例19: ensureFileWritable

import com.intellij.usages.UsageInfo2UsageAdapter; //导入依赖的package包/类
private static void ensureFileWritable(final UsageInfo2UsageAdapter usage) {
  final VirtualFile file = usage.getFile();

  if (file != null && !file.isWritable()) {
    ReadonlyStatusHandler.getInstance(usage.getElement().getProject()).ensureFilesWritable(file);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:ReplaceUsageViewContext.java


示例20: doReplace

import com.intellij.usages.UsageInfo2UsageAdapter; //导入依赖的package包/类
private void doReplace() {
  List<Usage> infos = getUsageView().getSortedUsages();
  List<ReplacementInfo> results = new ArrayList<ReplacementInfo>(infos.size());

  for (final Usage info : infos) {
    UsageInfo2UsageAdapter usage = (UsageInfo2UsageAdapter)info;

    if (isValid(usage)) {
      results.add(usage2ReplacementInfo.get(usage));
    }
  }

  getReplacer().replaceAll(results);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:ReplaceUsageViewContext.java



注:本文中的com.intellij.usages.UsageInfo2UsageAdapter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Receiver类代码示例发布时间:2022-05-22
下一篇:
Java ISpout类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap