public GherkinLanguageService(IProjectScope projectScope, IVisualStudioTracer visualStudioTracer)
        {
            this.projectScope = projectScope;
            this.visualStudioTracer = visualStudioTracer;
            AnalyzingEnabled = projectScope.GherkinScopeAnalyzer != null;

            visualStudioTracer.Trace("Language service created", "GherkinLanguageService");
        }
        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");
        }
 public void Dispose()
 {
     visualStudioTracer.Trace("Language service disposed", "GherkinLanguageService");
     isDisposed = true;
     projectScope.GherkinDialectServicesChanged -= ReParseEntireFile;
     if (enableStepMatchColoring)
     {
         projectScope.StepSuggestionProvider.Ready           -= ReParseEntireFile;
         projectScope.StepSuggestionProvider.BindingsChanged -= ReParseEntireFile;
     }
     lastGherkinFileScope = null;
 }
Exemple #4
0
        public ProjectScopeFactory()
        {
            dteReference = new SynchInitializedInstance <DteWithEvents>(
                () =>
            {
                var dtex = new DteWithEvents(VsxHelper.GetDte(ServiceProvider));
                dtex.SolutionEvents.AfterClosing += OnSolutionClosed;
                VisualStudioTracer.Trace("subscribed to solution closed " + Thread.CurrentThread.ManagedThreadId, "ProjectScopeFactory");
                return(dtex);
            });

            classificationsReference = new SynchInitializedInstance <GherkinFileEditorClassifications>(
                () => new GherkinFileEditorClassifications(ClassificationRegistry));

            projectScopeCache = new SynchronizedResultCache <Project, string, IProjectScope>(
                project => new VsProjectScope(project, dteReference.Value, classificationsReference.Value, VisualStudioTracer, IntegrationOptionsProvider, BindingSkeletonProviderFactory),
                VsxHelper.GetProjectUniqueId);

            noProjectScopeReference = new SynchInitializedInstance <NoProjectScope>(() =>
                                                                                    new NoProjectScope(classificationsReference.Value, VisualStudioTracer));
        }
Exemple #5
0
        public ProjectScopeFactory()
        {
            dteReference = new SynchInitializedInstance <DteWithEvents>(
                () =>
            {
                ContainerProvider.ObjectContainer.Resolve <InstallServices>().OnPackageUsed();        //TODO: find a better place
                var dtex = new DteWithEvents(VsxHelper.GetDte(ServiceProvider), VisualStudioTracer);
                dtex.SolutionEvents.AfterClosing += OnSolutionClosed;
                dtex.SolutionEventsListener.OnQueryUnloadProject += OnProjectClosed;
                VisualStudioTracer.Trace("subscribed to solution closed " + Thread.CurrentThread.ManagedThreadId, "ProjectScopeFactory");
                return(dtex);
            });

            classificationsReference = new SynchInitializedInstance <GherkinFileEditorClassifications>(
                () => new GherkinFileEditorClassifications(ClassificationRegistry));

            projectScopeCache = new SynchronizedResultCache <Project, string, IProjectScope>(
                project => new VsProjectScope(project, dteReference.Value, classificationsReference.Value, VisualStudioTracer, IntegrationOptionsProvider),
                VsxHelper.GetProjectUniqueId);

            noProjectScopeReference = new SynchInitializedInstance <NoProjectScope>(() =>
                                                                                    new NoProjectScope(classificationsReference.Value, VisualStudioTracer, IntegrationOptionsProvider));
        }
        public GherkinFileEditorParser(ITextBuffer buffer, IClassificationTypeRegistryService registry, IVisualStudioTracer visualStudioTracer, SpecFlowProject specFlowProject)
        {
            this.buffer = buffer;
            this.visualStudioTracer = visualStudioTracer;
            this.specFlowProject = specFlowProject;
            this.buffer.Changed += BufferChanged;

            this.classifications = new GherkinFileEditorClassifications(registry);

            // initial parsing
            visualStudioTracer.Trace("Initial parsing scheduled", ParserTraceCategory);
            ChangeInfo changeInfo = new ChangeInfo(buffer);
            parsingTask = parsingTaskFactory.StartNew(() =>
                ParseAndTriggerChanges(GherkinFileEditorInfo, changeInfo));
        }
