-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add options to enable/disable nuget search. #11023
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
8d5c08d
Remove option we aren't using.
CyrusNajmabadi a7a631f
Add UI options for configuring 'add using'
CyrusNajmabadi f39fd52
Update strings.
CyrusNajmabadi fd19f45
The option is not per language.
CyrusNajmabadi 5de5408
Merge the two symbol search APIs into one.
CyrusNajmabadi 968a975
Option serialization work.
CyrusNajmabadi f14aa61
Properly persist options.
CyrusNajmabadi 6f66b48
Rename group.
CyrusNajmabadi 9993a3d
Expose optoins for VS as well.
CyrusNajmabadi 87d43bd
Make the nuget options into per-language options.
CyrusNajmabadi 1132292
Update tests.
CyrusNajmabadi 41a326f
Rename type.
CyrusNajmabadi 70429d6
Rename files.
CyrusNajmabadi f58bc96
Move files to new folder.
CyrusNajmabadi 2d4291f
Move file.
CyrusNajmabadi c10a2d7
Move SymbolSearch into its own namespace.
CyrusNajmabadi 0ce9b17
Move files.
CyrusNajmabadi 19e6663
Rename types.
CyrusNajmabadi 3607ad9
Move types to SymbolSearch.
CyrusNajmabadi b8c6ae3
Move test code.
CyrusNajmabadi d03df21
Update type name.
CyrusNajmabadi f99d4e3
Update option name.
CyrusNajmabadi 0b8fe75
Fix accelerators.
CyrusNajmabadi 110bc76
Update accelerators.
CyrusNajmabadi 2f00943
Sort usings.
CyrusNajmabadi c5de602
Merge branch 'master' into usingOptions
CyrusNajmabadi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Collections.Concurrent; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
@@ -9,6 +8,8 @@ | |
using Microsoft.CodeAnalysis.LanguageServices; | ||
using Microsoft.CodeAnalysis.Packaging; | ||
using Microsoft.CodeAnalysis.Shared.Extensions; | ||
using Microsoft.CodeAnalysis.Shared.Options; | ||
using Microsoft.CodeAnalysis.SymbolSearch; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sort usings There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
using Roslyn.Utilities; | ||
|
||
namespace Microsoft.CodeAnalysis.CodeFixes.AddImport | ||
|
@@ -232,32 +233,41 @@ private async Task<IList<SymbolReference>> GetMatchingTypesAsync(SearchScope sea | |
{ | ||
var workspaceServices = _document.Project.Solution.Workspace.Services; | ||
|
||
var packageSearchService = _owner._packageSearchService ?? workspaceServices.GetService<IPackageSearchService>(); | ||
var referenceAssemblySearchService = _owner._referenceAssemblySearchService ?? workspaceServices.GetService<IReferenceAssemblySearchService>(); | ||
var symbolSearchService = _owner._symbolSearchService ?? workspaceServices.GetService<ISymbolSearchService>(); | ||
var installerService = _owner._packageInstallerService ?? workspaceServices.GetService<IPackageInstallerService>(); | ||
|
||
if (referenceAssemblySearchService != null) | ||
var language = _document.Project.Language; | ||
|
||
var options = workspaceServices.Workspace.Options; | ||
var searchReferenceAssemblies = options.GetOption( | ||
AddImportOptions.SuggestForTypesInReferenceAssemblies, language); | ||
var searchNugetPackages = options.GetOption( | ||
AddImportOptions.SuggestForTypesInNuGetPackages, language); | ||
|
||
if (symbolSearchService != null && | ||
searchReferenceAssemblies) | ||
{ | ||
cancellationToken.ThrowIfCancellationRequested(); | ||
await FindReferenceAssemblyTypeReferencesAsync( | ||
referenceAssemblySearchService, allReferences, nameNode, name, arity, isAttributeSearch, cancellationToken).ConfigureAwait(false); | ||
symbolSearchService, allReferences, nameNode, name, arity, isAttributeSearch, cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
if (packageSearchService != null && | ||
if (symbolSearchService != null && | ||
searchNugetPackages && | ||
installerService.IsEnabled) | ||
{ | ||
foreach (var packageSource in installerService.PackageSources) | ||
{ | ||
cancellationToken.ThrowIfCancellationRequested(); | ||
await FindNugetTypeReferencesAsync( | ||
packageSource, packageSearchService, installerService, allReferences, | ||
packageSource, symbolSearchService, installerService, allReferences, | ||
nameNode, name, arity, isAttributeSearch, cancellationToken).ConfigureAwait(false); | ||
} | ||
} | ||
} | ||
|
||
private async Task FindReferenceAssemblyTypeReferencesAsync( | ||
IReferenceAssemblySearchService searchService, | ||
ISymbolSearchService searchService, | ||
List<Reference> allReferences, | ||
TSimpleNameSyntax nameNode, | ||
string name, | ||
|
@@ -283,7 +293,7 @@ private async Task<IList<SymbolReference>> GetMatchingTypesAsync(SearchScope sea | |
|
||
private async Task FindNugetTypeReferencesAsync( | ||
PackageSource source, | ||
IPackageSearchService searchService, | ||
ISymbolSearchService searchService, | ||
IPackageInstallerService installerService, | ||
List<Reference> allReferences, | ||
TSimpleNameSyntax nameNode, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Types moved out of the packaging namespace into this new namespace.