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


Java UsageInfo.getReference方法代码示例

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


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

示例1: findInstancesOfPackageLocal

import com.intellij.usageView.UsageInfo; //导入方法依赖的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:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:MoveClassesOrPackagesProcessor.java

示例2: renameAll

import com.intellij.usageView.UsageInfo; //导入方法依赖的package包/类
private static void renameAll(PsiElement originalElement, UsageInfo[] infos, String newName,
                              String originalName) throws IncorrectOperationException {
  if (newName.equals(originalName)) return;
  Queue<PsiReference> queue = new Queue<PsiReference>(infos.length);
  for (UsageInfo info : infos) {
    if (info.getElement() == null) continue;
    PsiReference ref = info.getReference();
    if (ref == null) continue;
    queue.addLast(ref);
  }

  while(!queue.isEmpty()) {
    final PsiReference reference = queue.pullFirst();
    final PsiElement oldElement = reference.getElement();
    if (!oldElement.isValid() || oldElement == originalElement) continue;
    final PsiElement newElement = reference.handleElementRename(newName);
    if (!oldElement.isValid()) {
      for (PsiReference psiReference : ReferencesSearch.search(originalElement, new LocalSearchScope(newElement), false)) {
        queue.addLast(psiReference);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:RenameXmlAttributeProcessor.java

示例3: 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

示例4: preprocessUsages

import com.intellij.usageView.UsageInfo; //导入方法依赖的package包/类
@Override
public void preprocessUsages(Collection<UsageInfo> results) {
  //remove all alias-imported usages from collection
  for (Iterator<UsageInfo> iterator = results.iterator(); iterator.hasNext(); ) {
    UsageInfo info = iterator.next();
    if (info == null) {
      LOG.debug("info==null");
      continue;
    }
    final PsiReference ref = info.getReference();
    if (ref==null) continue;

    final PsiElement element = ref.getElement();
    if (!(element instanceof GrReferenceElement)) continue;

    final GroovyResolveResult resolveResult = ((GrReferenceElement)element).advancedResolve();
    final PsiElement context = resolveResult.getCurrentFileResolveContext();
    if (!(context instanceof GrImportStatement)) continue;

    if (!((GrImportStatement)context).isAliasedImport()) continue;

    iterator.remove();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:MoveGroovyClassHandler.java

示例5: convertUsagesToRefs

import com.intellij.usageView.UsageInfo; //导入方法依赖的package包/类
private static ArrayList<PsiReference> convertUsagesToRefs(UsageInfo[] usagesIn) {
  ArrayList<PsiReference> refs = new ArrayList<PsiReference>();
  for (UsageInfo info : usagesIn) {
    final PsiReference ref = info.getReference();
    if (ref != null) { //ref can be null if it is conflict usage info
      refs.add(ref);
    }
  }
  return refs;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:InlineMethodProcessor.java

示例6: classifyUsages

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

示例7: postProcessUsages

import com.intellij.usageView.UsageInfo; //导入方法依赖的package包/类
@Override
public void postProcessUsages(UsageInfo[] usages, Function<PsiDirectory, PsiDirectory> newDirMapper) {
  for (UsageInfo usage : usages) {
    if (usage instanceof MyUsageInfo) {
      PsiReference reference = usage.getReference();
      if (reference != null) {
        PsiFileSystemItem file = ((MyUsageInfo)usage).myFile;
        if (file instanceof PsiDirectory) {
          file = newDirMapper.fun((PsiDirectory)file);
        }
        reference.bindToElement(file);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:MoveDirectoryWithClassesHelper.java

示例8: renameElement

import com.intellij.usageView.UsageInfo; //导入方法依赖的package包/类
@Override
public void renameElement(final PsiElement element,
                          final String newName,
                          final UsageInfo[] usages,
                          @Nullable final RefactoringElementListener listener) {
  Preconditions.checkArgument(canProcessElement(element), "Element can't be renamed, call #canProcessElement first " + element);
  element.replace(PyElementGenerator.getInstance(element.getProject()).createStringLiteral((PyStringLiteralExpression)element, newName));
  for (final UsageInfo usage : usages) {
    final PsiReference reference = usage.getReference();
    if (reference != null) {
      reference.handleElementRename(newName);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:PyMagicLiteralRenameProcessor.java

示例9: detectConflicts

import com.intellij.usageView.UsageInfo; //导入方法依赖的package包/类
private static MultiMap<PsiElement, String> detectConflicts(UsageInfo[] usages) {
  final List<PsiElement> nonXmlUsages = new ArrayList<PsiElement>();
  final List<PsiElement> unsupportedUsages = new ArrayList<PsiElement>();
  final List<PsiElement> unambiguousUsages = new ArrayList<PsiElement>();
  final List<PsiElement> implicitlyInherited = new ArrayList<PsiElement>();

  for (UsageInfo usage : usages) {
    final PsiElement element = usage.getElement();
    if (element == null) continue;

    if (element.getLanguage() != XMLLanguage.INSTANCE) {
      nonXmlUsages.add(element);
      continue;
    }
    final XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class);
    StyleUsageData usageData = tag != null ? AndroidInlineUtil.getStyleUsageData(tag) : null;

    if (usageData == null) {
      if (usage.getReference() instanceof ResourceNameConverter.MyParentStyleReference) {
        implicitlyInherited.add(element);
      }
      else {
        unsupportedUsages.add(element);
      }
      continue;
    }

    if (usageData.getReference().computeTargetElements().length > 1) {
      unambiguousUsages.add(element);
    }
  }
  return AndroidInlineUtil.buildConflicts(nonXmlUsages, unambiguousUsages, unsupportedUsages, implicitlyInherited);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:AndroidInlineAllStyleUsagesProcessor.java

示例10: ignoreUsage

import com.intellij.usageView.UsageInfo; //导入方法依赖的package包/类
/**
 * We keep globs which reference the file directly (i.e. without wildcards), and remove all
 * indirect references for the purposes of the 'safe delete' action.
 */
private static boolean ignoreUsage(UsageInfo usage) {
  if (usage.getReference() instanceof GlobReference && usage instanceof SafeDeleteUsageInfo) {
    PsiElement referencedElement = ((SafeDeleteUsageInfo) usage).getReferencedElement();
    PsiFileSystemItem file = ResolveUtil.asFileSystemItemSearch(referencedElement);
    String relativePath = getBlazePackageRelativePathToFile(file);
    if (relativePath == null) {
      return false;
    }
    return !((GlobReference) usage.getReference())
        .matchesDirectly(relativePath, file.isDirectory());
  }
  return false;
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:18,代码来源:BuildFileSafeDeleteProcessor.java

示例11: rename

import com.intellij.usageView.UsageInfo; //导入方法依赖的package包/类
public static void rename(UsageInfo info, String newName) throws IncorrectOperationException {
  if (info.getElement() == null) return;
  PsiReference ref = info.getReference();
  if (ref == null) return;
  ref.handleElementRename(newName);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:RenameUtil.java


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