private static void AddNonIncluded(ArrayBuilder <string> builder, string item) { if (!builder.Contains(item)) { builder.Add(item); } }
private void RegisterOutput(IIncrementalGeneratorOutputNode outputNode) { if (!_outputNodes.Contains(outputNode)) { _outputNodes.Add(outputNode); } }
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())); } }
private void RegisterOutputAndDeferredInput(SyntaxInputNode node, IIncrementalGeneratorOutputNode output) { _registerOutput(output); if (!_inputNodes.Contains(node)) { _inputNodes.Add(node); } }
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(); } }