Search in sources :

Example 1 with BindingTraceContext

use of org.jetbrains.kotlin.resolve.BindingTraceContext in project kotlin by JetBrains.

the class KotlinTypeCheckerTest method assertType.

private void assertType(LexicalScope scope, String expression, String expectedTypeStr) {
    Project project = getProject();
    KtExpression ktExpression = KtPsiFactoryKt.KtPsiFactory(project).createExpression(expression);
    KotlinType type = expressionTypingServices.getType(scope, ktExpression, TypeUtils.NO_EXPECTED_TYPE, DataFlowInfoFactory.EMPTY, new BindingTraceContext());
    KotlinType expectedType = expectedTypeStr == null ? null : makeType(expectedTypeStr);
    assertEquals(expectedType, type);
}
Also used : Project(com.intellij.openapi.project.Project) KtExpression(org.jetbrains.kotlin.psi.KtExpression) BindingTraceContext(org.jetbrains.kotlin.resolve.BindingTraceContext)

Example 2 with BindingTraceContext

use of org.jetbrains.kotlin.resolve.BindingTraceContext in project kotlin by JetBrains.

the class TrackingSliceMapTest method testFurtherSlices.

public void testFurtherSlices() {
    WritableSlice<String, Integer> NAME_COLOR = Slices.<String, Integer>sliceBuilder().setDebugName("NAME_COLOR").build();
    @SuppressWarnings("unchecked") WritableSlice<String, Object> NAME_OBJECT = Slices.<String, Object>sliceBuilder().setFurtherLookupSlices(new ReadOnlySlice[] { NAME_COLOR }).setDebugName("NAME_OBJECT").build();
    BindingTraceContext traceContext = BindingTraceContext.createTraceableBindingTrace();
    traceContext.record(NAME_COLOR, "RED", 0xff0000);
    Object object = traceContext.get(NAME_OBJECT, "RED");
    assertNotNull(object);
    Integer color = (Integer) object;
    assertEquals(0xff0000, (int) color);
}
Also used : BindingTraceContext(org.jetbrains.kotlin.resolve.BindingTraceContext)

Example 3 with BindingTraceContext

use of org.jetbrains.kotlin.resolve.BindingTraceContext in project kotlin by JetBrains.

the class TrackingSliceMapTest method testSimpleSlice.

public void testSimpleSlice() {
    WritableSlice<String, Integer> SUPER_COMPUTER = Slices.<String, Integer>sliceBuilder().setDebugName("SUPER_COMPUTER").build();
    BindingTraceContext traceContext = BindingTraceContext.createTraceableBindingTrace();
    traceContext.record(SUPER_COMPUTER, "Answer", 42);
    Integer answer = traceContext.get(SUPER_COMPUTER, "Answer");
    assertNotNull(answer);
    assertEquals(42, (int) answer);
}
Also used : BindingTraceContext(org.jetbrains.kotlin.resolve.BindingTraceContext)

Aggregations

BindingTraceContext (org.jetbrains.kotlin.resolve.BindingTraceContext)3 Project (com.intellij.openapi.project.Project)1 KtExpression (org.jetbrains.kotlin.psi.KtExpression)1