/** Initialize the execution stack. */ public CloudExecutionStack( @NotNull Project project, @NotNull String name, @Nullable List<StackFrame> frames, @Nullable List<Variable> variableTable, @Nullable List<Variable> evaluatedExpressions) { super(name); if (frames != null) { if (variableTable == null) { variableTable = Collections.emptyList(); } for (StackFrame nativeFrame : frames) { this.frames.add( new CloudStackFrame( project, nativeFrame, variableTable, evaluatedExpressions, new ServerToIdeFileResolver())); // We only show custom watches on the top frame. evaluatedExpressions = null; } } }
@Test public void testGetTopFrame_nonNull() { List<StackFrame> frames = new ArrayList<StackFrame>(); StackFrame frame1 = new StackFrame(); SourceLocation location1 = new SourceLocation(); location1.setLine(1); frame1.setLocation(location1); List<Variable> variables = new ArrayList<Variable>(); Variable variable = new Variable(); variable.setName("foo"); variables.add(variable); frame1.setLocals(variables); StackFrame frame2 = new StackFrame(); SourceLocation location2 = new SourceLocation(); location2.setLine(2); frame2.setLocation(location2); frames.add(frame1); frames.add(frame2); CloudExecutionStack stack = new CloudExecutionStack(project, "name", frames, null, null); CloudStackFrame localFrame = stack.getTopFrame(); Assert.assertNotNull(localFrame); SpyNode node = new SpyNode(); localFrame.computeChildren(node); Assert.assertEquals(1, node.seenChildren.size()); Assert.assertEquals("foo", node.seenChildren.get(0)); }