is there a hidden intellij middle ground between s...
# random
s
is there a hidden intellij middle ground between suppressing a warning for a line and suppressing it for an entire method? I’m in a spot where I want to make it clear that usage of some deprecated methods on more than one line is intentional but don’t really want to apply it to the whole function
r
@Suppress("deprecation")
above the line of code you want to suppress.
r
What middle ground would there be between line and method?
s
Something piggybacking off of editor regions, I suppose—or in this case, being able to suppress it for the body of an if block would be nice, if not especially practical to implement 😅
@rtsketo annotations aren’t allowed in method bodies unless you’re attaching one to a local field declaration, I don’t think
r
If there's a handful of statements you want to suppress, you can wrap them in a run and add
@Suppress("DEPRECATION")
before the run. Nothing within the run will show deprecation warnings. e.g.
Copy code
deprecatedFunction()  // Warning
@Suppress("DEPRECATION")
run {
    deprecatedFunction()  // No warning
    ...
    anotherDeprecatedFunction()  // No warning
}
anotherDeprecatedFunction()  // Warning
☝️ 1
☝🏼 1
💯 4