Inheritance: Microsoft.Languages.Editor.ContainedLanguage.ContainedLanguageHandler
Ejemplo n.º 1
0
        public MdEditorDocument(ITextBuffer textBuffer, IProjectionBufferFactoryService projectionBufferFactoryService, IContentTypeRegistryService contentTypeRegistryService, ICoreShell coreShell) {

            this.TextBuffer = textBuffer;
            ServiceManager.AddService(this, TextBuffer, coreShell);

            _projectionBufferManager = new ProjectionBufferManager(textBuffer, 
                        projectionBufferFactoryService, contentTypeRegistryService,
                        coreShell, MdProjectionContentTypeDefinition.ContentType, RContentTypeDefinition.ContentType);
            ContainedLanguageHandler = _rLanguageHandler = new RLanguageHandler(textBuffer, _projectionBufferManager, coreShell);
        }
Ejemplo n.º 2
0
        public void RCodeGen(string markdown) {
            var tb = new TextBufferMock(markdown, MdContentTypeDefinition.ContentType);
            var pbm = Substitute.For<IProjectionBufferManager>();

            string secondaryBuffer = null;
            ProjectionMapping[] mappings = null;
            pbm.When(x => x.SetProjectionMappings(Arg.Any<string>(), Arg.Any<ProjectionMapping[]>())).Do(x => {
                secondaryBuffer = ((string)x[0]);
                mappings = (ProjectionMapping[])x[1];
            });

            var expectedSecondaryBuffer = markdown.Replace("```", string.Empty) + Environment.NewLine;
            var handler = new RLanguageHandler(tb, pbm, _exportProvider.GetExportedValue<ICoreShell>());
            secondaryBuffer.Should().Be(expectedSecondaryBuffer);

            mappings.Should().HaveCount(1);
            mappings[0].SourceStart.Should().Be(3);
            mappings[0].ProjectionRange.Start.Should().Be(0);
            mappings[0].Length.Should().Be(expectedSecondaryBuffer.Length - Environment.NewLine.Length);
        }