private void checkAccessors( @NotNull JetProperty property, @NotNull PropertyDescriptor propertyDescriptor) { for (JetPropertyAccessor accessor : property.getAccessors()) { PropertyAccessorDescriptor propertyAccessorDescriptor = accessor.isGetter() ? propertyDescriptor.getGetter() : propertyDescriptor.getSetter(); assert propertyAccessorDescriptor != null : "No property accessor descriptor for " + property.getText(); modifiersChecker.checkModifiersForDeclaration(accessor, propertyAccessorDescriptor); modifiersChecker.reportIllegalModalityModifiers(accessor); } JetPropertyAccessor getter = property.getGetter(); PropertyGetterDescriptor getterDescriptor = propertyDescriptor.getGetter(); JetModifierList getterModifierList = getter != null ? getter.getModifierList() : null; if (getterModifierList != null && getterDescriptor != null) { Map<JetModifierKeywordToken, ASTNode> nodes = ModifiersChecker.getNodesCorrespondingToModifiers( getterModifierList, Sets.newHashSet( JetTokens.PUBLIC_KEYWORD, JetTokens.PROTECTED_KEYWORD, JetTokens.PRIVATE_KEYWORD, JetTokens.INTERNAL_KEYWORD)); if (getterDescriptor.getVisibility() != propertyDescriptor.getVisibility()) { for (ASTNode node : nodes.values()) { trace.report(Errors.GETTER_VISIBILITY_DIFFERS_FROM_PROPERTY_VISIBILITY.on(node.getPsi())); } } else { for (ASTNode node : nodes.values()) { trace.report(Errors.REDUNDANT_MODIFIER_IN_GETTER.on(node.getPsi())); } } } }
protected void checkFunction( JetNamedFunction function, SimpleFunctionDescriptor functionDescriptor) { reportErrorIfHasIllegalModifier(function); DeclarationDescriptor containingDescriptor = functionDescriptor.getContainingDeclaration(); boolean hasAbstractModifier = function.hasModifier(JetTokens.ABSTRACT_KEYWORD); checkDeclaredTypeInPublicMember(function, functionDescriptor); if (containingDescriptor instanceof ClassDescriptor) { ClassDescriptor classDescriptor = (ClassDescriptor) containingDescriptor; boolean inTrait = classDescriptor.getKind() == ClassKind.INTERFACE; if (hasAbstractModifier && !classCanHaveAbstractMembers(classDescriptor)) { trace.report( ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS.on( function, functionDescriptor.getName().asString(), classDescriptor)); } if (hasAbstractModifier && inTrait) { trace.report(ABSTRACT_MODIFIER_IN_TRAIT.on(function)); } boolean hasBody = function.hasBody(); if (hasBody && hasAbstractModifier) { trace.report(ABSTRACT_FUNCTION_WITH_BODY.on(function, functionDescriptor)); } if (!hasBody && function.hasModifier(JetTokens.FINAL_KEYWORD) && inTrait) { trace.report(FINAL_FUNCTION_WITH_NO_BODY.on(function, functionDescriptor)); } if (!hasBody && !hasAbstractModifier && !inTrait) { trace.report(NON_ABSTRACT_FUNCTION_WITH_NO_BODY.on(function, functionDescriptor)); } return; } modifiersChecker.reportIllegalModalityModifiers(function); if (!function.hasBody() && !hasAbstractModifier) { trace.report(NON_MEMBER_FUNCTION_NO_BODY.on(function, functionDescriptor)); } }
private void checkProperty(JetProperty property, PropertyDescriptor propertyDescriptor) { reportErrorIfHasIllegalModifier(property); DeclarationDescriptor containingDeclaration = propertyDescriptor.getContainingDeclaration(); if (containingDeclaration instanceof ClassDescriptor) { checkPropertyAbstractness( property, propertyDescriptor, (ClassDescriptor) containingDeclaration); } else { modifiersChecker.reportIllegalModalityModifiers(property); } checkPropertyInitializer(property, propertyDescriptor); checkAccessors(property, propertyDescriptor); checkDeclaredTypeInPublicMember(property, propertyDescriptor); }
private void checkConstructorDeclaration( ConstructorDescriptor constructorDescriptor, JetDeclaration declaration) { modifiersChecker.reportIllegalModalityModifiers(declaration); reportErrorIfHasIllegalModifier(declaration); modifiersChecker.checkModifiersForDeclaration(declaration, constructorDescriptor); }