當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。