Пример #1
0
 private void checkTraitModifiers(JetClass aClass) {
   reportErrorIfHasIllegalModifier(aClass);
   JetModifierList modifierList = aClass.getModifierList();
   if (modifierList == null) return;
   if (modifierList.hasModifier(JetTokens.FINAL_KEYWORD)) {
     trace.report(Errors.TRAIT_CAN_NOT_BE_FINAL.on(aClass));
   }
   if (modifierList.hasModifier(JetTokens.SEALED_KEYWORD)) {
     trace.report(Errors.TRAIT_CAN_NOT_BE_SEALED.on(aClass));
   }
   if (modifierList.hasModifier(JetTokens.ABSTRACT_KEYWORD)) {
     trace.report(Errors.ABSTRACT_MODIFIER_IN_TRAIT.on(aClass));
   }
   if (modifierList.hasModifier(JetTokens.OPEN_KEYWORD)) {
     trace.report(Errors.OPEN_MODIFIER_IN_TRAIT.on(aClass));
   }
 }
 @Override
 public void invoke(@NotNull Project project, Editor editor, @NotNull JetFile file)
     throws IncorrectOperationException {
   JetPsiFactory factory = new JetPsiFactory(annotationClass.getProject());
   JetModifierList list = annotationClass.getModifierList();
   String annotation = KotlinBuiltIns.FQ_NAMES.annotation.shortName().asString();
   PsiElement added;
   if (list == null) {
     JetModifierList newModifierList = factory.createModifierList(annotation);
     added =
         annotationClass.addBefore(newModifierList, annotationClass.getClassOrInterfaceKeyword());
   } else {
     JetAnnotationEntry entry = factory.createAnnotationEntry(annotation);
     added = list.addBefore(entry, list.getFirstChild());
   }
   annotationClass.addAfter(factory.createWhiteSpace(), added);
 }