I want to make a user defined attribute attachable only to the struct/class methods. In Java's annotation there is such option: @Target restricts annotation attach targets. Is there analogue in D?
No, but you could make the processor you write that handles it static assert(0)
if it finds it attached to one.