Skip to content
Closed
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
8 changes: 6 additions & 2 deletions src/fsharp/InternalCollections.fs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@ type internal AgedLookup<'Token, 'Key, 'Value when 'Value : not struct>(keepStro
let keep = FilterAndHold(tok)
AssignWithStrength(tok,keep)


member al.Keys(tok) =
FilterAndHold(tok) |> List.map fst



type internal MruCache<'Token, 'Key,'Value when 'Value : not struct>(keepStrongly, areSame, ?isStillValid : 'Key*'Value->bool, ?areSimilar, ?requiredToKeep, ?keepMax) =

Expand Down Expand Up @@ -199,4 +202,5 @@ type internal MruCache<'Token, 'Key,'Value when 'Value : not struct>(keepStrongl

member bc.Resize(tok, newKeepStrongly, ?newKeepMax) =
cache.Resize(tok, newKeepStrongly, ?newKeepMax=newKeepMax)


member bc.Keys(tok) = cache.Keys(tok)
7 changes: 6 additions & 1 deletion src/fsharp/InternalCollections.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ type internal AgedLookup<'Token, 'Key, 'Value when 'Value : not struct> =

/// Resize
member Resize : 'Token * newKeepStrongly: int * ?newKeepMax : int -> unit


/// Keys
member Keys : 'Token -> 'Key list

/// Simple priority caching for a small number of key/value associations.
/// This cache may age-out results that have been Set by the caller.
/// Because of this, the caller must be able to tolerate values
Expand Down Expand Up @@ -84,3 +87,5 @@ type internal MruCache<'Token, 'Key,'Value when 'Value : not struct> =
/// Resize
member Resize : 'Token * newKeepStrongly: int * ?newKeepMax : int -> unit

/// Keys
member Keys : 'Token -> 'Key list
15 changes: 13 additions & 2 deletions src/fsharp/service/service.fs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ type BackgroundCompiler(
let fileChecked = Event<string * FSharpProjectOptions>()
let projectChecked = Event<FSharpProjectOptions>()

let getScriptProjectFileName scriptFileName = scriptFileName + ".fsproj"

// STATIC ROOT: FSharpLanguageServiceTestable.FSharpChecker.backgroundCompiler.scriptClosureCache
/// Information about the derived script closure.
let scriptClosureCache =
Expand Down Expand Up @@ -908,7 +910,7 @@ type BackgroundCompiler(

let options =
{
ProjectFileName = filename + ".fsproj" // Make a name that is unique in this directory.
ProjectFileName = getScriptProjectFileName filename // Make a name that is unique in this directory.
ProjectId = None
SourceFiles = loadClosure.SourceFiles |> List.map fst |> List.toArray
OtherOptions = otherFlags
Expand All @@ -925,7 +927,13 @@ type BackgroundCompiler(
return options, (diags @ errors.Diagnostics)
}
|> Cancellable.toAsync


member _.GetCachedProjectOptions(projectOrScriptFileName, isScript) =
let projectFileName =
if isScript then getScriptProjectFileName projectOrScriptFileName
else projectOrScriptFileName
incrementalBuildersCache.Keys(AnyCallerThread) |> List.filter (fun x -> x.ProjectFileName = projectFileName)

member bc.InvalidateConfiguration(options: FSharpProjectOptions, userOpName) =
if incrementalBuildersCache.ContainsSimilarKey (AnyCallerThread, options) then
let _ = createBuilderNode (options, userOpName, CancellationToken.None)
Expand Down Expand Up @@ -1078,6 +1086,9 @@ type FSharpChecker(legacyReferenceResolver,
let argv = List.ofArray options.OtherOptions
ic.GetParsingOptionsFromCommandLineArgs(sourceFiles, argv, options.UseScriptResolutionRules)

member _.GetCachedProjectOptions(projectOrScriptFileName, isScript) =
backgroundCompiler.GetCachedProjectOptions(projectOrScriptFileName, isScript)

member ic.ParseFile(filename, sourceText, options, ?cache, ?userOpName: string) =
let cache = defaultArg cache true
let userOpName = defaultArg userOpName "Unknown"
Expand Down
6 changes: 6 additions & 0 deletions src/fsharp/service/service.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ type public FSharpChecker =
?userOpName: string
-> Async<FSharpProjectOptions * FSharpDiagnostic list>

/// <summary>Get the list of FSharpProjectOptions for the project/script if they exist in the FCS cache.</summary>
///
/// <param name="projectOrScriptFileName">The project or script filename.</param>
/// <param name="isScript">Is the passed <paramref name="projectOrScriptFileName"/> the path to the script file.</param>
member GetCachedProjectOptions: projectOrScriptFileName: string * isScript: bool -> FSharpProjectOptions list

/// <summary>Get the FSharpProjectOptions implied by a set of command line arguments.</summary>
///
/// <param name="projectFileName">Used to differentiate between projects and for the base directory of the project.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2015,6 +2015,7 @@ FSharp.Compiler.CodeAnalysis.FSharpChecker: Int32 ActualCheckFileCount
FSharp.Compiler.CodeAnalysis.FSharpChecker: Int32 ActualParseFileCount
FSharp.Compiler.CodeAnalysis.FSharpChecker: Int32 get_ActualCheckFileCount()
FSharp.Compiler.CodeAnalysis.FSharpChecker: Int32 get_ActualParseFileCount()
FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.CodeAnalysis.FSharpProjectOptions] GetCachedProjectOptions(System.String, Boolean)
FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.CodeAnalysis.FSharpCheckFileAnswer] CheckFileInProject(FSharp.Compiler.CodeAnalysis.FSharpParseFileResults, System.String, Int32, FSharp.Compiler.Text.ISourceText, FSharp.Compiler.CodeAnalysis.FSharpProjectOptions, Microsoft.FSharp.Core.FSharpOption`1[System.String])
FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.CodeAnalysis.FSharpCheckProjectResults] ParseAndCheckProject(FSharp.Compiler.CodeAnalysis.FSharpProjectOptions, Microsoft.FSharp.Core.FSharpOption`1[System.String])
FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.CodeAnalysis.FSharpParseFileResults] GetBackgroundParseResultsForFileInProject(System.String, FSharp.Compiler.CodeAnalysis.FSharpProjectOptions, Microsoft.FSharp.Core.FSharpOption`1[System.String])
Expand Down