From 7649d68ff02a8a759a9df82f25794f460207000b Mon Sep 17 00:00:00 2001 From: ronshapiro Date: Wed, 5 Jul 2017 11:18:33 -0700 Subject: [PATCH] Delete KeyFormatter. It has a well-defined toString(), which is all this object does ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=160981170 --- .../codegen/BindingDeclarationFormatter.java | 9 +++---- .../codegen/BindingGraphValidator.java | 5 +--- .../internal/codegen/ComponentProcessor.java | 4 +-- .../dagger/internal/codegen/KeyFormatter.java | 25 ------------------- 4 files changed, 5 insertions(+), 38 deletions(-) delete mode 100644 java/dagger/internal/codegen/KeyFormatter.java diff --git a/java/dagger/internal/codegen/BindingDeclarationFormatter.java b/java/dagger/internal/codegen/BindingDeclarationFormatter.java index 0652b4d3cbc..334298dad88 100644 --- a/java/dagger/internal/codegen/BindingDeclarationFormatter.java +++ b/java/dagger/internal/codegen/BindingDeclarationFormatter.java @@ -48,12 +48,9 @@ final class BindingDeclarationFormatter extends Formatter { SYNTHETIC_RELEASABLE_REFERENCE_MANAGER, SYNTHETIC_RELEASABLE_REFERENCE_MANAGERS); private final MethodSignatureFormatter methodSignatureFormatter; - private final KeyFormatter keyFormatter; - BindingDeclarationFormatter( - MethodSignatureFormatter methodSignatureFormatter, KeyFormatter keyFormatter) { + BindingDeclarationFormatter(MethodSignatureFormatter methodSignatureFormatter) { this.methodSignatureFormatter = methodSignatureFormatter; - this.keyFormatter = keyFormatter; } /** @@ -93,11 +90,11 @@ public String format(BindingDeclaration bindingDeclaration) { case SYNTHETIC_RELEASABLE_REFERENCE_MANAGER: return String.format( "binding for %s from the scope declaration", - stripCommonTypePrefixes(keyFormatter.format(binding.key()))); + stripCommonTypePrefixes(binding.key().toString())); case SYNTHETIC_RELEASABLE_REFERENCE_MANAGERS: return String.format( "Dagger-generated binding for %s", - stripCommonTypePrefixes(keyFormatter.format(binding.key()))); + stripCommonTypePrefixes(binding.key().toString())); default: break; } diff --git a/java/dagger/internal/codegen/BindingGraphValidator.java b/java/dagger/internal/codegen/BindingGraphValidator.java index d68d8697507..8f5ac605e06 100644 --- a/java/dagger/internal/codegen/BindingGraphValidator.java +++ b/java/dagger/internal/codegen/BindingGraphValidator.java @@ -134,7 +134,6 @@ final class BindingGraphValidator { private final BindingDeclarationFormatter bindingDeclarationFormatter; private final MethodSignatureFormatter methodSignatureFormatter; private final DependencyRequestFormatter dependencyRequestFormatter; - private final KeyFormatter keyFormatter; private final Key.Factory keyFactory; BindingGraphValidator( @@ -146,7 +145,6 @@ final class BindingGraphValidator { BindingDeclarationFormatter bindingDeclarationFormatter, MethodSignatureFormatter methodSignatureFormatter, DependencyRequestFormatter dependencyRequestFormatter, - KeyFormatter keyFormatter, Key.Factory keyFactory) { this.elements = elements; this.types = types; @@ -156,7 +154,6 @@ final class BindingGraphValidator { this.bindingDeclarationFormatter = bindingDeclarationFormatter; this.methodSignatureFormatter = methodSignatureFormatter; this.dependencyRequestFormatter = dependencyRequestFormatter; - this.keyFormatter = keyFormatter; this.keyFactory = keyFactory; } @@ -1165,7 +1162,7 @@ private FluentIterable provisionsDependingOnLatestRequest() } private String formatCurrentDependencyRequestKey() { - return keyFormatter.format(dependencyRequest().key()); + return dependencyRequest().key().toString(); } } } diff --git a/java/dagger/internal/codegen/ComponentProcessor.java b/java/dagger/internal/codegen/ComponentProcessor.java index b0a85270215..f140bc7b50f 100644 --- a/java/dagger/internal/codegen/ComponentProcessor.java +++ b/java/dagger/internal/codegen/ComponentProcessor.java @@ -65,10 +65,9 @@ protected Iterable initSteps() { CompilerOptions compilerOptions = CompilerOptions.create(processingEnv, elements); Filer filer = new FormattingFiler(processingEnv.getFiler()); - KeyFormatter keyFormatter = new KeyFormatter(); MethodSignatureFormatter methodSignatureFormatter = new MethodSignatureFormatter(types); BindingDeclarationFormatter bindingDeclarationFormatter = - new BindingDeclarationFormatter(methodSignatureFormatter, keyFormatter); + new BindingDeclarationFormatter(methodSignatureFormatter); DependencyRequestFormatter dependencyRequestFormatter = new DependencyRequestFormatter(types, elements); @@ -187,7 +186,6 @@ protected Iterable initSteps() { bindingDeclarationFormatter, methodSignatureFormatter, dependencyRequestFormatter, - keyFormatter, keyFactory); return ImmutableList.of( diff --git a/java/dagger/internal/codegen/KeyFormatter.java b/java/dagger/internal/codegen/KeyFormatter.java deleted file mode 100644 index e5d391f63dc..00000000000 --- a/java/dagger/internal/codegen/KeyFormatter.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2014 The Dagger Authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dagger.internal.codegen; - -/** Formats a {@link Key} into a {@link String} suitable for use in error messages. */ -final class KeyFormatter extends Formatter { - @Override - public String format(Key key) { - return key.toString(); - } -}