Ejemplo n.º 1
0
        private static async Task <(Data existingData, Data newData)> ComputeAndPersistTodoCommentsAsync(
            Document document,
            TodoCommentState state,
            TodoCommentTokens todoCommentTokens,
            CancellationToken cancellationToken)
        {
            // use tree version so that things like compiler option changes are considered
            var textVersion = await document.GetTextVersionAsync(cancellationToken).ConfigureAwait(false);

            var syntaxVersion = await document.GetSyntaxVersionAsync(cancellationToken).ConfigureAwait(false);

            var existingData = await state.TryGetExistingDataAsync(document, cancellationToken).ConfigureAwait(false);

            if (existingData != null)
            {
                // check whether we can use the data as it is (can happen when re-using persisted data from previous VS session)
                if (CheckVersions(document, textVersion, syntaxVersion, existingData))
                {
                    return(existingData, existingData);
                }
            }

            var tokens   = todoCommentTokens.GetTokens(document);
            var comments = await GetTodoCommentsAsync(document, tokens, cancellationToken).ConfigureAwait(false);

            var items = await CreateItemsAsync(document, comments, cancellationToken).ConfigureAwait(false);

            var data = new Data(textVersion, syntaxVersion, items);
            await state.PersistAsync(document, data, cancellationToken).ConfigureAwait(false);

            return(existingData, data);
        }
Ejemplo n.º 2
0
        public TodoCommentIncrementalAnalyzer(Workspace workspace, TodoCommentIncrementalAnalyzerProvider owner, TodoCommentTokens todoCommentTokens)
        {
            _workspace = workspace;

            _owner             = owner;
            _todoCommentTokens = todoCommentTokens;

            _state = new TodoCommentState();
        }
        public TodoCommentIncrementalAnalyzer(Workspace workspace, TodoCommentIncrementalAnalyzerProvider owner, TodoCommentTokens todoCommentTokens)
        {
            _workspace = workspace;

            _owner = owner;
            _todoCommentTokens = todoCommentTokens;

            _state = new TodoCommentState();
        }