예제 #1
0
        /// <summary>
        /// create a new root node from the given root after adding annotations to the tokens
        ///
        /// tokens should belong to the given root
        /// </summary>
        public static SyntaxNode AddAnnotations(this SyntaxNode root, IEnumerable <Tuple <SyntaxToken, SyntaxAnnotation> > pairs)
        {
            var tokenMap = pairs.GroupBy(p => p.Item1, p => p.Item2).ToDictionary(g => g.Key, g => g.ToArray());

            return(root.ReplaceTokens(tokenMap.Keys, (o, n) => o.WithAdditionalAnnotations(tokenMap[o])));
        }