本文整理汇总了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));
}
示例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);
}
}
}
}
示例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);
}
}
}
示例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();
}
}
示例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;
}
示例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;
}
示例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);
}
}
}
}
示例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);
}
}
}
示例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);
}
示例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;
}
示例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);
}