Ejemplo n.º 1
0
        internal SyntaxTree?GetSyntaxTreeSynchronously(CancellationToken cancellationToken)
        {
            if (!this.SupportsSyntaxTree)
            {
                return(null);
            }

            return(DocumentState.GetSyntaxTree(cancellationToken));
        }
Ejemplo n.º 2
0
        internal SyntaxTree GetSyntaxTreeSynchronously(CancellationToken cancellationToken)
        {
            if (!this.SupportsSyntaxTree)
            {
                return(null);
            }

            // if we already have a stask for getting this syntax tree, and the task
            // has completed, then we can just return that value.
            var syntaxTreeTask = GetExistingSyntaxTreeTask();

            if (syntaxTreeTask?.Status == TaskStatus.RanToCompletion)
            {
                return(syntaxTreeTask.Result);
            }

            // Otherwise defer to our state to get this value.
            return(DocumentState.GetSyntaxTree(cancellationToken));
        }