Пример #1
0
 public DeveroomCompletionSource(ITextBuffer buffer, ITagAggregator <DeveroomTag> tagAggregator, IIdeScope ideScope)
     : base("Deveroom", buffer)
 {
     _tagAggregator = tagAggregator;
     _ideScope      = ideScope;
     _project       = ideScope.GetProject(buffer);
 }
        private void SaveAsStepDefinitionClass(IProjectScope projectScope, string combinedSnippet, string className,
                                               string indent, string newLine)
        {
            string targetFolder          = projectScope.ProjectFolder;
            var    projectSettings       = projectScope.GetProjectSettings();
            var    defaultNamespace      = projectSettings.DefaultNamespace ?? projectScope.ProjectName;
            var    fileNamespace         = defaultNamespace;
            var    stepDefinitionsFolder = Path.Combine(targetFolder, "StepDefinitions");

            if (projectScope.IdeScope.FileSystem.Directory.Exists(stepDefinitionsFolder))
            {
                targetFolder  = stepDefinitionsFolder;
                fileNamespace = fileNamespace + ".StepDefinitions";
            }

            var targetFilePath = Path.Combine(targetFolder, className + ".cs");

            var template = $"using System;" + newLine +
                           $"using TechTalk.SpecFlow;" + newLine +
                           newLine +
                           $"namespace {fileNamespace}" + newLine +
                           $"{{" + newLine +
                           $"{indent}[Binding]" + newLine +
                           $"{indent}public class {className}" + newLine +
                           $"{indent}{{" + newLine +
                           combinedSnippet +
                           $"{indent}}}" + newLine +
                           $"}}" + newLine;

            projectScope.AddFile(targetFilePath, template);
            projectScope.IdeScope.Actions.NavigateTo(new SourceLocation(targetFilePath, 9, 1));
        }
 public GherkinTextBufferPartialParserListener(GherkinDialect gherkinDialect, ITextSnapshot textSnapshot, IProjectScope projectScope, IGherkinFileScope previousScope, int changeLastLine, int changeLineDelta)
     : base(gherkinDialect, textSnapshot, projectScope)
 {
     this.previousScope = previousScope;
     this.changeLastLine = changeLastLine;
     this.changeLineDelta = changeLineDelta;
 }
        private static string GetSpecFlowToolsFolderSafe(IProjectScope projectScope, ProjectSettings projectSettings, out string toolsFolderErrorMessage)
        {
            toolsFolderErrorMessage = null;
            try
            {
                var specFlowToolsFolder = projectSettings.SpecFlowGeneratorFolder;
                if (string.IsNullOrEmpty(specFlowToolsFolder))
                {
                    projectScope.IdeScope.Actions.ShowProblem($"Unable to generate feature-file code behind, because SpecFlow NuGet package folder could not be detected. For configuring SpecFlow tools folder manually, check http://speclink.me/deveroomsfassref.");
                    toolsFolderErrorMessage = "Folder is not configured. See http://speclink.me/deveroomsfassref for details.";
                    return(null);
                }

                if (!projectScope.IdeScope.FileSystem.Directory.Exists(specFlowToolsFolder))
                {
                    projectScope.IdeScope.Actions.ShowProblem($"Unable to find SpecFlow tools folder: '{specFlowToolsFolder}'. Build solution to ensure that all packages are restored. The feature file has to be re-generated (e.g. by saving) after the packages have been restored.");
                    toolsFolderErrorMessage = "Folder does not exist";
                    return(null);
                }

                return(specFlowToolsFolder);
            }
            catch (Exception ex)
            {
                projectScope.IdeScope.Logger.LogException(projectScope.IdeScope.MonitoringService, ex);
                toolsFolderErrorMessage = ex.Message;
                return(null);
            }
        }
        private NuGetPackageReference GetSpecFlowPackage(IProjectScope projectScope, IEnumerable <NuGetPackageReference> packageReferences, out SpecFlowProjectTraits specFlowProjectTraits)
        {
            specFlowProjectTraits = SpecFlowProjectTraits.None;
            if (packageReferences == null)
            {
                return(null);
            }
            var packageReferencesArray = packageReferences.ToArray();
            var detector        = new SpecFlowPackageDetector(projectScope.IdeScope.FileSystem);
            var specFlowPackage = detector.GetSpecFlowPackage(packageReferencesArray);

            if (specFlowPackage != null)
            {
                var specFlowVersion = specFlowPackage.Version.Version;
                if (detector.IsMsBuildGenerationEnabled(packageReferencesArray) ||
                    IsImplicitMsBuildGeneration(detector, specFlowVersion, packageReferencesArray))
                {
                    specFlowProjectTraits |= SpecFlowProjectTraits.MsBuildGeneration;
                }
                if (detector.IsXUnitAdapterEnabled(packageReferencesArray))
                {
                    specFlowProjectTraits |= SpecFlowProjectTraits.XUnitAdapter;
                }
                if (detector.IsCucumberExpressionPluginEnabled(packageReferencesArray))
                {
                    specFlowProjectTraits |= SpecFlowProjectTraits.CucumberExpression;
                }
            }

            return(specFlowPackage);
        }
 protected GherkinTextBufferParserListenerBase(GherkinDialect gherkinDialect, ITextSnapshot textSnapshot, IProjectScope projectScope)
 {
     this.textSnapshot = textSnapshot;
     this.classifications = projectScope.Classifications;
     this.projectScope = projectScope;
    
     gherkinFileScope = new GherkinFileScope(gherkinDialect, textSnapshot);
 }
        public GherkinLanguageService(IProjectScope projectScope, IVisualStudioTracer visualStudioTracer)
        {
            this.projectScope = projectScope;
            this.visualStudioTracer = visualStudioTracer;
            AnalyzingEnabled = projectScope.GherkinScopeAnalyzer != null;

            visualStudioTracer.Trace("Language service created", "GherkinLanguageService");
        }
        public static MockableDiscoveryService Setup(IProjectScope projectScope)
        {
            var discoveryResultProviderMock = new Mock <IDiscoveryResultProvider>();
            var discoveryService            = new MockableDiscoveryService(projectScope, discoveryResultProviderMock);

            projectScope.Properties.AddProperty(typeof(IDiscoveryService), discoveryService);
            return(discoveryService);
        }
