예제 #1
0
        private static async Task <TreeAndVersion> FullyParseTreeAsync(
            ValueSource <TextAndVersion> newTextSource,
            string filePath,
            ParseOptions options,
            IWorkspaceServiceProvider workspaceServices,
            ILanguageServiceProvider languageServices,
            PreservationMode mode,
            CancellationToken cancellationToken)
        {
            using (Logger.LogBlock(FeatureId.DocumentState, FunctionId.DocumentState_FullyParseSyntaxTree, cancellationToken))
            {
                var textAndVersion = await newTextSource.GetValueAsync(cancellationToken).ConfigureAwait(false);

                var text = textAndVersion.Text;

                var treeFactory = languageServices.GetService <ISyntaxTreeFactoryService>();

                var tree = treeFactory.ParseSyntaxTree(filePath, options, text, cancellationToken);

                if (mode == PreservationMode.PreserveValue)
                {
                    var root = await tree.GetRootAsync(cancellationToken).ConfigureAwait(false);

                    // get a recoverable tree that reparses from the source text if it gets used after being kicked out of memory
                    tree = treeFactory.CreateRecoverableTree(tree.FilePath, tree.Options, newTextSource, root, reparse: true);
                }

                Contract.ThrowIfNull(tree);

                // text version for this document should be unique. use it as a starting point.
                return(TreeAndVersion.Create(tree, textAndVersion.Version));
            }
        }
 public LanguageServiceProviderFactory(
     IWorkspaceServiceProvider workspaceServices,
     ImmutableList <KeyValuePair <LanguageServiceMetadata, Func <ILanguageServiceProvider, ILanguageService> > > services)
 {
     this.workspaceServices = workspaceServices;
     this.services          = services;
     this.constructLanguageServiceProvider = this.ConstructLanguageServiceProvider;
 }
예제 #3
0
 public SolutionServices(Workspace workspace, IWorkspaceServiceProvider workspaceServices)
 {
     this.Workspace = workspace;
     this.WorkspaceServices = workspaceServices;
     this.LanguageServicesFactory = WorkspaceServices.GetService<ILanguageServiceProviderFactory>();
     this.TemporaryStorage = WorkspaceServices.GetService<ITemporaryStorageService>();
     this.TextFactory = WorkspaceServices.GetService<ITextFactoryService>();
     this.TextCache = WorkspaceServices.GetService<ITextCacheService>();
     this.CompilationCacheService = WorkspaceServices.GetService<ICompilationCacheService>();
     this.MetadataReferenceProvider = WorkspaceServices.GetService<IMetadataReferenceProviderService>().GetProvider();
 }
예제 #4
0
 public SolutionServices(Workspace workspace, IWorkspaceServiceProvider workspaceServices)
 {
     this.Workspace                 = workspace;
     this.WorkspaceServices         = workspaceServices;
     this.LanguageServicesFactory   = WorkspaceServices.GetService <ILanguageServiceProviderFactory>();
     this.TemporaryStorage          = WorkspaceServices.GetService <ITemporaryStorageService>();
     this.TextFactory               = WorkspaceServices.GetService <ITextFactoryService>();
     this.TextCache                 = WorkspaceServices.GetService <ITextCacheService>();
     this.CompilationCacheService   = WorkspaceServices.GetService <ICompilationCacheService>();
     this.MetadataReferenceProvider = WorkspaceServices.GetService <IMetadataReferenceProviderService>().GetProvider();
 }
예제 #5
0
 private static ValueSource <TreeAndVersion> CreateLazyFullyParsedTree(
     ValueSource <TextAndVersion> newTextSource,
     string filePath,
     ParseOptions options,
     IWorkspaceServiceProvider workspaceServices,
     ILanguageServiceProvider languageServices,
     PreservationMode mode = PreservationMode.PreserveValue)
 {
     return(new AsyncLazy <TreeAndVersion>(
                c => FullyParseTreeAsync(newTextSource, filePath, options, workspaceServices, languageServices, mode, c),
                cacheResult: true));
 }
