Ejemplo n.º 1
0
 private void checkSealedModifiers(JetClass aClass) {
   if (aClass.hasModifier(JetTokens.OPEN_KEYWORD)) {
     trace.report(OPEN_MODIFIER_IN_SEALED.on(aClass));
   }
   if (aClass.hasModifier(JetTokens.FINAL_KEYWORD)) {
     trace.report(FINAL_MODIFIER_IN_SEALED.on(aClass));
   }
   if (aClass.hasModifier(JetTokens.ABSTRACT_KEYWORD)) {
     trace.report(ABSTRACT_MODIFIER_IN_SEALED.on(aClass));
   }
 }
Ejemplo n.º 2
0
 private void checkEnumModifiers(JetClass aClass) {
   if (aClass.hasModifier(JetTokens.OPEN_KEYWORD)) {
     trace.report(OPEN_MODIFIER_IN_ENUM.on(aClass));
   }
   if (aClass.hasModifier(JetTokens.ABSTRACT_KEYWORD)) {
     trace.report(ABSTRACT_MODIFIER_IN_ENUM.on(aClass));
   }
   if (aClass.hasModifier(JetTokens.SEALED_KEYWORD)) {
     trace.report(SEALED_MODIFIER_IN_ENUM.on(aClass));
   }
 }
Ejemplo n.º 3
0
  private void checkClass(
      BodiesResolveContext c,
      JetClass aClass,
      ClassDescriptorWithResolutionScopes classDescriptor) {
    checkOpenMembers(classDescriptor);
    checkTypeParameters(aClass);

    if (aClass.isInterface()) {
      ASTNode traitKeyword = aClass.getNode().findChildByType(JetTokens.TRAIT_KEYWORD);
      if (traitKeyword != null) {
        trace.report(Errors.DEPRECATED_TRAIT_KEYWORD.on(traitKeyword.getPsi()));
      }

      checkTraitModifiers(aClass);
      checkConstructorInTrait(aClass);
    } else if (aClass.isAnnotation()) {
      checkAnnotationClassWithBody(aClass);
      checkValOnAnnotationParameter(aClass);
    } else if (aClass.isEnum()) {
      checkEnumModifiers(aClass);
      if (aClass.isLocal()) {
        trace.report(LOCAL_ENUM_NOT_ALLOWED.on(aClass, classDescriptor));
      }
    } else if (aClass.hasModifier(JetTokens.SEALED_KEYWORD)) {
      checkSealedModifiers(aClass);
    } else if (aClass instanceof JetEnumEntry) {
      checkEnumEntry((JetEnumEntry) aClass, classDescriptor);
    }
  }
Ejemplo n.º 4
0
  @Override
  public Icon getIcon(@NotNull PsiElement psiElement, int flags) {
    if (psiElement instanceof JetFile) {
      JetFile file = (JetFile) psiElement;
      JetClassOrObject mainClass = getMainClass(file);
      return mainClass != null ? getIcon(mainClass, flags) : JetIcons.FILE;
    }
    if (psiElement instanceof JetNamespaceHeader) {
      return (flags & Iconable.ICON_FLAG_OPEN) != 0
          ? PlatformIcons.PACKAGE_OPEN_ICON
          : PlatformIcons.PACKAGE_ICON;
    }
    if (psiElement instanceof JetNamedFunction) {
      return PsiTreeUtil.getParentOfType(psiElement, JetNamedDeclaration.class) instanceof JetClass
          ? PlatformIcons.METHOD_ICON
          : JetIcons.FUNCTION;
    }
    if (psiElement instanceof JetClass) {
      JetClass jetClass = (JetClass) psiElement;
      if (jetClass.isTrait()) {
        return JetIcons.TRAIT;
      }

      Icon icon =
          jetClass.hasModifier(JetTokens.ENUM_KEYWORD) ? PlatformIcons.ENUM_ICON : JetIcons.CLASS;
      if (jetClass instanceof JetEnumEntry) {
        JetEnumEntry enumEntry = (JetEnumEntry) jetClass;
        if (enumEntry.getPrimaryConstructorParameterList() == null) {
          icon = PlatformIcons.ENUM_ICON;
        }
      }
      return icon;
    }
    if (psiElement instanceof JetObjectDeclaration || psiElement instanceof JetClassObject) {
      return JetIcons.OBJECT;
    }
    if (psiElement instanceof JetParameter) {
      JetParameter parameter = (JetParameter) psiElement;
      if (parameter.getValOrVarNode() != null) {
        JetParameterList parameterList =
            PsiTreeUtil.getParentOfType(psiElement, JetParameterList.class);
        if (parameterList != null && parameterList.getParent() instanceof JetClass) {
          return parameter.isMutable() ? JetIcons.FIELD_VAR : JetIcons.FIELD_VAL;
        }
      }
      return JetIcons.PARAMETER;
    }
    if (psiElement instanceof JetProperty) {
      JetProperty property = (JetProperty) psiElement;
      return property.isVar() ? JetIcons.FIELD_VAR : JetIcons.FIELD_VAL;
    }
    return null;
  }