Esempio n. 1
0
        private FormattingStructureValidationPass GetPass(RazorCodeDocument codeDocument)
        {
            var mappingService = new DefaultRazorDocumentMappingService();

            var client = new FormattingLanguageServerClient();

            client.AddCodeDocument(codeDocument);
            var languageServer = Mock.Of <ILanguageServer>(ls => ls.Client == client);
            var pass           = new FormattingStructureValidationPass(mappingService, FilePathNormalizer, languageServer, LoggerFactory);

            return(pass);
        }
Esempio n. 2
0
        private RazorFormattingService CreateFormattingService(RazorCodeDocument codeDocument)
        {
            var mappingService     = new DefaultRazorDocumentMappingService();
            var filePathNormalizer = new FilePathNormalizer();

            var client = new FormattingLanguageServerClient();

            client.AddCodeDocument(codeDocument);
            var languageServer = Mock.Of <ILanguageServer>(ls => ls.Client == client);


            return(new DefaultRazorFormattingService(mappingService, filePathNormalizer, languageServer, LoggerFactory));
        }
        private RazorFormattingService CreateFormattingService(RazorCodeDocument codeDocument)
        {
            var mappingService     = new DefaultRazorDocumentMappingService();
            var filePathNormalizer = new FilePathNormalizer();

            var client = new FormattingLanguageServerClient();

            client.AddCodeDocument(codeDocument);
            var languageServer = Mock.Of <ILanguageServer>(ls => ls.Client == client);

            var optionsMonitor = new Mock <IOptionsMonitor <RazorLSPOptions> >();

            optionsMonitor.SetupGet(o => o.CurrentValue).Returns(RazorLSPOptions.Default);

            return(new DefaultRazorFormattingService(mappingService, filePathNormalizer, languageServer, optionsMonitor.Object, LoggerFactory));
        }
        private RazorFormattingService CreateFormattingService(RazorCodeDocument codeDocument)
        {
            var mappingService = new DefaultRazorDocumentMappingService();

            var client = new FormattingLanguageServerClient(TestProjectPath, FileName);

            client.AddCodeDocument(codeDocument);
            var passes = new List <IFormattingPass>()
            {
                new HtmlFormattingPass(mappingService, FilePathNormalizer, client, LoggerFactory),
                new CSharpFormattingPass(mappingService, FilePathNormalizer, client, LoggerFactory),
                new CSharpOnTypeFormattingPass(mappingService, FilePathNormalizer, client, LoggerFactory),
                new FormattingDiagnosticValidationPass(mappingService, FilePathNormalizer, client, LoggerFactory),
                new FormattingContentValidationPass(mappingService, FilePathNormalizer, client, LoggerFactory),
            };

            return(new DefaultRazorFormattingService(passes, LoggerFactory));
        }
        private RazorFormattingService CreateFormattingService(RazorCodeDocument codeDocument)
        {
            var mappingService = new DefaultRazorDocumentMappingService();

            var client = new FormattingLanguageServerClient();

            client.AddCodeDocument(codeDocument);
            var languageServer = Mock.Of <ILanguageServer>(ls => ls.Client == client);
            var passes         = new List <IFormattingPass>()
            {
                new CodeBlockDirectiveFormattingPass(mappingService, FilePathNormalizer, languageServer, LoggerFactory),
                new CSharpOnTypeFormattingPass(mappingService, FilePathNormalizer, languageServer, LoggerFactory),
                new FormattingStructureValidationPass(mappingService, FilePathNormalizer, languageServer, LoggerFactory),
                new FormattingContentValidationPass(mappingService, FilePathNormalizer, languageServer, LoggerFactory),
            };

            return(new DefaultRazorFormattingService(passes, LoggerFactory));
        }
        private RazorFormattingService CreateFormattingService(RazorCodeDocument codeDocument)
        {
            var mappingService = new DefaultRazorDocumentMappingService(LoggerFactory);

            var dispatcher   = new LSPProjectSnapshotManagerDispatcher(LoggerFactory);
            var versionCache = new DefaultDocumentVersionCache(dispatcher);

            var client = new FormattingLanguageServerClient();

            client.AddCodeDocument(codeDocument);
            var passes = new List <IFormattingPass>()
            {
                new HtmlFormattingPass(mappingService, FilePathNormalizer, client, versionCache, LoggerFactory),
                new CSharpFormattingPass(mappingService, FilePathNormalizer, client, LoggerFactory),
                new CSharpOnTypeFormattingPass(mappingService, FilePathNormalizer, client, LoggerFactory),
                new RazorFormattingPass(mappingService, FilePathNormalizer, client, LoggerFactory),
                new FormattingDiagnosticValidationPass(mappingService, FilePathNormalizer, client, LoggerFactory),
                new FormattingContentValidationPass(mappingService, FilePathNormalizer, client, LoggerFactory),
            };

            return(new DefaultRazorFormattingService(passes, LoggerFactory, TestAdhocWorkspaceFactory.Instance));
        }