private void resolvePropertyDeclarationBodies(@NotNull BodiesResolveContext c) { // Member properties Set<JetProperty> processed = Sets.newHashSet(); for (Map.Entry<JetClassOrObject, ClassDescriptorWithResolutionScopes> entry : c.getDeclaredClasses().entrySet()) { if (!(entry.getKey() instanceof JetClass)) continue; JetClass jetClass = (JetClass) entry.getKey(); ClassDescriptorWithResolutionScopes classDescriptor = entry.getValue(); for (JetProperty property : jetClass.getProperties()) { PropertyDescriptor propertyDescriptor = c.getProperties().get(property); assert propertyDescriptor != null; resolveProperty( c, classDescriptor.getScopeForMemberDeclarationResolution(), property, propertyDescriptor); processed.add(property); } } // Top-level properties & properties of objects for (Map.Entry<JetProperty, PropertyDescriptor> entry : c.getProperties().entrySet()) { JetProperty property = entry.getKey(); if (processed.contains(property)) continue; PropertyDescriptor propertyDescriptor = entry.getValue(); resolveProperty(c, null, property, propertyDescriptor); } }
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)); } }
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)); } }
private void checkNestedClassAllowed( @NotNull JetModifierListOwner modifierListOwner, @NotNull DeclarationDescriptor descriptor) { if (modifierListOwner.hasModifier(INNER_KEYWORD)) return; if (modifierListOwner instanceof JetClass && !(modifierListOwner instanceof JetEnumEntry)) { JetClass aClass = (JetClass) modifierListOwner; boolean localEnumError = aClass.isLocal() && aClass.isEnum(); if (!localEnumError && isIllegalNestedClass(descriptor)) { trace.report(NESTED_CLASS_NOT_ALLOWED.on(aClass)); } } }
private void checkValOnAnnotationParameter(JetClass aClass) { for (JetParameter parameter : aClass.getPrimaryConstructorParameters()) { if (!parameter.hasValOrVar()) { trace.report(MISSING_VAL_ON_ANNOTATION_PARAMETER.on(parameter)); } } }
private void checkTypesInClassHeader(@NotNull JetClassOrObject classOrObject) { for (JetDelegationSpecifier delegationSpecifier : classOrObject.getDelegationSpecifiers()) { checkBoundsForTypeInClassHeader(delegationSpecifier.getTypeReference()); } if (!(classOrObject instanceof JetClass)) return; JetClass jetClass = (JetClass) classOrObject; for (JetTypeParameter jetTypeParameter : jetClass.getTypeParameters()) { checkBoundsForTypeInClassHeader(jetTypeParameter.getExtendsBound()); checkFinalUpperBounds(jetTypeParameter.getExtendsBound()); } for (JetTypeConstraint constraint : jetClass.getTypeConstraints()) { checkBoundsForTypeInClassHeader(constraint.getBoundTypeReference()); checkFinalUpperBounds(constraint.getBoundTypeReference()); } }
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); } }
public void resolveConstructorParameterDefaultValuesAndAnnotations( @NotNull DataFlowInfo outerDataFlowInfo, @NotNull BindingTrace trace, @NotNull JetClass klass, @NotNull ConstructorDescriptor constructorDescriptor, @NotNull LexicalScope declaringScope) { List<JetParameter> valueParameters = klass.getPrimaryConstructorParameters(); List<ValueParameterDescriptor> valueParameterDescriptors = constructorDescriptor.getValueParameters(); LexicalScope scope = getPrimaryConstructorParametersScope(declaringScope, constructorDescriptor); valueParameterResolver.resolveValueParameters( valueParameters, valueParameterDescriptors, scope, outerDataFlowInfo, trace); }
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)); } }
private void checkConstructorInTrait(JetClass klass) { JetPrimaryConstructor primaryConstructor = klass.getPrimaryConstructor(); if (primaryConstructor != null) { trace.report(CONSTRUCTOR_IN_TRAIT.on(primaryConstructor)); } }