Add renderAccessors flag to DescriptorRenderer to render property accessors as "setter for …"
This commit is contained in:
@@ -59,6 +59,7 @@ public class DescriptorRendererBuilder {
|
|||||||
private Collection<FqName> excludedAnnotationClasses = Collections.emptyList();
|
private Collection<FqName> excludedAnnotationClasses = Collections.emptyList();
|
||||||
private boolean receiverAfterName = false;
|
private boolean receiverAfterName = false;
|
||||||
private boolean renderCompanionObjectName = false;
|
private boolean renderCompanionObjectName = false;
|
||||||
|
private boolean renderAccessors = false;
|
||||||
|
|
||||||
public DescriptorRendererBuilder() {
|
public DescriptorRendererBuilder() {
|
||||||
}
|
}
|
||||||
@@ -224,6 +225,12 @@ public class DescriptorRendererBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public DescriptorRendererBuilder setRenderAccessors(boolean renderAccessors) {
|
||||||
|
this.renderAccessors = renderAccessors;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public DescriptorRenderer build() {
|
public DescriptorRenderer build() {
|
||||||
return new DescriptorRendererImpl(
|
return new DescriptorRendererImpl(
|
||||||
@@ -231,8 +238,8 @@ public class DescriptorRendererBuilder {
|
|||||||
normalizedVisibilities, showInternalKeyword, prettyFunctionTypes, uninferredTypeParameterAsName,
|
normalizedVisibilities, showInternalKeyword, prettyFunctionTypes, uninferredTypeParameterAsName,
|
||||||
overrideRenderingPolicy, valueParametersHandler, textFormat, excludedAnnotationClasses, includePropertyConstant,
|
overrideRenderingPolicy, valueParametersHandler, textFormat, excludedAnnotationClasses, includePropertyConstant,
|
||||||
parameterNameRenderingPolicy, withoutTypeParameters, receiverAfterName, renderCompanionObjectName, withoutSuperTypes,
|
parameterNameRenderingPolicy, withoutTypeParameters, receiverAfterName, renderCompanionObjectName, withoutSuperTypes,
|
||||||
typeNormalizer, renderDefaultValues, flexibleTypesForCode, secondaryConstructorsAsPrimary
|
typeNormalizer, renderDefaultValues, flexibleTypesForCode, secondaryConstructorsAsPrimary,
|
||||||
);
|
renderAccessors);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
|
|||||||
private final boolean includePropertyConstant;
|
private final boolean includePropertyConstant;
|
||||||
private final boolean secondaryConstructorsAsPrimary;
|
private final boolean secondaryConstructorsAsPrimary;
|
||||||
private final Set<FqName> excludedAnnotationClasses;
|
private final Set<FqName> excludedAnnotationClasses;
|
||||||
|
private final boolean renderAccessors;
|
||||||
|
|
||||||
/* package */ DescriptorRendererImpl(
|
/* package */ DescriptorRendererImpl(
|
||||||
NameShortness nameShortness,
|
NameShortness nameShortness,
|
||||||
@@ -97,7 +98,8 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
|
|||||||
@NotNull Function1<JetType, JetType> typeNormalizer,
|
@NotNull Function1<JetType, JetType> typeNormalizer,
|
||||||
boolean renderDefaultValues,
|
boolean renderDefaultValues,
|
||||||
boolean flexibleTypesForCode,
|
boolean flexibleTypesForCode,
|
||||||
boolean secondaryConstructorsAsPrimary
|
boolean secondaryConstructorsAsPrimary,
|
||||||
|
boolean renderAccessors
|
||||||
) {
|
) {
|
||||||
this.nameShortness = nameShortness;
|
this.nameShortness = nameShortness;
|
||||||
this.withDefinedIn = withDefinedIn;
|
this.withDefinedIn = withDefinedIn;
|
||||||
@@ -114,6 +116,7 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
|
|||||||
this.textFormat = textFormat;
|
this.textFormat = textFormat;
|
||||||
this.includePropertyConstant = includePropertyConstant;
|
this.includePropertyConstant = includePropertyConstant;
|
||||||
this.secondaryConstructorsAsPrimary = secondaryConstructorsAsPrimary;
|
this.secondaryConstructorsAsPrimary = secondaryConstructorsAsPrimary;
|
||||||
|
this.renderAccessors = renderAccessors;
|
||||||
this.excludedAnnotationClasses = new HashSet<FqName>(excludedAnnotationClasses);
|
this.excludedAnnotationClasses = new HashSet<FqName>(excludedAnnotationClasses);
|
||||||
this.prettyFunctionTypes = prettyFunctionTypes;
|
this.prettyFunctionTypes = prettyFunctionTypes;
|
||||||
this.uninferredTypeParameterAsName = uninferredTypeParameterAsName;
|
this.uninferredTypeParameterAsName = uninferredTypeParameterAsName;
|
||||||
@@ -1107,6 +1110,29 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void visitPropertyGetterDescriptor(PropertyGetterDescriptor descriptor, StringBuilder builder) {
|
||||||
|
if (renderAccessors) {
|
||||||
|
builder.append("getter for ");
|
||||||
|
renderProperty(descriptor.getCorrespondingProperty(), builder);
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return super.visitPropertyGetterDescriptor(descriptor, builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void visitPropertySetterDescriptor(PropertySetterDescriptor descriptor, StringBuilder builder) {
|
||||||
|
if (renderAccessors) {
|
||||||
|
builder.append("setter for ");
|
||||||
|
renderProperty(descriptor.getCorrespondingProperty(), builder);
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return super.visitPropertySetterDescriptor(descriptor, builder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void visitFunctionDescriptor(FunctionDescriptor descriptor, StringBuilder builder) {
|
public Void visitFunctionDescriptor(FunctionDescriptor descriptor, StringBuilder builder) {
|
||||||
renderFunction(descriptor, builder);
|
renderFunction(descriptor, builder);
|
||||||
|
|||||||
Reference in New Issue
Block a user