public VisualStudioWorkspace( SVsServiceProvider serviceProvider, ITextDocumentFactoryService textDocumentFactoryService) : base(MefV1HostServices.Create(GetExportProvider(serviceProvider))) { PrimaryWorkspace.Register(this); _serviceProvider = serviceProvider; _textDocumentFactoryService = textDocumentFactoryService; _backgroundParser = new BackgroundParser(this); _backgroundParser.Start(); _textBufferToTextDocumentMap = new ConditionalWeakTable <ITextBuffer, ITextDocument>(); _documentIdToTextBufferMap = new ConditionalWeakTable <DocumentId, ITextBuffer>(); _textBufferToDocumentIdMap = new ConditionalWeakTable <ITextBuffer, DocumentId>(); _textBufferToViewsMap = new ConditionalWeakTable <ITextBuffer, List <ITextView> >(); _textViewToBuffersMap = new ConditionalWeakTable <ITextView, List <ITextBuffer> >(); Services.GetService <IDocumentTrackingService>(); if (Services.GetService <IOptionService>() is OptionServiceFactory.OptionService optionService) { optionService.RegisterDocumentOptionsProvider(new Implementation.Options.EditorconfigDocumentOptionsProvider()); } }
public TestWorkspace( ExportProvider?exportProvider = null, TestComposition?composition = null, string?workspaceKind = WorkspaceKind.Host, bool disablePartialSolutions = true, bool ignoreUnchangeableDocumentsWhenApplyingChanges = true ) : base(GetHostServices(exportProvider, composition), workspaceKind ?? WorkspaceKind.Host) { Contract.ThrowIfTrue(exportProvider != null && composition != null); this.TestHookPartialSolutionsDisabled = disablePartialSolutions; this.ExportProvider = exportProvider ?? GetComposition(composition).ExportProviderFactory.CreateExportProvider(); _workspaceKind = workspaceKind ?? WorkspaceKind.Host; this.Projects = new List <TestHostProject>(); this.Documents = new List <TestHostDocument>(); this.AdditionalDocuments = new List <TestHostDocument>(); this.AnalyzerConfigDocuments = new List <TestHostDocument>(); this.ProjectionDocuments = new List <TestHostDocument>(); this.CanApplyChangeDocument = true; this.IgnoreUnchangeableDocumentsWhenApplyingChanges = ignoreUnchangeableDocumentsWhenApplyingChanges; if ( Services.GetService <INotificationService>() is INotificationServiceCallback callback ) { // Avoid showing dialogs in tests by default callback.NotificationCallback = (message, title, severity) => { var severityText = severity switch { NotificationSeverity.Information => "💡", NotificationSeverity.Warning => "⚠", _ => "❌" }; var fullMessage = string.IsNullOrEmpty(title) ? message : $"{title}:{Environment.NewLine}{Environment.NewLine}{message}"; throw new InvalidOperationException($"{severityText} {fullMessage}"); }; } _backgroundCompiler = new BackgroundCompiler(this); _backgroundParser = new BackgroundParser(this); _backgroundParser.Start(); _metadataAsSourceFileService = ExportProvider .GetExportedValues <IMetadataAsSourceFileService>() .FirstOrDefault(); RegisterDocumentOptionProviders( ExportProvider.GetExports <IDocumentOptionsProviderFactory, OrderableMetadata>() ); }
/// <summary> /// Constructs the editor parser. One instance should be used per active editor. This /// instance _can_ be shared among reparses, but should _never_ be shared between documents. /// </summary> /// <param name="host">The <see cref="RazorEngineHost"/> which defines the environment in which the generated code will live. <see cref="F:RazorEngineHost.DesignTimeMode"/> should be set if design-time code mappings are desired</param> /// <param name="sourceFileName">The physical path to use in line pragmas</param> public RazorEditorParser([NotNull] RazorEngineHost host, string sourceFileName) { if (string.IsNullOrEmpty(sourceFileName)) { throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, nameof(sourceFileName)); } Host = host; FileName = sourceFileName; _parser = new BackgroundParser(host, sourceFileName); _parser.ResultsReady += (sender, args) => OnDocumentParseComplete(args); _parser.Start(); }
internal VisualStudioWorkspace(HostServices hostServices, WorkspaceBackgroundWork backgroundWork) : base(hostServices, WorkspaceKind.Host) { if ((backgroundWork & WorkspaceBackgroundWork.Compile) != 0) { _backgroundCompiler = new BackgroundCompiler(this); } if ((backgroundWork & WorkspaceBackgroundWork.Parse) != 0) { _backgroundParser = new BackgroundParser(this); _backgroundParser.Start(); } }
internal VisualStudioWorkspace(HostServices hostServices) : base(hostServices, WorkspaceKind.Host) { _backgroundCompiler = new BackgroundCompiler(this); var cacheService = Services.GetService <IWorkspaceCacheService>(); if (cacheService != null) { cacheService.CacheFlushRequested += OnCacheFlushRequested; } _backgroundParser = new BackgroundParser(this); _backgroundParser.Start(); }
public TestWorkspace(ExportProvider exportProvider, string workspaceKind = null, bool disablePartialSolutions = true) : base(MefV1HostServices.Create(exportProvider.AsExportProvider()), workspaceKind ?? WorkspaceName) { ResetThreadAffinity(); this.TestHookPartialSolutionsDisabled = disablePartialSolutions; this.ExportProvider = exportProvider; this.Projects = new List <TestHostProject>(); this.Documents = new List <TestHostDocument>(); this.AdditionalDocuments = new List <TestHostDocument>(); this.ProjectionDocuments = new List <TestHostDocument>(); this.CanApplyChangeDocument = true; _backgroundCompiler = new BackgroundCompiler(this); _backgroundParser = new BackgroundParser(this); _backgroundParser.Start(); }
public TestWorkspace(ExportProvider exportProvider, string workspaceKind = null, bool disablePartialSolutions = true) : base(VisualStudioMefHostServices.Create(exportProvider), workspaceKind ?? WorkspaceKind.Test) { this.TestHookPartialSolutionsDisabled = disablePartialSolutions; this.ExportProvider = exportProvider; this.Projects = new List <TestHostProject>(); this.Documents = new List <TestHostDocument>(); this.AdditionalDocuments = new List <TestHostDocument>(); this.ProjectionDocuments = new List <TestHostDocument>(); this.CanApplyChangeDocument = true; _backgroundCompiler = new BackgroundCompiler(this); _backgroundParser = new BackgroundParser(this); _backgroundParser.Start(); _metadataAsSourceFileService = exportProvider.GetExportedValues <IMetadataAsSourceFileService>().FirstOrDefault(); }
public RazorEditorParser(RazorTemplateEngine templateEngine, string filePath) { if (templateEngine == null) { throw new ArgumentNullException(nameof(templateEngine)); } if (string.IsNullOrEmpty(filePath)) { throw new ArgumentException( AspNetCore.Razor.Language.Resources.ArgumentCannotBeNullOrEmpty, nameof(filePath)); } TemplateEngine = templateEngine; FilePath = filePath; _parser = new BackgroundParser(this, filePath); _parser.ResultsReady += (sender, args) => OnDocumentParseComplete(args); _parser.Start(); }
public VisualStudioWorkspace( SVsServiceProvider serviceProvider, ITextDocumentFactoryService textDocumentFactoryService) : base(MefV1HostServices.Create(GetExportProvider(serviceProvider))) { PrimaryWorkspace.Register(this); _serviceProvider = serviceProvider; _textDocumentFactoryService = textDocumentFactoryService; _backgroundParser = new BackgroundParser(this); _backgroundParser.Start(); _textBufferToTextDocumentMap = new ConditionalWeakTable <ITextBuffer, ITextDocument>(); _textBufferToDocumentIdMap = new ConditionalWeakTable <ITextBuffer, DocumentId>(); _textBufferToViewsMap = new ConditionalWeakTable <ITextBuffer, List <ITextView> >(); _textViewToBuffersMap = new ConditionalWeakTable <ITextView, List <ITextBuffer> >(); Services.GetService <IDocumentTrackingService>(); }
public TestWorkspace(ExportProvider exportProvider, string?workspaceKind = null, bool disablePartialSolutions = true, bool ignoreUnchangeableDocumentsWhenApplyingChanges = true) : base(VisualStudioMefHostServices.Create(exportProvider), workspaceKind ?? WorkspaceKind.Test) { this.TestHookPartialSolutionsDisabled = disablePartialSolutions; this.ExportProvider = exportProvider; this.Projects = new List <TestHostProject>(); this.Documents = new List <TestHostDocument>(); this.AdditionalDocuments = new List <TestHostDocument>(); this.AnalyzerConfigDocuments = new List <TestHostDocument>(); this.ProjectionDocuments = new List <TestHostDocument>(); this.CanApplyChangeDocument = true; this.IgnoreUnchangeableDocumentsWhenApplyingChanges = ignoreUnchangeableDocumentsWhenApplyingChanges; _backgroundCompiler = new BackgroundCompiler(this); _backgroundParser = new BackgroundParser(this); _backgroundParser.Start(); _metadataAsSourceFileService = exportProvider.GetExportedValues <IMetadataAsSourceFileService>().FirstOrDefault(); RegisterDocumentOptionProviders(exportProvider.GetExports <IDocumentOptionsProviderFactory, OrderableMetadata>()); }
/// <summary> /// Constructs the editor parser. One instance should be used per active editor. This /// instance <em>can</em> be shared among reparses, but should <em>never</em> be shared between documents. /// </summary> /// <param name="host">The <see cref="RazorEngineHost"/> which defines the environment in which the generated /// code will live. <see cref="RazorEngineHost.DesignTimeMode"/> should be set if design-time behavior is /// desired.</param> /// <param name="sourceFileName">The physical path to use in line pragmas.</param> public RazorEditorParser(RazorEngineHost host, string sourceFileName) { if (host == null) { throw new ArgumentNullException(nameof(host)); } if (string.IsNullOrEmpty(sourceFileName)) { throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, nameof(sourceFileName)); } Host = host; FileName = sourceFileName; _parser = new BackgroundParser(host, sourceFileName); _parser.ResultsReady += (sender, args) => OnDocumentParseComplete(args); _parser.Start(); }