예제 #6
0
        internal Workspace(IWorkspaceServiceProvider workspaceServicesProvider)
        {
            this.primaryBranchId = BranchId.GetNextId();

            this.workspaceServicesProvider = workspaceServicesProvider;

            // queue used for sending events
            var workspaceTaskSchedulerFactory = workspaceServicesProvider.GetService <IWorkspaceTaskSchedulerFactory>();

            this.taskQueue = workspaceTaskSchedulerFactory.CreateTaskQueue();

            // initialize with empty solution
            this.latestSolution = CreateSolution(SolutionId.CreateNewId());
        }
예제 #7
0
파일: Solution.cs 프로젝트: riversky/roslyn
 internal Solution(
     Workspace workspace,
     IWorkspaceServiceProvider workspaceServices,
     SolutionInfo info)
     : this(
         workspace.PrimaryBranchId,
         workspaceVersion: 0,
         solutionServices: new SolutionServices(workspace, workspaceServices),
         id: info.Id,
         filePath: info.FilePath,
         version: info.Version,
         projectIds: ImmutableList.Create<ProjectId>(),
         idToProjectStateMap: ImmutableDictionary<ProjectId, ProjectState>.Empty,
         projectIdToTrackerMap: ImmutableDictionary<ProjectId, CompilationTracker>.Empty,
         dependencyGraph: ProjectDependencyGraph.Empty,
         lazyLatestProjectVersion: null)
 {
     this.lazyLatestProjectVersion = new Lazy<VersionStamp>(() => ComputeLatestProjectVersion());
 }
 public IWorkspaceService CreateService(IWorkspaceServiceProvider workspaceServices)
 {
     var textFactory = workspaceServices.GetService<ITextFactoryService>();
     return new TemporaryStorageService(textFactory);
 }
예제 #9
0
 public TestWorkspace(IWorkspaceServiceProvider workspaceServiceProvider = null)
     : base(workspaceServiceProvider ?? WorkspaceService.GetProvider(new CustomWorkspace()))
 {
 }
 public IWorkspaceService CreateService(IWorkspaceServiceProvider workspaceServices)
 {
     return new SemanticModelService();
 }
 public IWorkspaceService CreateService(IWorkspaceServiceProvider workspaceServices)
 {
     return(new AssemblyShadowCopyProviderService());
 }
예제 #12
0
 public IWorkspaceService CreateService(IWorkspaceServiceProvider workspaceServices)
 {
     return(singleton);
 }
 public IWorkspaceService CreateService(IWorkspaceServiceProvider workspaceServices)
 {
     return new MetadataReferenceProviderService();
 }
예제 #14
0
 private static ValueSource<TreeAndVersion> CreateLazyFullyParsedTree(
     ValueSource<TextAndVersion> newTextSource,
     string filePath,
     ParseOptions options,
     IWorkspaceServiceProvider workspaceServices,
     ILanguageServiceProvider languageServices,
     PreservationMode mode = PreservationMode.PreserveValue)
 {
     return new AsyncLazy<TreeAndVersion>(
         c => FullyParseTreeAsync(newTextSource, filePath, options, workspaceServices, languageServices, mode, c),
         cacheResult: true);
 }
예제 #15
0
 public IWorkspaceService CreateService(IWorkspaceServiceProvider workspaceServices)
 {
     return(new EmptyTelemetryLogger());
 }
예제 #16
0
 public IWorkspaceService CreateService(IWorkspaceServiceProvider workspaceServices)
 {
     return(new Factory());
 }
 public IWorkspaceService CreateService(IWorkspaceServiceProvider workspaceServices)
 {
     // all different workspace kinds will share same service
     return singleton;
 }
 public IWorkspaceService CreateService(IWorkspaceServiceProvider workspaceServices)
 {
     return(new ExtensionManager());
 }
예제 #19
0
 public IWorkspaceService CreateService(IWorkspaceServiceProvider workspaceServices)
 {
     return new OptionService(this.exports);
 }
예제 #20
0
 public IWorkspaceService CreateService(IWorkspaceServiceProvider workspaceServices)
 {
     return optionService;
 }
 public IWorkspaceService CreateService(IWorkspaceServiceProvider workspaceServices)
 {
     return new ExtensionManager();
 }
 public IWorkspaceService CreateService(IWorkspaceServiceProvider workspaceServices)
 {
     return(optionService);
 }
 public IWorkspaceService CreateService(IWorkspaceServiceProvider workspaceServices)
 {
     return(new OptionService(this.exports));
 }
 public IWorkspaceService CreateService(IWorkspaceServiceProvider workspaceServices)
 {
     // all different workspace kinds will share same service
     return(singleton);
 }
 public IWorkspaceService CreateService(IWorkspaceServiceProvider workspaceServices)
 {
     return new Cache();
 }
 public IWorkspaceService CreateService(IWorkspaceServiceProvider workspaceServices)
 {
     return(new LanguageServiceProviderFactory(workspaceServices, this.unboundServices.Value));
 }
