示例#1
0
        internal SyntaxTree?GetSyntaxTreeSynchronously(CancellationToken cancellationToken)
        {
            if (!this.SupportsSyntaxTree)
            {
                return(null);
            }

            return(DocumentState.GetSyntaxTree(cancellationToken));
        }
示例#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));
        }