private GherkinLanguageService CreateLanguageService(ITextBuffer textBuffer)
        {
            var project         = VsxHelper.GetCurrentProject(textBuffer, AdaptersFactory, ServiceProvider);
            var projectScope    = ProjectScopeFactory.GetProjectScope(project);
            var languageService = new GherkinLanguageService(projectScope, VisualStudioTracer, enableStepMatchColoring: IntegrationOptionsProvider.GetOptions().EnableStepMatchColoring);

            textBuffer.Changed +=
                (sender, args) => languageService.TextBufferChanged(GetTextBufferChange(args));

            return(languageService);
        }
        private GherkinLanguageService CreateLanguageService(ITextBuffer textBuffer)
        {
            var project         = VsxHelper.GetCurrentProject(textBuffer, AdaptersFactory, ServiceProvider);
            var projectScope    = ProjectScopeFactory.GetProjectScope(project);
            var languageService = new GherkinLanguageService(projectScope, VisualStudioTracer);

            textBuffer.Changed +=
                (sender, args) => languageService.TextBufferChanged(GetTextBufferChange(args));

            languageService.Initialize(textBuffer);

            return(languageService);
        }
        private GherkinLanguageService CreateLanguageService(ITextBuffer textBuffer)
        {
            var project      = VsxHelper.GetCurrentProject(textBuffer, AdaptersFactory, ServiceProvider);
            var projectScope = ProjectScopeFactory.GetProjectScope(project);

            ContainerProvider.ObjectContainer.Resolve <InstallServicesHelper>().OnPackageUsed(); //TODO: find a better place

            var languageService = new GherkinLanguageService(projectScope, VisualStudioTracer, enableStepMatchColoring: IntegrationOptionsProvider.GetOptions().EnableStepMatchColoring);

            textBuffer.Changed +=
                (sender, args) => languageService.TextBufferChanged(GetTextBufferChange(args));

            return(languageService);
        }
        private Project GetTartgetProject(string targetPath, Project specFlowProject)
        {
            string folder = Path.GetDirectoryName(targetPath);

            if (folder == null)
            {
                return(specFlowProject);
            }

            var ps            = (VsProjectScope)projectScopeFactory.GetProjectScope(specFlowProject);
            var targetProject = ps.BindingFilesTracker.BindingAssemblies.Where(ba => ba.IsProject).Select(ba => ba.Project)
                                .FirstOrDefault(prj =>
            {
                var projectFolder = VsxHelper.GetProjectFolder(prj);
                return(projectFolder != null && folder.StartsWith(projectFolder));
            });

            return(targetProject ?? specFlowProject);
        }
        public bool RunFeatures(ProjectItem projectItem, bool debug)
        {
            var projectScope = (VsProjectScope)projectScopeFactory.GetProjectScope(projectItem.ContainingProject);

            if (!projectScope.FeatureFilesTracker.IsInitialized)
            {
                MessageBox.Show("The feature files are not analyzed yet. Please wait.",
                                "SpecFlow",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                tracer.Trace("Feature file tracker is not yet initialized.", GetType().Name);
                return(false);
            }

            string filter = string.Join(" | ", CollectPaths(projectScope, projectItem));

            if (string.IsNullOrEmpty(filter))
            {
                return(false);
            }
            return(RunTests(projectItem.ContainingProject, filter, debug));
        }
        protected override void Invoke(OleMenuCommand command, SelectedItems selection)
        {
            var selectedItem = selection.Item(1);

            if (selectedItem.Project == null)
            {
                return;
            }

            var projectScope = projectScopeFactory.GetProjectScope(selectedItem.Project) as VsProjectScope;

            if (projectScope == null)
            {
                return;
            }

            if (!projectScope.FeatureFilesTracker.IsInitialized)
            {
                MessageBox.Show("Feature files are still being analyzed. Please wait.", "Regenerate Feature Files");
                return;
            }

            projectScope.FeatureFilesTracker.ReGenerateAll();
        }