Skip to content

Commit 273780a

Browse files
krasnotsvetovauduchinok
authored andcommitted
Fix for API changes (VirtualFileSystemPath)
1 parent 8e14d4a commit 273780a

32 files changed

+143
-130
lines changed

ReSharper.FSharp/src/FSharp.Common/src/Checker/FcsCheckerService.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ module FcsCheckerService =
3131

3232

3333
type FcsProject =
34-
{ OutputPath: FileSystemPath
35-
FileIndices: Dictionary<FileSystemPath, int>
34+
{ OutputPath: VirtualFileSystemPath
35+
FileIndices: Dictionary<VirtualFileSystemPath, int>
3636
ProjectOptions: FSharpProjectOptions
3737
ParsingOptions: FSharpParsingOptions
38-
ImplementationFilesWithSignatures: ISet<FileSystemPath> }
38+
ImplementationFilesWithSignatures: ISet<VirtualFileSystemPath> }
3939

4040
member x.IsKnownFile(sourceFile: IPsiSourceFile) =
4141
x.FileIndices.ContainsKey(sourceFile.GetLocation())
@@ -200,7 +200,7 @@ type IFcsProjectProvider =
200200

201201
type IScriptFcsProjectProvider =
202202
abstract GetScriptOptions: IPsiSourceFile -> FSharpProjectOptions option
203-
abstract GetScriptOptions: FileSystemPath * string -> FSharpProjectOptions option
203+
abstract GetScriptOptions: VirtualFileSystemPath * string -> FSharpProjectOptions option
204204

205205

206206
type IFcsAssemblyReaderShim =

ReSharper.FSharp/src/FSharp.Common/src/Checker/FcsProjectBuilder.fs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ open JetBrains.Util
1717
open JetBrains.Util.Dotnet.TargetFrameworkIds
1818

