Add location string showing where method or property is defined
This commit is contained in:
@@ -54,7 +54,7 @@ public interface DescriptorRenderer extends Renderer<DeclarationDescriptor> {
|
||||
.setModifiers()
|
||||
.setStartFromName(true).build();
|
||||
|
||||
DescriptorRenderer STARTS_FROM_NAME_WITH_SHORT_TYPES = new DescriptorRendererBuilder()
|
||||
DescriptorRenderer ONLY_NAMES_WITH_SHORT_TYPES = new DescriptorRendererBuilder()
|
||||
.setWithDefinedIn(false)
|
||||
.setModifiers()
|
||||
.setShortNames(true)
|
||||
@@ -62,6 +62,7 @@ public interface DescriptorRenderer extends Renderer<DeclarationDescriptor> {
|
||||
.setWithoutFunctionParameterNames(true)
|
||||
.setReceiverAfterName(true)
|
||||
.setRenderClassObjectName(true)
|
||||
.setWithoutSuperTypes(true)
|
||||
.setStartFromName(true).build();
|
||||
|
||||
DescriptorRenderer FQ_NAMES_IN_TYPES = new DescriptorRendererBuilder().build();
|
||||
|
||||
@@ -41,6 +41,7 @@ public class DescriptorRendererBuilder {
|
||||
private boolean includeSynthesizedParameterNames = true;
|
||||
private boolean withoutFunctionParameterNames = false;
|
||||
private boolean withoutTypeParameters = false;
|
||||
private boolean withoutSuperTypes = false;
|
||||
|
||||
@NotNull
|
||||
private DescriptorRenderer.OverrideRenderingPolicy overrideRenderingPolicy = DescriptorRenderer.OverrideRenderingPolicy.RENDER_OPEN;
|
||||
@@ -187,6 +188,11 @@ public class DescriptorRendererBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
public DescriptorRendererBuilder setWithoutSuperTypes(boolean withoutSuperTypes) {
|
||||
this.withoutSuperTypes = withoutSuperTypes;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public DescriptorRenderer build() {
|
||||
return new DescriptorRendererImpl(
|
||||
@@ -194,7 +200,7 @@ public class DescriptorRendererBuilder {
|
||||
normalizedVisibilities, showInternalKeyword, prettyFunctionTypes, uninferredTypeParameterAsName,
|
||||
overrideRenderingPolicy, valueParametersHandler, textFormat, excludedAnnotationClasses, includePropertyConstant,
|
||||
includeSynthesizedParameterNames, withoutFunctionParameterNames, withoutTypeParameters, receiverAfterName,
|
||||
renderClassObjectName);
|
||||
renderClassObjectName, withoutSuperTypes);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,7 +42,8 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.jet.lang.types.ErrorUtils.UninferredParameterType;
|
||||
import static org.jetbrains.jet.lang.types.TypeUtils.*;
|
||||
import static org.jetbrains.jet.lang.types.TypeUtils.CANT_INFER_LAMBDA_PARAM_TYPE;
|
||||
import static org.jetbrains.jet.lang.types.TypeUtils.DONT_CARE;
|
||||
|
||||
public class DescriptorRendererImpl implements DescriptorRenderer {
|
||||
private final boolean shortNames;
|
||||
@@ -61,8 +62,9 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
|
||||
private final boolean withoutFunctionParameterNames;
|
||||
private final boolean withoutTypeParameters;
|
||||
private final boolean renderClassObjectName;
|
||||
|
||||
private final boolean withoutSuperTypes;
|
||||
private final boolean receiverAfterName;
|
||||
|
||||
@NotNull
|
||||
private final OverrideRenderingPolicy overrideRenderingPolicy;
|
||||
@NotNull
|
||||
@@ -95,7 +97,8 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
|
||||
boolean withoutFunctionParameterNames,
|
||||
boolean withoutTypeParameters,
|
||||
boolean receiverAfterName,
|
||||
boolean renderClassObjectName
|
||||
boolean renderClassObjectName,
|
||||
boolean withoutSuperTypes
|
||||
) {
|
||||
this.shortNames = shortNames;
|
||||
this.withDefinedIn = withDefinedIn;
|
||||
@@ -119,6 +122,7 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
|
||||
this.withoutTypeParameters = withoutTypeParameters;
|
||||
this.receiverAfterName = receiverAfterName;
|
||||
this.renderClassObjectName = renderClassObjectName;
|
||||
this.withoutSuperTypes = withoutSuperTypes;
|
||||
}
|
||||
|
||||
/* FORMATTING */
|
||||
@@ -807,10 +811,18 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
renderSuperTypes(klass, builder);
|
||||
renderWhereSuffix(typeParameters, builder);
|
||||
}
|
||||
|
||||
private void renderSuperTypes(@NotNull ClassDescriptor klass, @NotNull StringBuilder builder) {
|
||||
if (withoutSuperTypes) return;
|
||||
|
||||
if (!klass.equals(KotlinBuiltIns.getInstance().getNothing())) {
|
||||
Collection<JetType> supertypes = klass.getTypeConstructor().getSupertypes();
|
||||
if (supertypes.isEmpty() || supertypes.size() == 1 && KotlinBuiltIns.getInstance().isAnyOrNullableAny(
|
||||
supertypes.iterator().next())) {
|
||||
|
||||
if (supertypes.isEmpty() ||
|
||||
supertypes.size() == 1 && KotlinBuiltIns.getInstance().isAnyOrNullableAny(supertypes.iterator().next())) {
|
||||
}
|
||||
else {
|
||||
builder.append(" : ");
|
||||
@@ -823,8 +835,6 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
renderWhereSuffix(typeParameters, builder);
|
||||
}
|
||||
|
||||
private void renderClassKindPrefix(ClassDescriptor klass, StringBuilder builder) {
|
||||
|
||||
Reference in New Issue
Block a user