public DeclaredSymbolNavigableItem(Document document, DeclaredSymbolInfo declaredSymbolInfo) { Document = document; _declaredSymbolInfo = declaredSymbolInfo; // Cancellation isn't supported when computing the various properties that depend on the symbol, hence // CancellationToken.None. _lazySymbol = new Lazy <ISymbol>(() => declaredSymbolInfo.GetSymbolAsync(document, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult()); _lazyDisplayString = new Lazy <string>(() => { try { if (Symbol == null) { return(null); } return(GetSymbolDisplayString(Document.Project, Symbol)); } catch (Exception e) when(FatalError.Report(e)) { throw ExceptionUtilities.Unreachable; } }); }
public DeclaredSymbolNavigableItem(Document document, DeclaredSymbolInfo declaredSymbolInfo, CancellationToken cancellationToken) { Document = document; _declaredSymbolInfo = declaredSymbolInfo; _lazySymbol = new Lazy <ISymbol>(() => declaredSymbolInfo.GetSymbolAsync(document, cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult()); _lazyDisplayName = new Lazy <string>(() => { if (Symbol == null) { return(null); } var symbolDisplayService = Document.GetLanguageService <ISymbolDisplayService>(); switch (Symbol.Kind) { case SymbolKind.NamedType: return(symbolDisplayService.ToDisplayString(Symbol, s_shortFormatWithModifiers)); case SymbolKind.Method: return(Symbol.IsStaticConstructor() ? symbolDisplayService.ToDisplayString(Symbol, s_shortFormatWithModifiers) : symbolDisplayService.ToDisplayString(Symbol, s_shortFormat)); default: return(symbolDisplayService.ToDisplayString(Symbol, s_shortFormat)); } }); }
public DeclaredSymbolNavigableItem(Document document, DeclaredSymbolInfo declaredSymbolInfo) { Document = document; _declaredSymbolInfo = declaredSymbolInfo; // Cancellation isn't supported when computing the various properties that depend on the symbol, hence // CancellationToken.None. _lazySymbol = new Lazy <ISymbol>(() => declaredSymbolInfo.GetSymbolAsync(document, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult()); _lazyDisplayName = new Lazy <string>(() => { try { if (Symbol == null) { return(null); } var symbolDisplayService = Document.GetLanguageService <ISymbolDisplayService>(); switch (Symbol.Kind) { case SymbolKind.NamedType: return(symbolDisplayService.ToDisplayString(Symbol, s_shortFormatWithModifiers)); case SymbolKind.Method: return(Symbol.IsStaticConstructor() ? symbolDisplayService.ToDisplayString(Symbol, s_shortFormatWithModifiers) : symbolDisplayService.ToDisplayString(Symbol, s_shortFormat)); default: return(symbolDisplayService.ToDisplayString(Symbol, s_shortFormat)); } } catch (Exception e) when(FatalError.Report(e)) { throw ExceptionUtilities.Unreachable; } }); }