IDEA-108052 Groovy: "@DelegatesTo inspection" could report unused @DelegatesTo.Target if a closure parameter delegates to a different target

This commit is contained in:
Max Medvedev
2013-05-31 16:06:59 +04:00
parent 16f26b45c6
commit 677f123aae
2 changed files with 7 additions and 1 deletions
@@ -67,7 +67,7 @@ public class DelegatesToInspection extends BaseInspection {
}
}
else {
if (delegatesTo.findDeclaredAttributeValue("target") == null) {
if (delegatesTo.findDeclaredAttributeValue("target") == null && delegatesTo.findDeclaredAttributeValue("value") == null) {
return; // target is used
}
}
@@ -253,6 +253,12 @@ def with5(@<warning descr="@Target is unused">DelegatesTo.Target</warning>() Obj
arg.delegate = target
arg()
}
def with6(@<warning descr="@Target is unused">DelegatesTo.Target</warning>() Object target, @DelegatesTo(String) Closure arg) {
arg.delegate = target
arg()
}
''', DelegatesToInspection)
}
}