private GherkinFileScopeChange FullParse(ITextSnapshot textSnapshot, GherkinDialect gherkinDialect)
        {
            visualStudioTracer.Trace("Start full parsing", ParserTraceCategory);
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            partialParseCount = 0;

            var gherkinListener = new GherkinTextBufferParserListener(gherkinDialect, textSnapshot, projectScope.Classifications);

            var scanner = new GherkinScanner(gherkinDialect, textSnapshot.GetText(), 0);

            scanner.Scan(gherkinListener);

            var gherkinFileScope = gherkinListener.GetResult();

            var result = new GherkinFileScopeChange(
                gherkinFileScope,
                true, true,
                gherkinFileScope.GetAllBlocks(),
                Enumerable.Empty <IGherkinFileBlock>());

            stopwatch.Stop();
            TraceFinishParse(stopwatch, "full", result);

            return(result);
        }
 private void TriggerScopeChange(GherkinFileScopeChange scopeChange)
 {
     if (FileScopeChanged != null)
     {
         FileScopeChanged(this, scopeChange);
     }
 }
            public IGherkinProcessingTask Merge(IGherkinProcessingTask other)
            {
                if (other is PingTask)
                {
                    return(this);
                }

                AnalyzingTask otherAnalyzingTask = other as AnalyzingTask;

                if (otherAnalyzingTask == null || languageService != otherAnalyzingTask.languageService)
                {
                    return(null);
                }

                if (otherAnalyzingTask.change.EntireScopeChanged)
                {
                    return(otherAnalyzingTask);
                }

                if (change.EntireScopeChanged)
                {
                    return(new AnalyzingTask(languageService, GherkinFileScopeChange.CreateEntireScopeChange(otherAnalyzingTask.change.GherkinFileScope)));
                }

                return(new AnalyzingTask(languageService, Merge(change, otherAnalyzingTask.change)));
            }
 private void GherkinLanguageServiceOnFileScopeChanged(object sender, GherkinFileScopeChange gherkinFileScopeChange)
 {
     if (ClassificationChanged != null)
     {
         ClassificationChangedEventArgs args = new ClassificationChangedEventArgs(gherkinFileScopeChange.CreateChangeSpan());
         ClassificationChanged(this, args);
     }
 }
        private GherkinFileScopeChange GetInvalidDialectScopeChange(GherkinTextBufferChange change)
        {
            var fileScope = new GherkinFileScope(null, change.ResultTextSnapshot)
            {
                InvalidFileEndingBlock = new InvalidFileBlock(0,
                                                              change.ResultTextSnapshot.LineCount - 1,
                                                              new ErrorInfo("Invalid Gherkin dialect!", 0, 0, null))
            };

            return(GherkinFileScopeChange.CreateEntireScopeChange(fileScope));
        }
        public static SnapshotSpan CreateChangeSpan(this GherkinFileScopeChange gherkinFileScopeChange)
        {
            var textSnapshot = gherkinFileScopeChange.GherkinFileScope.TextSnapshot;

            if (gherkinFileScopeChange.EntireScopeChanged)
            {
                return(new SnapshotSpan(textSnapshot, 0, textSnapshot.Length));
            }

            return(gherkinFileScopeChange.ChangedBlocks.CreateSpan(textSnapshot));
        }
        private void EnqueueAnalyzingRequest(GherkinFileScopeChange scopeChange)
        {
            if (!AnalyzingEnabled)
            {
                return;
            }

            var task = new AnalyzingTask(this, scopeChange);

            projectScope.GherkinProcessingScheduler.EnqueueAnalyzingRequest(task);
            //            task.Apply(); // synchronous execution
        }
            private static GherkinFileScopeChange Merge(GherkinFileScopeChange change1, GherkinFileScopeChange change2)
            {
                var ramainingChanged1Blocks = change1.ChangedBlocks.Intersect(change2.GherkinFileScope.GetAllBlocks()).ToArray();

                var firstChanged1 = ramainingChanged1Blocks.FirstOrDefault();
                var lastChanged1  = ramainingChanged1Blocks.LastOrDefault();

                var firstChanged2 = change2.ChangedBlocks.First();
                var lastChanged2  = change2.ChangedBlocks.Last();

                var firstChanged = firstChanged1 != null && firstChanged1.GetStartLine() < firstChanged2.GetStartLine() ? firstChanged1 : firstChanged2;
                var lastChanged  = lastChanged1 != null && lastChanged1.GetEndLine() > lastChanged2.GetEndLine() ? lastChanged1 : lastChanged2;

                var changedBlocks = change2.GherkinFileScope.GetAllBlocks().SkipFromItemInclusive(firstChanged).TakeUntilItemInclusive(lastChanged);
                var shiftedBlocks = change1.ShiftedBlocks.Any() || change2.ShiftedBlocks.Any() ?
                                    change2.GherkinFileScope.GetAllBlocks().SkipFromItemExclusive(lastChanged) :
                                    Enumerable.Empty <IGherkinFileBlock>();

                return(new GherkinFileScopeChange(change2.GherkinFileScope, false, false, changedBlocks, shiftedBlocks));
            }
        private GherkinFileScopeChange FullParse(ITextSnapshot textSnapshot, GherkinDialect gherkinDialect)
        {
            visualStudioTracer.Trace("Start full parsing", ParserTraceCategory);
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();

            partialParseCount = 0;

            var gherkinListener = new GherkinTextBufferParserListener(gherkinDialect, textSnapshot, projectScope.Classifications);

            var scanner = new GherkinScanner(gherkinDialect, textSnapshot.GetText(), 0);
            scanner.Scan(gherkinListener);

            var gherkinFileScope = gherkinListener.GetResult();

            var result = new GherkinFileScopeChange(
                gherkinFileScope,
                true, true,
                gherkinFileScope.GetAllBlocks(),
                Enumerable.Empty<IGherkinFileBlock>());

            stopwatch.Stop();
            TraceFinishParse(stopwatch, "full", result);

            return result;
        }
