Example #1
0
 @Nullable
 @Contract("_, !null -> !null")
 public static KtModifierList replaceModifierList(
     @NotNull KtModifierListOwner owner, @Nullable KtModifierList modifierList) {
   KtModifierList oldModifierList = owner.getModifierList();
   if (modifierList == null) {
     if (oldModifierList != null) oldModifierList.delete();
     return null;
   } else {
     if (oldModifierList == null) {
       PsiElement firstChild = owner.getFirstChild();
       return (KtModifierList) owner.addBefore(modifierList, firstChild);
     } else {
       return (KtModifierList) oldModifierList.replace(modifierList);
     }
   }
 }
Example #2
0
 public static boolean isDeprecated(@NotNull KtModifierListOwner owner) {
   KtModifierList modifierList = owner.getModifierList();
   if (modifierList != null) {
     List<KtAnnotationEntry> annotationEntries = modifierList.getAnnotationEntries();
     for (KtAnnotationEntry annotation : annotationEntries) {
       Name shortName = getShortName(annotation);
       if (KotlinBuiltIns.FQ_NAMES.deprecated.shortName().equals(shortName)) {
         return true;
       }
     }
   }
   return false;
 }