Source:
<code>protected ICleanUpFix createFix(CompilationUnit unit) throws CoreException { if (!isEnabled(CleanUpConstants.USE_DIRECTLY_MAP_METHOD)) { return null; } final List<CompilationUnitRewriteOperation> rewriteOperations= new ArrayList<>(); unit.accept(new ASTVisitor() { @Override public boolean visit(MethodInvocation mi) { MethodInvocation miExpression= ASTNodes.as(mi.getExpression(), MethodInvocation.class); <START> if (miExpression != null && ASTNodes.usesGivenSignature(miExpression, Map.class.getCanonicalName(), "keySet")) { END> if (ASTNodes.usesGivenSignature(mi, Set.class.getCanonicalName(), "clear")) { rewriteOperations.add(new MapMethodOperation(miExpression, mi, "clear")); return false; } if (ASTNodes.usesGivenSignature(mi, Set.class.getCanonicalName(), "size")) { rewriteOperations.add(new MapMethodOperation(miExpression, mi, "size")); return false; } if (ASTNodes.usesGivenSignature(mi, Set.class.getCanonicalName(), "isEmpty")) { rewriteOperations.add(new MapMethodOperation(miExpression, mi, "isEmpty")); return false; } if (ASTNodes.usesGivenSignature(mi, Set.class.getCanonicalName(), "remove", Object.class.getCanonicalName()) && mi.getParent().getNodeType() == ASTNode.EXPRESSION_STATEMENT) { rewriteOperations.add(new MapMethodOperation(miExpression, mi, "remove")); return false; } if (ASTNodes.usesGivenSignature(mi, Set.class.getCanonicalName(), "contains", Object.class.getCanonicalName())) { rewriteOperations.add(new MapMethodOperation(miExpression, mi, "containsKey")); return false; } } return true; } }); if (rewriteOperations.isEmpty()) { return null; } return new CompilationUnitRewriteOperationsFix(MultiFixMessages.UseDirectlyMapMethodCleanup_description, unit, rewriteOperations.toArray(new CompilationUnitRewriteOperation[rewriteOperations.size()])); }</code><technical_language>this section of code extended cover values() method well? E.g. someMap.values().contains(someValue) ->someMap.containsValue(someValue), etc. preview tests need changing well</technical_language>

Target:
protected ICleanUpFix createFix(CompilationUnit unit) throws CoreException { if (!isEnabled(CleanUpConstants.USE_DIRECTLY_MAP_METHOD)) { return null; } final List<CompilationUnitRewriteOperation> rewriteOperations= new ArrayList<>(); unit.accept(new ASTVisitor() { @Override public boolean visit(MethodInvocation mi) { MethodInvocation miExpression= ASTNodes.as(mi.getExpression(), MethodInvocation.class); if (miExpression != null) { if (ASTNodes.usesGivenSignature(miExpression, Map.class.getCanonicalName(), "keySet")) { if (ASTNodes.usesGivenSignature(mi, Set.class.getCanonicalName(), "clear")) { rewriteOperations.add(new MapMethodOperation(miExpression, mi, "clear")); return false; } if (ASTNodes.usesGivenSignature(mi, Set.class.getCanonicalName(), "size")) { rewriteOperations.add(new MapMethodOperation(miExpression, mi, "size")); return false; } if (ASTNodes.usesGivenSignature(mi, Set.class.getCanonicalName(), "isEmpty")) { rewriteOperations.add(new MapMethodOperation(miExpression, mi, "isEmpty")); return false; } if (ASTNodes.usesGivenSignature(mi, Set.class.getCanonicalName(), "remove", Object.class.getCanonicalName()) && mi.getParent().getNodeType() == ASTNode.EXPRESSION_STATEMENT) { rewriteOperations.add(new MapMethodOperation(miExpression, mi, "remove")); return false; } if (ASTNodes.usesGivenSignature(mi, Set.class.getCanonicalName(), "contains", Object.class.getCanonicalName())) { rewriteOperations.add(new MapMethodOperation(miExpression, mi, "containsKey")); return false; } } else if (ASTNodes.usesGivenSignature(miExpression, Map.class.getCanonicalName(), "values") && ASTNodes.usesGivenSignature(mi, Set.class.getCanonicalName(), "contains", Object.class.getCanonicalName())) { rewriteOperations.add(new MapMethodOperation(miExpression, mi, "containsValue")); return false; } } return true; } }); if (rewriteOperations.isEmpty()) { return null; } return new CompilationUnitRewriteOperationsFix(MultiFixMessages.UseDirectlyMapMethodCleanup_description, unit, rewriteOperations.toArray(new CompilationUnitRewriteOperation[rewriteOperations.size()])); }