当前位置: 首页>>代码示例>>Java>>正文


Java UsageInfo类代码示例

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


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

示例1: findUsages

import com.intellij.usageView.UsageInfo; //导入依赖的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: findJavaUsages

import com.intellij.usageView.UsageInfo; //导入依赖的package包/类
static Map<Pair<FeaturePath, PsiElement>, List<UsageInfo>> findJavaUsages( PsiElement element, List<PsiElement> javaElems )
{
  if( !(element instanceof PsiNamedElement) || javaElems.isEmpty() )
  {
    return Collections.emptyMap();
  }

  Map<Pair<FeaturePath, PsiElement>, List<UsageInfo>> allUsages = new HashMap<>();
  for( PsiElement javaElem : javaElems )
  {
    if( javaElem == null )
    {
      continue;
    }

    List<UsageInfo> usages = findUsages( javaElem, element );
    if( !usages.isEmpty() )
    {
      FeaturePath path = javaElem.getUserData( KEY_FEATURE_PATH );
      allUsages.put( new Pair<>( path, javaElem ), usages );
    }
  }

  return allUsages;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:26,代码来源:RenameResourceElementProcessor.java

示例3: findUsages

import com.intellij.usageView.UsageInfo; //导入依赖的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

示例4: filterImports

import com.intellij.usageView.UsageInfo; //导入依赖的package包/类
@Override
public List<PsiElement> filterImports(@NotNull List<UsageInfo> usageInfos, @NotNull Project project) {
  final List<PsiElement> importStatements = new ArrayList<PsiElement>();
  if (!CodeStyleSettingsManager.getSettings(project).INSERT_INNER_CLASS_IMPORTS) {
    filterUsagesInImportStatements(usageInfos, importStatements);
  }
  else {
    //rebind imports first
    Collections.sort(usageInfos, new Comparator<UsageInfo>() {
      public int compare(UsageInfo o1, UsageInfo o2) {
        return PsiUtil.BY_POSITION.compare(o1.getElement(), o2.getElement());
      }
    });
  }
  return importStatements;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:JavaMoveClassToInnerHandler.java

示例5: addResultFromReference

import com.intellij.usageView.UsageInfo; //导入依赖的package包/类
private static boolean addResultFromReference(@NotNull PsiReference reference,
                                              @NotNull PsiClass methodClass,
                                              @NotNull PsiManager manager,
                                              @NotNull PsiClass aClass,
                                              @NotNull FindUsagesOptions options,
                                              @NotNull Processor<UsageInfo> processor) {
  PsiElement refElement = reference.getElement();
  if (refElement instanceof PsiReferenceExpression) {
    PsiClass usedClass = getFieldOrMethodAccessedClass((PsiReferenceExpression)refElement, methodClass);
    if (usedClass != null) {
      if (manager.areElementsEquivalent(usedClass, aClass) || usedClass.isInheritor(aClass, true)) {
        if (!addResult(refElement, options, processor)) return false;
      }
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:JavaFindUsagesHelper.java

示例6: analyzeConflictsOnUsages

import com.intellij.usageView.UsageInfo; //导入依赖的package包/类
private static void analyzeConflictsOnUsages(UsageInfo[] usages,
                                             Set<PsiMember> membersToMove,
                                             String newVisibility,
                                             @NotNull PsiClass targetClass,
                                             Map<PsiMember, PsiModifierList> modifierListCopies,
                                             MultiMap<PsiElement, String> conflicts) {
  for (UsageInfo usage : usages) {
    if (!(usage instanceof MoveMembersUsageInfo)) continue;
    final MoveMembersUsageInfo usageInfo = (MoveMembersUsageInfo)usage;
    final PsiMember member = usageInfo.member;
    final MoveMemberHandler handler = MoveMemberHandler.EP_NAME.forLanguage(member.getLanguage());
    if (handler != null) {
      handler.checkConflictsOnUsage(usageInfo, newVisibility, modifierListCopies.get(member), targetClass, membersToMove, conflicts);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:MoveMembersProcessor.java

示例7: getUsageInfo

import com.intellij.usageView.UsageInfo; //导入依赖的package包/类
@Nullable
public UsageInfo getUsageInfo() {
  if (myElementAnchors.length == 1) {
    final PsiElement element = myElementAnchors[0].retrieve();
    if (element == null || !element.isValid()) return null;
    return new UsageInfo(element);
  }

  PsiElement parent = PsiTreeUtil.findCommonParent(getElements());
  if (parent == null) return null;
  int offs = parent.getTextRange().getStartOffset();

  final int startOffsetInParent = getStartOffset() - offs;
  final int endOffsetInParent = getEndOffset() - offs;
  if (startOffsetInParent < 0) return null;
  if (endOffsetInParent < startOffsetInParent) return null;
  return new UsageInfo(parent, startOffsetInParent, endOffsetInParent);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:PsiFragment.java

示例8: findUsages

import com.intellij.usageView.UsageInfo; //导入依赖的package包/类
@NotNull
protected UsageInfo[] findUsages() {
  ArrayList<UsageInfo> usages = new ArrayList<UsageInfo>();
  final PsiClass[] inheritors = ClassInheritorsSearch.search(myClass, true).toArray(PsiClass.EMPTY_ARRAY);
  myClassInheritors = new HashSet<PsiClass>();
  myClassInheritors.add(myClass);
  addAll(myClassInheritors, inheritors);

  {
    ClassReferenceScanner scanner = new ClassReferenceSearchingScanner(myClass);
    final MyClassInstanceReferenceVisitor instanceReferenceVisitor = new MyClassInstanceReferenceVisitor(myClass, usages);
    scanner.processReferences(new ClassInstanceScanner(myClass, instanceReferenceVisitor));

    MyClassMemberReferencesVisitor visitor = new MyClassMemberReferencesVisitor(usages, instanceReferenceVisitor);
    myClass.accept(visitor);

    myClassImplementedInterfaces = instanceReferenceVisitor.getImplementedInterfaces();
  }
  for (PsiClass inheritor : inheritors) {
    processClass(inheritor, usages);
  }

  return usages.toArray(new UsageInfo[usages.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:InheritanceToDelegationProcessor.java

示例9: testFindInPathInLibrarySourceDirShouldSearchJustInThisDirectoryOnly

import com.intellij.usageView.UsageInfo; //导入依赖的package包/类
public void testFindInPathInLibrarySourceDirShouldSearchJustInThisDirectoryOnly() throws Exception {
  FindModel model = new FindModel();
  final PsiClass aClass = myJavaFacade.findClass("x.X");
  assertNotNull(aClass);
  String classDirPath = aClass.getContainingFile().getContainingDirectory().getVirtualFile().getPath();
  String sourceDirPath = ((PsiFile)aClass.getContainingFile().getNavigationElement()).getContainingDirectory().getVirtualFile().getPath();
  assertFalse(classDirPath.equals(sourceDirPath));
  model.setDirectoryName(sourceDirPath);
  model.setCaseSensitive(true);
  model.setCustomScope(false);
  model.setStringToFind("xxx");
  model.setProjectScope(false);

  List<UsageInfo> usages = new ArrayList<>();
  FindInProjectUtil.findUsages(model, getProject(),
                               new CommonProcessors.CollectProcessor<>(
                                 usages), FindInProjectUtil
                                 .setupProcessPresentation(getProject(), false, FindInProjectUtil.setupViewPresentation(false, model)));

  UsageInfo info = assertOneElement(usages);
  assertEquals("X.java", info.getFile().getName());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:SearchInLibsTest.java

示例10: getConflictMessage

import com.intellij.usageView.UsageInfo; //导入依赖的package包/类
@Override
public String getConflictMessage() {
  final MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>();
  final PsiElement element = getElement();
  if (element instanceof PsiMethodCallExpression) {
    PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)element;
    final PsiMethod superConstructor = methodCallExpression.resolveMethod();
    if (superConstructor != null) {
      InlineMethodProcessor.addInaccessibleMemberConflicts(superConstructor, new UsageInfo[]{new UsageInfo(methodCallExpression.getMethodExpression())}, new ReferencedElementsCollector(){
        @Override
        protected void checkAddMember(@NotNull PsiMember member) {
          if (!PsiTreeUtil.isAncestor(superConstructor.getContainingClass(), member, false)) {
            super.checkAddMember(member);
          }
        }
      }, conflicts);
      if (InlineMethodProcessor.checkBadReturns(superConstructor) && !InlineUtil.allUsagesAreTailCalls(superConstructor)) {
        conflicts.putValue(superConstructor, CommonRefactoringUtil.capitalize(RefactoringBundle.message("refactoring.is.not.supported.when.return.statement.interrupts.the.execution.flow", "") + " of super constructor"));
      }
    }
  }
  return conflicts.isEmpty() ? null : conflicts.values().iterator().next(); //todo
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:InlineSuperCallUsageInfo.java

示例11: rename

import com.intellij.usageView.UsageInfo; //导入依赖的package包/类
private static void rename(PsiNamedElement element,
                           UsageInfo info,
                           String nameToUse,
                           boolean shouldCheckForCorrectResolve,
                           PsiManager manager) {
  final PsiReference ref = info.getReference();
  final PsiElement renamed = ((GrReferenceExpression)ref).handleElementRenameSimple(nameToUse);
  PsiElement newly_resolved = ref.resolve();
  if (shouldCheckForCorrectResolve) {
    if (element instanceof GrAccessorMethod && newly_resolved instanceof GrAccessorMethod) {
      final GrAccessorMethod oldAccessor = (GrAccessorMethod)element;
      final GrAccessorMethod newAccessor = (GrAccessorMethod)newly_resolved;
      if (!manager.areElementsEquivalent(oldAccessor.getProperty(), newAccessor.getProperty()) &&
          oldAccessor.isSetter() == newAccessor.isSetter()) {
        qualify(oldAccessor, renamed, nameToUse);
      }
    }
    else if (!manager.areElementsEquivalent(element, newly_resolved)) {
      qualify((PsiMember)element, renamed, nameToUse);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:RenameGrFieldProcessor.java

示例12: createUsageViewDescriptor

import com.intellij.usageView.UsageInfo; //导入依赖的package包/类
@NotNull
@Override
protected UsageViewDescriptor createUsageViewDescriptor(@NotNull UsageInfo[] usages) {
  return new UsageViewDescriptorAdapter() {
    @NotNull
    @Override
    public PsiElement[] getElements() {
      return new PsiElement[]{myHelper.getToSearchFor()};
    }

    @Override
    public String getProcessedElementsHeader() {
      return EXTRACT_CLOSURE;
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ExtractClosureProcessorBase.java

示例13: performRefactoring

import com.intellij.usageView.UsageInfo; //导入依赖的package包/类
protected void performRefactoring(@NotNull UsageInfo[] usages) {
  final PsiMigration psiMigration = PsiMigrationManager.getInstance(myProject).startMigration();
  LocalHistoryAction a = LocalHistory.getInstance().startAction(getCommandName());

  try {
    for (int i = 0; i < myMigrationMap.getEntryCount(); i++) {
      MigrationMapEntry entry = myMigrationMap.getEntryAt(i);
      if (entry.getType() == MigrationMapEntry.PACKAGE) {
        MigrationUtil.doPackageMigration(myProject, psiMigration, entry.getNewName(), usages);
      }
      if (entry.getType() == MigrationMapEntry.CLASS) {
        MigrationUtil.doClassMigration(myProject, psiMigration, entry.getNewName(), usages);
      }
    }

    for(RefactoringHelper helper: Extensions.getExtensions(RefactoringHelper.EP_NAME)) {
      Object preparedData = helper.prepareOperation(usages);
      //noinspection unchecked
      helper.performOperation(myProject, preparedData);
    }
  }
  finally {
    a.finish();
    psiMigration.finish();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:MigrationProcessor.java

示例14: createUsageViewDescriptor

import com.intellij.usageView.UsageInfo; //导入依赖的package包/类
@NotNull
@Override
protected final UsageViewDescriptor createUsageViewDescriptor(@NotNull UsageInfo[] usages) {
  return new UsageViewDescriptorAdapter() {
    @NotNull
    @Override
    public PsiElement[] getElements() {
      return new PsiElement[] {myFunction};
    }

    @Override
    public String getProcessedElementsHeader() {
      return getRefactoringName();
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:PyBaseMakeFunctionTopLevelProcessor.java

示例15: performRefactoring

import com.intellij.usageView.UsageInfo; //导入依赖的package包/类
@Override
protected void performRefactoring(@NotNull UsageInfo[] usages) {
  try {
    encodeRefs();
    if (myCreateClassDlg != null) { //usages.length == 0
      final PsiClass psiClass =
        CreateSubclassAction.createSubclass(myClass, myCreateClassDlg.getTargetDirectory(), myCreateClassDlg.getClassName());
      if (psiClass != null) {
        pushDownToClass(psiClass);
      }
    }
    for (UsageInfo usage : usages) {
      if (usage.getElement() instanceof PsiClass) {
        final PsiClass targetClass = (PsiClass)usage.getElement();
        pushDownToClass(targetClass);
      }
    }
    removeFromTargetClass();
  }
  catch (IncorrectOperationException e) {
    LOG.error(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:PushDownProcessor.java


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