protected override Task <ImmutableArray <Document> > DetermineDocumentsToSearchAsync( IMethodSymbol symbol, Project project, IImmutableSet <Document>?documents, FindReferencesSearchOptions options, CancellationToken cancellationToken) { return(FindDocumentsAsync(project, documents, async(d, c) => { var index = await SyntaxTreeIndex.GetIndexAsync(d, c).ConfigureAwait(false); if (index.ContainsBaseConstructorInitializer) { return true; } if (index.ProbablyContainsIdentifier(symbol.ContainingType.Name)) { if (index.ContainsThisConstructorInitializer) { return true; } else if (project.Language == LanguageNames.VisualBasic && index.ProbablyContainsIdentifier("New")) { // "New" can be explicitly accessed in xml doc comments to reference a constructor. return true; } } return false; }, cancellationToken)); }
protected override Task <ImmutableArray <Document> > DetermineDocumentsToSearchAsync( IMethodSymbol symbol, Project project, IImmutableSet <Document> documents, FindReferencesSearchOptions options, CancellationToken cancellationToken) { return(FindDocumentsAsync(project, documents, async(d, c) => { var index = await SyntaxTreeIndex.GetIndexAsync(d, c).ConfigureAwait(false); if (index.ContainsBaseConstructorInitializer) { return true; } if (index.ProbablyContainsIdentifier(symbol.ContainingType.Name)) { if (index.ContainsThisConstructorInitializer) { return true; } } return false; }, cancellationToken)); }
public static async ValueTask <SyntaxTreeIndex> GetSyntaxTreeIndexAsync(this Document document, CancellationToken cancellationToken) { var result = await SyntaxTreeIndex.GetIndexAsync(document, loadOnly : false, cancellationToken).ConfigureAwait(false); Contract.ThrowIfNull(result); return(result); }
private Task <ImmutableArray <Document> > FindDocumentWithElementAccessExpressionsAsync( Project project, IImmutableSet <Document> documents, CancellationToken cancellationToken) { return(FindDocumentsAsync(project, documents, async(d, c) => { var info = await SyntaxTreeIndex.GetIndexAsync(d, c).ConfigureAwait(false); return info.ContainsElementAccessExpression; }, cancellationToken)); }
protected Task <ImmutableArray <Document> > FindDocumentsAsync( Project project, IImmutableSet <Document> documents, PredefinedType predefinedType, CancellationToken cancellationToken) { return(FindDocumentsAsync(project, documents, async(d, c) => { var info = await SyntaxTreeIndex.GetIndexAsync(d, c).ConfigureAwait(false); return info.ContainsPredefinedType(predefinedType); }, cancellationToken)); }
/// <summary> /// Finds all the documents in the provided project that contain the requested string /// values /// </summary> protected Task <ImmutableArray <Document> > FindDocumentsAsync(Project project, IImmutableSet <Document> documents, CancellationToken cancellationToken, params string[] values) { return(FindDocumentsAsync(project, documents, async(d, c) => { var info = await SyntaxTreeIndex.GetIndexAsync(d, c).ConfigureAwait(false); foreach (var value in values) { if (!info.ProbablyContainsIdentifier(value)) { return false; } } return true; }, cancellationToken)); }
protected Task <ImmutableArray <Document> > FindDocumentsAsync( Project project, IImmutableSet <Document> documents, PredefinedOperator op, CancellationToken cancellationToken) { if (op == PredefinedOperator.None) { return(SpecializedTasks.EmptyImmutableArray <Document>()); } return(FindDocumentsAsync(project, documents, async(d, c) => { var info = await SyntaxTreeIndex.GetIndexAsync(d, c).ConfigureAwait(false); return info.ContainsPredefinedOperator(op); }, cancellationToken)); }
private async Task AddDocumentsWithPotentialConflicts(IEnumerable <Document> documents) { try { foreach (var document in documents) { if (_documentsIdsToBeCheckedForConflict.Contains(document.Id)) { continue; } var info = await SyntaxTreeIndex.GetIndexAsync(document, CancellationToken.None).ConfigureAwait(false); if (info.ProbablyContainsEscapedIdentifier(_originalText)) { _documentsIdsToBeCheckedForConflict.Add(document.Id); continue; } if (info.ProbablyContainsIdentifier(_replacementText)) { _documentsIdsToBeCheckedForConflict.Add(document.Id); continue; } foreach (var replacementName in _possibleNameConflicts) { if (info.ProbablyContainsIdentifier(replacementName)) { _documentsIdsToBeCheckedForConflict.Add(document.Id); break; } } } } catch (Exception e) when(FatalError.ReportUnlessCanceled(e)) { throw ExceptionUtilities.Unreachable; } }
public static Task <SyntaxTreeIndex> GetSyntaxTreeIndexAsync(this Document document, bool loadOnly, CancellationToken cancellationToken) => SyntaxTreeIndex.GetIndexAsync(document, loadOnly, cancellationToken);
public static ValueTask <SyntaxTreeIndex> GetSyntaxTreeIndexAsync(this Document document, CancellationToken cancellationToken) => SyntaxTreeIndex.GetIndexAsync(document, loadOnly: false, cancellationToken);