本文整理汇总了Java中com.intellij.refactoring.util.ConflictsUtil.checkMethodConflicts方法的典型用法代码示例。如果您正苦于以下问题:Java ConflictsUtil.checkMethodConflicts方法的具体用法?Java ConflictsUtil.checkMethodConflicts怎么用?Java ConflictsUtil.checkMethodConflicts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.refactoring.util.ConflictsUtil
的用法示例。
在下文中一共展示了ConflictsUtil.checkMethodConflicts方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例3: 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);
}
示例4: 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);
}
}
示例5: 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);
}
示例6: preprocessUsages
import com.intellij.refactoring.util.ConflictsUtil; //导入方法依赖的package包/类
protected boolean preprocessUsages(Ref<UsageInfo[]> refUsages)
{
final UsageInfo[] usages = refUsages.get();
MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>();
final Set<PsiMember> members = new HashSet<PsiMember>();
members.add(myMethod);
if(myTargetVariable instanceof PsiField)
{
members.add((PsiMember) myTargetVariable);
}
if(!myTargetClass.isInterface())
{
RefactoringConflictsUtil.analyzeAccessibilityConflicts(members, myTargetClass, conflicts, myNewVisibility);
}
else
{
for(final UsageInfo usage : usages)
{
if(usage instanceof InheritorUsageInfo)
{
RefactoringConflictsUtil.analyzeAccessibilityConflicts(members, ((InheritorUsageInfo) usage).getInheritor(), conflicts, myNewVisibility);
}
}
}
if(myTargetVariable instanceof PsiParameter)
{
PsiParameter parameter = (PsiParameter) myTargetVariable;
for(final UsageInfo usageInfo : usages)
{
if(usageInfo instanceof MethodCallUsageInfo)
{
final PsiElement methodCall = ((MethodCallUsageInfo) usageInfo).getMethodCallExpression();
if(methodCall instanceof PsiMethodCallExpression)
{
final PsiExpression[] expressions = ((PsiMethodCallExpression) methodCall).getArgumentList().getExpressions();
final int index = myMethod.getParameterList().getParameterIndex(parameter);
if(index < expressions.length)
{
PsiExpression instanceValue = expressions[index];
instanceValue = RefactoringUtil.unparenthesizeExpression(instanceValue);
if(instanceValue instanceof PsiLiteralExpression && ((PsiLiteralExpression) instanceValue).getValue() == null)
{
String message = RefactoringBundle.message("0.contains.call.with.null.argument.for.parameter.1", RefactoringUIUtil.getDescription(ConflictsUtil.getContainer
(methodCall), true), CommonRefactoringUtil.htmlEmphasize(parameter.getName()));
conflicts.putValue(instanceValue, message);
}
}
}
else if(methodCall instanceof PsiMethodReferenceExpression)
{
conflicts.putValue(methodCall, "Method reference would be broken after move");
}
}
}
}
try
{
ConflictsUtil.checkMethodConflicts(myTargetClass, myMethod, getPatternMethod(), conflicts);
}
catch(IncorrectOperationException e)
{
}
return showConflicts(conflicts, usages);
}
示例7: addMethodConflicts
import com.intellij.refactoring.util.ConflictsUtil; //导入方法依赖的package包/类
private void addMethodConflicts(MultiMap<PsiElement, String> conflicts)
{
String newMethodName = myChangeInfo.getNewName();
if(!(myChangeInfo instanceof JavaChangeInfo))
{
return;
}
try
{
PsiMethod prototype;
final PsiMethod method = myChangeInfo.getMethod();
if(!JavaLanguage.INSTANCE.equals(method.getLanguage()))
{
return;
}
PsiManager manager = method.getManager();
PsiElementFactory factory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory();
final CanonicalTypes.Type returnType = myChangeInfo.getNewReturnType();
if(returnType != null)
{
prototype = factory.createMethod(newMethodName, returnType.getType(method, manager));
}
else
{
prototype = factory.createConstructor();
prototype.setName(newMethodName);
}
JavaParameterInfo[] parameters = myChangeInfo.getNewParameters();
for(JavaParameterInfo info : parameters)
{
PsiType parameterType = info.createType(method, manager);
if(parameterType == null)
{
parameterType = JavaPsiFacade.getElementFactory(method.getProject()).createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, method);
}
PsiParameter param = factory.createParameter(info.getName(), parameterType);
prototype.getParameterList().add(param);
}
ConflictsUtil.checkMethodConflicts(method.getContainingClass(), method, prototype, conflicts);
}
catch(IncorrectOperationException e)
{
LOG.error(e);
}
}