Exemple #7
0
        private SpecFlowProjectConfiguration LoadConfiguration()
        {
            ISpecFlowConfigurationReader        configurationReader = new VsSpecFlowConfigurationReader(project, visualStudioTracer); //TODO: load through DI
            ISpecFlowProjectConfigurationLoader configurationLoader = new SpecFlowProjectConfigurationLoaderWithoutPlugins();         //TODO: load through DI

            try
            {
                return(configurationLoader.LoadConfiguration(configurationReader.ReadConfiguration()));
            }
            catch (Exception exception)
            {
                visualStudioTracer.Trace("Configuration loading error: " + exception, "VsProjectScope");
                return(new SpecFlowProjectConfiguration());
            }
        }
        private void EnsureInitialized()
        {
            if (!_initialized)
            {
                lock (this)
                {
                    if (!_initialized)
                    {
                        if (_initializing)
                        {
                            _tracer.Trace("ERROR: Nested VsProjectScope is triggered by the initialize. This is bad. Please record the following stack trace: {1}{0}", this, Environment.StackTrace, Environment.NewLine);
                            return;
                        }

                        try
                        {
                            _initializing = true;
                            Initialize();
                        }
                        finally
                        {
                            _initializing = false;
                        }
                    }
                }
            }
        }
Exemple #9
0
        private void SubscribeToDteEvents(DteWithEvents dteWithEvents)
        {
            dteWithEvents.ProjectItemsEvents.ItemAdded +=
                item =>
            {
                visualStudioTracer.Trace("Item Added: " + item.Name, "VsProjectFileTracker");
                if (IsItemRelevant(item))
                {
                    OnFileChanged(item);
                }
            };

            dteWithEvents.ProjectItemsEvents.ItemRemoved +=
                item =>
            {
                visualStudioTracer.Trace("Item Removed: " + item.Name, "VsProjectFileTracker");
                if (IsItemRelevant(item))
                {
                    OnFileChanged(null);
                }
            };

            dteWithEvents.ProjectItemsEvents.ItemRenamed +=
                (item, oldName) =>
            {
                visualStudioTracer.Trace("Item Renamed to: " + item.Name + " from " + oldName, "VsProjectFileTracker");
                if (IsItemRelevant(item))
                {
                    OnFileChanged(item);
                }
                else if (IsItemRelevant(item, oldName))
                {
                    if (followTrackingAfterRename)
                    {
                        fileName = VsxHelper.GetProjectRelativePath(item);
                        OnFileChanged(item);
                    }
                    else
                    {
                        OnFileChanged(null);
                    }
                }
            };

            dteWithEvents.DocumentEvents.DocumentSaved +=
                document =>
            {
                visualStudioTracer.Trace("Document Saved: " + document, "VsProjectFileTracker");
                ProjectItem item = document.ProjectItem;
                if (IsItemRelevant(item))
                {
                    OnFileChanged(item);
                }
            };

            dteWithEvents.BuildEvents.OnBuildDone +=
                (scope, action) =>
            {
                this.visualStudioTracer.Trace("Build Done.", "VsProjectFileTracker");
                ProjectItem item          = VsxHelper.FindProjectItemByProjectRelativePath(project, fileName);
                var         newChangeDate = GetLastChangeDate(item);
                if (newChangeDate != LastChangeDate)
                {
                    OnFileChanged(item);
                }
            };
        }
 public GherkinFileScopeChange Analyze(GherkinFileScopeChange change)
 {
     visualStudioTracer.Trace("Analyzing started", "GherkinScopeAnalyzer");
     return(change); //TODO
 }