Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
5bd6359
Merge remote-tracking branch 'upstream/main' into lsp-main
0101 Oct 2, 2024
2b4c729
re-enable tests
0101 Oct 3, 2024
86de47f
exp
0101 Oct 3, 2024
95645b1
exp
0101 Oct 7, 2024
f9c1148
exp
0101 Oct 9, 2024
95165f2
exp
0101 Oct 10, 2024
4227bc0
ex
0101 Oct 10, 2024
d6be3af
exp
0101 Oct 16, 2024
3d8d251
working diagnostics
0101 Oct 17, 2024
3b72cfc
exp
0101 Oct 17, 2024
e976b08
some comments
0101 Oct 23, 2024
be78697
remove node
0101 Oct 23, 2024
a850f6b
wip
0101 Oct 23, 2024
d48083d
something that works
0101 Oct 24, 2024
31c96c1
..
0101 Oct 24, 2024
4a6e30a
Merge branch 'lsp' into lsp-exp
0101 Oct 24, 2024
bbd7cd3
better debug graph output
0101 Oct 25, 2024
bb496d0
Merge branch 'lsp' of https://github.com/dotnet/fsharp into lsp-exp
0101 Oct 29, 2024
98c3b3e
extracting dep graph type constraints into extension methods
0101 Oct 30, 2024
65e365f
Merge branch 'lsp' of https://github.com/dotnet/fsharp into lsp-exp
0101 Oct 30, 2024
8bd847b
Merge branch 'lsp' of https://github.com/dotnet/fsharp into lsp-exp
0101 Nov 1, 2024
45240b8
undo test change
0101 Nov 1, 2024
7ec3af0
some refactoring
0101 Nov 1, 2024
296b867
thanks copilot
0101 Nov 1, 2024
0774ba7
Merge branch 'lsp-exp' of https://github.com/0101/fsharp into lsp-exp
0101 Nov 1, 2024
03ff97d
fix tests
0101 Nov 1, 2024
df32314
copilot tests
0101 Nov 1, 2024
fc8838c
0101 Nov 1, 2024
60e56e6
update
0101 Nov 1, 2024
aa458e2
update
0101 Nov 1, 2024
9693acc
ProjectCore -> ProjectConfig
0101 Nov 5, 2024
bb3b44a
Merge branch 'lsp' of https://github.com/dotnet/fsharp into lsp-exp
0101 Nov 5, 2024
fbc42aa
rename
0101 Nov 5, 2024
b9ed106
update
0101 Nov 6, 2024
06df5e2
refactoring
0101 Nov 6, 2024
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 src/Compiler/Facilities/AsyncMemoize.fs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ type internal JobEvent =
| Cleared

type internal ICacheKey<'TKey, 'TVersion> =
// TODO Key should probably be renamed to Identifier
abstract member GetKey: unit -> 'TKey
abstract member GetVersion: unit -> 'TVersion
abstract member GetLabel: unit -> string
Expand Down
301 changes: 186 additions & 115 deletions src/Compiler/Service/FSharpProjectSnapshot.fs

Large diffs are not rendered by default.

44 changes: 21 additions & 23 deletions src/Compiler/Service/TransparentCompiler.fs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ type internal CompilerCaches(sizeFactor: int) =

member val ScriptClosure = AsyncMemoize(sf, 2 * sf, name = "ScriptClosure")

member this.Clear(projects: Set<ProjectIdentifier>) =
member this.Clear(projects: Set<FSharpProjectIdentifier>) =
let shouldClear project = projects |> Set.contains project

