public static async Task <IEnumerable <SyntaxToken> > GetConstructorInitializerTokensAsync(this Document document, SemanticModel model, CancellationToken cancellationToken) { var root = await model.SyntaxTree.GetRootAsync(cancellationToken).ConfigureAwait(false); var syntaxFacts = document.GetLanguageService <ISyntaxFactsService>(); if (syntaxFacts == null) { return(SpecializedCollections.EmptyEnumerable <SyntaxToken>()); } return(FindReferenceCache.GetConstructorInitializerTokens(syntaxFacts, model, root, cancellationToken)); }
public static async Task <IEnumerable <SyntaxToken> > GetConstructorInitializerTokensAsync(this Document document, CancellationToken cancellationToken) { // model should exist already if (!document.TryGetSemanticModel(out var model)) { return(Contract.FailWithReturn <IEnumerable <SyntaxToken> >("we should never reach here")); } var root = await model.SyntaxTree.GetRootAsync(cancellationToken).ConfigureAwait(false); var syntaxFacts = document.GetLanguageService <ISyntaxFactsService>(); if (syntaxFacts == null) { return(SpecializedCollections.EmptyEnumerable <SyntaxToken>()); } return(FindReferenceCache.GetConstructorInitializerTokens(syntaxFacts, model, root, cancellationToken)); }