Render property constant
This commit is contained in:
@@ -47,6 +47,7 @@ public class RecursiveDescriptorComparator {
|
|||||||
.setWithDefinedIn(false)
|
.setWithDefinedIn(false)
|
||||||
.setExcludedAnnotationClasses(Arrays.asList(new FqName(ExpectedLoadErrorsUtil.ANNOTATION_CLASS_NAME)))
|
.setExcludedAnnotationClasses(Arrays.asList(new FqName(ExpectedLoadErrorsUtil.ANNOTATION_CLASS_NAME)))
|
||||||
.setOverrideRenderingPolicy(DescriptorRenderer.OverrideRenderingPolicy.RENDER_OPEN_OVERRIDE)
|
.setOverrideRenderingPolicy(DescriptorRenderer.OverrideRenderingPolicy.RENDER_OPEN_OVERRIDE)
|
||||||
|
.setIncludePropertyConstant(true)
|
||||||
.setVerbose(true).build();
|
.setVerbose(true).build();
|
||||||
|
|
||||||
public static final Configuration DONT_INCLUDE_METHODS_OF_OBJECT = new Configuration(false, false, false,
|
public static final Configuration DONT_INCLUDE_METHODS_OF_OBJECT = new Configuration(false, false, false,
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ public class DescriptorRendererBuilder {
|
|||||||
private boolean normalizedVisibilities = false;
|
private boolean normalizedVisibilities = false;
|
||||||
private boolean showInternalKeyword = true;
|
private boolean showInternalKeyword = true;
|
||||||
private boolean prettyFunctionTypes = true;
|
private boolean prettyFunctionTypes = true;
|
||||||
|
private boolean includePropertyConstant = false;
|
||||||
@NotNull
|
@NotNull
|
||||||
private DescriptorRenderer.OverrideRenderingPolicy overrideRenderingPolicy = DescriptorRenderer.OverrideRenderingPolicy.RENDER_OPEN;
|
private DescriptorRenderer.OverrideRenderingPolicy overrideRenderingPolicy = DescriptorRenderer.OverrideRenderingPolicy.RENDER_OPEN;
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -143,11 +144,17 @@ public class DescriptorRendererBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DescriptorRendererBuilder setIncludePropertyConstant(boolean includePropertyConstant) {
|
||||||
|
this.includePropertyConstant = includePropertyConstant;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public DescriptorRenderer build() {
|
public DescriptorRenderer build() {
|
||||||
return new DescriptorRendererImpl(shortNames, withDefinedIn, modifiers, startFromName, debugMode, classWithPrimaryConstructor,
|
return new DescriptorRendererImpl(shortNames, withDefinedIn, modifiers, startFromName, debugMode, classWithPrimaryConstructor,
|
||||||
verbose, unitReturnType, normalizedVisibilities, showInternalKeyword, prettyFunctionTypes,
|
verbose, unitReturnType, normalizedVisibilities, showInternalKeyword, prettyFunctionTypes,
|
||||||
overrideRenderingPolicy, valueParametersHandler, textFormat, excludedAnnotationClasses);
|
overrideRenderingPolicy, valueParametersHandler, textFormat, excludedAnnotationClasses,
|
||||||
|
includePropertyConstant);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
|
|||||||
private final ValueParametersHandler handler;
|
private final ValueParametersHandler handler;
|
||||||
@NotNull
|
@NotNull
|
||||||
private final TextFormat textFormat;
|
private final TextFormat textFormat;
|
||||||
|
private final boolean includePropertyConstant;
|
||||||
@NotNull
|
@NotNull
|
||||||
private final Set<FqName> excludedAnnotationClasses;
|
private final Set<FqName> excludedAnnotationClasses;
|
||||||
|
|
||||||
@@ -80,7 +81,8 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
|
|||||||
@NotNull OverrideRenderingPolicy overrideRenderingPolicy,
|
@NotNull OverrideRenderingPolicy overrideRenderingPolicy,
|
||||||
@NotNull ValueParametersHandler handler,
|
@NotNull ValueParametersHandler handler,
|
||||||
@NotNull TextFormat textFormat,
|
@NotNull TextFormat textFormat,
|
||||||
@NotNull Collection<FqName> excludedAnnotationClasses
|
@NotNull Collection<FqName> excludedAnnotationClasses,
|
||||||
|
boolean includePropertyConstant
|
||||||
) {
|
) {
|
||||||
this.shortNames = shortNames;
|
this.shortNames = shortNames;
|
||||||
this.withDefinedIn = withDefinedIn;
|
this.withDefinedIn = withDefinedIn;
|
||||||
@@ -95,6 +97,7 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
|
|||||||
this.overrideRenderingPolicy = overrideRenderingPolicy;
|
this.overrideRenderingPolicy = overrideRenderingPolicy;
|
||||||
this.debugMode = debugMode;
|
this.debugMode = debugMode;
|
||||||
this.textFormat = textFormat;
|
this.textFormat = textFormat;
|
||||||
|
this.includePropertyConstant = includePropertyConstant;
|
||||||
this.excludedAnnotationClasses = Sets.newHashSet(excludedAnnotationClasses);
|
this.excludedAnnotationClasses = Sets.newHashSet(excludedAnnotationClasses);
|
||||||
this.prettyFunctionTypes = prettyFunctionTypes;
|
this.prettyFunctionTypes = prettyFunctionTypes;
|
||||||
}
|
}
|
||||||
@@ -663,6 +666,8 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
|
|||||||
renderName(variable, builder);
|
renderName(variable, builder);
|
||||||
builder.append(": ").append(escape(renderType(typeToRender)));
|
builder.append(": ").append(escape(renderType(typeToRender)));
|
||||||
|
|
||||||
|
renderInitializer(variable, builder);
|
||||||
|
|
||||||
if (verbose && varargElementType != null) {
|
if (verbose && varargElementType != null) {
|
||||||
builder.append(" /*").append(escape(renderType(realType))).append("*/");
|
builder.append(" /*").append(escape(renderType(realType))).append("*/");
|
||||||
}
|
}
|
||||||
@@ -688,9 +693,19 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
|
|||||||
renderName(property, builder);
|
renderName(property, builder);
|
||||||
builder.append(": ").append(escape(renderType(property.getType())));
|
builder.append(": ").append(escape(renderType(property.getType())));
|
||||||
|
|
||||||
|
renderInitializer(property, builder);
|
||||||
|
|
||||||
renderWhereSuffix(property.getTypeParameters(), builder);
|
renderWhereSuffix(property.getTypeParameters(), builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void renderInitializer(@NotNull VariableDescriptor variable, @NotNull StringBuilder builder) {
|
||||||
|
if (includePropertyConstant) {
|
||||||
|
CompileTimeConstant<?> initializer = variable.getCompileTimeInitializer();
|
||||||
|
if (initializer != null) {
|
||||||
|
builder.append(" = ").append(escape(renderConstant(initializer)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* CLASSES */
|
/* CLASSES */
|
||||||
private void renderClass(@NotNull ClassDescriptor klass, @NotNull StringBuilder builder) {
|
private void renderClass(@NotNull ClassDescriptor klass, @NotNull StringBuilder builder) {
|
||||||
|
|||||||
Reference in New Issue
Block a user