public CodeCompletionFeatureSteps(Feature feature)
        {
            var givens = new List<string>();
            var thens = new List<string>();
            var whens = new List<string>();
            var previousStepType = string.Empty;
            foreach (var line in feature.Content.ReadLines())
            {
                if (string.IsNullOrWhiteSpace(line)) continue;

                var match = _regex.Match(line);
                if (!match.Success) continue;
                var stepType = match.Groups["type"].Value;
                if (stepType == Gherkin.And || stepType == Gherkin.But) stepType = previousStepType;
                if (string.IsNullOrEmpty(stepType)) continue;
                var text = match.Groups["text"].Value;
                switch (stepType)
                {
                    case Gherkin.Given:
                        givens.Add(text);
                        break;
                    case Gherkin.When:
                        whens.Add(text);
                        break;
                    case Gherkin.Then:
                        thens.Add(text);
                        break;
                }
                previousStepType = stepType;
            }
            Givens = givens.Distinct().ToList();
            Whens = whens.Distinct().ToList();
            Thens = thens.Distinct().ToList();
        }
 public void RefreshSteps(Feature feature)
 {
     _steps[feature] = new CodeCompletionFeatureSteps(feature);
     Invalidate();
 }
 private void RefreshSteps(Feature feature)
 {
     _steps.RefreshSteps(feature);
 }
Example #4
0
 public void Open(string filePath)
 {
     var isFeature = filePath.IsFeature();
     if (isFeature)
     {
         var feature = new Feature(filePath, OnFeatureContentChanged, OnFeatureSaved);
         if (Name == NoProjectName)
         {
             var existingFeatureIndex = Features.FindIndex(f => f.FilePath == filePath);
             if (existingFeatureIndex >= 0)
             {
                 Features[existingFeatureIndex] = feature;
             }
             else
             {
                 Features.Add(feature);
             }
             FeatureOpened.Raise(this, this, feature);
             return;
         }
         else
         {
             Name = NoProjectName;
             FilePath = string.Empty;
             Features = new List<Feature> { feature };
         }
     }
     else
     {
         Name = Path.GetFileNameWithoutExtension(filePath);
         FilePath = filePath;
         var project = GetProject(filePath);
         Features = project.Items
             .Where(i => i.EvaluatedInclude.IsFeature())
             .Select(i => new Feature(Path.Combine(project.DirectoryPath, i.EvaluatedInclude), OnFeatureContentChanged, OnFeatureSaved))
             .ToList();
     }
     Command.TestRun.SetEnabled(Name != NoProjectName);
     ProjectOpened.Raise(this, this);
 }