Skip to content

Commit

Permalink
Buildable solution
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Feb 22, 2024
1 parent 927a802 commit 84ff2d5
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 26 deletions.
4 changes: 2 additions & 2 deletions ReSharper.FSharp/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
<PsiFeaturesTestSubplatform>$(Subplatform).Psi.Features_test_Framework.Props</PsiFeaturesTestSubplatform>
<RdBackendCommonSubplatform>$(Subplatform).Rider_RdBackend.Common.Props</RdBackendCommonSubplatform>
<RiderBackendSubplatform>$(Subplatform).Rider_Rider.Backend.Props</RiderBackendSubplatform>
<UseLocalFSharpCompilerService>true</UseLocalFSharpCompilerService>
<LocalFCSProject>$(MSBuildThisFileDirectory)../../fsharp/src/Compiler/FSharp.Compiler.Service.fsproj</LocalFCSProject>
<UseLocalFSharpCompilerService>true</UseLocalFSharpCompilerService>
<LocalFCSProject>$(MSBuildThisFileDirectory)../../fsharp/src/Compiler/FSharp.Compiler.Service.fsproj</LocalFCSProject>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion ReSharper.FSharp/TypeProviders.Host.targets
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<ItemGroup>
<PackageReference Include="FSharp.Core" />
<PackageReference Include="JetBrains.FSharp.Compiler.Service" />
<PackageReference Condition="'$(UseLocalFSharpCompilerService)' == 'false'" Include="JetBrains.FSharp.Compiler.Service" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<ItemGroup>
<PackageReference Include="FSharp.Core" />
<PackageReference Include="JetBrains.Annotations" />

