This commit is contained in:
Bas Leijdekkers
2013-01-20 11:02:42 +01:00
parent 770dae9c99
commit 3f3b2e09d6
6 changed files with 16 additions and 27 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2001-2007 the original author or authors.
* Copyright 2001-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,8 +28,7 @@ public class CancelPolicy implements ConflictResolutionPolicy {
private static final CancelPolicy instance = new CancelPolicy();
private CancelPolicy() {
}
private CancelPolicy() {}
public static CancelPolicy getInstance() {
return instance;
@@ -39,13 +38,11 @@ public class CancelPolicy implements ConflictResolutionPolicy {
// not used as this is cancel
}
public PsiMethod applyMethod(PsiClass clazz, PsiMethod existingMethod, @NotNull PsiMethod newMethod, Editor editor) throws IncorrectOperationException {
public PsiMethod applyMethod(PsiClass clazz, PsiMethod existingMethod, @NotNull PsiMethod newMethod, Editor editor) {
return null;
}
public String toString() {
return "Cancel";
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2001-2007 the original author or authors.
* Copyright 2001-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@ public interface ConflictResolutionPolicy {
void setNewMethodStrategy(InsertNewMethodStrategy strategy);
/**
* Applies the choosen policy.
* Applies the chosen policy.
*
* @param clazz PSIClass.
* @param existingMethod existing method if one exists.
@@ -48,5 +48,5 @@ public interface ConflictResolutionPolicy {
* @throws IncorrectOperationException is thrown if there is an IDEA error.
*/
@Nullable
PsiMethod applyMethod(PsiClass clazz, PsiMethod existingMethod, @NotNull PsiMethod newMethod, Editor editor) throws IncorrectOperationException;
PsiMethod applyMethod(PsiClass clazz, PsiMethod existingMethod, @NotNull PsiMethod newMethod, Editor editor);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2001-2007 the original author or authors.
* Copyright 2001-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,10 +27,9 @@ import org.jetbrains.annotations.NotNull;
public class DuplicatePolicy implements ConflictResolutionPolicy {
private static final DuplicatePolicy instance = new DuplicatePolicy();
private static InsertNewMethodStrategy newMethodStrategy = InsertAtCaretStrategy.getInstance();
private InsertNewMethodStrategy newMethodStrategy = InsertAtCaretStrategy.getInstance();
private DuplicatePolicy() {
}
private DuplicatePolicy() {}
public static DuplicatePolicy getInstance() {
return instance;
@@ -40,13 +39,11 @@ public class DuplicatePolicy implements ConflictResolutionPolicy {
newMethodStrategy = strategy;
}
public PsiMethod applyMethod(PsiClass clazz, PsiMethod existingMethod, @NotNull PsiMethod newMethod, Editor editor)
throws IncorrectOperationException {
public PsiMethod applyMethod(PsiClass clazz, PsiMethod existingMethod, @NotNull PsiMethod newMethod, Editor editor) {
return newMethodStrategy.insertNewMethod(clazz, newMethod, editor);
}
public String toString() {
return "Duplicate";
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2001-2012 the original author or authors.
* Copyright 2001-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@ package org.jetbrains.generate.tostring.config;
import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiMethod;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.generate.tostring.psi.PsiAdapter;
@@ -35,7 +34,7 @@ public class InsertAfterEqualsHashCodeStrategy implements InsertNewMethodStrateg
return instance;
}
public PsiMethod insertNewMethod(PsiClass clazz, @NotNull PsiMethod newMethod, Editor editor) throws IncorrectOperationException {
public PsiMethod insertNewMethod(PsiClass clazz, @NotNull PsiMethod newMethod, Editor editor) {
PsiMethod methodHashCode = PsiAdapter.findHashCodeMethod(clazz);
PsiMethod methodEquals = PsiAdapter.findEqualsMethod(clazz);
@@ -1,5 +1,5 @@
/*
* Copyright 2001-2012 the original author or authors.
* Copyright 2001-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -56,5 +56,4 @@ public class InsertLastStrategy implements InsertNewMethodStrategy {
public String toString() {
return "Last";
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2001-2007 the original author or authors.
* Copyright 2001-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,16 +29,13 @@ import org.jetbrains.annotations.Nullable;
public interface InsertNewMethodStrategy {
/**
* Applies the choosen policy.
* Applies the chosen policy.
*
* @param clazz PSIClass.
* @param newMethod new method.
* @param editor
* @return if the policy was executed normally (not cancelled)
* @throws com.intellij.util.IncorrectOperationException
* is thrown if there is an IDEA error.
*/
@Nullable
PsiMethod insertNewMethod(PsiClass clazz, @NotNull PsiMethod newMethod, Editor editor) throws IncorrectOperationException;
PsiMethod insertNewMethod(PsiClass clazz, @NotNull PsiMethod newMethod, Editor editor);
}