this.ParseFile.Clear(fst >> shouldClear)
Expand Down Expand Up @@ -422,11 +422,11 @@ type internal TransparentCompiler
(useFsiAuxLib: bool)
(useSdkRefs: bool)
(assumeDotNetFramework: bool)
(projectIdentifier: ProjectIdentifier)
(projectIdentifier: FSharpProjectIdentifier)
(otherOptions: string list)
(stamp: int64 option)
=
{ new ICacheKey<string * ProjectIdentifier, string> with
{ new ICacheKey<string * FSharpProjectIdentifier, string> with
member _.GetKey() = fileName, projectIdentifier
member _.GetLabel() = $"ScriptClosure for %s{fileName}"

Expand Down Expand Up @@ -456,15 +456,15 @@ type internal TransparentCompiler
(useSdkRefs: bool option)
(sdkDirOverride: string option)
(assumeDotNetFramework: bool option)
(projectIdentifier: ProjectIdentifier)
(projectIdentifier: FSharpProjectIdentifier)
(otherOptions: string list)
(stamp: int64 option)
=
let useFsiAuxLib = defaultArg useFsiAuxLib true
let useSdkRefs = defaultArg useSdkRefs true
let assumeDotNetFramework = defaultArg assumeDotNetFramework false

let key: ICacheKey<string * ProjectIdentifier, string> =
let key =
mkScriptClosureCacheKey
fileName
source
Expand Down Expand Up @@ -826,8 +826,8 @@ type internal TransparentCompiler
let mutable BootstrapInfoIdCounter = 0

/// Bootstrap info that does not depend source files
let ComputeBootstrapInfoStatic (projectSnapshot: ProjectCore, tcConfig: TcConfig, assemblyName: string, loadClosureOpt) =
let cacheKey = projectSnapshot.CacheKeyWith("BootstrapInfoStatic", assemblyName)
let ComputeBootstrapInfoStatic (projectSnapshot: ProjectSnapshotBase<_>, tcConfig: TcConfig, assemblyName: string, loadClosureOpt) =
let cacheKey = projectSnapshot.BaseCacheKeyWith("BootstrapInfoStatic", assemblyName)

caches.BootstrapInfoStatic.Get(
cacheKey,
Expand Down Expand Up @@ -957,7 +957,7 @@ type internal TransparentCompiler
let outFile, _, assemblyName = tcConfigB.DecideNames sourceFiles

let! bootstrapId, tcImports, tcGlobals, initialTcInfo, importsInvalidatedByTypeProvider =
ComputeBootstrapInfoStatic(projectSnapshot.ProjectCore, tcConfig, assemblyName, loadClosureOpt)
ComputeBootstrapInfoStatic(projectSnapshot, tcConfig, assemblyName, loadClosureOpt)

// Check for the existence of loaded sources and prepend them to the sources list if present.
let loadedSources =
Expand Down Expand Up @@ -1056,7 +1056,7 @@ type internal TransparentCompiler
|> Seq.map (fun f -> LoadSource f isExe (f.FileName = bootstrapInfo.LastFileName))
|> MultipleDiagnosticsLoggers.Parallel

return ProjectSnapshotWithSources(projectSnapshot.ProjectCore, sources |> Array.toList)
return ProjectSnapshotWithSources(projectSnapshot.ProjectConfig, projectSnapshot.ReferencedProjects, sources |> Array.toList)

}

Expand All @@ -1067,7 +1067,7 @@ type internal TransparentCompiler
member _.GetLabel() = file.FileName |> shortPath

member _.GetKey() =
projectSnapshot.ProjectCore.Identifier, file.FileName
projectSnapshot.ProjectConfig.Identifier, file.FileName

member _.GetVersion() =
projectSnapshot.ParsingVersion,
Expand Down Expand Up @@ -1467,7 +1467,7 @@ type internal TransparentCompiler
|> Seq.map (ComputeParseFile projectSnapshot tcConfig)
|> MultipleDiagnosticsLoggers.Parallel

return ProjectSnapshotBase<_>(projectSnapshot.ProjectCore, parsedInputs |> Array.toList)
return ProjectSnapshotBase<_>(projectSnapshot.ProjectConfig, projectSnapshot.ReferencedProjects, parsedInputs |> Array.toList)
}

// Type check file and all its dependencies
Expand Down Expand Up @@ -2137,19 +2137,19 @@ type internal TransparentCompiler
use _ =
Activity.start "TransparentCompiler.ClearCache" [| Activity.Tags.userOpName, userOpName |]

this.Caches.Clear(
projects
|> Seq.map (function
| FSharpProjectIdentifier(x, y) -> (x, y))
|> Set
)
this.Caches.Clear(Set projects)

member this.ClearCache(options: seq<FSharpProjectOptions>, userOpName: string) : unit =
use _ =
Activity.start "TransparentCompiler.ClearCache" [| Activity.Tags.userOpName, userOpName |]

backgroundCompiler.ClearCache(options, userOpName)
this.Caches.Clear(options |> Seq.map (fun o -> o.GetProjectIdentifier()) |> Set)

this.Caches.Clear(
options
|> Seq.map (fun o -> o.GetProjectIdentifier() |> FSharpProjectIdentifier)
|> Set
)

member _.ClearCaches() : unit =
backgroundCompiler.ClearCaches()
Expand Down Expand Up @@ -2365,7 +2365,7 @@ type internal TransparentCompiler
useFsiAuxLib
useSdkRefs
assumeDotNetFramework
(projectFileName, "")
(FSharpProjectIdentifier(projectFileName, ""))
otherFlags
optionsStamp

Expand Down Expand Up @@ -2394,6 +2394,7 @@ type internal TransparentCompiler
FSharpProjectSnapshot.Create(
fileName + ".fsproj",
None,
None,
sourceFiles,
references,
otherFlags,
Expand Down Expand Up @@ -2445,10 +2446,7 @@ type internal TransparentCompiler
backgroundCompiler.InvalidateConfiguration(options, userOpName)

member this.InvalidateConfiguration(projectSnapshot: FSharpProjectSnapshot, _userOpName: string) : unit =
let (FSharpProjectIdentifier(projectFileName, outputFileName)) =
projectSnapshot.Identifier

this.Caches.Clear(Set.singleton (ProjectIdentifier(projectFileName, outputFileName)))
this.Caches.Clear(Set.singleton projectSnapshot.Identifier)

member this.NotifyFileChanged(fileName: string, options: FSharpProjectOptions, userOpName: string) : Async<unit> =
backgroundCompiler.NotifyFileChanged(fileName, options, userOpName)
Expand Down
23 changes: 13 additions & 10 deletions src/Compiler/Service/TransparentCompiler.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ open FSharp.Compiler.NameResolution
open FSharp.Compiler.TypedTree
open FSharp.Compiler.CheckDeclarations
open FSharp.Compiler.EditorServices
open FSharp.Compiler.CodeAnalysis.ProjectSnapshot

/// Accumulated results of type checking. The minimum amount of state in order to continue type-checking following files.
[<NoEquality; NoComparison>]
Expand Down Expand Up @@ -101,41 +102,43 @@ type internal CompilerCaches =

new: sizeFactor: int -> CompilerCaches

member AssemblyData: AsyncMemoize<(string * string), (string * string), ProjectAssemblyDataResult>
member AssemblyData: AsyncMemoize<FSharpProjectIdentifier, (string * string), ProjectAssemblyDataResult>

member BootstrapInfo: AsyncMemoize<(string * string), string, (BootstrapInfo option * FSharpDiagnostic array)>
member BootstrapInfo: AsyncMemoize<FSharpProjectIdentifier, string, (BootstrapInfo option * FSharpDiagnostic array)>

member BootstrapInfoStatic:
AsyncMemoize<(string * string), (string * string), (int * TcImports * TcGlobals * TcInfo * Event<unit>)>
AsyncMemoize<FSharpProjectIdentifier, (string * string), (int * TcImports * TcGlobals * TcInfo * Event<unit>)>

member DependencyGraph:
AsyncMemoize<(DependencyGraphType option * byte array), string, (Graph<NodeToTypeCheck> * Graph<FileIndex>)>

member FrameworkImports: AsyncMemoize<string, FrameworkImportsCacheKey, (TcGlobals * TcImports)>

member ItemKeyStore: AsyncMemoize<(string * (string * string)), string, ItemKeyStore option>
member ItemKeyStore: AsyncMemoize<(string * FSharpProjectIdentifier), string, ItemKeyStore option>

member ParseAndCheckAllFilesInProject: AsyncMemoizeDisabled<obj, obj, obj>

member ParseAndCheckFileInProject:
AsyncMemoize<(string * (string * string)), string * string, (FSharpParseFileResults * FSharpCheckFileAnswer)>
AsyncMemoize<(string * FSharpProjectIdentifier), string * string, (FSharpParseFileResults *
FSharpCheckFileAnswer)>

member ParseAndCheckProject: AsyncMemoize<(string * string), string, FSharpCheckProjectResults>
member ParseAndCheckProject: AsyncMemoize<FSharpProjectIdentifier, string, FSharpCheckProjectResults>

member ParseFile:
AsyncMemoize<((string * string) * string), (string * string * bool), ProjectSnapshot.FSharpParsedFile>
AsyncMemoize<(FSharpProjectIdentifier * string), (string * string * bool), ProjectSnapshot.FSharpParsedFile>

member ParseFileWithoutProject: AsyncMemoize<string, string, FSharpParseFileResults>

member ProjectExtras: AsyncMemoizeDisabled<obj, obj, obj>

member SemanticClassification: AsyncMemoize<(string * (string * string)), string, SemanticClassificationView option>
member SemanticClassification:
AsyncMemoize<(string * FSharpProjectIdentifier), string, SemanticClassificationView option>

member SizeFactor: int

member TcIntermediate: AsyncMemoize<(string * (string * string)), (string * int), TcIntermediate>
member TcIntermediate: AsyncMemoize<(string * FSharpProjectIdentifier), (string * int), TcIntermediate>

member ScriptClosure: AsyncMemoize<(string * (string * string)), string, LoadClosure>
member ScriptClosure: AsyncMemoize<(string * FSharpProjectIdentifier), string, LoadClosure>

member TcLastFile: AsyncMemoizeDisabled<obj, obj, obj>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ type CapabilitiesManager(scOverrides: IServerCapabilitiesOverride seq) =
TextDocumentSync = TextDocumentSyncOptions(OpenClose = true, Change = TextDocumentSyncKind.Full),
DiagnosticOptions =
DiagnosticOptions(WorkDoneProgress = true, InterFileDependencies = true, Identifier = "potato", WorkspaceDiagnostics = true),
CompletionProvider =
CompletionOptions(TriggerCharacters=[|"."; " "|], ResolveProvider=true, WorkDoneProgress=true),
CompletionProvider = CompletionOptions(TriggerCharacters = [| "."; " " |], ResolveProvider = true, WorkDoneProgress = true),
HoverProvider = SumType<bool, HoverOptions>(HoverOptions(WorkDoneProgress = true))
)

Expand All @@ -33,4 +32,4 @@ type CapabilitiesManager(scOverrides: IServerCapabilitiesOverride seq) =
member this.GetInitializeParams() =
match initializeParams with
| Some params' -> params'
| None -> failwith "InitializeParams is null"
| None -> failwith "InitializeParams is null"
Loading