Exemplo n.º 1
0
 private static void AddNonIncluded(ArrayBuilder <string> builder, string item)
 {
     if (!builder.Contains(item))
     {
         builder.Add(item);
     }
 }
Exemplo n.º 2
0
 private void RegisterOutput(IIncrementalGeneratorOutputNode outputNode)
 {
     if (!_outputNodes.Contains(outputNode))
     {
         _outputNodes.Add(outputNode);
     }
 }
Exemplo n.º 3
0
        public static TNode WithAdditionalAnnotationsGreen <TNode>(this TNode node, IEnumerable <SyntaxAnnotation> annotations) where TNode : GreenNode
        {
            SyntaxAnnotation[] existingAnnotations = node.GetAnnotations();

            if (annotations == null)
            {
                return(node);
            }

            ArrayBuilder <SyntaxAnnotation> newAnnotations = ArrayBuilder <SyntaxAnnotation> .GetInstance();

            newAnnotations.AddRange(existingAnnotations);

            foreach (SyntaxAnnotation candidate in annotations)
            {
                if (!newAnnotations.Contains(candidate))
                {
                    newAnnotations.Add(candidate);
                }
            }

            if (newAnnotations.Count == existingAnnotations.Length)
            {
                newAnnotations.Free();
                return(node);
            }
            else
            {
                return((TNode)node.SetAnnotations(newAnnotations.ToArrayAndFree()));
            }
        }
Exemplo n.º 4
0
 private void RegisterOutputAndDeferredInput(SyntaxInputNode node, IIncrementalGeneratorOutputNode output)
 {
     _registerOutput(output);
     if (!_inputNodes.Contains(node))
     {
         _inputNodes.Add(node);
     }
 }
Exemplo n.º 5
0
        public static TNode WithoutAnnotationsGreen <TNode>(this TNode node, IEnumerable <SyntaxAnnotation> annotations) where TNode : GreenNode
        {
            SyntaxAnnotation[] existingAnnotations = node.GetAnnotations();

            if (annotations == null || existingAnnotations.Length == 0)
            {
                return(node);
            }

            ArrayBuilder <SyntaxAnnotation> removalAnnotations = ArrayBuilder <SyntaxAnnotation> .GetInstance();

            removalAnnotations.AddRange(annotations);
            try
            {
                if (removalAnnotations.Count == 0)
                {
                    return(node);
                }

                ArrayBuilder <SyntaxAnnotation> newAnnotations = ArrayBuilder <SyntaxAnnotation> .GetInstance();

                foreach (SyntaxAnnotation candidate in existingAnnotations)
                {
                    if (!removalAnnotations.Contains(candidate))
                    {
                        newAnnotations.Add(candidate);
                    }
                }

                return((TNode)node.SetAnnotations(newAnnotations.ToArrayAndFree()));
            }
            finally
            {
                removalAnnotations.Free();
            }
        }