Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<Compile Include="LanguageService\ProvideFSharpVersionRegistrationAttribute.fs" />
<Compile Include="LanguageService\MetadataAsSource.fs" />
<Compile Include="LanguageService\FSharpProjectOptionsManager.fs" />
<Compile Include="LanguageService\IFSharpWorkspaceService.fs" />
<Compile Include="LanguageService\SingleFileWorkspaceMap.fs" />
<Compile Include="LanguageService\LegacyProjectWorkspaceMap.fs" />
<Compile Include="LanguageService\FSharpAnalysisSaveFileCommandHandler.fs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,14 @@ type private FSharpProjectOptionsReactor (checker: FSharpChecker) =
let legacyProjectSites = ConcurrentDictionary<ProjectId, IProjectSite>()

let cache = ConcurrentDictionary<ProjectId, Project * FSharpParsingOptions * FSharpProjectOptions>()
let singleFileCache = ConcurrentDictionary<DocumentId, VersionStamp * FSharpParsingOptions * FSharpProjectOptions>()
let singleFileCache = ConcurrentDictionary<DocumentId, Project * VersionStamp * FSharpParsingOptions * FSharpProjectOptions>()

// This is used to not constantly emit the same compilation.
let weakPEReferences = ConditionalWeakTable<Compilation, FSharpReferencedProject>()
let lastSuccessfulCompilations = ConcurrentDictionary<ProjectId, Compilation>()

let scriptUpdatedEvent = Event<FSharpProjectOptions>()

let createPEReference (referencedProject: Project) (comp: Compilation) =
let projectId = referencedProject.Id

Expand Down Expand Up @@ -185,6 +187,7 @@ type private FSharpProjectOptionsReactor (checker: FSharpChecker) =

let projectOptions =
if isScriptFile document.FilePath then
scriptUpdatedEvent.Trigger(scriptProjectOptions)
scriptProjectOptions
else
{
Expand All @@ -203,12 +206,12 @@ type private FSharpProjectOptionsReactor (checker: FSharpChecker) =

let parsingOptions, _ = checker.GetParsingOptionsFromProjectOptions(projectOptions)

singleFileCache.[document.Id] <- (fileStamp, parsingOptions, projectOptions)
singleFileCache.[document.Id] <- (document.Project, fileStamp, parsingOptions, projectOptions)

return Some(parsingOptions, projectOptions)

| true, (fileStamp2, parsingOptions, projectOptions) ->
if fileStamp <> fileStamp2 then
| true, (oldProject, oldFileStamp, parsingOptions, projectOptions) ->
if fileStamp <> oldFileStamp || isProjectInvalidated document.Project oldProject ct then
singleFileCache.TryRemove(document.Id) |> ignore
return! tryComputeOptionsBySingleScriptOrFile document ct userOpName
else
Expand Down Expand Up @@ -399,7 +402,7 @@ type private FSharpProjectOptionsReactor (checker: FSharpChecker) =
legacyProjectSites.TryRemove(projectId) |> ignore
| FSharpProjectOptionsMessage.ClearSingleFileOptionsCache(documentId) ->
match singleFileCache.TryRemove(documentId) with
| true, (_, _, projectOptions) ->
| true, (_, _, _, projectOptions) ->
lastSuccessfulCompilations.TryRemove(documentId.ProjectId) |> ignore
checker.ClearCache([projectOptions])
| _ ->
Expand Down Expand Up @@ -438,6 +441,8 @@ type private FSharpProjectOptionsReactor (checker: FSharpChecker) =
singleFileCache.Clear()
lastSuccessfulCompilations.Clear()

member _.ScriptUpdated = scriptUpdatedEvent.Publish

interface IDisposable with
member _.Dispose() =
cancellationTokenSource.Cancel()
Expand Down Expand Up @@ -468,6 +473,8 @@ type internal FSharpProjectOptionsManager
reactor.ClearSingleFileOptionsCache(doc.Id)
)

member _.ScriptUpdated = reactor.ScriptUpdated

member _.SetLegacyProjectSite (projectId, projectSite) =
reactor.SetLegacyProjectSite (projectId, projectSite)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

namespace Microsoft.VisualStudio.FSharp.Editor

open FSharp.Compiler.CodeAnalysis
open Microsoft.VisualStudio.FSharp.Editor
open Microsoft.CodeAnalysis.Host

// Used to expose FSharpChecker/ProjectInfo manager to diagnostic providers
// Diagnostic providers can be executed in environment that does not use MEF so they can rely only
// on services exposed by the workspace
type internal IFSharpWorkspaceService =
inherit IWorkspaceService
abstract Checker: FSharpChecker
abstract FSharpProjectOptionsManager: FSharpProjectOptionsManager
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@ open Microsoft.CodeAnalysis.Host.Mef

#nowarn "9" // NativePtr.toNativeInt

// Used to expose FSharpChecker/ProjectInfo manager to diagnostic providers
// Diagnostic providers can be executed in environment that does not use MEF so they can rely only
// on services exposed by the workspace
type internal IFSharpWorkspaceService =
inherit IWorkspaceService
abstract Checker: FSharpChecker
abstract FSharpProjectOptionsManager: FSharpProjectOptionsManager

type internal RoamingProfileStorageLocation(keyName: string) =
inherit OptionStorageLocation()

Expand Down Expand Up @@ -269,10 +261,11 @@ type internal FSharpPackage() as this =
let miscFilesWorkspace = this.ComponentModel.GetService<MiscellaneousFilesWorkspace>()
let _singleFileWorkspaceMap =
new SingleFileWorkspaceMap(
workspace,
miscFilesWorkspace,
optionsManager,
projectContextFactory,
FSharpMiscellaneousFileService(
workspace,
miscFilesWorkspace,
FSharpWorkspaceProjectContextFactory(projectContextFactory)
),
rdt)
let _legacyProjectWorkspaceMap = new LegacyProjectWorkspaceMap(solution, optionsManager, projectContextFactory)
()
Expand Down
Loading