Beispiel #1
0
        private IScenarioBlock GetCurrentScenario(GherkinLanguageService languageService, int currentLine, out IGherkinFileScope fileScope)
        {
            fileScope = languageService.GetFileScope();
            if (fileScope == null)
                return null;

            var block = fileScope.GetStepBlockFromStepPosition(currentLine) as IScenarioBlock;
            if (block != null && currentLine > block.KeywordLine + block.BlockRelativeContentEndLine)
                return null; // between two scenarios

            return block;
        }
        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<InstallServices>().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 IScenarioBlock GetCurrentScenario(GherkinLanguageService languageService, Document activeDocument, out IGherkinFileScope fileScope)
        {
            var currentTextDocument = ((TextDocument)activeDocument.Object("TextDocument"));
            var currentLine = currentTextDocument.Selection.ActivePoint.Line;

            fileScope = languageService.GetFileScope();
            if (fileScope == null)
                return null;

            var block = fileScope.GetStepBlockFromStepPosition(currentLine) as IScenarioBlock;
            if (block != null && currentLine > block.KeywordLine + block.BlockRelativeContentEndLine)
                return null; // between two scenarios

            return block;
        }
        public bool RunFromEditor(GherkinLanguageService languageService, bool debug)
        {
            if (dte.ActiveDocument == null || dte.ActiveDocument.ProjectItem == null)
                return false;

            IGherkinFileScope fileScope;
            var currentScenario = GetCurrentScenario(languageService, dte.ActiveDocument, out fileScope);
            if (currentScenario == null)
            {
                // run for the entire file
                return RunFromProjectItem(dte.ActiveDocument.ProjectItem, debug);
            }

            var testRunnerGateway = testRunnerGatewayProvider.GetTestRunnerGateway();
            if (testRunnerGateway == null)
                return false;

            return testRunnerGateway.RunScenario(dte.ActiveDocument.ProjectItem, currentScenario, fileScope, debug);
        }
Beispiel #6
0
        public bool RunFromEditor(GherkinLanguageService languageService, bool debug, TestRunnerTool? runnerTool = null)
        {
            if (dte.ActiveDocument == null || dte.ActiveDocument.ProjectItem == null)
                return false;

            IGherkinFileScope fileScope;
            int currentLine = GetCurrentLine(dte.ActiveDocument);
            var currentScenario = GetCurrentScenario(languageService, currentLine, out fileScope);
            if (currentScenario == null)
            {
                // run for the entire file
                return RunFromProjectItem(dte.ActiveDocument.ProjectItem, debug, runnerTool);
            }

            //TODO: select the scenario outline example, if it was invoked from that line

            var testRunnerGateway = testRunnerGatewayProvider.GetTestRunnerGateway(runnerTool);
            if (testRunnerGateway == null)
                return false;

            return testRunnerGateway.RunScenario(dte.ActiveDocument.ProjectItem, currentScenario, fileScope, debug);
        }
 public AnalyzingTask(GherkinLanguageService languageService, GherkinFileScopeChange change)
 {
     this.languageService = languageService;
     this.change = change;
 }
 public ParsingTask(GherkinLanguageService languageService, GherkinTextBufferChange change)
 {
     this.languageService = languageService;
     this.change = change;
 }
Beispiel #9
0
 public GherkinEditorContext(GherkinLanguageService languageService, IWpfTextView textView)
 {
     LanguageService = languageService;
     TextView = textView;
 }
Beispiel #10
0
 public ParsingTask(GherkinLanguageService languageService, GherkinTextBufferChange change)
 {
     this.languageService = languageService;
     this.change          = change;
 }
        static internal bool IsKeywordPrefix(SnapshotPoint triggerPoint, GherkinLanguageService languageService)
        {
            var line = triggerPoint.GetContainingLine();
            SnapshotPoint start = line.Start;
            ForwardWhile(ref start, triggerPoint, p => char.IsWhiteSpace(p.GetChar()));
            SnapshotPoint end = start;
            ForwardWhile(ref end, triggerPoint, p => !char.IsWhiteSpace(p.GetChar()));
            if (start >= end)
                return true; // returns true for empty word
            if (end < triggerPoint)
                return false;

            var firstWord = triggerPoint.Snapshot.GetText(start, end.Position - start);
            GherkinDialect dialect = GetDialect(languageService);
            return dialect.GetKeywords().Any(k => k.StartsWith(firstWord, StringComparison.CurrentCultureIgnoreCase));
        }
 static private GherkinDialect GetDialect(GherkinLanguageService languageService)
 {
     var fileScope = languageService.GetFileScope();
     return fileScope != null ? fileScope.GherkinDialect : languageService.ProjectScope.GherkinDialectServices.GetDefaultDialect();
 }