Пример #9
0
        public GherkinLanguageService(IProjectScope projectScope, IVisualStudioTracer visualStudioTracer)
        {
            this.projectScope       = projectScope;
            this.visualStudioTracer = visualStudioTracer;
            AnalyzingEnabled        = projectScope.GherkinScopeAnalyzer != null;

            visualStudioTracer.Trace("Language service created", "GherkinLanguageService");
        }
        private string GetSpecFlowConfigFilePath(IProjectScope projectScope)
        {
            var projectFolder = projectScope.ProjectFolder;
            var fileSystem    = projectScope.IdeScope.FileSystem;

            return(fileSystem.GetFilePathIfExists(Path.Combine(projectFolder, ProjectScopeDeveroomConfigurationProvider.SpecFlowJsonConfigFileName)) ??
                   fileSystem.GetFilePathIfExists(Path.Combine(projectFolder, ProjectScopeDeveroomConfigurationProvider.SpecFlowAppConfigFileName)));
        }
Пример #11
0
        protected GherkinTextBufferParserListenerBase(GherkinDialect gherkinDialect, ITextSnapshot textSnapshot, IProjectScope projectScope)
        {
            this.textSnapshot            = textSnapshot;
            this.classifications         = projectScope.Classifications;
            this.projectScope            = projectScope;
            this.enableStepMatchColoring = projectScope.IntegrationOptionsProvider.GetOptions().EnableStepMatchColoring;

            gherkinFileScope = new GherkinFileScope(gherkinDialect, textSnapshot);
        }
Пример #12
0
        public GherkinLanguageService(IProjectScope projectScope, IVisualStudioTracer visualStudioTracer, bool enableStepMatchColoring)
        {
            this.projectScope            = projectScope;
            this.visualStudioTracer      = visualStudioTracer;
            this.enableStepMatchColoring = enableStepMatchColoring && projectScope.StepSuggestionProvider != null;
            AnalyzingEnabled             = projectScope.GherkinScopeAnalyzer != null;

            visualStudioTracer.Trace("Language service created", "GherkinLanguageService");
        }
Пример #13
0
 public WizardRunParameters(bool isAddNewItem, IProjectScope projectScope, string templateFolder, string targetFolder, string targetFileName, Dictionary <string, string> replacementsDictionary)
 {
     IsAddNewItem           = isAddNewItem;
     ProjectScope           = projectScope;
     TemplateFolder         = templateFolder;
     TargetFolder           = targetFolder;
     TargetFileName         = targetFileName;
     ReplacementsDictionary = replacementsDictionary;
 }
