@Override
  protected boolean setupConfigurationFromContext(@NotNull RestRunConfiguration configuration,
                                                  @NotNull ConfigurationContext context,
                                                  @NotNull Ref<PsiElement> sourceElement) {
    assert (configuration instanceof DocutilsRunConfiguration);
    PsiFile script = sourceElement.get().getContainingFile();
    if (script == null || script.getFileType() != RestFileType.INSTANCE) {
      return false;
    }
    Module module = ModuleUtilCore.findModuleForPsiElement(script);
    final VirtualFile vFile = script.getVirtualFile();
    if (vFile == null) return false;
    configuration.setInputFile(vFile.getPath());
    configuration.setName(script.getName());

    String outputPath = vFile.getPath();
    int index = outputPath.lastIndexOf('.');
    if (index > 0) outputPath = outputPath.substring(0, index);
    outputPath += ".html";
    VirtualFile outputFile = LocalFileSystem.getInstance().findFileByPath(outputPath);
    if (outputFile == null) {
      configuration.setOutputFile(outputPath);
      configuration.setOpenInBrowser(true);
    }

    if (configuration.getTask().isEmpty()) {
      configuration.setTask("rst2html");
    }
    final VirtualFile parent = vFile.getParent();
    if (parent != null) {
      configuration.setWorkingDirectory(parent.getPath());
    }
    configuration.setName(configuration.suggestedName());
    if (module != null) {
      configuration.setUseModuleSdk(true);
      configuration.setModule(module);
    }
    return true;
  }
@Override
  protected boolean setupConfigurationFromContext(@NotNull RestRunConfiguration configuration,
                                                  @NotNull ConfigurationContext context,
                                                  @NotNull Ref<PsiElement> sourceElement)