/// <summary>
        /// Does the code structure analysis.
        /// </summary>
        /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
        private async Task AnalyzeCodeStructureAsync(CancellationToken token)
        {
            try
            {
                var content = await _editor.GetRawEditorContentAsync().ConfigureAwait(false);

                var tree = _syntaxAnalyzer.ParseText(content);

                if (token.IsCancellationRequested)
                {
                    return;
                }

                await _syntaxAnalyzer.Analyze(tree.GetRoot(), CancellationToken.None).ConfigureAwait(false);

                if (token.IsCancellationRequested)
                {
                    return;
                }

                Nodes = _syntaxAnalyzer.NodeList;
                AnalysisFinished?.Invoke(this, EventArgs.Empty);
            }
            catch
            {
                // TODO: logging
            }
        }
Example #2
0
        /// <summary>
        /// Performs the document analysis, after the <see cref="AnalysisStartDelay"/> exceeded.
        /// </summary>
        private void Analysis()
        {
            var document = _textView.GetDocument();

            AnalyzeCodeStructureAsync(document)
            .ContinueWith(t => AnalysisFinished?.Invoke(this, EventArgs.Empty), TaskContinuationOptions.OnlyOnRanToCompletion)
            .ConfigureAwait(false);
        }