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

Java MoveRenameUsageInfo类代码示例

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

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



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

示例1: findUsages

import com.intellij.refactoring.util.MoveRenameUsageInfo; //导入依赖的package包/类
@Nullable
@Override
public List<UsageInfo> findUsages( PsiFile psiFile, PsiDirectory newParent, boolean searchInComments, boolean searchInNonJavaFiles )
{
  Module mod = ModuleUtilCore.findModuleForPsiElement( psiFile );
  ManModule module = ManProject.getModule( mod );
  PsiClass psiClass = findPsiClass( psiFile );
  if( psiClass == null )
  {
    return Collections.emptyList();
  }

  Query<PsiReference> search = ReferencesSearch.search( psiClass, GlobalSearchScope.moduleWithDependenciesAndLibrariesScope( module.getIjModule() ) );
  List<UsageInfo> usages = new ArrayList<>();
  for( PsiReference ref: search.findAll() )
  {
    usages.add( new MoveRenameUsageInfo( ref.getElement(), ref, ref.getRangeInElement().getStartOffset(),
      ref.getRangeInElement().getEndOffset(), psiClass,
      ref.resolve() == null && !(ref instanceof PsiPolyVariantReference && ((PsiPolyVariantReference)ref).multiResolve( true ).length > 0) ) );
  }
  return usages;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:23,代码来源:MoveTypeManifoldFileProcessor.java


示例2: findUsages

import com.intellij.refactoring.util.MoveRenameUsageInfo; //导入依赖的package包/类
private static List<UsageInfo> findUsages( PsiElement element, PsiElement ctx )
  {
//    Module mod = ModuleUtilCore.findModuleForPsiElement( element );
//    if( mod == null )
//    {
//      return Collections.emptyList();
//    }

    Query<PsiReference> search = ReferencesSearch.search( element, GlobalSearchScope.moduleScope( ModuleUtilCore.findModuleForPsiElement( ctx ) ) );
    List<UsageInfo> usages = new ArrayList<>();
    for( PsiReference ref : search.findAll() )
    {
      MoveRenameUsageInfo usageInfo = new MoveRenameUsageInfo( ref.getElement(), ref, ref.getRangeInElement().getStartOffset(),
                                                               ref.getRangeInElement().getEndOffset(), element,
                                                               ref.resolve() == null && !(ref instanceof PsiPolyVariantReference && ((PsiPolyVariantReference)ref).multiResolve( true ).length > 0) );
      usages.add( usageInfo );
    }
    return usages;
  }
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:20,代码来源:RenameResourceElementProcessor.java


示例3: retargetUsages

import com.intellij.refactoring.util.MoveRenameUsageInfo; //导入依赖的package包/类
@Override
public void retargetUsages(List<UsageInfo> usageInfos, Map<PsiElement, PsiElement> oldToNewMap) {
  for (UsageInfo usage : usageInfos) {
    if (usage instanceof MoveRenameUsageInfo) {
      final MoveRenameUsageInfo moveRenameUsage = (MoveRenameUsageInfo)usage;
      final PsiElement oldElement = moveRenameUsage.getReferencedElement();
      final PsiElement newElement = oldToNewMap.get(oldElement);
      final PsiReference reference = moveRenameUsage.getReference();
      if (reference != null) {
        try {
          LOG.assertTrue(newElement != null, oldElement != null ? oldElement : reference);
          reference.bindToElement(newElement);
        } catch (IncorrectOperationException ex) {
          LOG.error(ex);
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:MoveJavaFileHandler.java


示例4: findUsages

import com.intellij.refactoring.util.MoveRenameUsageInfo; //导入依赖的package包/类
public static UsageInfo[] findUsages(final PsiElement element,
                                     boolean searchInStringsAndComments,
                                     boolean searchInNonJavaFiles,
                                     final String newQName) {
  PsiManager manager = element.getManager();

  ArrayList<UsageInfo> results = new ArrayList<UsageInfo>();
  Set<PsiReference> foundReferences = new HashSet<PsiReference>();

  GlobalSearchScope projectScope = GlobalSearchScope.projectScope(manager.getProject());
  for (PsiReference reference : ReferencesSearch.search(element, projectScope, false)) {
    TextRange range = reference.getRangeInElement();
    if (foundReferences.contains(reference)) continue;
    results.add(new MoveRenameUsageInfo(reference.getElement(), reference, range.getStartOffset(), range.getEndOffset(), element, false));
    foundReferences.add(reference);
  }

  findNonCodeUsages(searchInStringsAndComments, searchInNonJavaFiles, element, newQName, results);
  preprocessUsages(results);
  return results.toArray(new UsageInfo[results.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:MoveClassesOrPackagesUtil.java


示例5: filterUsages

import com.intellij.refactoring.util.MoveRenameUsageInfo; //导入依赖的package包/类
protected List<UsageInfo> filterUsages(List<UsageInfo> infos) {
  Map<PsiElement, MoveRenameUsageInfo> moveRenameInfos = new HashMap<PsiElement, MoveRenameUsageInfo>();
  Set<PsiElement> usedElements = new HashSet<PsiElement>();

  List<UsageInfo> result = new ArrayList<UsageInfo>(infos.size() / 2);
  for (UsageInfo info : infos) {
    LOG.assertTrue(info != null, getClass());
    PsiElement element = info.getElement();
    if (info instanceof MoveRenameUsageInfo) {
      if (usedElements.contains(element)) continue;
      moveRenameInfos.put(element, (MoveRenameUsageInfo)info);
    }
    else {
      moveRenameInfos.remove(element);
      usedElements.add(element);
      if (!(info instanceof PossiblyIncorrectUsage) || ((PossiblyIncorrectUsage)info).isCorrect()) {
        result.add(info);
      }
    }
  }
  result.addAll(moveRenameInfos.values());
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:ChangeSignatureProcessorBase.java


示例6: retargetUsages

import com.intellij.refactoring.util.MoveRenameUsageInfo; //导入依赖的package包/类
@Override
public void retargetUsages(List<UsageInfo> usageInfos, Map<PsiElement, PsiElement> oldToNewMap) {
  for (UsageInfo usage : usageInfos) {
    if (usage instanceof MoveRenameUsageInfo) {
      final MoveRenameUsageInfo moveRenameUsage = (MoveRenameUsageInfo)usage;
      final PsiElement oldElement = moveRenameUsage.getReferencedElement();
      final PsiElement newElement = oldToNewMap.get(oldElement);
      final PsiReference reference = moveRenameUsage.getReference();
      if (reference != null) {
        try {
          LOG.assertTrue(newElement != null, oldElement != null ? oldElement : reference);
          reference.bindToElement(newElement);
        }
        catch (IncorrectOperationException ex) {
          LOG.error(ex);
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:MoveGroovyFileHandler.java


示例7: groupUsage

import com.intellij.refactoring.util.MoveRenameUsageInfo; //导入依赖的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


示例8: findInstancesOfPackageLocal

import com.intellij.refactoring.util.MoveRenameUsageInfo; //导入依赖的package包/类
private static void findInstancesOfPackageLocal(final PsiClass aClass,
                                         final UsageInfo[] usages,
                                         final MyClassInstanceReferenceVisitor instanceReferenceVisitor) {
  ClassReferenceScanner referenceScanner = new ClassReferenceScanner(aClass) {
    public PsiReference[] findReferences() {
      ArrayList<PsiReference> result = new ArrayList<PsiReference>();
      for (UsageInfo usage : usages) {
        if (usage instanceof MoveRenameUsageInfo && ((MoveRenameUsageInfo)usage).getReferencedElement() == aClass) {
          final PsiReference reference = usage.getReference();
          if (reference != null) {
            result.add(reference);
          }
        }
      }
      return result.toArray(new PsiReference[result.size()]);
    }
  };
  referenceScanner.processReferences(new ClassInstanceScanner(aClass, instanceReferenceVisitor));
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:20,代码来源:MoveClassesOrPackagesProcessor.java


示例9: storeTypeManifoldReferences

import com.intellij.refactoring.util.MoveRenameUsageInfo; //导入依赖的package包/类
private void storeTypeManifoldReferences( @NotNull PsiElement element )
{
  Module mod = ModuleUtilCore.findModuleForPsiElement( element );
  if( mod == null )
  {
    return;
  }

  ManModule module = ManProject.getModule( mod );

  PsiClass psiClass = findPsiClass( (PsiFileSystemItem)element, module );
  if( psiClass == null )
  {
    return;
  }

  Query<PsiReference> search = ReferencesSearch.search( psiClass, GlobalSearchScope.projectScope( mod.getProject() ) );
  List<UsageInfo> usages = new ArrayList<>();
  for( PsiReference ref: search.findAll() )
  {
    usages.add( new MoveRenameUsageInfo( ref.getElement(), ref, ref.getRangeInElement().getStartOffset(),
      ref.getRangeInElement().getEndOffset(), element,
      ref.resolve() == null && !(ref instanceof PsiPolyVariantReference && ((PsiPolyVariantReference)ref).multiResolve( true ).length > 0) ) );
  }
  _usages = usages;

  if( psiClass instanceof ManifoldPsiClass )
  {
    PsiElement fakeElement = ManGotoDeclarationHandler.find( psiClass, (ManifoldPsiClass)psiClass );
    if( fakeElement instanceof PsiNamedElement && isTopLevelClassDeclaration( fakeElement ) )
    {
      _classDeclElement = (PsiNamedElement)fakeElement;
    }
  }
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:36,代码来源:RenameTypeManifoldFileProcessor.java


示例10: findCollisions

import com.intellij.refactoring.util.MoveRenameUsageInfo; //导入依赖的package包/类
public void findCollisions(final PsiElement element, final String newName, final Map<? extends PsiElement, String> allRenames, final List<UsageInfo> result) {
  final PsiClass aClass = (PsiClass)element;
  final ClassCollisionsDetector classCollisionsDetector = new ClassCollisionsDetector(aClass);
  Collection<UsageInfo> initialResults = new ArrayList<UsageInfo>(result);
  for(UsageInfo usageInfo: initialResults) {
    if (usageInfo instanceof MoveRenameUsageInfo) {
      classCollisionsDetector.addClassCollisions(usageInfo.getElement(), newName, result);
    }
  }
  findSubmemberHidesMemberCollisions(aClass, newName, result);

  if (aClass instanceof PsiTypeParameter) {
    final PsiTypeParameterListOwner owner = ((PsiTypeParameter)aClass).getOwner();
    if (owner != null) {
      for (PsiTypeParameter typeParameter : owner.getTypeParameters()) {
        if (Comparing.equal(newName, typeParameter.getName())) {
          result.add(new UnresolvableCollisionUsageInfo(aClass, typeParameter) {
            @Override
            public String getDescription() {
              return "There is already type parameter in " + RefactoringUIUtil.getDescription(aClass, false) + " with name " + newName;
            }
          });
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:RenameJavaClassProcessor.java


示例11: testAllUsagesInCode

import com.intellij.refactoring.util.MoveRenameUsageInfo; //导入依赖的package包/类
public void testAllUsagesInCode() throws Exception {
  configureByFile(BASE_PATH + getTestName(false) + ".java");
  PsiElement element = TargetElementUtil
      .findTargetElement(myEditor, TargetElementUtil.ELEMENT_NAME_ACCEPTED | TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED);
  assertNotNull(element);
  final UsageInfo[] usageInfos = RenameUtil.findUsages(element, "newName", true, true, new HashMap<>());
  assertSize(1, usageInfos);
  for (UsageInfo usageInfo : usageInfos) {
    assertTrue(usageInfo instanceof MoveRenameUsageInfo);
    assertFalse(usageInfo.isNonCodeUsage);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:RenameCollisionsTest.java


示例12: classifyUsages

import com.intellij.refactoring.util.MoveRenameUsageInfo; //导入依赖的package包/类
public static MultiMap<PsiElement, UsageInfo> classifyUsages(Collection<? extends PsiElement> elements, UsageInfo[] usages) {
  final MultiMap<PsiElement, UsageInfo> result = new MultiMap<PsiElement, UsageInfo>();
  for (UsageInfo usage : usages) {
    LOG.assertTrue(usage instanceof MoveRenameUsageInfo);
    if (usage.getReference() instanceof LightElement) {
      continue; //filter out implicit references (e.g. from derived class to super class' default constructor)
    }
    MoveRenameUsageInfo usageInfo = (MoveRenameUsageInfo)usage;
    if (usage instanceof RelatedUsageInfo) {
      final PsiElement relatedElement = ((RelatedUsageInfo)usage).getRelatedElement();
      if (elements.contains(relatedElement)) {
        result.putValue(relatedElement, usage);
      }
    } else {
      PsiElement referenced = usageInfo.getReferencedElement();
      if (elements.contains(referenced)) {
        result.putValue(referenced, usage);
      } else if (referenced != null) {
        PsiElement indirect = referenced.getNavigationElement();
        if (elements.contains(indirect)) {
          result.putValue(indirect, usage);
        }
      }

    }
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:RenameProcessor.java


示例13: extractUsagesForElement

import com.intellij.refactoring.util.MoveRenameUsageInfo; //导入依赖的package包/类
private static UsageInfo[] extractUsagesForElement(PsiElement element, UsageInfo[] usages) {
  final ArrayList<UsageInfo> extractedUsages = new ArrayList<UsageInfo>(usages.length);
  for (UsageInfo usage : usages) {
    if (usage instanceof MoveRenameUsageInfo) {
      MoveRenameUsageInfo usageInfo = (MoveRenameUsageInfo)usage;
      if (element.equals(usageInfo.getReferencedElement())) {
        extractedUsages.add(usageInfo);
      }
    }
  }
  return extractedUsages.toArray(new UsageInfo[extractedUsages.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:InvertBooleanProcessor.java


示例14: findCollisions

import com.intellij.refactoring.util.MoveRenameUsageInfo; //导入依赖的package包/类
@Override
public void findCollisions(PsiElement element,
                           String newName,
                           Map<? extends PsiElement, String> allRenames,
                           List<UsageInfo> result) {
  List<UsageInfo> collisions = new ArrayList<UsageInfo>();

  for (UsageInfo info : result) {
    if (!(info instanceof MoveRenameUsageInfo)) continue;
    final PsiElement infoElement = info.getElement();
    final PsiElement referencedElement = ((MoveRenameUsageInfo)info).getReferencedElement();

    if (!(infoElement instanceof GrReferenceExpression)) continue;

    final GrReferenceExpression refExpr = (GrReferenceExpression)infoElement;

    if (!(referencedElement instanceof GrField || refExpr.advancedResolve().isInvokedOnProperty())) continue;

    if (!(refExpr.getParent() instanceof GrCall)) continue;

    final PsiType[] argTypes = PsiUtil.getArgumentTypes(refExpr, false);
    final PsiType[] typeArguments = refExpr.getTypeArguments();
    final MethodResolverProcessor processor =
      new MethodResolverProcessor(newName, refExpr, false, null, argTypes, typeArguments);
    final PsiMethod resolved = ResolveUtil.resolveExistingElement(refExpr, processor, PsiMethod.class);
    if (resolved == null) continue;

    collisions.add(new UnresolvableCollisionUsageInfo(resolved, refExpr) {
      @Override
      public String getDescription() {
        return GroovyRefactoringBundle.message("usage.will.be.overriden.by.method", refExpr.getParent().getText(), PsiFormatUtil
          .formatMethod(resolved, PsiSubstitutor.EMPTY, PsiFormatUtilBase.SHOW_NAME, PsiFormatUtilBase.SHOW_TYPE));
      }
    });
  }
  result.addAll(collisions);
  super.findCollisions(element, newName, allRenames, result);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:RenameGrFieldProcessor.java


示例15: testAllUsagesInCode

import com.intellij.refactoring.util.MoveRenameUsageInfo; //导入依赖的package包/类
public void testAllUsagesInCode() throws Exception {
  configureByFile(BASE_PATH + getTestName(false) + ".java");
  PsiElement element = TargetElementUtilBase
      .findTargetElement(myEditor, TargetElementUtilBase.ELEMENT_NAME_ACCEPTED | TargetElementUtilBase.REFERENCED_ELEMENT_ACCEPTED);
  assertNotNull(element);
  final UsageInfo[] usageInfos = RenameUtil.findUsages(element, "newName", true, true, new HashMap<PsiElement, String>());
  assertSize(1, usageInfos);
  for (UsageInfo usageInfo : usageInfos) {
    assertTrue(usageInfo instanceof MoveRenameUsageInfo);
    assertFalse(usageInfo.isNonCodeUsage);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:13,代码来源:RenameCollisionsTest.java


示例16: classifyUsages

import com.intellij.refactoring.util.MoveRenameUsageInfo; //导入依赖的package包/类
public static MultiMap<PsiElement, UsageInfo> classifyUsages(Collection<? extends PsiElement> elements, UsageInfo[] usages) {
  final MultiMap<PsiElement, UsageInfo> result = new MultiMap<>();
  for (UsageInfo usage : usages) {
    LOG.assertTrue(usage instanceof MoveRenameUsageInfo);
    if (usage.getReference() instanceof LightElement) {
      continue; //filter out implicit references (e.g. from derived class to super class' default constructor)
    }
    MoveRenameUsageInfo usageInfo = (MoveRenameUsageInfo)usage;
    if (usage instanceof RelatedUsageInfo) {
      final PsiElement relatedElement = ((RelatedUsageInfo)usage).getRelatedElement();
      if (elements.contains(relatedElement)) {
        result.putValue(relatedElement, usage);
      }
    } else {
      PsiElement referenced = usageInfo.getReferencedElement();
      if (elements.contains(referenced)) {
        result.putValue(referenced, usage);
      } else if (referenced != null) {
        PsiElement indirect = referenced.getNavigationElement();
        if (elements.contains(indirect)) {
          result.putValue(indirect, usage);
        }
      }

    }
  }
  return result;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:29,代码来源:RenameProcessor.java


示例17: testAllUsagesInCode

import com.intellij.refactoring.util.MoveRenameUsageInfo; //导入依赖的package包/类
public void testAllUsagesInCode() throws Exception {
  configureByFile(BASE_PATH + getTestName(false) + ".java");
  PsiElement element = TargetElementUtil
      .findTargetElement(myEditor, ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED, TargetElementUtilEx.REFERENCED_ELEMENT_ACCEPTED));
  assertNotNull(element);
  final UsageInfo[] usageInfos = RenameUtil.findUsages(element, "newName", true, true, new HashMap<PsiElement, String>());
  assertSize(1, usageInfos);
  for (UsageInfo usageInfo : usageInfos) {
    assertTrue(usageInfo instanceof MoveRenameUsageInfo);
    assertFalse(usageInfo.isNonCodeUsage);
  }
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:13,代码来源:RenameCollisionsTest.java


示例18: retargetUsages

import com.intellij.refactoring.util.MoveRenameUsageInfo; //导入依赖的package包/类
public static NonCodeUsageInfo[] retargetUsages(final UsageInfo[] usages, final Map<PsiElement, PsiElement> oldToNewElementsMapping)
  throws IncorrectOperationException {
  Arrays.sort(usages, new Comparator<UsageInfo>() {
    @Override
    public int compare(UsageInfo o1, UsageInfo o2) {
      final VirtualFile file1 = o1.getVirtualFile();
      final VirtualFile file2 = o2.getVirtualFile();
      if (Comparing.equal(file1, file2)) {
        final ProperTextRange rangeInElement1 = o1.getRangeInElement();
        final ProperTextRange rangeInElement2 = o2.getRangeInElement();
        if (rangeInElement1 != null && rangeInElement2 != null) {
          return rangeInElement2.getStartOffset() - rangeInElement1.getStartOffset();
        }
        return 0;
      }
      if (file1 == null) return -1;
      if (file2 == null) return 1;
      return Comparing.compare(file1.getPath(), file2.getPath());
    }
  });
  List<NonCodeUsageInfo> nonCodeUsages = new ArrayList<NonCodeUsageInfo>();
  for (UsageInfo usage : usages) {
    if (usage instanceof NonCodeUsageInfo) {
      nonCodeUsages.add((NonCodeUsageInfo)usage);
    }
    else if (usage instanceof MoveRenameUsageInfo) {
      final MoveRenameUsageInfo moveRenameUsage = (MoveRenameUsageInfo)usage;
      final PsiElement oldElement = moveRenameUsage.getReferencedElement();
      final PsiElement newElement = oldToNewElementsMapping.get(oldElement);
      LOG.assertTrue(newElement != null, oldElement);
      final PsiReference reference = moveRenameUsage.getReference();
      if (reference != null) {
        try {
          reference.bindToElement(newElement);
        }
        catch (IncorrectOperationException e) {//
        }
      }
    }
  }
  return nonCodeUsages.toArray(new NonCodeUsageInfo[nonCodeUsages.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:43,代码来源:CommonMoveUtil.java


示例19: createPresentation

import com.intellij.refactoring.util.MoveRenameUsageInfo; //导入依赖的package包/类
@NotNull
private static UsageViewPresentation createPresentation(@NotNull UsageViewDescriptor descriptor, @NotNull Usage[] usages) {
  UsageViewPresentation presentation = new UsageViewPresentation();
  presentation.setTabText(RefactoringBundle.message("usageView.tabText"));
  presentation.setTargetsNodeText(descriptor.getProcessedElementsHeader());
  presentation.setShowReadOnlyStatusAsRed(true);
  presentation.setShowCancelButton(true);
  presentation.setUsagesString(RefactoringBundle.message("usageView.usagesText"));
  int codeUsageCount = 0;
  int nonCodeUsageCount = 0;
  int dynamicUsagesCount = 0;
  Set<PsiFile> codeFiles = new HashSet<PsiFile>();
  Set<PsiFile> nonCodeFiles = new HashSet<PsiFile>();
  Set<PsiFile> dynamicUsagesCodeFiles = new HashSet<PsiFile>();

  for (Usage usage : usages) {
    if (usage instanceof PsiElementUsage) {
      final PsiElementUsage elementUsage = (PsiElementUsage)usage;
      final PsiElement element = elementUsage.getElement();
      if (element == null) continue;
      final PsiFile containingFile = element.getContainingFile();
      if (elementUsage.isNonCodeUsage()) {
        nonCodeUsageCount++;
        nonCodeFiles.add(containingFile);
      }
      else {
        codeUsageCount++;
        codeFiles.add(containingFile);
      }
      if (usage instanceof UsageInfo2UsageAdapter) {
        final UsageInfo usageInfo = ((UsageInfo2UsageAdapter)usage).getUsageInfo();
        if (usageInfo instanceof MoveRenameUsageInfo && usageInfo.isDynamicUsage()) {
          dynamicUsagesCount++;
          dynamicUsagesCodeFiles.add(containingFile);
        }
      }
    }
  }
  codeFiles.remove(null);
  nonCodeFiles.remove(null);
  dynamicUsagesCodeFiles.remove(null);

  String codeReferencesText = descriptor.getCodeReferencesText(codeUsageCount, codeFiles.size());
  presentation.setCodeUsagesString(codeReferencesText);
  final String commentReferencesText = descriptor.getCommentReferencesText(nonCodeUsageCount, nonCodeFiles.size());
  if (commentReferencesText != null) {
    presentation.setNonCodeUsagesString(commentReferencesText);
  }
  presentation.setDynamicUsagesString("Dynamic " + StringUtil.decapitalize(descriptor.getCodeReferencesText(dynamicUsagesCount, dynamicUsagesCodeFiles.size())));
  String generatedCodeString;
  if (codeReferencesText.contains("in code")) {
    generatedCodeString = StringUtil.replace(codeReferencesText, "in code", "in generated code");
  }
  else {
    generatedCodeString = codeReferencesText + " in generated code";
  }
  presentation.setUsagesInGeneratedCodeString(generatedCodeString);
  return presentation;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:60,代码来源:BaseRefactoringProcessor.java


示例20: createPresentation

import com.intellij.refactoring.util.MoveRenameUsageInfo; //导入依赖的package包/类
private static UsageViewPresentation createPresentation(UsageViewDescriptor descriptor, final Usage[] usages) {
  UsageViewPresentation presentation = new UsageViewPresentation();
  presentation.setTabText(RefactoringBundle.message("usageView.tabText"));
  presentation.setTargetsNodeText(descriptor.getProcessedElementsHeader());
  presentation.setShowReadOnlyStatusAsRed(true);
  presentation.setShowCancelButton(true);
  presentation.setUsagesString(RefactoringBundle.message("usageView.usagesText"));
  int codeUsageCount = 0;
  int nonCodeUsageCount = 0;
  int dynamicUsagesCount = 0;
  Set<PsiFile> codeFiles = new HashSet<PsiFile>();
  Set<PsiFile> nonCodeFiles = new HashSet<PsiFile>();
  Set<PsiFile> dynamicUsagesCodeFiles = new HashSet<PsiFile>();

  for (Usage usage : usages) {
    if (usage instanceof PsiElementUsage) {
      final PsiElementUsage elementUsage = (PsiElementUsage)usage;
      final PsiElement element = elementUsage.getElement();
      if (element == null) continue;
      final PsiFile containingFile = element.getContainingFile();
      if (elementUsage.isNonCodeUsage()) {
        nonCodeUsageCount++;
        nonCodeFiles.add(containingFile);
      }
      else {
        codeUsageCount++;
        codeFiles.add(containingFile);
      }
      if (usage instanceof UsageInfo2UsageAdapter) {
        final UsageInfo usageInfo = ((UsageInfo2UsageAdapter)usage).getUsageInfo();
        if (usageInfo instanceof MoveRenameUsageInfo && usageInfo.isDynamicUsage()) {
          dynamicUsagesCount++;
          dynamicUsagesCodeFiles.add(containingFile);
        }
      }
    }
  }
  codeFiles.remove(null);
  nonCodeFiles.remove(null);
  dynamicUsagesCodeFiles.remove(null);

  presentation.setCodeUsagesString(descriptor.getCodeReferencesText(codeUsageCount, codeFiles.size()));
  presentation.setNonCodeUsagesString(descriptor.getCommentReferencesText(nonCodeUsageCount, nonCodeFiles.size()));
  presentation.setDynamicUsagesString("Dynamic " + StringUtil.decapitalize(descriptor.getCodeReferencesText(dynamicUsagesCount, dynamicUsagesCodeFiles.size())));
  return presentation;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:47,代码来源:BaseRefactoringProcessor.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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