Minor refactoring: rename methods

This commit is contained in:
Natalia.Ukhorskaya
2013-07-25 14:51:08 +04:00
parent 6d1e46bae0
commit 1066fc7f2a
4 changed files with 13 additions and 11 deletions
@@ -91,7 +91,7 @@ public abstract class AnnotationCodegen {
public void generateAnnotationDefaultValue(CompileTimeConstant value) {
AnnotationVisitor visitor = visitAnnotation(null, false); // Parameters are unimportant
genAnnotationArgument(null, value, visitor);
genCompileTimeValue(null, value, visitor);
visitor.visitEnd();
}
@@ -113,11 +113,11 @@ public abstract class AnnotationCodegen {
for (Map.Entry<ValueParameterDescriptor, CompileTimeConstant<?>> entry : annotationDescriptor.getAllValueArguments().entrySet()) {
ValueParameterDescriptor descriptor = entry.getKey();
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,
@NotNull CompileTimeConstant<?> value,
@NotNull final AnnotationVisitor annotationVisitor
@@ -179,7 +179,7 @@ public abstract class AnnotationCodegen {
public Void visitArrayValue(ArrayValue value, Void data) {
AnnotationVisitor visitor = annotationVisitor.visitArray(name);
for (CompileTimeConstant<?> argument : value.getValue()) {
genAnnotationArgument(null, argument, visitor);
genCompileTimeValue(null, argument, visitor);
}
visitor.visitEnd();
return null;
@@ -106,12 +106,10 @@ public class PropertyCodegen extends GenerationStateAware {
public void generateConstructorPropertyAsMethodForAnnotationClass(JetParameter p, PropertyDescriptor descriptor) {
Type type = state.getTypeMapper().mapType(descriptor);
MethodVisitor visitor =
v.newMethod(p, ACC_PUBLIC | ACC_ABSTRACT, p.getName(), "()" + type.getDescriptor(), null, null);
MethodVisitor visitor = v.newMethod(p, ACC_PUBLIC | ACC_ABSTRACT, p.getName(), "()" + type.getDescriptor(), null, null);
JetExpression defaultValue = p.getDefaultValue();
if (defaultValue != null) {
CompileTimeConstant<?> constant =
state.getBindingContext().get(BindingContext.COMPILE_TIME_VALUE, defaultValue);
CompileTimeConstant<?> constant = state.getBindingContext().get(BindingContext.COMPILE_TIME_VALUE, defaultValue);
assert constant != null : "Default value for annotation parameter should be compile time value: " + defaultValue.getText();
AnnotationCodegen annotationCodegen = AnnotationCodegen.forAnnotationDefaultValue(visitor, typeMapper);
annotationCodegen.generateAnnotationDefaultValue(constant);
@@ -213,7 +213,7 @@ public class AnnotationResolver {
for (ValueArgument argument : resolvedValueArgument.getArguments()) {
JetExpression argumentExpression = argument.getArgumentExpression();
if (argumentExpression != null) {
CompileTimeConstant<?> constant = resolveAnnotationArgument(argumentExpression, expectedType, trace);
CompileTimeConstant<?> constant = resolveExpressionToCompileTimeValue(argumentExpression, expectedType, trace);
if (constant != null) {
constants.add(constant);
}
@@ -223,7 +223,11 @@ public class AnnotationResolver {
}
@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>() {
@Override
public CompileTimeConstant<?> visitConstantExpression(JetConstantExpression expression, Void nothing) {
@@ -699,7 +699,7 @@ public class BodyResolver {
expressionTypingServices.getType(declaringScope, defaultValue, valueParameterDescriptor.getType(), DataFlowInfo.EMPTY, trace);
if (DescriptorUtils.isAnnotationClass(DescriptorUtils.getContainingClass(declaringScope))) {
CompileTimeConstant<?> constant =
annotationResolver.resolveAnnotationArgument(defaultValue, valueParameterDescriptor.getType(), trace);
annotationResolver.resolveExpressionToCompileTimeValue(defaultValue, valueParameterDescriptor.getType(), trace);
if (constant != null) {
trace.record(BindingContext.COMPILE_TIME_VALUE, defaultValue, constant);
}