예제 #27
0
 public ScriptWorkspace(IWorkspaceServiceProvider workspaceServiceProvider)
     : base(workspaceServiceProvider, true, true)
 {
 }
예제 #28
0
        private static async Task<TreeAndVersion> FullyParseTreeAsync(
            ValueSource<TextAndVersion> newTextSource,
            string filePath,
            ParseOptions options,
            IWorkspaceServiceProvider workspaceServices,
            ILanguageServiceProvider languageServices,
            PreservationMode mode,
            CancellationToken cancellationToken)
        {
            using (Logger.LogBlock(FeatureId.DocumentState, FunctionId.DocumentState_FullyParseSyntaxTree, cancellationToken))
            {
                var textAndVersion = await newTextSource.GetValueAsync(cancellationToken).ConfigureAwait(false);
                var text = textAndVersion.Text;

                var treeFactory = languageServices.GetService<ISyntaxTreeFactoryService>();

                var tree = treeFactory.ParseSyntaxTree(filePath, options, text, cancellationToken);

                if (mode == PreservationMode.PreserveValue)
                {
                    var root = await tree.GetRootAsync(cancellationToken).ConfigureAwait(false);

                    // get a recoverable tree that reparses from the source text if it gets used after being kicked out of memory
                    tree = treeFactory.CreateRecoverableTree(tree.FilePath, tree.Options, newTextSource, root, reparse: true);
                }

                Contract.ThrowIfNull(tree);

                // text version for this document should be unique. use it as a starting point.
                return TreeAndVersion.Create(tree, textAndVersion.Version);
            }
        }
 public IWorkspaceService CreateService(IWorkspaceServiceProvider workspaceServices)
 {
     return new LanguageServiceProviderFactory(workspaceServices, this.unboundServices.Value);
 }
예제 #30
0
 public IWorkspaceService CreateService(IWorkspaceServiceProvider workspaceServices)
 {
     return(new MetadataReferenceProviderService());
 }
예제 #31
0
 public IWorkspaceService CreateService(IWorkspaceServiceProvider workspaceServices)
 {
     return(new SyntaxTreeCacheService(DefaultTextCount, DefaultSize, tv => tv.FullSpan.Length));
 }
예제 #32
0
 public ScriptWorkspace(IWorkspaceServiceProvider workspaceServiceProvider)
     : base(workspaceServiceProvider, true, true)
 {
 }
예제 #33
0
 public IWorkspaceService CreateService(IWorkspaceServiceProvider workspaceServices)
 {
     return(new TextCacheService(DefaultTextCount, DefaultSize, itemCost: tv => tv.Text.Length));
 }
 public IWorkspaceService CreateService(IWorkspaceServiceProvider workspaceServices)
 {
     return(new CacheService());
 }
 public IWorkspaceService CreateService(IWorkspaceServiceProvider workspaceServices)
 {
     return new EmptyTelemetryLogger();
 }
 public IWorkspaceService CreateService(IWorkspaceServiceProvider workspaceServices)
 {
     return new Factory();
 }
예제 #37
0
        public IWorkspaceService CreateService(IWorkspaceServiceProvider workspaceServices)
        {
            var textFactory = workspaceServices.GetService <ITextFactoryService>();

            return(new TemporaryStorageService(textFactory));
        }
예제 #38
0
 public IWorkspaceService CreateService(IWorkspaceServiceProvider workspaceServices)
 {
     return singleton;
 }
 public IWorkspaceService CreateService(IWorkspaceServiceProvider workspaceServices)
 {
     return(new FileTrackingService());
 }
 public IWorkspaceService CreateService(IWorkspaceServiceProvider workspaceServices)
 {
     return(new SemanticModelService());
 }
예제 #41
0
 internal InteractiveWorkspace(IWorkspaceServiceProvider workspaceServices)
     : base(workspaceServices, true, true)
 {
 }