Package org.jetbrains.plugins.cucumber.steps

Examples of org.jetbrains.plugins.cucumber.steps.AbstractStepDefinition


        for (GherkinStep step : stepsHolder.getSteps()) {
          final PsiReference[] references = step.getReferences();
          for (PsiReference reference : references) {
            if (!(reference instanceof CucumberStepReference)) continue;

            final AbstractStepDefinition definition = ((CucumberStepReference)reference).resolveToDefinition();
            if (definition == null) {
              String pattern = Pattern.quote(step.getStepName());
              pattern = StringUtil.trimEnd(StringUtil.trimStart(pattern, "\\Q"), "\\E");
              pattern = CucumberUtil.prepareStepRegexp(pattern);
              if (!createdStepDefPatterns.contains(pattern)) {
View Full Code Here


      }
      final CucumberStepsIndex index = CucumberStepsIndex.getInstance(file.getProject());
      final List<PsiFile> resultFiles = new ArrayList<PsiFile>();
      final List<GotoRelatedItem> result = new ArrayList<GotoRelatedItem>();
      for (GherkinStep step : steps) {
        AbstractStepDefinition stepDef = index.findStepDefinition(gherkinFile, step);
        final PsiElement stepDefMethod = stepDef != null ? stepDef.getElement() : null;

        if (stepDefMethod != null) {
          final PsiFile stepDefFile = stepDefMethod.getContainingFile();
          if (!resultFiles.contains(stepDefFile)) {
            resultFiles.add(stepDefFile);
View Full Code Here

        if (parent instanceof GherkinStepsHolder) {
          final PsiReference[] references = step.getReferences();
          if (references.length != 1 || !(references[0] instanceof CucumberStepReference)) return;

          CucumberStepReference reference = (CucumberStepReference)references[0];
          final AbstractStepDefinition definition = reference.resolveToDefinition();
          if (definition == null) {
            CucumberCreateStepFix createStepFix = null;
            CucumberCreateAllStepsFix createAllStepsFix = null;
            if (CucumberStepsIndex.getInstance(step.getProject()).getExtensionCount() > 0) {
              createStepFix = new CucumberCreateStepFix();
View Full Code Here

    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);
View Full Code Here

  public void renameElement(PsiElement element, String newName, UsageInfo[] usages, @Nullable RefactoringElementListener listener)
    throws IncorrectOperationException {

    final CucumberStepReference reference = getCucumberStepReference(element);
    if (reference != null) {
      final AbstractStepDefinition stepDefinition = reference.resolveToDefinition();
      if (stepDefinition != null) {
        final PsiElement elementToRename = stepDefinition.getElement();

        final List<String> newStaticTexts = prepareRegexAndGetStaticTexts(newName);
        final String oldStepDefPatternText = stepDefinition.getCucumberRegex();
        if (oldStepDefPatternText != null) {
          final Pattern oldStepDefPattern = Pattern.compile(prepareRegexAndGetStaticTexts(oldStepDefPatternText).get(0));

          for (UsageInfo usage : usages) {
            final PsiElement possibleStep = usage.getElement();
            if (possibleStep instanceof GherkinStep) {
              final String oldStepName = ((GherkinStep)possibleStep).getStepName();
              final String newStepName = getNewStepName(oldStepName, oldStepDefPattern, newStaticTexts);
              ((GherkinStep)possibleStep).setName(newStepName);
            }
          }

          final String prefix = oldStepDefPatternText.startsWith("^") ? "^" : "";
          final String suffix = oldStepDefPatternText.endsWith("$") ? "$" : "";
          stepDefinition.setCucumberRegex(prefix + newName + suffix);

          if (listener != null && elementToRename != null) {
            listener.elementRenamed(elementToRename);
          }
        }
View Full Code Here

    }
  }

  @Override
  public String[] getSuggestedNames() {
    AbstractStepDefinition stepDefinition = getStepDefinition();
    if (stepDefinition != null) {
      String result = stepDefinition.getCucumberRegex();
      if (result != null) {
        if (result.startsWith("^")) {
          result = result.substring(1);
        }
        if (result.endsWith("$")) {
View Full Code Here

TOP

Related Classes of org.jetbrains.plugins.cucumber.steps.AbstractStepDefinition

Copyright © 2018 www.massapicom. 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.