PsiClass (@NotNull KtClassOrObject classOrObject) { PsiClass lightClass = toLightClass(classOrObject); if (lightClass != null) return lightClass; // TODO: Remove this code when light classes are generated for builtins PsiElementFactory factory = PsiElementFactory.getInstance(classOrObject.getProject()); String name = classOrObject.getName(); if (name == null || name.isEmpty()) { name = KotlinBundle.message("find.usages.class.name.anonymous"); } PsiClass javaClass; if (classOrObject instanceof KtClass klass) { javaClass = !klass.isInterface() ? factory.createClass(name) : klass.isAnnotation() ? factory.createAnnotationType(name) : factory.createInterface(name); } else { javaClass = factory.createClass(name); } //noinspection ConstantConditions javaClass.getModifierList().setModifierProperty( PsiModifier.FINAL, !(classOrObject instanceof KtClass && KotlinSearchUsagesSupport.SearchUtils.isInheritable((KtClass) classOrObject)) ); javaClass.putUserData(ORIGINAL_CLASS, classOrObject); return javaClass; }