forked from dotnet/fsharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from vasily-kirichenko/toupper
Make ProposeUppercaseLabel code fix work on all symbol uses
- Loading branch information
Showing
5 changed files
with
145 additions
and
87 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
namespace Microsoft.VisualStudio.FSharp.Editor | ||
|
||
open System | ||
open System.Collections.Generic | ||
open System.Collections.Immutable | ||
open System.Threading | ||
open System.Threading.Tasks | ||
open System.Runtime.CompilerServices | ||
|
||
open Microsoft.CodeAnalysis | ||
open Microsoft.CodeAnalysis.Classification | ||
open Microsoft.CodeAnalysis.Text | ||
|
||
open Microsoft.VisualStudio.FSharp.LanguageService | ||
open Microsoft.FSharp.Compiler | ||
open Microsoft.FSharp.Compiler.SourceCodeServices | ||
open Microsoft.FSharp.Compiler.SourceCodeServices.ItemDescriptionIcons | ||
|
||
|
||
module internal SymbolHelpers = | ||
let getSymbolUsesInSolution (symbol: FSharpSymbol, declLoc: SymbolDeclarationLocation, checkFileResults: FSharpCheckFileResults, | ||
projectInfoManager: ProjectInfoManager, checker: FSharpChecker, solution: Solution) = | ||
async { | ||
let! symbolUses = | ||
match declLoc with | ||
| SymbolDeclarationLocation.CurrentDocument -> | ||
checkFileResults.GetUsesOfSymbolInFile(symbol) | ||
| SymbolDeclarationLocation.Projects (projects, isInternalToProject) -> | ||
let projects = | ||
if isInternalToProject then projects | ||
else | ||
[ for project in projects do | ||
yield project | ||
yield! project.GetDependentProjects() ] | ||
|> List.distinctBy (fun x -> x.Id) | ||
|
||
projects | ||
|> Seq.map (fun project -> | ||
async { | ||
match projectInfoManager.TryGetOptionsForProject(project.Id) with | ||
| Some options -> | ||
let! projectCheckResults = checker.ParseAndCheckProject(options) | ||
return! projectCheckResults.GetUsesOfSymbol(symbol) | ||
| None -> return [||] | ||
}) | ||
|> Async.Parallel | ||
|> Async.Map Array.concat | ||
|
||
return | ||
(symbolUses | ||
|> Seq.collect (fun symbolUse -> | ||
solution.GetDocumentIdsWithFilePath(symbolUse.FileName) |> Seq.map (fun id -> id, symbolUse)) | ||
|> Seq.groupBy fst | ||
).ToImmutableDictionary( | ||
(fun (id, _) -> id), | ||
fun (_, xs) -> xs |> Seq.map snd |> Seq.toArray) | ||
} | ||
|
||
|
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