Пример #14
0
        public GherkinLanguageService(IProjectScope projectScope, IVisualStudioTracer visualStudioTracer, bool enableStepMatchColoring)
        {
            this.projectScope = projectScope;
            this.visualStudioTracer = visualStudioTracer;
            this.enableStepMatchColoring = enableStepMatchColoring && projectScope.StepSuggestionProvider != null;
            AnalyzingEnabled = projectScope.GherkinScopeAnalyzer != null;

            visualStudioTracer.Trace("Language service created", "GherkinLanguageService");
        }
 protected GherkinTextBufferParserListenerBase(GherkinDialect gherkinDialect, ITextSnapshot textSnapshot, IProjectScope projectScope)
 {
     this.textSnapshot = textSnapshot;
     this.classifications = projectScope.Classifications;
     this.projectScope = projectScope;
     this.enableStepMatchColoring = projectScope.IntegrationOptionsProvider.GetOptions().EnableStepMatchColoring;
    
     gherkinFileScope = new GherkinFileScope(gherkinDialect, textSnapshot);
 }
 public MockableDiscoveryService(IProjectScope projectScope, Mock <IDiscoveryResultProvider> discoveryResultProviderMock) : base(projectScope, discoveryResultProviderMock.Object)
 {
     discoveryResultProviderMock.Setup(ds => ds.RunDiscovery(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <ProjectSettings>())).Returns(
         delegate
     {
         System.Threading.Thread.Sleep(100);     //make it a bit more realistic
         return(LastDiscoveryResult);
     });
 }
        public static SnippetService GetSnippetService(this IProjectScope projectScope)
        {
            if (!projectScope.GetProjectSettings().IsSpecFlowProject)
            {
                return(null);
            }

            return(projectScope.Properties.GetOrCreateSingletonProperty(() =>
                                                                        new SnippetService(projectScope)));
        }
        private async Task <ProjectStepDefinitionBinding[]> GetStepDefinitionsAsync(IProjectScope project, string fileName, SnapshotPoint triggerPoint)
        {
            var discoveryService = project.GetDiscoveryService();
            var bindingRegistry  = await discoveryService.GetBindingRegistryAsync();

            if (bindingRegistry == null)
            {
                Logger.LogWarning($"Unable to get step definitions from project '{project.ProjectName}', usages will not be found for this project.");
            }
            return(GetStepDefinitions(fileName, triggerPoint, bindingRegistry));
        }