示例#10
0
 private void TriggerScopeChange(GherkinFileScopeChange scopeChange)
 {
     if (FileScopeChanged != null)
         FileScopeChanged(this, scopeChange);
 }
 private void TraceFinishParse(Stopwatch stopwatch, string parseKind, GherkinFileScopeChange result)
 {
     visualStudioTracer.Trace(
         string.Format("Finished {0} parsing in {1} ms, {2} errors", parseKind, stopwatch.ElapsedMilliseconds, result.GherkinFileScope.TotalErrorCount()), ParserTraceCategory);
 }
示例#12
0
            private static GherkinFileScopeChange Merge(GherkinFileScopeChange change1, GherkinFileScopeChange change2)
            {
                var ramainingChanged1Blocks = change1.ChangedBlocks.Intersect(change2.GherkinFileScope.GetAllBlocks()).ToArray();

                var firstChanged1 = ramainingChanged1Blocks.FirstOrDefault();
                var lastChanged1 = ramainingChanged1Blocks.LastOrDefault();

                var firstChanged2 = change2.ChangedBlocks.First();
                var lastChanged2 = change2.ChangedBlocks.Last();

                var firstChanged = firstChanged1 != null && firstChanged1.GetStartLine() < firstChanged2.GetStartLine() ? firstChanged1 : firstChanged2;
                var lastChanged = lastChanged1 != null && lastChanged1.GetEndLine() > lastChanged2.GetEndLine() ? lastChanged1 : lastChanged2;

                var changedBlocks = change2.GherkinFileScope.GetAllBlocks().SkipFromItemInclusive(firstChanged).TakeUntilItemInclusive(lastChanged);
                var shiftedBlocks = change1.ShiftedBlocks.Any() || change2.ShiftedBlocks.Any() ?
                    change2.GherkinFileScope.GetAllBlocks().SkipFromItemExclusive(lastChanged) :
                    Enumerable.Empty<IGherkinFileBlock>();
                return new GherkinFileScopeChange(change2.GherkinFileScope, false, false, changedBlocks, shiftedBlocks);
            }
示例#13
0
        private void EnqueueAnalyzingRequest(GherkinFileScopeChange scopeChange)
        {
            if (!AnalyzingEnabled)
                return;

            var task = new AnalyzingTask(this, scopeChange);

            projectScope.GherkinProcessingScheduler.EnqueueAnalyzingRequest(task);
            //            task.Apply(); // synchronous execution
        }
示例#14
0
 private void RegisterScopeChange(GherkinFileScopeChange scopeChange)
 {
     lastGherkinFileScope = scopeChange.GherkinFileScope;
     TriggerScopeChange(scopeChange);
 }
示例#15
0
 public AnalyzingTask(GherkinLanguageService languageService, GherkinFileScopeChange change)
 {
     this.languageService = languageService;
     this.change = change;
 }
 private void TraceFinishParse(Stopwatch stopwatch, string parseKind, GherkinFileScopeChange result)
 {
     visualStudioTracer.Trace(
         string.Format("Finished {0} parsing in {1} ms, {2} errors", parseKind, stopwatch.ElapsedMilliseconds, result.GherkinFileScope.TotalErrorCount()), ParserTraceCategory);
 }
示例#17
0
 public GherkinFileScopeChange Analyze(GherkinFileScopeChange change)
 {
     visualStudioTracer.Trace("Analyzing started", "GherkinScopeAnalyzer");
     return change; //TODO
 }
 public GherkinFileScopeChange Analyze(GherkinFileScopeChange change)
 {
     visualStudioTracer.Trace("Analyzing started", "GherkinScopeAnalyzer");
     return(change); //TODO
 }
 private void RegisterScopeChange(GherkinFileScopeChange scopeChange)
 {
     lastGherkinFileScope = scopeChange.GherkinFileScope;
     TriggerScopeChange(scopeChange);
 }
 public AnalyzingTask(GherkinLanguageService languageService, GherkinFileScopeChange change)
 {
     this.languageService = languageService;
     this.change          = change;
 }