Add constructor parameter for compileTimeConstant (can be used in annotation)
This commit is contained in:
@@ -25,7 +25,7 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
public class AnnotationValue extends CompileTimeConstant<AnnotationDescriptor> {
|
||||
|
||||
public AnnotationValue(@NotNull AnnotationDescriptor value) {
|
||||
super(value);
|
||||
super(value, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -27,8 +27,8 @@ public class ArrayValue extends CompileTimeConstant<List<CompileTimeConstant<?>>
|
||||
|
||||
private final JetType type;
|
||||
|
||||
public ArrayValue(@NotNull List<CompileTimeConstant<?>> value, @NotNull JetType type) {
|
||||
super(value);
|
||||
public ArrayValue(@NotNull List<CompileTimeConstant<?>> value, @NotNull JetType type, boolean canBeUsedInAnnotations) {
|
||||
super(value, canBeUsedInAnnotations);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,16 +23,8 @@ import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
public class BooleanValue extends CompileTimeConstant<Boolean> {
|
||||
|
||||
public static final BooleanValue FALSE = new BooleanValue(false);
|
||||
public static final BooleanValue TRUE = new BooleanValue(true);
|
||||
|
||||
private BooleanValue(boolean value) {
|
||||
super(value);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static BooleanValue valueOf(boolean value) {
|
||||
return value ? TRUE : FALSE;
|
||||
public BooleanValue(boolean value, boolean canBeUseInAnnotation) {
|
||||
super(value, canBeUseInAnnotation);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -16,24 +16,15 @@
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.constants;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
public class ByteValue extends CompileTimeConstant<Byte> {
|
||||
public static final Function<Long, ByteValue> CREATE = new Function<Long, ByteValue>() {
|
||||
@Override
|
||||
public ByteValue apply(@Nullable Long input) {
|
||||
assert input != null;
|
||||
return new ByteValue(input.byteValue());
|
||||
}
|
||||
};
|
||||
|
||||
public ByteValue(byte value) {
|
||||
super(value);
|
||||
public ByteValue(byte value, boolean canBeUsedInAnnotations) {
|
||||
super(value, canBeUsedInAnnotations);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -23,8 +23,8 @@ import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
public class CharValue extends CompileTimeConstant<Character> {
|
||||
|
||||
public CharValue(char value) {
|
||||
super(value);
|
||||
public CharValue(char value, boolean canBeUsedInAnnotations) {
|
||||
super(value, canBeUsedInAnnotations);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+3
-6
@@ -24,20 +24,17 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
public abstract class CompileTimeConstant<T> {
|
||||
protected final T value;
|
||||
private boolean canBeUsedInAnnotations = true;
|
||||
private final boolean canBeUsedInAnnotations;
|
||||
|
||||
protected CompileTimeConstant(T value) {
|
||||
protected CompileTimeConstant(T value, boolean canBeUsedInAnnotations) {
|
||||
this.value = value;
|
||||
this.canBeUsedInAnnotations = canBeUsedInAnnotations;
|
||||
}
|
||||
|
||||
public boolean canBeUsedInAnnotations() {
|
||||
return canBeUsedInAnnotations;
|
||||
}
|
||||
|
||||
public void setCanBeUsedInAnnotations(boolean canBeUsedInAnnotations) {
|
||||
this.canBeUsedInAnnotations = canBeUsedInAnnotations;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public T getValue() {
|
||||
return value;
|
||||
|
||||
@@ -23,8 +23,8 @@ import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
public class DoubleValue extends CompileTimeConstant<Double> {
|
||||
|
||||
public DoubleValue(double value) {
|
||||
super(value);
|
||||
public DoubleValue(double value, boolean canBeUsedInAnnotations) {
|
||||
super(value, canBeUsedInAnnotations);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
public class EnumValue extends CompileTimeConstant<ClassDescriptor> {
|
||||
|
||||
public EnumValue(@NotNull ClassDescriptor value) {
|
||||
super(value);
|
||||
super(value, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
public abstract class ErrorValue extends CompileTimeConstant<Void> {
|
||||
|
||||
public ErrorValue() {
|
||||
super(null);
|
||||
super(null, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,8 +23,8 @@ import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
public class FloatValue extends CompileTimeConstant<Float> {
|
||||
|
||||
public FloatValue(float value) {
|
||||
super(value);
|
||||
public FloatValue(float value, boolean canBeUsedInAnnotations) {
|
||||
super(value, canBeUsedInAnnotations);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -16,24 +16,15 @@
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.constants;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
public class IntValue extends CompileTimeConstant<Integer> {
|
||||
public static final Function<Long, IntValue> CREATE = new Function<Long, IntValue>() {
|
||||
@Override
|
||||
public IntValue apply(@Nullable Long input) {
|
||||
assert input != null;
|
||||
return new IntValue(input.intValue());
|
||||
}
|
||||
};
|
||||
|
||||
public IntValue(int value) {
|
||||
super(value);
|
||||
public IntValue(int value, boolean canBeUsedInAnnotations) {
|
||||
super(value, canBeUsedInAnnotations);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+2
-2
@@ -30,8 +30,8 @@ public class IntegerValueTypeConstant extends CompileTimeConstant<Number> {
|
||||
|
||||
private final IntegerValueTypeConstructor typeConstructor;
|
||||
|
||||
public IntegerValueTypeConstant(@NotNull Number value) {
|
||||
super(value);
|
||||
public IntegerValueTypeConstant(@NotNull Number value, boolean canBeUsedInAnnotations) {
|
||||
super(value, canBeUsedInAnnotations);
|
||||
this.typeConstructor = new IntegerValueTypeConstructor(value.longValue());
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
public class JavaClassValue extends CompileTimeConstant<JetType> {
|
||||
|
||||
public JavaClassValue(JetType value) {
|
||||
super(value);
|
||||
public JavaClassValue(@NotNull JetType value) {
|
||||
super(value, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -16,23 +16,15 @@
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.constants;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
public class LongValue extends CompileTimeConstant<Long> {
|
||||
public static final Function<Long, LongValue> CREATE = new Function<Long, LongValue>() {
|
||||
@Override
|
||||
public LongValue apply(@Nullable Long input) {
|
||||
return new LongValue(input);
|
||||
}
|
||||
};
|
||||
|
||||
public LongValue(long value) {
|
||||
super(value);
|
||||
public LongValue(long value, boolean canBeUsedInAnnotations) {
|
||||
super(value, canBeUsedInAnnotations);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -26,7 +26,7 @@ public class NullValue extends CompileTimeConstant<Void> {
|
||||
public static final NullValue NULL = new NullValue();
|
||||
|
||||
private NullValue() {
|
||||
super(null);
|
||||
super(null, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -16,24 +16,15 @@
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.constants;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
public class ShortValue extends CompileTimeConstant<Short> {
|
||||
public static final Function<Long, ShortValue> CREATE = new Function<Long, ShortValue>() {
|
||||
@Override
|
||||
public ShortValue apply(@Nullable Long input) {
|
||||
assert input != null;
|
||||
return new ShortValue(input.shortValue());
|
||||
}
|
||||
};
|
||||
|
||||
public ShortValue(short value) {
|
||||
super(value);
|
||||
public ShortValue(short value, boolean canBeUsedInAnnotations) {
|
||||
super(value, canBeUsedInAnnotations);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -24,8 +24,8 @@ import org.jetbrains.jet.lang.types.JetType;
|
||||
public class StringValue extends CompileTimeConstant<String> {
|
||||
|
||||
|
||||
public StringValue(String value) {
|
||||
super(value);
|
||||
public StringValue(String value, boolean canBeUsedInAnnotations) {
|
||||
super(value, canBeUsedInAnnotations);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user