Examples of GherkinStep


Examples of org.jetbrains.plugins.cucumber.psi.GherkinStep

  private static GherkinStep createStepIn(String language) {
    GherkinFile featureFile = EasyMock.createNiceMock(GherkinFile.class);
    expect(featureFile.getLocaleLanguage()).andReturn(language).anyTimes();

    GherkinStep step = EasyMock.createNiceMock(GherkinStep.class);
    expect(step.getContainingFile()).andReturn(featureFile).anyTimes();

    replay(featureFile, step);
    return step;
  }
View Full Code Here

Examples of org.jetbrains.plugins.cucumber.psi.GherkinStep

    if (! (element instanceof GherkinStep)) {
      return result; // Not a step, so there is nothing to check
    }

    final GherkinStep step = (GherkinStep)element;

    for (final AbstractStepDefinition stepDefinition : stepDefinitions) {
      for (final String s : stepVariants) {
        if (stepDefinition.matches(s) && stepDefinition.supportsStep(step)) {
          result.add(stepDefinition.getElement());
View Full Code Here

Examples of org.jetbrains.plugins.cucumber.psi.GherkinStep

  public String getFamilyName() {
    return getName();
  }

  public void applyFix(@NotNull final Project project, @NotNull ProblemDescriptor descriptor) {
    final GherkinStep step = (GherkinStep)descriptor.getPsiElement();
    final GherkinFile featureFile = (GherkinFile)step.getContainingFile();
    // TODO + step defs pairs from other content roots
    //Tree is used to prevent duplicates (if several frameworks take care about one file)
    final SortedSet<Pair<PsiFile, BDDFrameworkType>> pairSortedSet = ContainerUtilRt.newTreeSet(FILE_FRAMEWORK_COMPARATOR);
    pairSortedSet.addAll(getStepDefinitionContainers(featureFile));
    final List<Pair<PsiFile, BDDFrameworkType>> pairs = ContainerUtil.newArrayList(pairSortedSet);
    if (!pairs.isEmpty()) {
      pairs.add(0, null);

      final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
      final ListPopup popupStep =
        popupFactory.createListPopup(new BaseListPopupStep<Pair<PsiFile, BDDFrameworkType>>(
          CucumberBundle.message("choose.step.definition.file"), ContainerUtil.newArrayList(pairs)) {
          @Override
          public boolean isSpeedSearchEnabled() {
            return true;
          }

          @NotNull
          @Override
          public String getTextFor(Pair<PsiFile, BDDFrameworkType> value) {
            if (value == null) {
              return CucumberBundle.message("create.new.file");
            }

            final VirtualFile file = value.getFirst().getVirtualFile();
            assert file != null;

            CucumberStepsIndex stepsIndex = CucumberStepsIndex.getInstance(value.getFirst().getProject());
            StepDefinitionCreator stepDefinitionCreator = stepsIndex.getExtensionMap().get(value.getSecond()).getStepDefinitionCreator();
            return stepDefinitionCreator.getStepDefinitionFilePath(value.getFirst());
          }

          @Override
          public Icon getIconFor(Pair<PsiFile, BDDFrameworkType> value) {
            return value == null ? AllIcons.Actions.CreateFromUsage : value.getFirst().getIcon(0);
          }

          @Override
          public PopupStep onChosen(final Pair<PsiFile, BDDFrameworkType> selectedValue, boolean finalChoice) {
            return doFinalStep(new Runnable() {
              public void run() {
                createStepOrSteps(step, selectedValue != null ? selectedValue.first : null);
              }
            });
          }
        });

      if (!ApplicationManager.getApplication().isUnitTestMode()) {
        popupStep.showCenteredInCurrentWindow(step.getProject());
      } else {
        new WriteCommandAction.Simple(step.getProject()) {
          @Override
          protected void run() throws Throwable {
            createStepOrSteps(step, pairs.get(1).getFirst());
          }
        }.execute();
View Full Code Here

Examples of org.jetbrains.plugins.cucumber.psi.GherkinStep

    if (editor.getSettings().isCamelWords()) {
      result.addAll(super.select(e, editorText, cursorOffset, editor));
    }
    final PsiElement parent = e.getParent();
    if (parent instanceof GherkinStep) {
      final GherkinStep step = (GherkinStep)parent;
      final PsiReference[] references = step.getReferences();
      for (PsiReference reference : references) {
        if (reference instanceof CucumberStepReference) {
          final AbstractStepDefinition definition = ((CucumberStepReference)reference).resolveToDefinition();
          if (definition != null) {
            final List<TextRange> ranges =
              GherkinPsiUtil.buildParameterRanges(step, definition, step.getTextOffset() + reference.getRangeInElement().getStartOffset());
            if (ranges != null) {
              result.addAll(ranges);
              result.addAll(buildAdditionalRanges(ranges, editorText));
            }
          }
View Full Code Here

Examples of org.jetbrains.plugins.cucumber.psi.GherkinStep

    return element != null;
  }

  @Override
  public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
    final GherkinStep step = getGherkinStep(dataContext);
    if (step == null) {
      return;
    }

    if (!step.isRenameAllowed(null)) {
      CommonRefactoringUtil.showErrorHint(project, editor, GherkinStep.RENAME_DISABLED_MESSAGE, "", null);
      return;
    }

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.