[kotlin] fix uast annotations

- firKotlinInternalUastUtils: ensure that boxed primitives and String become annotations; otherwise @Nls is missed from the analysis
- AnnotationContext: ensure symbol-based accessor methods are processed; otherwise annotations on properties are ignored
- move tests to k2

^KTIJ-32161 fixed


(cherry picked from commit 0cfbb46aae09df62b6fe5a432ca965e55ed6b5ad)

IJ-CR-192381

GitOrigin-RevId: c4295bc61abd6507622379faed2982170665f151
This commit is contained in:
Anna Kozlova
2026-02-25 10:05:05 +00:00
committed by intellij-monorepo-bot
parent e81dfd761d
commit bd98ab211c
69 changed files with 504 additions and 377 deletions
@@ -49,6 +49,7 @@ import org.jetbrains.uast.UastUtils;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.function.Supplier;
import java.util.stream.Stream;
@@ -223,10 +224,11 @@ public final class AnnotationContext {
return result;
}
private static final Set<String> ACCESSORS_NAMES = Set.of("KtUltraLightMethodForSourceDeclaration", "SymbolLightAccessorMethod");
private static @Nullable PsiModifierListOwner getKotlinProperty(@NotNull PsiModifierListOwner owner) {
if (!(owner instanceof PsiMethod method)) return null;
// Looks ugly but without this check, owner.getNavigationElement() may load PSI or even call decompiler
if (!owner.getClass().getSimpleName().equals("KtUltraLightMethodForSourceDeclaration")) return null;
if (!ACCESSORS_NAMES.contains(owner.getClass().getSimpleName())) return null;
String name = method.getName();
boolean maybeGetter = (name.startsWith("get") || name.startsWith("is")) && method.getParameterList().isEmpty();
boolean maybeSetter = name.startsWith("set") && method.getParameterList().getParametersCount() == 1;