private bool CleanupWholeNode(List <ValueTuple <SyntaxAnnotation, SyntaxAnnotation> > annotations) { if (annotations.Count != 1) { return(false); } var startMarker = SpanMarker.FromAnnotation(annotations[0].Item1); var endMarker = SpanMarker.FromAnnotation(annotations[0].Item2); return(startMarker.Type == SpanMarkerType.BeginningOfFile && endMarker.Type == SpanMarkerType.EndOfFile); }
private IEnumerable <TextSpan> GetTextSpansFromAnnotation(SyntaxNode node, List <ValueTuple <SyntaxAnnotation, SyntaxAnnotation> > annotations, CancellationToken cancellationToken) { // Now try to retrieve the text span from the annotations injected into the node. foreach (var annotationPair in annotations) { cancellationToken.ThrowIfCancellationRequested(); var previousMarkerAnnotation = annotationPair.Item1; var nextMarkerAnnotation = annotationPair.Item2; var previousTokenMarker = SpanMarker.FromAnnotation(previousMarkerAnnotation); var nextTokenMarker = SpanMarker.FromAnnotation(nextMarkerAnnotation); var previousTokens = node.GetAnnotatedNodesAndTokens(previousMarkerAnnotation).Where(n => n.IsToken).Select(n => n.AsToken()); var nextTokens = node.GetAnnotatedNodesAndTokens(nextMarkerAnnotation).Where(n => n.IsToken).Select(n => n.AsToken()); // Check whether we can use the tokens we got back from the node. TextSpan span; if (TryGetTextSpanFromAnnotation(previousTokenMarker, nextTokenMarker, node, previousTokens, nextTokens, out span)) { yield return(span); } } }