Beispiel #13
0
 public EditorCommands(GherkinLanguageService languageService, IWpfTextView textView)
 {
     this.languageService = languageService;
     this.textView = textView;
 }
 public GherkinCompletionCommandFilter(IWpfTextView textView, ICompletionBroker broker, GherkinLanguageService languageService, IIdeTracer tracer) : base(textView, broker, tracer)
 {
     this.languageService = languageService;
 }
 public EditorCommandFilter(IObjectContainer container, IWpfTextView textView, GherkinLanguageService languageService)
 {
     editorCommands = new EditorCommands(container, languageService, textView);
 }
        private IStepDefinitionMatchService GetBindingMatchService(GherkinLanguageService languageService)
        {
            var bindingMatchService = languageService.ProjectScope.BindingMatchService;
            if (bindingMatchService == null)
                return null;

            return bindingMatchService;
        }
        static internal bool IsStepLine(SnapshotPoint triggerPoint, GherkinLanguageService languageService)
        {
            var keywordCandidate = GetFirstWord(triggerPoint);
            if (keywordCandidate == null)
                return false;
            GherkinDialect dialect = GetDialect(languageService);
            if (dialect == null)
                return false;

            if (dialect.IsStepKeyword(keywordCandidate))
                return true;

            keywordCandidate = GetFirstTwoWords(triggerPoint);
            if (keywordCandidate == null)
                return false;
            return dialect.IsStepKeyword(keywordCandidate);
        }
        private IStepDefinitionMatchService GetBindingMatchService(GherkinLanguageService languageService)
        {
            var bindingMatchService = languageService.ProjectScope.BindingMatchService;
            if (bindingMatchService == null)
                return null;

            if (!bindingMatchService.Ready)
            {
                MessageBox.Show("Step bindings are still being analyzed. Please wait.", "Generate step definition skeleton");
                return null;
            }

            return bindingMatchService;
        }
 public GherkinStepCompletionSource(ITextBuffer textBuffer, GherkinLanguageService languageService, IIdeTracer tracer)
 {
     this.textBuffer = textBuffer;
     this.languageService = languageService;
     this.tracer = tracer;
 }
 public EditorCommandFilter(IWpfTextView textView, GherkinLanguageService languageService)
 {
     editorCommands = new EditorCommands(languageService, textView);
 }
 public EditorCommandFilter(IObjectContainer container, IWpfTextView textView, GherkinLanguageService languageService)
 {
     editorCommands = new EditorCommands(container, languageService, textView);
     tracer = languageService.ProjectScope.Tracer;
 }
Beispiel #22
0
 public EditorCommands(IObjectContainer container, GherkinLanguageService languageService, IWpfTextView textView)
 {
     this.container = container;
     this.languageService = languageService;
     this.textView = textView;
 }
Beispiel #23
0
 public AnalyzingTask(GherkinLanguageService languageService, GherkinFileScopeChange change)
 {
     this.languageService = languageService;
     this.change          = change;
 }
 static internal bool IsStepLine(SnapshotPoint triggerPoint, GherkinLanguageService languageService)
 {
     var firstWord = GetFirstWord(triggerPoint);
     if (firstWord == null)
         return false;
     GherkinDialect dialect = GetDialect(languageService);
     return dialect.IsStepKeyword(firstWord);
 }
        public GherkinFileClassifier(GherkinLanguageService gherkinLanguageService)
        {
            this.gherkinLanguageService = gherkinLanguageService;

            gherkinLanguageService.FileScopeChanged += GherkinLanguageServiceOnFileScopeChanged;
        }
 public GherkinStepCompletionSource(ITextBuffer textBuffer, GherkinLanguageService languageService)
 {
     this.textBuffer = textBuffer;
     this.languageService = languageService;
 }
 public GherkinStepCompletionSource(ITextBuffer textBuffer, ISpecFlowServices specFlowServices, GherkinLanguageService languageService)
 {
     this.textBuffer = textBuffer;
     this.specFlowServices = specFlowServices;
     this.languageService = languageService;
 }