Пример #19
0
 protected StepSuggestionProvider(INativeSuggestionItemFactory <TNativeSuggestionItem> nativeSuggestionItemFactory, IProjectScope projectScope)
 {
     boundStepSuggestions = new RegexDictionary <BoundStepSuggestions <TNativeSuggestionItem> >(item => item.StepBinding == null ? null : item.StepBinding.Regex);
     notMatchingSteps     = new Dictionary <StepDefinitionType, BoundStepSuggestions <TNativeSuggestionItem> >
     {
         { StepDefinitionType.Given, new BoundStepSuggestions <TNativeSuggestionItem>(StepDefinitionType.Given, nativeSuggestionItemFactory) },
         { StepDefinitionType.When, new BoundStepSuggestions <TNativeSuggestionItem>(StepDefinitionType.When, nativeSuggestionItemFactory) },
         { StepDefinitionType.Then, new BoundStepSuggestions <TNativeSuggestionItem>(StepDefinitionType.Then, nativeSuggestionItemFactory) }
     };
     this.nativeSuggestionItemFactory = nativeSuggestionItemFactory;
     this.projectScope = projectScope;
 }
        public static OutProcSpecFlowConnector Create(IProjectScope projectScope)
        {
            var ideScope              = projectScope.IdeScope;
            var projectSettings       = projectScope.GetProjectSettings();
            var deveroomConfiguration = projectScope.GetDeveroomConfiguration();
            var processorArchitecture = GetProcessorArchitecture(deveroomConfiguration, projectSettings);

            return(new OutProcSpecFlowConnector(
                       deveroomConfiguration,
                       ideScope.Logger,
                       projectSettings.TargetFrameworkMoniker,
                       projectScope.IdeScope.GetExtensionFolder(),
                       processorArchitecture));
        }
        private void InitializeWithDiscoveryService(IIdeScope ideScope, IProjectScope project)
        {
            var projectSettings = _projectSettingsProvider?.GetProjectSettings();

            if (projectSettings != null && projectSettings.IsSpecFlowLibProject)
            {
                // this is the first feature file in the project
                var updatedProjectSettings = _projectSettingsProvider.CheckProjectSettings();
                if (updatedProjectSettings.IsSpecFlowTestProject)
                {
                    _discoveryService?.CheckBindingRegistry();
                }
            }

            ideScope.Logger.LogVerbose($"Creating DeveroomTagger (project: {project}, SpecFlow: {projectSettings?.GetSpecFlowVersionLabel() ?? "n/a"})");
            ideScope.MonitoringService.MonitorOpenFeatureFile(projectSettings);
        }
        private void SaveAsStepDefinitionClass(IProjectScope projectScope, string combinedSnippet, string className,
                                               string indent, string newLine)
        {
            string targetFolder          = projectScope.ProjectFolder;
            var    projectSettings       = projectScope.GetProjectSettings();
            var    defaultNamespace      = projectSettings.DefaultNamespace ?? projectScope.ProjectName;
            var    fileNamespace         = defaultNamespace;
            var    stepDefinitionsFolder = Path.Combine(targetFolder, "StepDefinitions");

            if (IdeScope.FileSystem.Directory.Exists(stepDefinitionsFolder))
            {
                targetFolder  = stepDefinitionsFolder;
                fileNamespace = fileNamespace + ".StepDefinitions";
            }

            var targetFilePath = Path.Combine(targetFolder, className + ".cs");

            if (IdeScope.FileSystem.File.Exists(targetFilePath))
            {
                if (IdeScope.Actions.ShowSyncQuestion("Overwrite file?",
                                                      $"The selected step definition file '{targetFilePath}' already exists. By overwriting the existing file you might loose work. {Environment.NewLine}Do you want to overwrite the file?",
                                                      defaultButton: MessageBoxResult.No) != MessageBoxResult.Yes)
                {
                    return;
                }
            }

            var template = $"using System;" + newLine +
                           $"using TechTalk.SpecFlow;" + newLine +
                           newLine +
                           $"namespace {fileNamespace}" + newLine +
                           $"{{" + newLine +
                           $"{indent}[Binding]" + newLine +
                           $"{indent}public class {className}" + newLine +
                           $"{indent}{{" + newLine +
                           combinedSnippet +
                           $"{indent}}}" + newLine +
                           $"}}" + newLine;

            projectScope.AddFile(targetFilePath, template);
            projectScope.IdeScope.Actions.NavigateTo(new SourceLocation(targetFilePath, 9, 1));
        }
 public GherkinTextBufferParserListener(GherkinDialect gherkinDialect, ITextSnapshot textSnapshot, IProjectScope projectScope)
     : base(gherkinDialect, textSnapshot, projectScope)
 {
 }
Пример #24
0
 private static IEnumerable <string> GetAdditionalBindingAssemblyNames(IProjectScope projectScope)
 {
     return(projectScope.SpecFlowProjectConfiguration.RuntimeConfiguration.AdditionalStepAssemblies.Select(a => a.Split(new[] { ',' }, 2)[0]));
 }
