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


Java ConflictsUtil类代码示例

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


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

示例1: checkMethodConflicts

import com.intellij.refactoring.util.ConflictsUtil; //导入依赖的package包/类
protected void checkMethodConflicts(MultiMap<PsiElement, String> conflicts) {
  PsiMethod prototype;
  try {
    PsiElementFactory factory = JavaPsiFacade.getInstance(myProject).getElementFactory();
    prototype = factory.createMethod(myNameField.getEnteredName().trim(), myReturnType);
    if (myTypeParameterList != null) prototype.getTypeParameterList().replace(myTypeParameterList);
    for (VariableData data : myInputVariables) {
      if (data.passAsParameter) {
        prototype.getParameterList().add(factory.createParameter(data.name, data.type));
      }
    }
    // set the modifiers with which the method is supposed to be created
    PsiUtil.setModifierProperty(prototype, PsiModifier.PRIVATE, true);
  } catch (IncorrectOperationException e) {
    return;
  }

  ConflictsUtil.checkMethodConflicts(myTargetClass, null, prototype, conflicts);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:ExtractMethodDialog.java

示例2: checkMethodConflicts

import com.intellij.refactoring.util.ConflictsUtil; //导入依赖的package包/类
protected void checkMethodConflicts(MultiMap<PsiElement, String> conflicts) {
  PsiMethod prototype;
  try {
    PsiElementFactory factory = JavaPsiFacade.getInstance(myProject).getElementFactory();
    prototype = factory.createMethod(myNameField.getText().trim(), myReturnType);
    if (myTypeParameterList != null) prototype.getTypeParameterList().replace(myTypeParameterList);
    for (VariableData data : myInputVariables) {
      if (data.passAsParameter) {
        prototype.getParameterList().add(factory.createParameter(data.name, data.type));
      }
    }
    // set the modifiers with which the method is supposed to be created
    PsiUtil.setModifierProperty(prototype, PsiModifier.PRIVATE, true);
  } catch (IncorrectOperationException e) {
    return;
  }

  ConflictsUtil.checkMethodConflicts(myTargetClass, null, prototype, conflicts);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:ExtractMethodDialog.java

示例3: visitPackageLocalMemberReference

import com.intellij.refactoring.util.ConflictsUtil; //导入依赖的package包/类
private void visitPackageLocalMemberReference(PsiJavaCodeReferenceElement qualified, PsiModifierListOwner member) {
  PsiElement container = ConflictsUtil.getContainer(qualified);
  HashSet<PsiElement> reportedContainers = myReportedElementToContainer.get(member);
  if (reportedContainers == null) {
    reportedContainers = new HashSet<PsiElement>();
    myReportedElementToContainer.put(member, reportedContainers);
  }

  if (!reportedContainers.contains(container)) {
    reportedContainers.add(container);
    if (!isInsideMoved(container)) {
      PsiFile containingFile = container.getContainingFile();
      if (containingFile != null) {
        PsiDirectory directory = containingFile.getContainingDirectory();
        if (directory != null) {
          PsiJavaPackage aPackage = JavaDirectoryService.getInstance().getPackage(directory);
          if (!myTargetPackage.equalToPackage(aPackage)) {
            String message = RefactoringBundle.message("0.will.be.inaccessible.from.1", RefactoringUIUtil.getDescription(member, true),
                                                  RefactoringUIUtil.getDescription(container, true));
            myConflicts.putValue(member, CommonRefactoringUtil.capitalize(message));
          }
        }
      }
    }
  }
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:27,代码来源:MoveClassesOrPackagesProcessor.java

示例4: findExistingNameConflicts

import com.intellij.refactoring.util.ConflictsUtil; //导入依赖的package包/类
@Override
public void findExistingNameConflicts(PsiElement element, String newName, MultiMap<PsiElement, String> conflicts) {
  if (element instanceof PsiCompiledElement) return;
  if (element instanceof PsiField) {
    PsiField refactoredField = (PsiField)element;
    if (newName.equals(refactoredField.getName())) return;
    ConflictsUtil.checkFieldConflicts(
      refactoredField.getContainingClass(),
      newName,
      conflicts
    );
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:RenameJavaVariableProcessor.java

示例5: findExistingNameConflicts

import com.intellij.refactoring.util.ConflictsUtil; //导入依赖的package包/类
public void findExistingNameConflicts(final PsiElement element, final String newName, final MultiMap<PsiElement, String> conflicts) {
  if (element instanceof PsiCompiledElement) return;
  final PsiMethod refactoredMethod = (PsiMethod)element;
  if (newName.equals(refactoredMethod.getName())) return;
  final PsiMethod prototype = getPrototypeWithNewName(refactoredMethod, newName);
  if (prototype == null) return;

  ConflictsUtil.checkMethodConflicts(
    refactoredMethod.getContainingClass(),
    refactoredMethod,
    prototype,
    conflicts);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:RenameJavaMethodProcessor.java

示例6: registerConflict

import com.intellij.refactoring.util.ConflictsUtil; //导入依赖的package包/类
private static void registerConflict(PsiJavaCodeReferenceElement reference,
                                     PsiElement resolved,
                                     HashMap<PsiElement, HashSet<PsiElement>> reported, MultiMap<PsiElement, String> conflicts) {
  final PsiElement container = ConflictsUtil.getContainer(reference);
  HashSet<PsiElement> containerSet = reported.get(container);
  if (containerSet == null) {
    containerSet = new HashSet<PsiElement>();
    reported.put(container, containerSet);
  }
  if (!containerSet.contains(resolved)) {
    containerSet.add(resolved);
    String placesDescription;
    if (containerSet.size() == 1) {
      placesDescription = RefactoringUIUtil.getDescription(resolved, true);
    } else {
      placesDescription = "<ol><li>" + StringUtil.join(containerSet, new Function<PsiElement, String>() {
        @Override
        public String fun(PsiElement element) {
          return RefactoringUIUtil.getDescription(element, true);
        }
      }, "</li><li>") + "</li></ol>";
    }
    String message = RefactoringBundle.message("0.will.become.inaccessible.from.1",
                                               placesDescription,
                                               RefactoringUIUtil.getDescription(container, true));
    conflicts.put(container, Collections.singletonList(message));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:MoveInnerProcessor.java

示例7: visitResolvedReference

import com.intellij.refactoring.util.ConflictsUtil; //导入依赖的package包/类
private void visitResolvedReference(PsiElement resolved, PsiJavaCodeReferenceElement reference) {
  if (resolved instanceof PsiModifierListOwner) {
    final PsiModifierList modifierList = ((PsiModifierListOwner)resolved).getModifierList();
    if (PsiModifier.PACKAGE_LOCAL.equals(VisibilityUtil.getVisibilityModifier(modifierList))) {
      PsiFile aFile = resolved.getContainingFile();
      if (aFile != null && !isInsideMoved(resolved)) {
        final PsiDirectory containingDirectory = aFile.getContainingDirectory();
        if (containingDirectory != null) {
          PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage(containingDirectory);
          if (aPackage != null && !myTargetPackage.equalToPackage(aPackage)) {
            HashSet<PsiElement> reportedRefs = myReported.get(resolved);
            if (reportedRefs == null) {
              reportedRefs = new HashSet<PsiElement>();
              myReported.put(resolved, reportedRefs);
            }
            PsiElement container = ConflictsUtil.getContainer(reference);
            if (!reportedRefs.contains(container)) {
              final String message = RefactoringBundle.message("0.uses.a.package.local.1",
                                                               RefactoringUIUtil.getDescription(container, true),
                                                               RefactoringUIUtil.getDescription(resolved, true));
              myConflicts.putValue(resolved, CommonRefactoringUtil.capitalize(message));
              reportedRefs.add(container);
            }
          }
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:PackageLocalsUsageCollector.java

示例8: addInaccessibilityDescriptions

import com.intellij.refactoring.util.ConflictsUtil; //导入依赖的package包/类
private void addInaccessibilityDescriptions(Set<UsageInfo> usages, MultiMap<PsiElement, String> conflictDescriptions)
  throws IncorrectOperationException {
  PsiMethod method = myChangeInfo.getMethod();
  PsiModifierList modifierList = (PsiModifierList)method.getModifierList().copy();
  VisibilityUtil.setVisibility(modifierList, myChangeInfo.getNewVisibility());

  for (Iterator<UsageInfo> iterator = usages.iterator(); iterator.hasNext();) {
    UsageInfo usageInfo = iterator.next();
    PsiElement element = usageInfo.getElement();
    if (element != null) {
      if (element instanceof GrReferenceExpression) {
        PsiClass accessObjectClass = null;
        GrExpression qualifier = ((GrReferenceExpression)element).getQualifierExpression();
        if (qualifier != null) {
          accessObjectClass = (PsiClass)PsiUtil.getAccessObjectClass(qualifier).getElement();
        }

        PsiResolveHelper helper = JavaPsiFacade.getInstance(element.getProject()).getResolveHelper();
        if (!helper.isAccessible(method, modifierList, element, accessObjectClass, null)) {
          String message =
            RefactoringBundle.message("0.with.1.visibility.is.not.accessible.from.2",
                                      RefactoringUIUtil.getDescription(method, true),
                                      myChangeInfo.getNewVisibility(),
                                      RefactoringUIUtil.getDescription(ConflictsUtil.getContainer(element), true));
          conflictDescriptions.putValue(method, message);
          if (!needToChangeCalls()) {
            iterator.remove();
          }
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:GrChangeSignatureConflictSearcher.java

示例9: addMethodConflicts

import com.intellij.refactoring.util.ConflictsUtil; //导入依赖的package包/类
private void addMethodConflicts(MultiMap<PsiElement, String> conflicts) {
  try {
    GrMethod prototype;
    final PsiMethod method = myChangeInfo.getMethod();
    if (!(method instanceof GrMethod)) return;

    PsiManager manager = method.getManager();
    GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(manager.getProject());
    final CanonicalTypes.Type returnType = myChangeInfo.getNewReturnType();
    String newMethodName = myChangeInfo.getNewName();
    if (method.isConstructor()) {
      prototype = factory.createConstructorFromText("foo", ArrayUtil.EMPTY_STRING_ARRAY, ArrayUtil.EMPTY_STRING_ARRAY, "{}", method);
    }
    else {
      prototype = factory.createMethodFromText("", "foo", returnType != null ? returnType.getTypeText() : null, ArrayUtil.EMPTY_STRING_ARRAY, method);
    }
    prototype.setName(newMethodName);

    JavaParameterInfo[] parameters = myChangeInfo.getNewParameters();

    for (JavaParameterInfo info : parameters) {
      GrParameter param;
      if (info instanceof GrParameterInfo) {
        param = factory.createParameter(info.getName(), info.getTypeText(), ((GrParameterInfo)info).getDefaultInitializer(), (GroovyPsiElement)method);
      }
      else {
        param = factory.createParameter(info.getName(), info.getTypeText(), (GroovyPsiElement)method);
      }
      prototype.getParameterList().add(param);
    }

    ConflictsUtil.checkMethodConflicts(method.getContainingClass(), method, prototype, conflicts);
    GrMethodConflictUtil.checkMethodConflicts(method.getContainingClass(), prototype, ((GrMethod)method), conflicts, true);
  }
  catch (IncorrectOperationException e) {
    LOG.error(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:GrChangeSignatureConflictSearcher.java

示例10: detectAccessibilityConflicts

import com.intellij.refactoring.util.ConflictsUtil; //导入依赖的package包/类
public static void detectAccessibilityConflicts(@Nullable GroovyPsiElement elementToProcess,
                                                final UsageInfo[] usages,
                                                MultiMap<PsiElement, String> conflicts,
                                                boolean replaceFieldsWithGetters,
                                                Project project) {
  if (elementToProcess == null) return;

  final ReferencedElementsCollector collector = new ReferencedElementsCollector();
  elementToProcess.accept(collector);
  final List<PsiElement> result = collector.getResult();
  if (result.isEmpty()) return;

  for (final UsageInfo usageInfo : usages) {
    if (!(usageInfo instanceof ExternalUsageInfo) || !IntroduceParameterUtil.isMethodUsage(usageInfo)) continue;

    final PsiElement place = usageInfo.getElement();
    for (PsiElement element : result) {
      if (element instanceof PsiField && replaceFieldsWithGetters) {
        //check getter access instead
        final PsiClass psiClass = ((PsiField)element).getContainingClass();
        LOG.assertTrue(psiClass != null);
        final PsiMethod method = GroovyPropertyUtils.findGetterForField((PsiField)element);
        if (method != null) {
          element = method;
        }
      }
      if (element instanceof PsiMember &&
          !JavaPsiFacade.getInstance(project).getResolveHelper().isAccessible((PsiMember)element, place, null)) {
        String message = RefactoringBundle.message(
          "0.is.not.accessible.from.1.value.for.introduced.parameter.in.that.method.call.will.be.incorrect",
          RefactoringUIUtil.getDescription(element, true),
          RefactoringUIUtil.getDescription(ConflictsUtil.getContainer(place), true));
        conflicts.putValue(element, message);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:GroovyIntroduceParameterUtil.java

示例11: addInaccessibilityDescriptions

import com.intellij.refactoring.util.ConflictsUtil; //导入依赖的package包/类
private void addInaccessibilityDescriptions(Set<UsageInfo> usages, MultiMap<PsiElement, String> conflictDescriptions)
  throws IncorrectOperationException {
  PsiMethod method = myChangeInfo.getMethod();
  PsiModifierList modifierList = (PsiModifierList)method.getModifierList().copy();
  VisibilityUtil.setVisibility(modifierList, myChangeInfo.getNewVisibility());

  for (Iterator<UsageInfo> iterator = usages.iterator(); iterator.hasNext();) {
    UsageInfo usageInfo = iterator.next();
    PsiElement element = usageInfo.getElement();
    if (element != null) {
      if (element instanceof GrReferenceExpression) {
        PsiClass accessObjectClass = null;
        GrExpression qualifier = ((GrReferenceExpression)element).getQualifierExpression();
        if (qualifier != null) {
          accessObjectClass = getAccessObjectClass(qualifier);
        }

        PsiResolveHelper helper = JavaPsiFacade.getInstance(element.getProject()).getResolveHelper();
        if (!helper.isAccessible(method, modifierList, element, accessObjectClass, null)) {
          String message =
            RefactoringBundle.message("0.with.1.visibility.is.not.accessible.from.2",
                                      RefactoringUIUtil.getDescription(method, true),
                                      myChangeInfo.getNewVisibility(),
                                      RefactoringUIUtil.getDescription(ConflictsUtil.getContainer(element), true));
          conflictDescriptions.putValue(method, message);
          if (!needToChangeCalls()) {
            iterator.remove();
          }
        }
      }
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:34,代码来源:GrChangeSignatureConflictSearcher.java

示例12: visitResolvedReference

import com.intellij.refactoring.util.ConflictsUtil; //导入依赖的package包/类
private void visitResolvedReference(PsiElement resolved, PsiJavaCodeReferenceElement reference) {
  if (resolved instanceof PsiModifierListOwner) {
    final PsiModifierList modifierList = ((PsiModifierListOwner)resolved).getModifierList();
    if (PsiModifier.PACKAGE_LOCAL.equals(VisibilityUtil.getVisibilityModifier(modifierList))) {
      PsiFile aFile = resolved.getContainingFile();
      if (aFile != null && !isInsideMoved(resolved)) {
        final PsiDirectory containingDirectory = aFile.getContainingDirectory();
        if (containingDirectory != null) {
          PsiJavaPackage aPackage = JavaDirectoryService.getInstance().getPackage(containingDirectory);
          if (aPackage != null && !myTargetPackage.equalToPackage(aPackage)) {
            HashSet<PsiElement> reportedRefs = myReported.get(resolved);
            if (reportedRefs == null) {
              reportedRefs = new HashSet<PsiElement>();
              myReported.put(resolved, reportedRefs);
            }
            PsiElement container = ConflictsUtil.getContainer(reference);
            if (!reportedRefs.contains(container)) {
              final String message = RefactoringBundle.message("0.uses.a.package.local.1",
                                                               RefactoringUIUtil.getDescription(container, true),
                                                               RefactoringUIUtil.getDescription(resolved, true));
              myConflicts.putValue(resolved, CommonRefactoringUtil.capitalize(message));
              reportedRefs.add(container);
            }
          }
        }
      }
    }
  }
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:30,代码来源:PackageLocalsUsageCollector.java

示例13: addInaccessibilityDescriptions

import com.intellij.refactoring.util.ConflictsUtil; //导入依赖的package包/类
private void addInaccessibilityDescriptions(Set<UsageInfo> usages, MultiMap<PsiElement, String> conflictDescriptions) throws IncorrectOperationException
{
	PsiMethod method = myChangeInfo.getMethod();
	PsiModifierList modifierList = (PsiModifierList) method.getModifierList().copy();
	VisibilityUtil.setVisibility(modifierList, myChangeInfo.getNewVisibility());

	for(Iterator<UsageInfo> iterator = usages.iterator(); iterator.hasNext(); )
	{
		UsageInfo usageInfo = iterator.next();
		PsiElement element = usageInfo.getElement();
		if(element != null)
		{
			if(element instanceof PsiQualifiedReference)
			{
				PsiClass accessObjectClass = null;
				PsiElement qualifier = ((PsiQualifiedReference) element).getQualifier();
				if(qualifier instanceof PsiExpression)
				{
					accessObjectClass = (PsiClass) PsiUtil.getAccessObjectClass((PsiExpression) qualifier).getElement();
				}

				if(!JavaPsiFacade.getInstance(element.getProject()).getResolveHelper().isAccessible(method, modifierList, element, accessObjectClass, null))
				{
					String message = RefactoringBundle.message("0.with.1.visibility.is.not.accessible.from.2", RefactoringUIUtil.getDescription(method, true), VisibilityUtil
							.toPresentableText(myChangeInfo.getNewVisibility()), RefactoringUIUtil.getDescription(ConflictsUtil.getContainer(element), true));
					conflictDescriptions.putValue(method, message);
					if(!needToChangeCalls())
					{
						iterator.remove();
					}
				}
			}
		}
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:36,代码来源:JavaChangeSignatureUsageProcessor.java

示例14: checkMethodConflicts

import com.intellij.refactoring.util.ConflictsUtil; //导入依赖的package包/类
protected void checkMethodConflicts(MultiMap<PsiElement, String> conflicts)
{
	PsiMethod prototype;
	try
	{
		PsiElementFactory factory = JavaPsiFacade.getInstance(myProject).getElementFactory();
		prototype = factory.createMethod(myNameField.getEnteredName().trim(), myReturnType);
		if(myTypeParameterList != null)
		{
			prototype.getTypeParameterList().replace(myTypeParameterList);
		}
		for(VariableData data : myInputVariables)
		{
			if(data.passAsParameter)
			{
				prototype.getParameterList().add(factory.createParameter(data.name, data.type));
			}
		}
		// set the modifiers with which the method is supposed to be created
		PsiUtil.setModifierProperty(prototype, PsiModifier.PRIVATE, true);
	}
	catch(IncorrectOperationException e)
	{
		return;
	}

	ConflictsUtil.checkMethodConflicts(myTargetClass, null, prototype, conflicts);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:29,代码来源:ExtractMethodDialog.java

示例15: getDescription

import com.intellij.refactoring.util.ConflictsUtil; //导入依赖的package包/类
public String getDescription() {
  final PsiElement container = ConflictsUtil.getContainer(myHiddenClass);
  return RefactoringBundle.message("renamed.class.will.hide.0.in.1", RefactoringUIUtil.getDescription(myHiddenClass, false),
                                   RefactoringUIUtil.getDescription(container, false));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:ClassHidesUnqualifiableClassUsageInfo.java


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