1919
type ReferencedModule =
20-
{ ReferencedPath: FileSystemPath
20+
{ ReferencedPath: VirtualFileSystemPath
2121
ReferencingModules: HashSet<IPsiModule> }
2222

2323
module ReferencedModule =
@@ -96,7 +96,7 @@ type FcsProjectBuilder(checkerService: FcsCheckerService, itemsContainer: IFShar
9696
| _ -> "library"
9797

9898
abstract GetProjectItemsPaths:
99-
project: IProject * targetFrameworkId: TargetFrameworkId -> (FileSystemPath * BuildAction)[]
99+
project: IProject * targetFrameworkId: TargetFrameworkId -> (VirtualFileSystemPath * BuildAction)[]
100100

101101
default x.GetProjectItemsPaths(project, targetFrameworkId) =
102102
let projectMark = project.GetProjectMark().NotNull()
@@ -183,14 +183,14 @@ type FcsProjectBuilder(checkerService: FcsCheckerService, itemsContainer: IFShar
183183

184184
let filePaths, implsWithSig, resources = x.GetProjectFilesAndResources(project, targetFrameworkId)
185185

186-
otherOptions.AddRange(resources |> Seq.map (fun (r: FileSystemPath) -> "--resource:" + r.FullPath))
187-
let fileIndices = Dictionary<FileSystemPath, int>()
186+
otherOptions.AddRange(resources |> Seq.map (fun (r: VirtualFileSystemPath) -> "--resource:" + r.FullPath))
187+
let fileIndices = Dictionary<VirtualFileSystemPath, int>()
188188
Array.iteri (fun i p -> fileIndices.[p] <- i) filePaths
189189

190190
let projectOptions =
191191
{ ProjectFileName = $"{project.ProjectFileLocation}.{targetFrameworkId}.fsproj"
192192
ProjectId = None
193-
SourceFiles = Array.map (fun (p: FileSystemPath ) -> p.FullPath) filePaths
193+
SourceFiles = Array.map (fun (p: VirtualFileSystemPath ) -> p.FullPath) filePaths
194194
OtherOptions = otherOptions.ToArray()
195195
ReferencedProjects = Array.empty
196196
IsIncompleteTypeCheckEnvironment = false

ReSharper.FSharp/src/FSharp.Common/src/Checker/ScriptFcsProjectProvider.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type ScriptFcsProjectProvider(lifetime: Lifetime, logger: ILogger, checkerServic
3737
IPropertyEx.FlowInto(languageVersion, lifetime, flags, fun version -> getOtherFlags version)
3838
flags
3939

40-
let getOptions (path: FileSystemPath) source =
40+
let getOptions (path: VirtualFileSystemPath) source =
4141
let path = path.FullPath
4242
let source = SourceText.ofString source
4343
lock getScriptOptionsLock (fun _ ->
@@ -58,7 +58,7 @@ type ScriptFcsProjectProvider(lifetime: Lifetime, logger: ILogger, checkerServic
5858
None)
5959

6060
interface IScriptFcsProjectProvider with
61-
member x.GetScriptOptions(path: FileSystemPath, source) =
61+
member x.GetScriptOptions(path: VirtualFileSystemPath, source) =
6262
getOptions path source
6363

6464
member x.GetScriptOptions(file: IPsiSourceFile) =

ReSharper.FSharp/src/FSharp.Common/src/ProjectModel/FSharpFileService.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type FSharpFileService(settingsLocation: RiderAnyProductSettingsLocation, fileEx
1616
.Parent / "scratches"
1717

1818
interface IFSharpFileService with
19-
member x.IsScratchFile(path: FileSystemPath) =
19+
member x.IsScratchFile(path: VirtualFileSystemPath) =
2020
path.Parent.Equals(scratchesDir)
2121

2222
member x.IsScriptLike(file) =

ReSharper.FSharp/src/FSharp.Common/src/ProjectModel/FSharpLanguageLevelProvider.fs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ type FSharpLanguageLevelProjectProperty(lifetime, locks, projectPropertiesListen
4646
projectPropertiesListener, projectSettings, persistentProjectItemProperties,
4747
settingsSchema.GetKey<FSharpLanguageProjectSettings>().TryFindEntryByMemberName("LanguageLevel"))
4848

49-
let compilerPathToLanguageLevels = ConcurrentDictionary<FileSystemPath, VersionMapping>()
49+
let compilerPathToLanguageLevels = ConcurrentDictionary<VirtualFileSystemPath, VersionMapping>()
5050

5151
let getFSharpProjectConfiguration (project: IProject) targetFrameworkId =
5252
project.ProjectProperties.TryGetConfiguration<IFSharpProjectConfiguration>(targetFrameworkId)
@@ -76,26 +76,26 @@ type FSharpLanguageLevelProjectProperty(lifetime, locks, projectPropertiesListen
7676
| Version (11, 0) -> VersionMapping(FSharpLanguageLevel.FSharp50, FSharpLanguageLevel.Preview)
7777
| _ -> null
7878

79-
let getCompilerVersion (fscPath: FileSystemPath) =
79+
let getCompilerVersion (fscPath: VirtualFileSystemPath) =
8080
let assemblyNameInfo = AssemblyNameReader.GetAssemblyNameRaw(fscPath)
8181
assemblyNameInfo.Version
8282

83-
let getLanguageLevelByCompilerNoCache (fscPath: FileSystemPath): VersionMapping =
83+
let getLanguageLevelByCompilerNoCache (fscPath: VirtualFileSystemPath): VersionMapping =
8484
if fscPath.IsEmpty then getVersionMappingByToolset () else
8585

8686
let version = getCompilerVersion fscPath
8787
match getLanguageLevelByCompilerVersion version with
8888
| null -> getVersionMappingByToolset ()
8989
| mapping -> mapping
9090

91-
let getLanguageLevelByCompiler (fscPath: FileSystemPath): VersionMapping =
91+
let getLanguageLevelByCompiler (fscPath: VirtualFileSystemPath): VersionMapping =
9292
compilerPathToLanguageLevels.GetOrAdd(fscPath, getLanguageLevelByCompilerNoCache)
9393

94-
let getFscPath (configuration: IFSharpProjectConfiguration): FileSystemPath =
95-
if isNull configuration then FileSystemPath.Empty else
94+
let getFscPath (configuration: IFSharpProjectConfiguration): VirtualFileSystemPath =
95+
if isNull configuration then (VirtualFileSystemPath.GetEmptyPathFor InteractionContext.SolutionContext) else
9696

9797
let path = configuration.PropertiesCollection.GetPropertyValueSafe(FSharpProperties.DotnetFscCompilerPath)
98-
FileSystemPath.TryParse(path)
98+
VirtualFileSystemPath.TryParse(path, InteractionContext.SolutionContext)
9999

100100
let convertToLanguageLevel (configuration: IFSharpProjectConfiguration) version =
101101
match version with

ReSharper.FSharp/src/FSharp.Common/src/ProjectModel/FSharpProjectModelUtil.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ let getReferencedModules (psiModule: IPsiModule) =
2929
|> Seq.map (fun reference -> reference.Module)
3030

3131
module ModulePathProvider =
32-
let outputPathKey = Key<FileSystemPath>("AssemblyReaderTest.outputPath")
32+
let outputPathKey = Key<VirtualFileSystemPath>("AssemblyReaderTest.outputPath")
3333

3434
[<SolutionComponent>]
3535
type ModulePathProvider() =
36-
abstract GetModulePath: psiModule: IPsiModule -> FileSystemPath
36+
abstract GetModulePath: psiModule: IPsiModule -> VirtualFileSystemPath
3737
default this.GetModulePath(psiModule) =
3838
match psiModule with
3939
| :? IAssemblyPsiModule as assemblyPsiModule ->
@@ -42,4 +42,4 @@ type ModulePathProvider() =
4242
| :? IProjectPsiModule as projectPsiModule ->
4343
projectPsiModule.Project.GetOutputFilePath(projectPsiModule.TargetFrameworkId)
4444

45-
| _ -> FileSystemPath.Empty
45+
| _ -> (VirtualFileSystemPath.GetEmptyPathFor InteractionContext.SolutionContext)

ReSharper.FSharp/src/FSharp.Common/src/ProjectModel/FSharpScriptPsiModuleFactory.fs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ type FSharpScriptPsiModulesProvider(lifetime: Lifetime, solution: ISolution, cha
4343
projectFileTypeCoordinator) as this =
4444

4545
/// There may be multiple project files for a path (i.e. linked in multiple projects) and we must distinguish them.
46-
let scriptsFromProjectFiles = OneToListMap<FileSystemPath, FSharpScriptPsiModule>()
46+
let scriptsFromProjectFiles = OneToListMap<VirtualFileSystemPath, FSharpScriptPsiModule>()
4747

4848
/// Psi modules for files coming from #load directives and do not present in the project model.
49-
let scriptsFromPaths = Dictionary<FileSystemPath, FSharpScriptPsiModule>()
49+
let scriptsFromPaths = Dictionary<VirtualFileSystemPath, FSharpScriptPsiModule>()
5050

5151
/// References to assemblies and other source files for each known script path.
52-
let scriptsReferences = Dictionary<FileSystemPath, ScriptReferences>()
52+
let scriptsReferences = Dictionary<VirtualFileSystemPath, ScriptReferences>()
5353

5454
let psiModules = List<IPsiModule>()
5555
let mutable psiModulesCollection = HybridCollection.Empty
@@ -67,21 +67,21 @@ type FSharpScriptPsiModulesProvider(lifetime: Lifetime, solution: ISolution, cha
6767
let platformInfo = platformInfos |> Seq.maxBy (fun info -> info.TargetFrameworkId.Version)
6868
platformInfo.TargetFrameworkId
6969

70-
let getScriptOptions (path: FileSystemPath) (document: IDocument) =
70+
let getScriptOptions (path: VirtualFileSystemPath) (document: IDocument) =
7171
scriptOptionsProvider.GetScriptOptions(path, document.GetText())
7272
|> Option.orElseWith (fun _ -> failwithf "Could not get script options for: %O" path)
7373
|> Option.get
7474

75-
let getScriptReferences scriptPath scriptOptions =
76-
let assembliesPaths = HashSet<FileSystemPath>()
75+
let getScriptReferences (scriptPath: VirtualFileSystemPath) scriptOptions =
76+
let assembliesPaths = HashSet<VirtualFileSystemPath>()
7777
for o in scriptOptions.OtherOptions do
7878
if o.StartsWith("-r:", StringComparison.Ordinal) then
79-
let path = FileSystemPath.TryParse(o.Substring(3))
79+
let path = VirtualFileSystemPath.TryParse(o.Substring(3), InteractionContext.SolutionContext)
8080
if not path.IsEmpty then assembliesPaths.Add(path) |> ignore
8181

82-
let filesPaths = HashSet<FileSystemPath>()
82+
let filesPaths = HashSet<VirtualFileSystemPath>()
8383
for file in scriptOptions.SourceFiles do
84-
let path = FileSystemPath.TryParse(file)
84+
let path = VirtualFileSystemPath.TryParse(file, InteractionContext.SolutionContext)
8585
if not path.IsEmpty && not (path.Equals(scriptPath)) then
8686
filesPaths.Add(path) |> ignore
8787

@@ -136,7 +136,7 @@ type FSharpScriptPsiModulesProvider(lifetime: Lifetime, solution: ISolution, cha
136136

137137
psiModule
138138

139-
and createPsiModuleForPath (path: FileSystemPath) changeBuilder =
139+
and createPsiModuleForPath (path: VirtualFileSystemPath) changeBuilder =
140140
let modulesForPath = getPsiModulesForPath path
141141
if modulesForPath.IsEmpty() then
142142
let fileDocument = documentManager.GetOrCreateDocument(path)
@@ -147,7 +147,7 @@ type FSharpScriptPsiModulesProvider(lifetime: Lifetime, solution: ISolution, cha
147147
scriptsFromPaths.[path] <- psiModule
148148
addPsiModule psiModule
149149

150-
let rec updateReferences (path: FileSystemPath) (document: IDocument) =
150+
let rec updateReferences (path: VirtualFileSystemPath) (document: IDocument) =
151151
locks.QueueReadLock(lifetime, "Request new F# script references", fun _ ->
152152
let mutable oldReferences = Unchecked.defaultof<ScriptReferences>
153153
match scriptsReferences.TryGetValue(path, &oldReferences) with
@@ -238,7 +238,7 @@ type FSharpScriptPsiModulesProvider(lifetime: Lifetime, solution: ISolution, cha
238238
resultModule <- psiModule
239239
true
240240

241-
member x.CreatePsiModuleForPath(path: FileSystemPath, changeBuilder: PsiModuleChangeBuilder) =
241+
member x.CreatePsiModuleForPath(path: VirtualFileSystemPath, changeBuilder: PsiModuleChangeBuilder) =
242242
locks.AssertWriteAccessAllowed()
243243
createPsiModuleForPath path changeBuilder
244244

@@ -314,7 +314,7 @@ type FSharpScriptPsiModuleHandler(lifetime, solution, handler, modulesProvider,
314314
inherit DelegatingProjectPsiModuleHandler(handler)
315315

316316
let locks = solution.Locks
317-
let sourceFiles = Dictionary<FileSystemPath, IPsiSourceFile>()
317+
let sourceFiles = Dictionary<VirtualFileSystemPath, IPsiSourceFile>()
318318

319319
do
320320
lifetime.OnTermination(fun _ ->
@@ -378,7 +378,7 @@ type FSharpScriptPsiModule(lifetime, path, solution, sourceFileCtor, moduleId, a
378378
// We create at most one psi module for each project file and update list of handlers pointing to it.
379379
let projectHandlers = List<IProjectPsiModuleHandler>()
380380

381-
let assemblyCookies = DictionaryEvents<FileSystemPath, IAssemblyCookie>(lifetime, moduleId)
381+
let assemblyCookies = DictionaryEvents<VirtualFileSystemPath, IAssemblyCookie>(lifetime, moduleId)
382382

383383
do
384384
assemblyCookies.AddRemove.Advise_Remove(lifetime, fun (AddRemoveArgs (KeyValue (_, assemblyCookie))) ->
@@ -400,12 +400,12 @@ type FSharpScriptPsiModule(lifetime, path, solution, sourceFileCtor, moduleId, a
400400

401401
member x.IsValid = psiServices.Modules.HasModule(this)
402402

403-
member x.AddReference(path: FileSystemPath) =
403+
member x.AddReference(path: VirtualFileSystemPath) =
404404
solution.Locks.AssertWriteAccessAllowed()
405405
if not (assemblyCookies.ContainsKey(path)) then
406406
assemblyCookies.Add(path, assemblyFactory.AddRef(AssemblyLocation(path), moduleId, this.ResolveContext))
407407

408-
member x.RemoveReference(path: FileSystemPath) =
408+
member x.RemoveReference(path: VirtualFileSystemPath) =
409409
solution.Locks.AssertWriteAccessAllowed()
410410
if assemblyCookies.ContainsKey(path) then
411411
assemblyCookies.Remove(path) |> ignore
@@ -459,11 +459,11 @@ type IFSharpFileService =
459459
abstract member IsScriptLike: IPsiSourceFile -> bool
460460

461461
/// True when file is an IntelliJ scratch file.
462-
abstract member IsScratchFile: FileSystemPath -> bool
462+
abstract member IsScratchFile: VirtualFileSystemPath -> bool
463463

464464

465465
/// Holder for psi module resolve context.
466-
type FSharpScriptModule(path: FileSystemPath, solution: ISolution) =
466+
type FSharpScriptModule(path: VirtualFileSystemPath, solution: ISolution) =
467467
inherit UserDataHolder()
468468

469469
static let scratchesPath = RelativePath.TryParse("Scratches")
@@ -507,8 +507,8 @@ type ScriptFileProperties() =
507507

508508

509509
type ScriptReferences =
510-
{ Assemblies: ISet<FileSystemPath>
511-
Files: ISet<FileSystemPath> }
510+
{ Assemblies: ISet<VirtualFileSystemPath>
511+
Files: ISet<VirtualFileSystemPath> }
512512

513513

514514
[<SolutionFeaturePart>]

0 commit comments

Comments
 (0)