Пример #25
0
 public ISourceFileScope CreateFileScope(IFile file, IProjectScope projectScope, CompileToolContext context)
 {
     return this._asmProvider.CreateFileScope(file, projectScope, context);
 }
 private static IEnumerable<string> GetAdditionalBindingAssemblyNames(IProjectScope projectScope)
 {
     return projectScope.SpecFlowProjectConfiguration.RuntimeConfiguration.AdditionalStepAssemblies.Select(a => a.Split(new[] {','}, 2)[0]);
 }
 public GherkinTextBufferParser(IProjectScope projectScope, IVisualStudioTracer visualStudioTracer)
 {
     this.projectScope = projectScope;
     this.visualStudioTracer = visualStudioTracer;
 }
 public GherkinTextBufferParserListener(GherkinDialect gherkinDialect, ITextSnapshot textSnapshot, IProjectScope projectScope)
     : base(gherkinDialect, textSnapshot, projectScope)
 {
 }
 public GherkinScopeAnalyzer(IProjectScope projectScope, IVisualStudioTracer visualStudioTracer)
 {
     this.projectScope       = projectScope;
     this.visualStudioTracer = visualStudioTracer;
 }
        public static StubWpfTextView CreateTextView(StubIdeScope ideScope, TestText inputText, string newLine = null, IProjectScope projectScope = null, string contentType = "deveroom", string filePath = null)
        {
            var textBuffer = VsxStubObjects.CreateTextBuffer(inputText.ToString(newLine));

            textBuffer.Properties.AddProperty(typeof(IProjectScope), projectScope);
            if (filePath != null)
            {
                textBuffer.Properties.AddProperty(typeof(IVsTextBuffer), new FilePathProvider(filePath));
            }
            var textView = new StubWpfTextView(textBuffer);

            if (contentType == "deveroom")
            {
                var tagAggregator = new StubBufferTagAggregatorFactoryService(ideScope).CreateTagAggregator <DeveroomTag>(textView.TextBuffer);
                tagAggregator.GetTags(new SnapshotSpan(textView.TextSnapshot, 0, textView.TextSnapshot.Length)).ToArray();
            }

            inputText.SetSelection(textView);
            inputText.SetCaret(textView);

            return(textView);
        }
Пример #31
0
 public GherkinTextBufferPartialParserListener(GherkinDialect gherkinDialect, ITextSnapshot textSnapshot, IProjectScope projectScope, IGherkinFileScope previousScope, int changeLastLine, int changeLineDelta)
     : base(gherkinDialect, textSnapshot, projectScope)
 {
     this.previousScope   = previousScope;
     this.changeLastLine  = changeLastLine;
     this.changeLineDelta = changeLineDelta;
 }
Пример #32
0
 public static ProjectSettingsProvider GetProjectSettingsProvider(this IProjectScope projectScope)
 {
     return(projectScope.Properties.GetOrCreateSingletonProperty(() => new ProjectSettingsProvider(projectScope)));
 }
Пример #33
0
        public static ProjectSettings GetProjectSettings(this IProjectScope projectScope)
        {
            var provider = GetProjectSettingsProvider(projectScope);

            return(provider.GetProjectSettings());
        }
 public SnippetService(IProjectScope projectScope)
 {
     _projectScope = projectScope;
     _logger       = projectScope.IdeScope.Logger;
 }
 public DiscoveryResultProvider(IProjectScope projectScope)
 {
     _projectScope = projectScope;
 }
 public GenerationService(IProjectScope projectScope)
 {
     _projectScope = projectScope;
     _logger       = projectScope.IdeScope.Logger;
 }
Пример #37
0
        public ISourceFileScope CreateFileScope(IFile file, IProjectScope projectScope, CompileToolContext context)
        {
            var identifier = file.GetProperty("Identifier");
            if (string.IsNullOrEmpty(identifier))
            {
                context.AddMessage(new BinaryCompileMessage { Filename = file.AbsolutePath, Line = 0, Message = "No identifier was specified for the file", MessageLevel = Level.Error});
                return null;
            }

            return new BinaryFileScope(projectScope, identifier, file.AbsolutePath);
        }
        public static bool CheckSpecFlowToolsFolder(IProjectScope projectScope)
        {
            var toolsFolder = GetSpecFlowToolsFolderSafe(projectScope, projectScope.GetProjectSettings(), out _);

            return(toolsFolder != null);
        }
Пример #39
0
 public ISourceFileScope CreateFileScope(IFile file, IProjectScope projectScope, CompileToolContext context)
 {
     return new FileScope(file.AbsolutePath, projectScope);
 }
Пример #40
0
 public GherkinScopeAnalyzer(IProjectScope projectScope, IVisualStudioTracer visualStudioTracer)
 {
     this.projectScope = projectScope;
     this.visualStudioTracer = visualStudioTracer;
 }
 public GherkinTextBufferParser(IProjectScope projectScope, IVisualStudioTracer visualStudioTracer)
 {
     this.projectScope       = projectScope;
     this.visualStudioTracer = visualStudioTracer;
 }
 public SpecFlowProjectSettingsProvider([NotNull] IProjectScope projectScope)
 {
     _projectScope = projectScope ?? throw new ArgumentNullException(nameof(projectScope));
 }