@Test public void variablesFromForLoopHaveProperRegionReturned() { final TestCase holder = new TestCase(RobotToken.create("test")); final RobotExecutableRow<TestCase> executable = new RobotExecutableRow<>(); executable.setParent(holder); holder.addElement(executable); executable.setAction(RobotToken.create(":FOR", new FilePosition(1, 4, 54), RobotTokenType.FOR_TOKEN)); executable.addArgument(RobotToken.create("${x}", new FilePosition(1, 10, 60))); executable.addArgument(RobotToken.create("${y}", new FilePosition(1, 18, 68))); executable.addArgument(RobotToken.create("IN", new FilePosition(1, 26, 76), RobotTokenType.IN_TOKEN)); executable.addArgument(RobotToken.create("@{XS}", new FilePosition(1, 30, 80))); final ForLoopDeclarationRowDescriptor<?> desc = (ForLoopDeclarationRowDescriptor<?>) executable .buildLineDescription(); final ExecutableWithDescriptor loopHeader = new ExecutableWithDescriptor(executable, desc, null); final ExecutableWithDescriptor descriptor = new ExecutableWithDescriptor( new ForLoop(loopHeader, newArrayList()), null); final FileRegion region = descriptor.getForVariablesRegion(); assertThat(region.getStart().getOffset()).isEqualTo(60); assertThat(region.getEnd().getOffset()).isEqualTo(72); }
FileRegion getForVariablesRegion() { final List<RobotToken> tokens = getForVariables(); final RobotToken minToken = Collections.min(tokens, RobotToken.byStartOffset()); final RobotToken maxToken = Collections.max(tokens, RobotToken.byStartOffset()); return new FileRegion(minToken.getFilePosition(), maxToken.getEndFilePosition()); }
ExecutableWithDescriptor { FileRegion getForVariablesRegion() { final List<RobotToken> tokens = getForVariables(); final RobotToken minToken = Collections.min(tokens, RobotToken.byStartOffset()); final RobotToken maxToken = Collections.max(tokens, RobotToken.byStartOffset()); return new FileRegion(minToken.getFilePosition(), maxToken.getEndFilePosition()); } }
ExecutableWithDescriptor { FileRegion getForVariablesRegion() { final List<RobotToken> tokens = getForVariables(); final RobotToken minToken = Collections.min(tokens, RobotToken.byStartOffset()); final RobotToken maxToken = Collections.max(tokens, RobotToken.byStartOffset()); return new FileRegion(minToken.getFilePosition(), maxToken.getEndFilePosition()); } ExecutableWithDescriptor(final RobotExecutableRow<?> executable, final IExecutableRowDescriptor<?> descriptor,
            final String template);   ExecutableWithDescriptor(final ForLoop loopExecutable, final String template); }
ExecutableWithDescriptor { FileRegion getForVariablesRegion() { final List<RobotToken> tokens = getForVariables(); final RobotToken minToken = Collections.min(tokens, RobotToken.byStartOffset()); final RobotToken maxToken = Collections.max(tokens, RobotToken.byStartOffset()); return new FileRegion(minToken.getFilePosition(), maxToken.getEndFilePosition()); } ExecutableWithDescriptor(final RobotExecutableRow<?> executable, final IExecutableRowDescriptor<?> descriptor,
            final String template);   ExecutableWithDescriptor(final ForLoop loopExecutable, final String template);  }
ExecutableWithDescriptor { FileRegion getForVariablesRegion() { final List<RobotToken> tokens = getForVariables(); final RobotToken minToken = Collections.min(tokens, RobotToken.byStartOffset()); final RobotToken maxToken = Collections.max(tokens, RobotToken.byStartOffset()); return new FileRegion(minToken.getFilePosition(), maxToken.getEndFilePosition()); } ExecutableWithDescriptor(final RobotExecutableRow<?> executable, final IExecutableRowDescriptor<?> descriptor,
            final String template);   ExecutableWithDescriptor(final ForLoop loopExecutable, final String template);   }