package com.netflix.governator.visitors;

import com.google.inject.Binding;
import com.google.inject.spi.DefaultBindingTargetVisitor;
import com.google.inject.spi.DefaultElementVisitor;
import com.google.inject.spi.InstanceBinding;
import com.google.inject.spi.ProviderInstanceBinding;

public class WarnOfToInstanceInjectionVisitor extends DefaultElementVisitor<String> { 
    public <T> String visit(Binding<T> binding) {
        return binding.acceptTargetVisitor(new DefaultBindingTargetVisitor<T, String>() {
            public String visit(InstanceBinding<? extends T> instanceBinding) {
                return String.format("toInstance() at %s can force undesireable static initialization.  " +
                        "Consider replacing with an @Provides method instead.",
                        instanceBinding.getSource());
            }

            public String visit(ProviderInstanceBinding<? extends T> providerInstanceBinding) {
                return String.format("toInstance() at %s can force undesireable static initialization.  " +
                        "Consider replacing with an @Provides method instead.",
                        providerInstanceBinding.getSource());
            }            
        });
    }
}

@@ -228,62 +228,8 @@
 ing;
-%0Aimport com.google.inject.spi.ProviderInstanceBinding;
 %0A%0Apu
@@ -792,381 +792,8 @@
    %7D
-%0A%0A            public String visit(ProviderInstanceBinding%3C? extends T%3E providerInstanceBinding) %7B%0A                return String.format(%22toInstance() at %25s can force undesireable static initialization.  %22 +%0A                        %22Consider replacing with an @Provides method instead.%22,%0A                        providerInstanceBinding.getSource());%0A            %7D            
 %0A   

Remove ProviderInstanceBinding as it also captures @Provides methods