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)); } }
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 CSharpCodeGenerationService(ILanguageServiceProvider languageServices) : base(languageServices.GetService <ISymbolDeclarationService>()) { }