From 3f3b2e09d626c06b31412f3d42ef576e72e96e9b Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Sun, 20 Jan 2013 11:02:42 +0100 Subject: [PATCH] cleanup --- .../generate/tostring/config/CancelPolicy.java | 9 +++------ .../tostring/config/ConflictResolutionPolicy.java | 6 +++--- .../generate/tostring/config/DuplicatePolicy.java | 11 ++++------- .../config/InsertAfterEqualsHashCodeStrategy.java | 5 ++--- .../generate/tostring/config/InsertLastStrategy.java | 3 +-- .../tostring/config/InsertNewMethodStrategy.java | 9 +++------ 6 files changed, 16 insertions(+), 27 deletions(-) diff --git a/plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/CancelPolicy.java b/plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/CancelPolicy.java index a20ec7c084d2..a45f7b7bcbb9 100644 --- a/plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/CancelPolicy.java +++ b/plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/CancelPolicy.java @@ -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"; } - - } diff --git a/plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/ConflictResolutionPolicy.java b/plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/ConflictResolutionPolicy.java index 29afdd54f710..c726b88e8e2f 100644 --- a/plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/ConflictResolutionPolicy.java +++ b/plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/ConflictResolutionPolicy.java @@ -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); } diff --git a/plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/DuplicatePolicy.java b/plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/DuplicatePolicy.java index 65d65b00279c..5de932ede689 100644 --- a/plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/DuplicatePolicy.java +++ b/plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/DuplicatePolicy.java @@ -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"; } - } diff --git a/plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/InsertAfterEqualsHashCodeStrategy.java b/plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/InsertAfterEqualsHashCodeStrategy.java index 9fa4c073ff5b..d9757947531a 100644 --- a/plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/InsertAfterEqualsHashCodeStrategy.java +++ b/plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/InsertAfterEqualsHashCodeStrategy.java @@ -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); diff --git a/plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/InsertLastStrategy.java b/plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/InsertLastStrategy.java index b6b9fff04364..24c8461273a3 100644 --- a/plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/InsertLastStrategy.java +++ b/plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/InsertLastStrategy.java @@ -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"; } - } diff --git a/plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/InsertNewMethodStrategy.java b/plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/InsertNewMethodStrategy.java index 9e25039631c6..7b30a1b6e488 100644 --- a/plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/InsertNewMethodStrategy.java +++ b/plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/InsertNewMethodStrategy.java @@ -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); }