diff --git a/src/main/java/spoon/refactoring/CtRenameLocalVariableRefactoring.java b/src/main/java/spoon/refactoring/CtRenameLocalVariableRefactoring.java index 02e538f378f..846efe00cc2 100644 --- a/src/main/java/spoon/refactoring/CtRenameLocalVariableRefactoring.java +++ b/src/main/java/spoon/refactoring/CtRenameLocalVariableRefactoring.java @@ -84,11 +84,8 @@ private static class QueryDriver implements CtScannerListener { @Override public ScanningMode enter(CtElement element) { - if (ignoredParent != null && element instanceof CtElement) { - CtElement ele = (CtElement) element; - if (ele.hasParent(ignoredParent)) { - return ScanningMode.SKIP_ALL; - } + if (element.hasParent(ignoredParent)) { + return ScanningMode.SKIP_ALL; } if (element instanceof CtType) { nrOfNestedLocalClasses++; diff --git a/src/main/java/spoon/support/compiler/SnippetCompilationHelper.java b/src/main/java/spoon/support/compiler/SnippetCompilationHelper.java index 391d299c0ea..07efdefe186 100644 --- a/src/main/java/spoon/support/compiler/SnippetCompilationHelper.java +++ b/src/main/java/spoon/support/compiler/SnippetCompilationHelper.java @@ -48,18 +48,17 @@ private SnippetCompilationHelper() { } private static final String WRAPPER_CLASS_NAME = "Wrapper"; private static final String WRAPPER_METHOD_NAME = "wrap"; - public static void compileAndReplaceSnippetsIn(CtType c) { - Factory f = c.getFactory(); - CtType workCopy = c; + public static void compileAndReplaceSnippetsIn(CtType workType) { + Factory f = workType.getFactory(); Set backup = EnumSet.noneOf(ModifierKind.class); - backup.addAll(workCopy.getModifiers()); - workCopy.removeModifier(ModifierKind.PUBLIC); + backup.addAll(workType.getModifiers()); + workType.removeModifier(ModifierKind.PUBLIC); try { - build(f, workCopy.toString()); + build(f, workType.toString()); } finally { // restore modifiers - c.setModifiers(backup); + workType.setModifiers(backup); } } @@ -154,5 +153,4 @@ private static String createWrapperContent(final CtElement element, final Factor return contents; } - } diff --git a/src/main/java/spoon/support/visitor/ClassTypingContext.java b/src/main/java/spoon/support/visitor/ClassTypingContext.java index 8afb6837011..5d9cc313570 100644 --- a/src/main/java/spoon/support/visitor/ClassTypingContext.java +++ b/src/main/java/spoon/support/visitor/ClassTypingContext.java @@ -569,18 +569,17 @@ private boolean isSubTypeByActualTypeArguments(CtTypeReference superTypeRef, //the raw type or not a generic type. Arguments are ignored in sub type detection return true; } - List> subTypeArgs = expectedSuperTypeArguments; - if (subTypeArgs.isEmpty()) { + if (expectedSuperTypeArguments.isEmpty()) { //the raw type or not a generic type return true; } - if (subTypeArgs.size() != superTypeArgs.size()) { + if (expectedSuperTypeArguments.size() != superTypeArgs.size()) { //the number of arguments is not same - it should not happen ... return false; } - for (int i = 0; i < subTypeArgs.size(); i++) { + for (int i = 0; i < expectedSuperTypeArguments.size(); i++) { CtTypeReference superArg = superTypeArgs.get(i); - CtTypeReference subArg = subTypeArgs.get(i); + CtTypeReference subArg = expectedSuperTypeArguments.get(i); if (isSubTypeArg(subArg, superArg) == false) { return false; } diff --git a/src/test/java/spoon/generating/RoleHandlersGenerator.java b/src/test/java/spoon/generating/RoleHandlersGenerator.java index 2aee261bb30..9374e0da493 100644 --- a/src/test/java/spoon/generating/RoleHandlersGenerator.java +++ b/src/test/java/spoon/generating/RoleHandlersGenerator.java @@ -155,8 +155,7 @@ private CtTypeReference fixValueType(CtTypeReference valueType) { } private CtType getTemplate(String templateQName) { - CtType template = getFactory().Class().get(templateQName); - return template; + return getFactory().Class().get(templateQName); } private File file(String name) {