/* CLASSES */ private void renderClass(@NotNull ClassDescriptor klass, @NotNull StringBuilder builder) { if (!startFromName) { renderAnnotations(klass, builder); renderVisibility(klass.getVisibility(), builder); if (!(klass.getKind() == ClassKind.TRAIT && klass.getModality() == Modality.ABSTRACT || klass.getKind().isObject() && klass.getModality() == Modality.FINAL)) { renderModality(klass.getModality(), builder); } renderInner(klass.isInner(), builder); builder.append(renderKeyword(getClassKindPrefix(klass))); } if (klass.getKind() != ClassKind.CLASS_OBJECT || verbose) { builder.append(" "); renderName(klass, builder); } List<TypeParameterDescriptor> typeParameters = klass.getTypeConstructor().getParameters(); renderTypeParameters(typeParameters, builder, false); if (!klass.getKind().isObject() && classWithPrimaryConstructor) { ConstructorDescriptor primaryConstructor = klass.getUnsubstitutedPrimaryConstructor(); if (primaryConstructor != null) { renderValueParameters(primaryConstructor, builder); } } if (!klass.equals(KotlinBuiltIns.getInstance().getNothing())) { Collection<JetType> supertypes = klass.getTypeConstructor().getSupertypes(); if (supertypes.isEmpty() || !alwaysRenderAny && supertypes.size() == 1 && KotlinBuiltIns.getInstance().isAny(supertypes.iterator().next())) { } else { builder.append(" : "); for (Iterator<JetType> iterator = supertypes.iterator(); iterator.hasNext(); ) { JetType supertype = iterator.next(); builder.append(renderType(supertype)); if (iterator.hasNext()) { builder.append(", "); } } } } renderWhereSuffix(typeParameters, builder); }
public static FunctionDescriptor getInvokeFunction(@NotNull JetType functionType) { assert KotlinBuiltIns.getInstance().isFunctionOrExtensionFunctionType(functionType); ClassifierDescriptor classDescriptorForFunction = functionType.getConstructor().getDeclarationDescriptor(); assert classDescriptorForFunction instanceof ClassDescriptor; Collection<FunctionDescriptor> invokeFunctions = ((ClassDescriptor) classDescriptorForFunction) .getMemberScope(functionType.getArguments()) .getFunctions(Name.identifier("invoke")); assert invokeFunctions.size() == 1; return invokeFunctions.iterator().next(); }