StorageManager for compile-time initializer

This commit is contained in:
Natalia Ukhorskaya
2014-02-12 19:59:35 +04:00
parent 17259a052e
commit df3ed5059c
27 changed files with 75 additions and 89 deletions
@@ -41,7 +41,7 @@ abstract class AbstractEvaluateExpressionTest : AbstractAnnotationDescriptorReso
fun doConstantTest(path: String) {
doTest(path) {
property, context ->
val compileTimeConstant = context.get(BindingContext.COMPILE_TIME_VALUE, property.getInitializer())
val compileTimeConstant = property.getCompileTimeInitializer()
if (compileTimeConstant is StringValue) {
"\\\"${compileTimeConstant.getValue()}\\\""
} else {
@@ -54,7 +54,7 @@ abstract class AbstractEvaluateExpressionTest : AbstractAnnotationDescriptorReso
fun doIsPureTest(path: String) {
doTest(path) {
property, context ->
val compileTimeConstant = context.get(BindingContext.COMPILE_TIME_VALUE, property.getInitializer())
val compileTimeConstant = property.getCompileTimeInitializer()
if (compileTimeConstant is IntegerValueConstant) {
compileTimeConstant.isPure().toString()
} else {
@@ -63,7 +63,7 @@ abstract class AbstractEvaluateExpressionTest : AbstractAnnotationDescriptorReso
}
}
private fun doTest(path: String, getValueToTest: (JetProperty, BindingContext) -> String) {
private fun doTest(path: String, getValueToTest: (VariableDescriptor, BindingContext) -> String) {
val myFile = File(path)
val fileText = FileUtil.loadFile(myFile, true)
val packageView = getPackage(fileText)
@@ -80,9 +80,7 @@ abstract class AbstractEvaluateExpressionTest : AbstractAnnotationDescriptorReso
val property = AbstractAnnotationDescriptorResolveTest.getPropertyDescriptor(packageView, propertyName, false)
?: AbstractAnnotationDescriptorResolveTest.getLocalVarDescriptor(context!!, propertyName)
val jetProperty = BindingContextUtils.descriptorToDeclaration(context!!, property) as JetProperty
val testedObject = getValueToTest(jetProperty, context!!)
val testedObject = getValueToTest(property, context!!)
expectedActual.add(expectedPropertyPrefix + expected!! to expectedPropertyPrefix + testedObject)
}
@@ -56,16 +56,6 @@ public class RecursiveDescriptorComparator {
public static final Configuration RECURSIVE = new Configuration(false, false, true,
Predicates.<FqName>alwaysTrue(),
FORBID_ERROR_TYPES, DEFAULT_RENDERER);
public static final Configuration WITHOUT_COMPILE_TIME_CONSTANTS = new Configuration(false, false, true,
Predicates.<FqName>alwaysTrue(),
FORBID_ERROR_TYPES,
new DescriptorRendererBuilder()
.setWithDefinedIn(false)
.setExcludedAnnotationClasses(Arrays.asList(new FqName(ExpectedLoadErrorsUtil.ANNOTATION_CLASS_NAME)))
.setOverrideRenderingPolicy(DescriptorRenderer.OverrideRenderingPolicy.RENDER_OPEN_OVERRIDE)
.setVerbose(true)
.setIncludePropertyConstant(false)
.build());
public static final Configuration RECURSIVE_ALL = new Configuration(true, true, true,
Predicates.<FqName>alwaysTrue(),