Minor refactoring: rename methods
This commit is contained in:
@@ -91,7 +91,7 @@ public abstract class AnnotationCodegen {
|
|||||||
|
|
||||||
public void generateAnnotationDefaultValue(CompileTimeConstant value) {
|
public void generateAnnotationDefaultValue(CompileTimeConstant value) {
|
||||||
AnnotationVisitor visitor = visitAnnotation(null, false); // Parameters are unimportant
|
AnnotationVisitor visitor = visitAnnotation(null, false); // Parameters are unimportant
|
||||||
genAnnotationArgument(null, value, visitor);
|
genCompileTimeValue(null, value, visitor);
|
||||||
visitor.visitEnd();
|
visitor.visitEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,11 +113,11 @@ public abstract class AnnotationCodegen {
|
|||||||
for (Map.Entry<ValueParameterDescriptor, CompileTimeConstant<?>> entry : annotationDescriptor.getAllValueArguments().entrySet()) {
|
for (Map.Entry<ValueParameterDescriptor, CompileTimeConstant<?>> entry : annotationDescriptor.getAllValueArguments().entrySet()) {
|
||||||
ValueParameterDescriptor descriptor = entry.getKey();
|
ValueParameterDescriptor descriptor = entry.getKey();
|
||||||
String name = descriptor.getName().asString();
|
String name = descriptor.getName().asString();
|
||||||
genAnnotationArgument(name, entry.getValue(), annotationVisitor);
|
genCompileTimeValue(name, entry.getValue(), annotationVisitor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void genAnnotationArgument(
|
private void genCompileTimeValue(
|
||||||
@Nullable final String name,
|
@Nullable final String name,
|
||||||
@NotNull CompileTimeConstant<?> value,
|
@NotNull CompileTimeConstant<?> value,
|
||||||
@NotNull final AnnotationVisitor annotationVisitor
|
@NotNull final AnnotationVisitor annotationVisitor
|
||||||
@@ -179,7 +179,7 @@ public abstract class AnnotationCodegen {
|
|||||||
public Void visitArrayValue(ArrayValue value, Void data) {
|
public Void visitArrayValue(ArrayValue value, Void data) {
|
||||||
AnnotationVisitor visitor = annotationVisitor.visitArray(name);
|
AnnotationVisitor visitor = annotationVisitor.visitArray(name);
|
||||||
for (CompileTimeConstant<?> argument : value.getValue()) {
|
for (CompileTimeConstant<?> argument : value.getValue()) {
|
||||||
genAnnotationArgument(null, argument, visitor);
|
genCompileTimeValue(null, argument, visitor);
|
||||||
}
|
}
|
||||||
visitor.visitEnd();
|
visitor.visitEnd();
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -106,12 +106,10 @@ public class PropertyCodegen extends GenerationStateAware {
|
|||||||
|
|
||||||
public void generateConstructorPropertyAsMethodForAnnotationClass(JetParameter p, PropertyDescriptor descriptor) {
|
public void generateConstructorPropertyAsMethodForAnnotationClass(JetParameter p, PropertyDescriptor descriptor) {
|
||||||
Type type = state.getTypeMapper().mapType(descriptor);
|
Type type = state.getTypeMapper().mapType(descriptor);
|
||||||
MethodVisitor visitor =
|
MethodVisitor visitor = v.newMethod(p, ACC_PUBLIC | ACC_ABSTRACT, p.getName(), "()" + type.getDescriptor(), null, null);
|
||||||
v.newMethod(p, ACC_PUBLIC | ACC_ABSTRACT, p.getName(), "()" + type.getDescriptor(), null, null);
|
|
||||||
JetExpression defaultValue = p.getDefaultValue();
|
JetExpression defaultValue = p.getDefaultValue();
|
||||||
if (defaultValue != null) {
|
if (defaultValue != null) {
|
||||||
CompileTimeConstant<?> constant =
|
CompileTimeConstant<?> constant = state.getBindingContext().get(BindingContext.COMPILE_TIME_VALUE, defaultValue);
|
||||||
state.getBindingContext().get(BindingContext.COMPILE_TIME_VALUE, defaultValue);
|
|
||||||
assert constant != null : "Default value for annotation parameter should be compile time value: " + defaultValue.getText();
|
assert constant != null : "Default value for annotation parameter should be compile time value: " + defaultValue.getText();
|
||||||
AnnotationCodegen annotationCodegen = AnnotationCodegen.forAnnotationDefaultValue(visitor, typeMapper);
|
AnnotationCodegen annotationCodegen = AnnotationCodegen.forAnnotationDefaultValue(visitor, typeMapper);
|
||||||
annotationCodegen.generateAnnotationDefaultValue(constant);
|
annotationCodegen.generateAnnotationDefaultValue(constant);
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ public class AnnotationResolver {
|
|||||||
for (ValueArgument argument : resolvedValueArgument.getArguments()) {
|
for (ValueArgument argument : resolvedValueArgument.getArguments()) {
|
||||||
JetExpression argumentExpression = argument.getArgumentExpression();
|
JetExpression argumentExpression = argument.getArgumentExpression();
|
||||||
if (argumentExpression != null) {
|
if (argumentExpression != null) {
|
||||||
CompileTimeConstant<?> constant = resolveAnnotationArgument(argumentExpression, expectedType, trace);
|
CompileTimeConstant<?> constant = resolveExpressionToCompileTimeValue(argumentExpression, expectedType, trace);
|
||||||
if (constant != null) {
|
if (constant != null) {
|
||||||
constants.add(constant);
|
constants.add(constant);
|
||||||
}
|
}
|
||||||
@@ -223,7 +223,11 @@ public class AnnotationResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public CompileTimeConstant<?> resolveAnnotationArgument(@NotNull JetExpression expression, @NotNull final JetType expectedType, final BindingTrace trace) {
|
public CompileTimeConstant<?> resolveExpressionToCompileTimeValue(
|
||||||
|
@NotNull JetExpression expression,
|
||||||
|
@NotNull final JetType expectedType,
|
||||||
|
@NotNull final BindingTrace trace
|
||||||
|
) {
|
||||||
JetVisitor<CompileTimeConstant<?>, Void> visitor = new JetVisitor<CompileTimeConstant<?>, Void>() {
|
JetVisitor<CompileTimeConstant<?>, Void> visitor = new JetVisitor<CompileTimeConstant<?>, Void>() {
|
||||||
@Override
|
@Override
|
||||||
public CompileTimeConstant<?> visitConstantExpression(JetConstantExpression expression, Void nothing) {
|
public CompileTimeConstant<?> visitConstantExpression(JetConstantExpression expression, Void nothing) {
|
||||||
|
|||||||
@@ -699,7 +699,7 @@ public class BodyResolver {
|
|||||||
expressionTypingServices.getType(declaringScope, defaultValue, valueParameterDescriptor.getType(), DataFlowInfo.EMPTY, trace);
|
expressionTypingServices.getType(declaringScope, defaultValue, valueParameterDescriptor.getType(), DataFlowInfo.EMPTY, trace);
|
||||||
if (DescriptorUtils.isAnnotationClass(DescriptorUtils.getContainingClass(declaringScope))) {
|
if (DescriptorUtils.isAnnotationClass(DescriptorUtils.getContainingClass(declaringScope))) {
|
||||||
CompileTimeConstant<?> constant =
|
CompileTimeConstant<?> constant =
|
||||||
annotationResolver.resolveAnnotationArgument(defaultValue, valueParameterDescriptor.getType(), trace);
|
annotationResolver.resolveExpressionToCompileTimeValue(defaultValue, valueParameterDescriptor.getType(), trace);
|
||||||
if (constant != null) {
|
if (constant != null) {
|
||||||
trace.record(BindingContext.COMPILE_TIME_VALUE, defaultValue, constant);
|
trace.record(BindingContext.COMPILE_TIME_VALUE, defaultValue, constant);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user