internal static async Task FindLiteralReferencesAsync( object value, TypeCode typeCode, Solution solution, IStreamingFindLiteralReferencesProgress progress, CancellationToken cancellationToken) { using (Logger.LogBlock(FunctionId.FindReference, cancellationToken)) { var client = await RemoteHostClient.TryGetClientAsync(solution.Workspace, cancellationToken).ConfigureAwait(false); if (client != null) { // Create a callback that we can pass to the server process to hear about the // results as it finds them. When we hear about results we'll forward them to // the 'progress' parameter which will then update the UI. var serverCallback = new FindLiteralsServerCallback(solution, progress); _ = await client.TryInvokeAsync <IRemoteSymbolFinderService>( solution, (service, solutionInfo, callbackId, cancellationToken) => service.FindLiteralReferencesAsync(solutionInfo, callbackId, value, typeCode, cancellationToken), serverCallback, cancellationToken).ConfigureAwait(false); } else { await FindLiteralReferencesInCurrentProcessAsync(value, solution, progress, cancellationToken).ConfigureAwait(false); } } }
public FindLiteralsServerCallback( Solution solution, IStreamingFindLiteralReferencesProgress progress) { _solution = solution; _progress = progress; }
private static async Task <bool> TryFindLiteralReferencesInServiceProcessAsync( object value, Solution solution, IStreamingFindLiteralReferencesProgress progress, CancellationToken cancellationToken) { var client = await solution.Workspace.GetRemoteHostClientAsync(cancellationToken).ConfigureAwait(false); if (client == null) { return(false); } // Create a callback that we can pass to the server process to hear about the // results as it finds them. When we hear about results we'll forward them to // the 'progress' parameter which will then update the UI. var serverCallback = new FindLiteralsServerCallback(solution, progress, cancellationToken); using (var session = await client.TryCreateCodeAnalysisServiceSessionAsync( solution, serverCallback, cancellationToken).ConfigureAwait(false)) { if (session == null) { return(false); } await session.InvokeAsync( nameof(IRemoteSymbolFinder.FindLiteralReferencesAsync), value).ConfigureAwait(false); } return(true); }
internal static async Task FindLiteralReferencesAsync( object value, TypeCode typeCode, Solution solution, IStreamingFindLiteralReferencesProgress progress, CancellationToken cancellationToken) { using (Logger.LogBlock(FunctionId.FindReference, cancellationToken)) { var client = await RemoteHostClient.TryGetClientAsync(solution.Workspace, cancellationToken).ConfigureAwait(false); if (client != null) { // Create a callback that we can pass to the server process to hear about the // results as it finds them. When we hear about results we'll forward them to // the 'progress' parameter which will then update the UI. var serverCallback = new FindLiteralsServerCallback(solution, progress, cancellationToken); var success = await client.TryRunRemoteAsync( WellKnownServiceHubServices.CodeAnalysisService, nameof(IRemoteSymbolFinder.FindLiteralReferencesAsync), new object[] { value, typeCode }, solution, serverCallback, cancellationToken).ConfigureAwait(false); if (success) { return; } } await FindLiteralReferencesInCurrentProcessAsync(value, solution, progress, cancellationToken).ConfigureAwait(false); } }
public FindLiteralsServerCallback( Solution solution, IStreamingFindLiteralReferencesProgress progress, CancellationToken cancellationToken) { _solution = solution; _progress = progress; _cancellationToken = cancellationToken; }
internal static Task FindLiteralReferencesInCurrentProcessAsync( object value, Solution solution, IStreamingFindLiteralReferencesProgress progress, CancellationToken cancellationToken) { var engine = new FindLiteralsSearchEngine(solution, progress, value); return(engine.FindReferencesAsync(cancellationToken)); }
private static async Task FindLiteralReferencesInServiceProcessOrFallBackToLocalProcessAsync( object value, Solution solution, IStreamingFindLiteralReferencesProgress progress, CancellationToken cancellationToken) { var handled = await TryFindLiteralReferencesInServiceProcessAsync( value, solution, progress, cancellationToken).ConfigureAwait(false); if (handled) { return; } await FindLiteralReferencesInCurrentProcessAsync( value, solution, progress, cancellationToken).ConfigureAwait(false); }
public FindLiteralsSearchEngine( Solution solution, IStreamingFindLiteralReferencesProgress progress, object value, CancellationToken cancellationToken ) { _solution = solution; _progress = progress; _progressTracker = progress.ProgressTracker; _value = value; _cancellationToken = cancellationToken; switch (value) { case string s: _stringValue = s; _searchKind = SearchKind.StringLiterals; break; case double d: _longValue = BitConverter.DoubleToInt64Bits(d); _searchKind = SearchKind.NumericLiterals; break; case float f: _longValue = BitConverter.DoubleToInt64Bits(f); _searchKind = SearchKind.NumericLiterals; break; case decimal _: // unsupported _searchKind = SearchKind.None; break; case char _: _longValue = IntegerUtilities.ToInt64(value); _searchKind = SearchKind.CharacterLiterals; break; default: _longValue = IntegerUtilities.ToInt64(value); _searchKind = SearchKind.NumericLiterals; break; } }
private static async Task <bool> TryFindLiteralReferencesInServiceProcessAsync( object value, TypeCode typeCode, Solution solution, IStreamingFindLiteralReferencesProgress progress, CancellationToken cancellationToken) { // Create a callback that we can pass to the server process to hear about the // results as it finds them. When we hear about results we'll forward them to // the 'progress' parameter which will then update the UI. var serverCallback = new FindLiteralsServerCallback(solution, progress, cancellationToken); return(await solution.TryRunCodeAnalysisRemoteAsync( serverCallback, nameof(IRemoteSymbolFinder.FindLiteralReferencesAsync), new object[] { value, typeCode }, cancellationToken).ConfigureAwait(false)); }
internal static async Task FindLiteralReferencesAsync( object value, Solution solution, IStreamingFindLiteralReferencesProgress progress, CancellationToken cancellationToken) { using (Logger.LogBlock(FunctionId.FindReference, cancellationToken)) { var handled = await TryFindLiteralReferencesInServiceProcessAsync( value, solution, progress, cancellationToken).ConfigureAwait(false); if (handled) { return; } await FindLiteralReferencesInCurrentProcessAsync( value, solution, progress, cancellationToken).ConfigureAwait(false); } }
internal static async Task FindLiteralReferencesAsync( object value, Solution solution, IStreamingFindLiteralReferencesProgress progress, CancellationToken cancellationToken) { using (Logger.LogBlock(FunctionId.FindReference, cancellationToken)) { var outOfProcessAllowed = solution.Workspace.Options.GetOption(SymbolFinderOptions.OutOfProcessAllowed); if (!outOfProcessAllowed) { // This is a call through our old public API. We don't have the necessary // data to effectively run the call out of proc. await FindLiteralReferencesInCurrentProcessAsync( value, solution, progress, cancellationToken).ConfigureAwait(false); } else { await FindLiteralReferencesInServiceProcessOrFallBackToLocalProcessAsync( value, solution, progress, cancellationToken).ConfigureAwait(false); } } }