JetBrains / java-annotations

Annotations for JVM-based languages.
Apache License 2.0
404 stars 47 forks source link

@Language should be applicable as a type-annotation. #43

Open JarvisCraft opened 3 years ago

JarvisCraft commented 3 years ago

Description

@Target ElementType.TYPE_USE may be added to @Language annotation to allow its usage in applicablecontexts.

Example

Currently the following example won't compile although it is logical:

private final @NotNull Map<@NotNull NamespacedKey, @Language("json") @NotNull String> addedAdvancements;

Another positive side is that while currently IntelliJ warns on incorrect order in the following case:

public void addAdvancement(final @NotNull NamespacedKey key,
                           final @Language("json") @NotNull String advancementJson) { /* ... */ }

suggesting swapping of final and @Language("json"), this wouldn't be true if TYPE_USE was present on the annotation.

Sparky983 commented 1 year ago

This would be nice for other annotations like @MagicConstant, @Pattern, @RegExp, and @Subst as well, but I think it's intentional since all these annotations are in the org.intellij.annotations package (or maybe because they're old annotations).