<PackageReference Include="JetBrains.Lifetimes" />
<PackageReference Include="JetBrains.RdFramework" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ type FcsCheckerService(lifetime: Lifetime, logger: ILogger, onSolutionCloseNotif
new PinTypeCheckResultsCookie(sourceFile, parseAndCheckResults.ParseResults, parseAndCheckResults.CheckResults, prohibitTypeCheck) :> IDisposable
| _ -> { new IDisposable with member this.Dispose() = () }

member x.TryGetStaleCheckResults([<NotNull>] file: IPsiSourceFile, opName) =
member x.TryGetStaleCheckResults([<NotNull>] file: IPsiSourceFile, opName) : FSharpCheckFileResults option =
match x.FcsProjectProvider.GetProjectSnapshot(file) with
| None -> None
| Some snapshot ->
Expand All @@ -210,7 +210,8 @@ type FcsCheckerService(lifetime: Lifetime, logger: ILogger, onSolutionCloseNotif
logger.Trace("TryGetStaleCheckResults: start {0}, {1}", path, opName)

// TODO: TryGetRecentCheckResultsForFile for Snapshot
Unchecked.defaultof<FSharpProjectSnapshot option>
// https://github.com/dotnet/fsharp/pull/16720
None
// match x.Checker.TryGetRecentCheckResultsForFile(path, snapshot) with
// | Some (_, checkResults, _) ->
// logger.Trace("TryGetStaleCheckResults: finish {0}, {1}", path, opName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ type FcsProjectProvider(lifetime: Lifetime, solution: ISolution, changeManager:
dirtyProjects.Clear()

interface IFcsProjectProvider with
member x.GetProjectOptions(sourceFile: IPsiSourceFile) =
member x.GetProjectSnapshot(sourceFile: IPsiSourceFile) =
locks.AssertReadAccessAllowed()
processInvalidatedFcsProjects ()

Expand All @@ -531,7 +531,7 @@ type FcsProjectProvider(lifetime: Lifetime, solution: ISolution, changeManager:
| Some fcsProject when fcsProject.IsKnownFile(sourceFile) -> Some fcsProject.ProjectSnapshot
| _ -> None

member x.GetProjectOptions(psiModule: IPsiModule) =
member x.GetProjectSnapshot(psiModule: IPsiModule) =
locks.AssertReadAccessAllowed()
processInvalidatedFcsProjects ()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace rec JetBrains.ReSharper.Plugins.FSharp.Psi.Daemon.Stages

#nowarn "57"

open System.Collections.Generic
open JetBrains.Application
open JetBrains.ReSharper.Daemon.Stages
Expand Down Expand Up @@ -51,7 +53,7 @@ type ScriptLoadPathsStageProcess(fsFile, daemonProcess) =
fsFile.Accept(visitor)
if allDirectives.IsEmpty() then () else

match fsFile.CheckerService.FcsProjectProvider.GetProjectOptions(daemonProcess.SourceFile) with
match fsFile.CheckerService.FcsProjectProvider.GetProjectSnapshot(daemonProcess.SourceFile) with
| Some options when not options.OriginalLoadReferences.IsEmpty ->
let document = daemonProcess.Document
let linesCount = document.GetLineCount() |> int
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace rec JetBrains.ReSharper.Plugins.FSharp.Psi.Features.Searching

#nowarn "57"

open JetBrains.DataFlow
open JetBrains.ReSharper.Plugins.FSharp.Psi.Tree
open JetBrains.ReSharper.Plugins.FSharp.Util
Expand Down Expand Up @@ -48,9 +50,9 @@ type FSharpPathReference(owner, sourceFile) =
let fsFile = owner.GetContainingFile() :?> IFSharpFile
let document = sourceFile.Document
let tokenStartOffset = owner.Parent.GetTreeStartOffset()
fsFile.CheckerService.FcsProjectProvider.GetProjectOptions(sourceFile)
|> Option.bind (fun options ->
options.OriginalLoadReferences
fsFile.CheckerService.FcsProjectProvider.GetProjectSnapshot(sourceFile)
|> Option.bind (fun snapshot ->
snapshot.OriginalLoadReferences
|> List.tryFind (fun (range, _, _) -> getTreeStartOffset document range = tokenStartOffset)
|> Option.bind (fun (_, _, path) ->
let path = VirtualFileSystemPath.TryParse(path, InteractionContext.SolutionContext)
Expand Down
12 changes: 7 additions & 5 deletions ReSharper.FSharp/src/FSharp/FSharp.Tests.Host/FSharpTestHost.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace JetBrains.ReSharper.Plugins.FSharp.Tests.Host

#nowarn "57"

open System.Collections.Generic
open System.Globalization
open System.Linq
Expand Down Expand Up @@ -55,10 +57,10 @@ type FSharpTestHost(solution: ISolution, sourceCache: FSharpSourceCache, itemsCo
projectProvider.GetProjectSnapshot(sourceFile)
|> Option.map (fun options ->
options.OtherOptions
|> Array.choose (fun o -> if o.StartsWith("-r:") then Some (o.Substring("-r:".Length)) else None)
|> Array.map (fun p -> VirtualFileSystemPath.TryParse(p, InteractionContext.SolutionContext))
|> Array.filter (fun p -> not p.IsEmpty && directory.IsPrefixOf(p))
|> Array.map (fun p -> p.Name)
|> List.choose (fun o -> if o.StartsWith("-r:") then Some (o.Substring("-r:".Length)) else None)
|> List.map (fun p -> VirtualFileSystemPath.TryParse(p, InteractionContext.SolutionContext))
|> List.filter (fun p -> not p.IsEmpty && directory.IsPrefixOf(p))
|> List.map (fun p -> p.Name)
|> List)
|> Option.defaultWith (fun _ -> List())

Expand All @@ -76,7 +78,7 @@ type FSharpTestHost(solution: ISolution, sourceCache: FSharpSourceCache, itemsCo
let dumpFcsProjectReferences (projectModelId: int) =
let projectOptions = getProjectOptions projectModelId
projectOptions.ReferencedProjects
|> Array.map (fun project ->
|> List.map (fun project ->
let outputPath = VirtualFileSystemPath.Parse(project.OutputFile, InteractionContext.SolutionContext)
outputPath.NameWithoutExtension)
|> List
Expand Down
20 changes: 11 additions & 9 deletions ReSharper.FSharp/test/src/FSharp.Tests.Common/src/Common.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace JetBrains.ReSharper.Plugins.FSharp.Tests

#nowarn "57"

open System
open System.Collections.Generic
open System.IO
Expand Down Expand Up @@ -236,11 +238,11 @@ type TestFcsProjectProvider(lifetime: Lifetime, checkerService: FcsCheckerServic
// todo: referenced projects
// todo: unify with FcsProjectProvider check
let areSameForChecking (newProject: FcsProject) (oldProject: FcsProject) =
let getReferencedProjectOutputs (options: FSharpProjectOptions) =
options.ReferencedProjects |> Array.map (fun project -> project.OutputFile)
let getReferencedProjectOutputs (options: FSharpProjectSnapshot) =
options.ReferencedProjects |> List.map (fun project -> project.OutputFile)

let newOptions = newProject.ProjectOptions
let oldOptions = oldProject.ProjectOptions
let newOptions = newProject.ProjectSnapshot
let oldOptions = oldProject.ProjectSnapshot

newOptions.ProjectFileName = oldOptions.ProjectFileName &&
newOptions.SourceFiles = oldOptions.SourceFiles &&
Expand All @@ -258,9 +260,9 @@ type TestFcsProjectProvider(lifetime: Lifetime, checkerService: FcsCheckerServic
newFcsProject
)

let getProjectOptions (sourceFile: IPsiSourceFile) =
let getProjectSnapshot (sourceFile: IPsiSourceFile) =
let fcsProject = getFcsProject sourceFile.PsiModule
Some fcsProject.ProjectOptions
Some fcsProject.ProjectSnapshot

interface IHideImplementation<FcsProjectProvider>

Expand All @@ -269,11 +271,11 @@ type TestFcsProjectProvider(lifetime: Lifetime, checkerService: FcsCheckerServic
let fcsProject = getFcsProject sourceFile.PsiModule
fcsProject.ImplementationFilesWithSignatures.Contains(sourceFile.GetLocation())

member x.GetProjectOptions(sourceFile: IPsiSourceFile) =
member x.GetProjectSnapshot(sourceFile: IPsiSourceFile) =
if sourceFile.LanguageType.Is<FSharpScriptProjectFileType>() then
scriptFcsProjectProvider.GetScriptSnapshot(sourceFile) else

getProjectOptions sourceFile
getProjectSnapshot sourceFile

member x.GetParsingOptions(sourceFile) =
if isNull sourceFile then sandboxParsingOptions else
Expand Down Expand Up @@ -328,7 +330,7 @@ type TestFcsProjectProvider(lifetime: Lifetime, checkerService: FcsCheckerServic
member x.HasFcsProjects = false
member this.GetAllFcsProjects() = []

member this.GetProjectOptions(_: IPsiModule): FSharpProjectOptions option = failwith "todo"
member this.GetProjectSnapshot(_: IPsiModule): FSharpProjectSnapshot option = failwith "todo"
member this.GetFcsProject(psiModule) = Some (getFcsProject psiModule)
member this.PrepareAssemblyShim _ = ()
member this.GetReferencedModule _ = None
Expand Down

0 comments on commit 84ff2d5

Please sign in to comment.