Resource Bundles: Inspections on invalid property key/resource bundle references

#KT-6946 In Progress
This commit is contained in:
Alexey Sedunov
2015-09-17 20:11:02 +03:00
parent 44fd9d17ed
commit 594e4e5c31
14 changed files with 244 additions and 0 deletions
@@ -0,0 +1,5 @@
package org.jetbrains.annotations
@Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.LOCAL_VARIABLE, AnnotationTarget.FIELD)
public annotation class PropertyKey(public val resourceBundle: String)
@@ -0,0 +1,2 @@
foo.bar = test: {0}
foo.bar2 = test: {0}, {1}
@@ -0,0 +1,7 @@
import org.jetbrains.annotations.PropertyKey;
class J {
static String message(@PropertyKey(resourceBundle = "TestBundle") String key, Object... args) {
return key;
}
}
@@ -0,0 +1,6 @@
import org.jetbrains.annotations.PropertyKey
object K {
fun message(@PropertyKey(resourceBundle = "TestBundle") key: String, vararg args: Any) = key
fun message2(@PropertyKey(resourceBundle = "TestBundle") key: String, n: Int, vararg args: Any) = key
}
@@ -0,0 +1,7 @@
fun test() {
K.message("foo.bar")
J.message("foo.bar")
K.message(key = "foo.bar", args = 1)
K.message("foo.bar2", *arrayOf(1, 2))
K.message2("foo.bar", 1)
}
@@ -0,0 +1,6 @@
import org.jetbrains.annotations.PropertyKey
private val TEST_BUNDLE2 = "TestBundle2"
fun message(@PropertyKey(resourceBundle = "TestBundle2") key: String, vararg args: Any) = key
fun message2(@PropertyKey(resourceBundle = TEST_BUNDLE2) key: String, vararg args: Any) = key
@@ -0,0 +1,6 @@
fun test() {
K.message("foo.baz", "arg")
K.message("foo.baz")
J.message("foo.baz", "arg")
J.message("foo.baz")
}
@@ -0,0 +1,6 @@
fun test() {
K.message("foo.bar", "arg")
K.message("foo.bar", "arg1", "arg2")
J.message("foo.bar", "arg")
J.message("foo.bar", "arg1", "arg2")
}