SuiteContext extends DefaultContext { @Override public StackFrameContext moveTo(final RunningKeyword keyword, final RobotBreakpointSupplier breakpointSupplier) { if (keyword.isSetup() || keyword.isTeardown()) { if (isErroneous()) { final String errorMsg = String.format( ErrorMessages.errorOfSuitePrePostKwNotFound(keyword.isSetup()), keyword.asCall()); return new SetupTeardownContext(errorMsg, this); } final Optional<RobotFile> fileModel = associatedFileModelProvider.apply(locationUri); if (!fileModel.isPresent()) { final String msg = ErrorMessages.errorOfSuitePrePostKwNotFoundBecauseOfMissingInit(keyword.isSetup()); final String errorMsg = String.format(msg, keyword.asCall(), suiteName, getAssociatedPath().map(File::new).map(File::getAbsolutePath).orElse("<unknown>")); return new SetupTeardownContext(errorMsg, this); } final URI fileUri = fileModel.get().getParent().getProcessedFile().toURI(); final SettingTable settingsTable = fileModel.get().getSettingTable(); if (!settingsTable.isPresent()) { final String msg = ErrorMessages .errorOfSuitePrePostKwNotFoundBecauseOfMissingSetting(keyword.isSetup()); final String errorMsg = String.format(msg, keyword.asCall()); return new SetupTeardownContext(fileUri, 1, errorMsg, this); } final List<? extends ExecutableSetting> setupTeardowns = keyword.isSetup() ? settingsTable.getSuiteSetups() : settingsTable.getSuiteTeardowns(); final ExecutableSetting setting = setupTeardowns.isEmpty() ? null : setupTeardowns.get(0); if (setting == null) { final String msg = ErrorMessages .errorOfSuitePrePostKwNotFoundBecauseOfMissingSetting(keyword.isSetup()); final String errorMsg = String.format(msg, keyword.asCall()); final int line = settingsTable.getHeaders().get(0).getTableHeader().getLineNumber(); return new SetupTeardownContext(fileUri, line, errorMsg, this); } final int declarationLine = setting.getDeclaration().getLineNumber(); final RobotToken keywordToken = setting.getKeywordName(); if (keywordToken == null || keywordToken.getText().isEmpty()) { final String msg = ErrorMessages .errorOfSuitePrePostKwNotFoundBecauseOfMissingSetting(keyword.isSetup()); final String errorMsg = String.format(msg, keyword.asCall()); return new SetupTeardownContext(fileUri, declarationLine, errorMsg, this, breakpointSupplier); } if (CallChecker.isCallOf(keywordToken.getText(), keyword)) { return new SetupTeardownContext(fileUri, keywordToken.getText(), declarationLine, this, breakpointSupplier); } else { final String msg = ErrorMessages.errorOfSuitePrePostKwNotFoundBecauseOfDifferentCall(keyword.isSetup()); final String errorMsg = String.format(msg, keyword.asCall(), keywordToken.getText()); return new SetupTeardownContext(fileUri, declarationLine, errorMsg, this, breakpointSupplier); } } else { throw new IllegalDebugContextStateException( "Only suite setup or teardown keyword call is possible in current context"); } } SuiteContext(final String suiteName);  SuiteContext(final String suiteName, final boolean isDirectory, final String errorMessage);  SuiteContext(final String suiteName, final URI locationUri, final boolean isDirectory,
            final String errorMessage);  SuiteContext(final String suiteName, final URI locationUri, final boolean isDirectory,
            final Function<URI, Optional<RobotFile>> associatedFileModelProvider); private  SuiteContext(final String suiteName, final URI locationUri, final boolean isDirectory,
            final String errorMessage,
            final Function<URI, Optional<RobotFile>> associatedFileModelProvider); boolean isDirectory(); @Override boolean isErroneous(); @Override Optional<String> getErrorMessage(); @Override Optional<URI> getAssociatedPath(); @Override StackFrameContext moveTo(final RunningKeyword keyword, final RobotBreakpointSupplier breakpointSupplier);  }
@Test public void itIsIllegalToMoveToToDifferentKeywordTypeThanSetupOrTeardown() throws Exception { final SuiteContext context = new SuiteContext("suite", URI.create("file: for (final KeywordCallType type : EnumSet.of(KeywordCallType.NORMAL_CALL, KeywordCallType.FOR, KeywordCallType.FOR_ITERATION)) { assertThatExceptionOfType(IllegalDebugContextStateException.class).isThrownBy( () -> context.moveTo(new RunningKeyword("_", "_", type), mock(RobotBreakpointSupplier.class))) .withMessage("Only suite setup or teardown keyword call is possible in current context") .withNoCause(); } }