本文整理汇总了Java中com.intellij.refactoring.util.FixableUsageInfo类的典型用法代码示例。如果您正苦于以下问题:Java FixableUsageInfo类的具体用法?Java FixableUsageInfo怎么用?Java FixableUsageInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FixableUsageInfo类属于com.intellij.refactoring.util包,在下文中一共展示了FixableUsageInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findUsages
import com.intellij.refactoring.util.FixableUsageInfo; //导入依赖的package包/类
public void findUsages(@NotNull List<FixableUsageInfo> usages) {
if (myUseExistingClass && existingClass != null) {
myExistingClassCompatibleConstructor = existingClassIsCompatible(existingClass, parameters);
}
findUsagesForMethod(method, usages, true);
if (myUseExistingClass && existingClass != null && !(paramsNeedingGetters.isEmpty() && paramsNeedingSetters.isEmpty())) {
usages.add(new AppendAccessorsUsageInfo(existingClass, myGenerateAccessors, paramsNeedingGetters, paramsNeedingSetters, parameters));
}
final PsiMethod[] overridingMethods = OverridingMethodsSearch.search(method, true).toArray(PsiMethod.EMPTY_ARRAY);
for (PsiMethod siblingMethod : overridingMethods) {
findUsagesForMethod(siblingMethod, usages, false);
}
if (myNewVisibility != null) {
usages.add(new BeanClassVisibilityUsageInfo(existingClass, usages.toArray(new UsageInfo[usages.size()]), myNewVisibility, myExistingClassCompatibleConstructor));
}
}
示例2: processUsagesForMethod
import com.intellij.refactoring.util.FixableUsageInfo; //导入依赖的package包/类
private void processUsagesForMethod(final boolean deleteMethodHierarchy, PsiMethod method, int[] paramPermutation, String getterName, PsiMethod delegatedMethod,
List<FixableUsageInfo> usages) {
for (PsiReference reference : ReferencesSearch.search(method)) {
final PsiElement referenceElement = reference.getElement();
final PsiMethodCallExpression call = (PsiMethodCallExpression)referenceElement.getParent();
final String access;
if (call.getMethodExpression().getQualifierExpression() == null) {
access = field.getName();
} else {
access = getterName + "()";
if (getter == null) {
getter = GenerateMembersUtil.generateGetterPrototype(field);
}
}
usages.add(new InlineDelegatingCall(call, paramPermutation, access, delegatedMethod.getName()));
}
if (deleteMethodHierarchy) {
usages.add(new DeleteMethod(method));
}
}
示例3: findUsages
import com.intellij.refactoring.util.FixableUsageInfo; //导入依赖的package包/类
public void findUsages(@NotNull List<FixableUsageInfo> usages) {
for (PsiField field : fields) {
findUsagesForField(field, usages);
usages.add(new RemoveField(field));
}
usages.addAll(myExtractEnumProcessor.findEnumConstantUsages(new ArrayList<FixableUsageInfo>(usages)));
for (PsiClass innerClass : innerClasses) {
findUsagesForInnerClass(innerClass, usages);
usages.add(new RemoveInnerClass(innerClass));
}
for (PsiMethod method : methods) {
if (method.hasModifierProperty(PsiModifier.STATIC)) {
findUsagesForStaticMethod(method, usages);
}
else {
findUsagesForMethod(method, usages);
}
}
}
示例4: findUsagesForInnerClass
import com.intellij.refactoring.util.FixableUsageInfo; //导入依赖的package包/类
private void findUsagesForInnerClass(PsiClass innerClass, List<FixableUsageInfo> usages) {
final PsiManager psiManager = innerClass.getManager();
final Project project = psiManager.getProject();
final GlobalSearchScope scope = GlobalSearchScope.allScope(project);
final Iterable<PsiReference> calls = ReferencesSearch.search(innerClass, scope);
final String innerName = innerClass.getQualifiedName();
assert innerName != null;
final String sourceClassQualifiedName = sourceClass.getQualifiedName();
assert sourceClassQualifiedName != null;
final String newInnerClassName = getQualifiedName() + innerName.substring(sourceClassQualifiedName.length());
boolean hasExternalReference = false;
for (PsiReference reference : calls) {
final PsiElement referenceElement = reference.getElement();
if (referenceElement instanceof PsiJavaCodeReferenceElement) {
if (!isInMovedElement(referenceElement)) {
usages.add(new ReplaceClassReference((PsiJavaCodeReferenceElement)referenceElement, newInnerClassName));
hasExternalReference = true;
}
}
}
if (hasExternalReference) {
innerClassesToMakePublic.add(innerClass);
}
}
示例5: findUsagesForInnerClass
import com.intellij.refactoring.util.FixableUsageInfo; //导入依赖的package包/类
private void findUsagesForInnerClass(PsiClass innerClass, List<FixableUsageInfo> usages) {
final PsiManager psiManager = innerClass.getManager();
final Project project = psiManager.getProject();
final GlobalSearchScope scope = GlobalSearchScope.allScope(project);
final Iterable<PsiReference> calls = ReferencesSearch.search(innerClass, scope);
final String innerName = innerClass.getQualifiedName();
assert innerName != null;
final String sourceClassQualifiedName = sourceClass.getQualifiedName();
assert sourceClassQualifiedName != null;
final String newInnerClassName = StringUtil.getQualifiedName(newPackageName, newClassName) + innerName.substring(sourceClassQualifiedName.length());
boolean hasExternalReference = false;
for (PsiReference reference : calls) {
final PsiElement referenceElement = reference.getElement();
if (referenceElement instanceof PsiJavaCodeReferenceElement) {
if (!isInMovedElement(referenceElement)) {
usages.add(new ReplaceClassReference((PsiJavaCodeReferenceElement)referenceElement, newInnerClassName));
hasExternalReference = true;
}
}
}
if (hasExternalReference) {
innerClassesToMakePublic.add(innerClass);
}
}
示例6: processUsagesForMethod
import com.intellij.refactoring.util.FixableUsageInfo; //导入依赖的package包/类
private void processUsagesForMethod(final boolean deleteMethodHierarchy, PsiMethod method, int[] paramPermutation, String getterName, PsiMethod delegatedMethod,
List<FixableUsageInfo> usages) {
for (PsiReference reference : ReferencesSearch.search(method)) {
final PsiElement referenceElement = reference.getElement();
final PsiMethodCallExpression call = (PsiMethodCallExpression)referenceElement.getParent();
final String access;
if (call.getMethodExpression().getQualifierExpression() == null) {
access = field.getName();
} else {
access = getterName + "()";
if (getter == null) {
getter = GenerateMembersUtil.generateGetterPrototype(field);
}
}
usages.add(new InlineDelegatingCall(call, paramPermutation, access, delegatedMethod.getName()));
}
if (deleteMethodHierarchy) {
usages.add(new DeleteMethod(method));
}
}
示例7: findUsages
import com.intellij.refactoring.util.FixableUsageInfo; //导入依赖的package包/类
public void findUsages(@NotNull List<FixableUsageInfo> usages)
{
for(PsiField field : fields)
{
findUsagesForField(field, usages);
usages.add(new RemoveField(field));
}
usages.addAll(myExtractEnumProcessor.findEnumConstantUsages(new ArrayList<FixableUsageInfo>(usages)));
for(PsiClass innerClass : innerClasses)
{
findUsagesForInnerClass(innerClass, usages);
usages.add(new RemoveInnerClass(innerClass));
}
for(PsiMethod method : methods)
{
if(method.hasModifierProperty(PsiModifier.STATIC))
{
findUsagesForStaticMethod(method, usages);
}
else
{
findUsagesForMethod(method, usages);
}
}
}
示例8: findUsages
import com.intellij.refactoring.util.FixableUsageInfo; //导入依赖的package包/类
@Override
public void findUsages(@NotNull List<FixableUsageInfo> usages) {
findUsagesForMethod(myMethod, usages);
for (PsiMethod overridingMethod : OverridingMethodsSearch.search(myMethod)) {
findUsagesForMethod(overridingMethod, usages);
}
}
示例9: findUsagesForMethod
import com.intellij.refactoring.util.FixableUsageInfo; //导入依赖的package包/类
private void findUsagesForMethod(PsiMethod psiMethod, List<FixableUsageInfo> usages) {
for (PsiReference reference : ReferencesSearch.search(psiMethod, psiMethod.getUseScope())) {
final PsiElement referenceElement = reference.getElement();
final PsiElement parent = referenceElement.getParent();
if (parent instanceof PsiCallExpression) {
usages.add(new UnwrapCall((PsiCallExpression)parent, myUnwrapMethodName));
}
}
final String returnType = calculateReturnTypeString();
usages.add(new ChangeReturnType(psiMethod, returnType));
psiMethod.accept(new ReturnSearchVisitor(usages, returnType));
}
示例10: preprocessUsages
import com.intellij.refactoring.util.FixableUsageInfo; //导入依赖的package包/类
@Override
protected boolean preprocessUsages(@NotNull final Ref<UsageInfo[]> refUsages) {
MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>();
if (myUseExistingClass) {
if (existingClass == null) {
conflicts.putValue(null, RefactorJBundle.message("cannot.perform.the.refactoring") + "Could not find the selected class");
}
if (myExistingClassCompatibleConstructor == null) {
conflicts.putValue(existingClass, RefactorJBundle.message("cannot.perform.the.refactoring") + "Selected class has no compatible constructors");
}
}
else {
if (existingClass != null) {
conflicts.putValue(existingClass,
RefactorJBundle.message("cannot.perform.the.refactoring") +
RefactorJBundle.message("there.already.exists.a.class.with.the.chosen.name"));
}
if (myMoveDestination != null) {
if (!myMoveDestination.isTargetAccessible(myProject, method.getContainingFile().getVirtualFile())) {
conflicts.putValue(method, "Created class won't be accessible");
}
}
}
for (UsageInfo usageInfo : refUsages.get()) {
if (usageInfo instanceof FixableUsageInfo) {
final String conflictMessage = ((FixableUsageInfo)usageInfo).getConflictMessage();
if (conflictMessage != null) {
conflicts.putValue(usageInfo.getElement(), conflictMessage);
}
}
}
return showConflicts(conflicts, refUsages.get());
}
示例11: findUsages
import com.intellij.refactoring.util.FixableUsageInfo; //导入依赖的package包/类
protected void findUsages(@NotNull final List<FixableUsageInfo> usages) {
final String builderQualifiedName = StringUtil.getQualifiedName(myPackageName, myClassName);
final PsiClass builderClass =
JavaPsiFacade.getInstance(myProject).findClass(builderQualifiedName, GlobalSearchScope.projectScope(myProject));
for (PsiMethod constructor : myConstructors) {
for (PsiReference reference : ReferencesSearch.search(constructor)) {
final PsiElement element = reference.getElement();
final PsiNewExpression newExpression = PsiTreeUtil.getParentOfType(element, PsiNewExpression.class);
if (newExpression != null && !PsiTreeUtil.isAncestor(builderClass, element, false)) {
usages.add(new ReplaceConstructorWithSettersChainInfo(newExpression, StringUtil.getQualifiedName(myPackageName, myClassName), myParametersMap));
}
}
}
}
示例12: findUsages
import com.intellij.refactoring.util.FixableUsageInfo; //导入依赖的package包/类
public void findUsages(@NotNull List<FixableUsageInfo> usages) {
for (final MemberInfo memberInfo : myDelegateMethodInfos) {
if (!memberInfo.isChecked()) continue;
final PsiMethod method = (PsiMethod)memberInfo.getMember();
final String getterName = GenerateMembersUtil.suggestGetterName(field);
final int[] paramPermutation = DelegationUtils.getParameterPermutation(method);
final PsiMethod delegatedMethod = DelegationUtils.getDelegatedMethod(method);
LOG.assertTrue(!DelegationUtils.isAbstract(method));
processUsagesForMethod(memberInfo.isToAbstract(), method, paramPermutation, getterName, delegatedMethod, usages);
}
}
示例13: findUsagesForMethod
import com.intellij.refactoring.util.FixableUsageInfo; //导入依赖的package包/类
private void findUsagesForMethod(PsiMethod method, List<FixableUsageInfo> usages) {
final PsiManager psiManager = method.getManager();
final Project project = psiManager.getProject();
final GlobalSearchScope scope = GlobalSearchScope.allScope(project);
final Iterable<PsiReference> calls = ReferencesSearch.search(method, scope);
for (PsiReference reference : calls) {
final PsiElement referenceElement = reference.getElement();
final PsiElement parent = referenceElement.getParent();
if (parent instanceof PsiMethodCallExpression) {
final PsiMethodCallExpression call = (PsiMethodCallExpression)parent;
if (isInMovedElement(call)) {
continue;
}
final PsiReferenceExpression methodExpression = call.getMethodExpression();
final PsiExpression qualifier = methodExpression.getQualifierExpression();
if (qualifier == null || qualifier instanceof PsiThisExpression) {
usages.add(new ReplaceThisCallWithDelegateCall(call, delegateFieldName));
}
delegationRequired = true;
}
}
if (!delegationRequired && MethodInheritanceUtils.hasSiblingMethods(method)) {
delegationRequired = true;
}
if (delegationRequired) {
usages.add(new MakeMethodDelegate(method, delegateFieldName));
}
else {
usages.add(new RemoveMethod(method));
}
}
示例14: findUsagesForStaticMethod
import com.intellij.refactoring.util.FixableUsageInfo; //导入依赖的package包/类
private void findUsagesForStaticMethod(PsiMethod method, List<FixableUsageInfo> usages) {
final PsiManager psiManager = method.getManager();
final Project project = psiManager.getProject();
final GlobalSearchScope scope = GlobalSearchScope.allScope(project);
final Iterable<PsiReference> calls = ReferencesSearch.search(method, scope);
final String fullyQualifiedName = getQualifiedName();
for (PsiReference reference : calls) {
final PsiElement referenceElement = reference.getElement();
final PsiElement parent = referenceElement.getParent();
if (parent instanceof PsiMethodCallExpression) {
final PsiMethodCallExpression call = (PsiMethodCallExpression)parent;
if (!isInMovedElement(call)) {
usages.add(new RetargetStaticMethodCall(call, fullyQualifiedName));
}
} else if (parent instanceof PsiImportStaticStatement) {
final PsiJavaCodeReferenceElement importReference = ((PsiImportStaticStatement)parent).getImportReference();
if (importReference != null) {
final PsiElement qualifier = importReference.getQualifier();
if (qualifier instanceof PsiJavaCodeReferenceElement) {
usages.add(new ReplaceClassReference((PsiJavaCodeReferenceElement)qualifier, fullyQualifiedName));
}
}
}
}
usages.add(new RemoveMethod(method));
}
示例15: findEnumConstantConflicts
import com.intellij.refactoring.util.FixableUsageInfo; //导入依赖的package包/类
public void findEnumConstantConflicts(final Ref<UsageInfo[]> refUsages) {
if (hasUsages2Migrate()) {
final List<UsageInfo> resolvableConflicts = new ArrayList<UsageInfo>();
for (UsageInfo failedUsage : myTypeMigrationProcessor.getLabeler().getFailedUsages()) {
final PsiElement element = failedUsage.getElement();
if (element instanceof PsiReferenceExpression) {
resolvableConflicts.add(new FixableUsageInfo(element) {
@Override
public void fixUsage() throws IncorrectOperationException {
final PsiReferenceExpression expression = (PsiReferenceExpression)element;
final String link = GenerateMembersUtil.suggestGetterName("value", expression.getType(), myProject) + "()";
MutationUtils.replaceExpression(expression.getReferenceName() + "." + link, expression);
}
});
} else if (element != null) {
resolvableConflicts.add(new ConflictUsageInfo(element, null));
}
}
if (!resolvableConflicts.isEmpty()) {
final List<UsageInfo> usageInfos = new ArrayList<UsageInfo>(Arrays.asList(refUsages.get()));
for (Iterator<UsageInfo> iterator = resolvableConflicts.iterator(); iterator.hasNext();) {
final UsageInfo conflict = iterator.next();
for (UsageInfo usageInfo : usageInfos) {
if (conflict.getElement() == usageInfo.getElement()) {
iterator.remove();
break;
}
}
}
resolvableConflicts.addAll(0, usageInfos);
refUsages.set(resolvableConflicts.toArray(new UsageInfo[resolvableConflicts.size()]));
}
}
}