public CacheState ManageCache(ref ProviderCache cache, NormalizedSnapshotSpanCollection spans, ITextBuffer buffer) { if (cache != null && cache.Snapshot == spans[0].Snapshot) { return(CacheState.Resolved); } var task = ProviderCache.ResolveAsync(buffer, spans[0].Snapshot); try { // TODO: can we make this async? task.Wait(); } catch (Exception ex) { Log.LogError(ex.ToString()); return(CacheState.NotResolved); } // TODO: can we make this async? cache = task.Result; return(cache == null ? CacheState.NotResolved : CacheState.Resolved); }
internal IEnumerable <ITagSpan <IClassificationTag> > GetClassificationTags(ProviderCache cache, NormalizedSnapshotSpanCollection spans, Dictionary <string, IClassificationType> classificationTypeDictionary) { var snapshot = spans[0].Snapshot; IEnumerable <ClassifiedSpan> classifiedSpans = GetIdentifiersInSpans(cache.Workspace, cache.SemanticModel, spans); foreach (var classifiedSpan in classifiedSpans) { var node = GetExpression(cache.SyntaxRoot.FindNode(classifiedSpan.TextSpan)); var symbol = cache.SemanticModel.GetSymbolInfo(node).Symbol ?? cache.SemanticModel.GetDeclaredSymbol(node); yield return(GetTagSpan(node, classifiedSpan, snapshot, symbol, classificationTypeDictionary)); } }