Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita3d131e

Browse files
authored
add comments, fix formatting, cleanup flag (#4891)
* add docs* cleanup flag that's always true* correct comment
1 parent0fd7cdf commita3d131e

File tree

2 files changed

+50
-25
lines changed

2 files changed

+50
-25
lines changed

‎vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs‎

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,12 @@ type internal FSharpProjectOptionsManager
160160
// compiled and #r will refer to files on disk
161161
letreferencedProjectFileNames=[||]
162162
letsite= ProjectSitesAndFiles.CreateProjectSiteForScript(fileName, referencedProjectFileNames, options)
163-
letdeps,projectOptions= ProjectSitesAndFiles.GetProjectOptionsForProjectSite(Settings.LanguageServicePerformance.EnableInMemoryCrossProjectReferences, tryGetOptionsForReferencedProject, site, serviceProvider,(tryGetOrCreateProjectId fileName), fileName, options.ExtraProjectInfo, Some projectOptionsTable,true)
163+
letdeps,projectOptions= ProjectSitesAndFiles.GetProjectOptionsForProjectSite(Settings.LanguageServicePerformance.EnableInMemoryCrossProjectReferences, tryGetOptionsForReferencedProject, site, serviceProvider,(tryGetOrCreateProjectId fileName), fileName, options.ExtraProjectInfo, Some projectOptionsTable)
164164
letparsingOptions,_= checkerProvider.Checker.GetParsingOptionsFromProjectOptions(projectOptions)
165165
return(deps, parsingOptions, projectOptions)
166166
else
167167
letsite= ProjectSitesAndFiles.ProjectSiteOfSingleFile(fileName)
168-
letdeps,projectOptions= ProjectSitesAndFiles.GetProjectOptionsForProjectSite(Settings.LanguageServicePerformance.EnableInMemoryCrossProjectReferences, tryGetOptionsForReferencedProject, site, serviceProvider,(tryGetOrCreateProjectId fileName), fileName, extraProjectInfo, Some projectOptionsTable,true)
168+
letdeps,projectOptions= ProjectSitesAndFiles.GetProjectOptionsForProjectSite(Settings.LanguageServicePerformance.EnableInMemoryCrossProjectReferences, tryGetOptionsForReferencedProject, site, serviceProvider,(tryGetOrCreateProjectId fileName), fileName, extraProjectInfo, Some projectOptionsTable)
169169
letparsingOptions,_= checkerProvider.Checker.GetParsingOptionsFromProjectOptions(projectOptions)
170170
return(deps, parsingOptions, projectOptions)
171171
}
@@ -175,7 +175,7 @@ type internal FSharpProjectOptionsManager
175175
projectOptionsTable.AddOrUpdateProject(projectId,(fun isRefresh->
176176
letextraProjectInfo= Some(box workspace)
177177
lettryGetOptionsForReferencedProject f= f|> tryGetOrCreateProjectId|> Option.bind this.TryGetOptionsForProject|> Option.map(fun(_,_,projectOptions)-> projectOptions)
178-
letreferencedProjects,projectOptions= ProjectSitesAndFiles.GetProjectOptionsForProjectSite(Settings.LanguageServicePerformance.EnableInMemoryCrossProjectReferences, tryGetOptionsForReferencedProject, site, serviceProvider,(tryGetOrCreateProjectId(site.ProjectFileName)), site.ProjectFileName, extraProjectInfo, Some projectOptionsTable,true)
178+
letreferencedProjects,projectOptions= ProjectSitesAndFiles.GetProjectOptionsForProjectSite(Settings.LanguageServicePerformance.EnableInMemoryCrossProjectReferences, tryGetOptionsForReferencedProject, site, serviceProvider,(tryGetOrCreateProjectId(site.ProjectFileName)), site.ProjectFileName, extraProjectInfo, Some projectOptionsTable)
179179
if invalidateConfigthen checkerProvider.Checker.InvalidateConfiguration(projectOptions, startBackgroundCompileIfAlreadySeen=not isRefresh, userOpName= userOpName+".UpdateProjectInfo")
180180
letreferencedProjectIds= referencedProjects|> Array.choose tryGetOrCreateProjectId
181181
letparsingOptions,_= checkerProvider.Checker.GetParsingOptionsFromProjectOptions(projectOptions)
@@ -206,18 +206,18 @@ type internal FSharpProjectOptionsManager
206206
match singleFileProjectTable.TryGetValue(projectId)with
207207
|true,(loadTime,_,_)->
208208
try
209-
letfileName= document.FilePath
210-
let!cancellationToken= Async.CancellationToken
211-
let!sourceText= document.GetTextAsync(cancellationToken)|> Async.AwaitTask
212-
// NOTE: we don't use FCS cross-project references from scripts to projects. The projects must have been
213-
// compiled and #r will refer to files on disk.
214-
lettryGetOrCreateProjectId _= None
215-
let!_referencedProjectFileNames,parsingOptions,projectOptions= this.ComputeSingleFileOptions(tryGetOrCreateProjectId, fileName, loadTime, sourceText.ToString())
216-
this.AddOrUpdateSingleFileProject(projectId,(loadTime, parsingOptions, projectOptions))
217-
return Some(parsingOptions, None, projectOptions)
209+
letfileName= document.FilePath
210+
let!cancellationToken= Async.CancellationToken
211+
let!sourceText= document.GetTextAsync(cancellationToken)|> Async.AwaitTask
212+
// NOTE: we don't use FCS cross-project references from scripts to projects. The projects must have been
213+
// compiled and #r will refer to files on disk.
214+
lettryGetOrCreateProjectId _= None
215+
let!_referencedProjectFileNames,parsingOptions,projectOptions= this.ComputeSingleFileOptions(tryGetOrCreateProjectId, fileName, loadTime, sourceText.ToString())
216+
this.AddOrUpdateSingleFileProject(projectId,(loadTime, parsingOptions, projectOptions))
217+
return Some(parsingOptions, None, projectOptions)
218218
with ex->
219-
Assert.Exception(ex)
220-
return None
219+
Assert.Exception(ex)
220+
return None
221221
|_->return this.TryGetOptionsForProject(projectId)
222222
}
223223

@@ -658,26 +658,51 @@ type internal FSharpLanguageService(package : FSharpPackage) =
658658
|(VSConstants.S_OK, textLines)->
659659
letfilename= VsTextLines.GetFilename textLines
660660

661-
// CPS projects don't implement IProvideProjectSite and IVSProjectHierarchy
662-
// Simple explanation:
663-
// Legacy projects have IVSHierarchy and IPRojectSite
664-
// CPS Projects and loose script files don't
665661
match VsRunningDocumentTable.FindDocumentWithoutLocking(package.RunningDocumentTable,filename)with
666662
| Some(hier,_)->
663+
664+
665+
// Check if the file is in a CPS project or not.
666+
// CPS projects don't implement IProvideProjectSite and IVSProjectHierarchy
667+
// Simple explanation:
668+
// Legacy projects have IVSHierarchy and IProjectSite
669+
// CPS Projects, out-of-project file and script files don't
670+
667671
match hierwith
668672
|:? IProvideProjectSiteas siteProviderwhennot(IsScript(filename))->
673+
674+
// This is the path for .fs/.fsi files in legacy projects
675+
669676
this.SetupProjectFile(siteProvider, this.Workspace,"SetupNewTextView")
677+
670678
| hwhennot(IsScript(filename))->
679+
671680
letdocId= this.Workspace.CurrentSolution.GetDocumentIdsWithFilePath(filename).FirstOrDefault()
672681
match docIdwith
673682
|null->
674683
ifnot(h.IsCapabilityMatch("CPS"))then
684+
685+
// This is the path when opening out-of-project .fs/.fsi files in CPS projects
686+
675687
letfileContents= VsTextLines.GetFileContents(textLines, textViewAdapter)
676688
this.SetupStandAloneFile(filename, fileContents, this.Workspace, hier)
677689
| id->
690+
691+
// This is the path when opening in-project .fs/.fsi files in CPS projects when
692+
// there is already an existing DocumentId for that document in the solution (which
693+
// will normally be the case)
694+
//
695+
// However, it is not clear this call to UpdateProjectInfoWithProjectId is needed, and it seems
696+
// harmful as it will cause a complete recheck of the project every time a view for a file in the
697+
// project is freshly opened.
698+
678699
projectInfoManager.UpdateProjectInfoWithProjectId(id.ProjectId,"SetupNewTextView", invalidateConfig=true)
679700
|_->
701+
702+
// This is the path for both in-project and out-of-project .fsx files
703+
680704
letfileContents= VsTextLines.GetFileContents(textLines, textViewAdapter)
681705
this.SetupStandAloneFile(filename, fileContents, this.Workspace, hier)
706+
682707
|_->()
683708
|_->()

‎vsintegration/src/FSharp.Editor/LanguageService/ProjectSitesAndFiles.fs‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,20 +255,20 @@ type internal ProjectSitesAndFiles() =
255255
| None->()
256256
}
257257

258-
static let recreferencedProjectsOf(enableInMemoryCrossProjectReferences,tryGetOptionsForReferencedProject,projectSite,serviceProvider,extraProjectInfo,projectOptionsTable,useUniqueStamp)=
258+
static let recreferencedProjectsOf(enableInMemoryCrossProjectReferences,tryGetOptionsForReferencedProject,projectSite,serviceProvider,extraProjectInfo,projectOptionsTable)=
259259
[|for(projectId, projectFileName, outputPath, projectSiteProvider)in referencedProvideProjectSites(projectSite, serviceProvider, extraProjectInfo, projectOptionsTable)do
260260
letreferencedProjectOptions=
261261
// Lookup may not succeed if the project has not been established yet
262262
// In this case we go and compute the options recursively.
263263
match tryGetOptionsForReferencedProject projectFileNamewith
264-
| None-> getProjectOptionsForProjectSite(enableInMemoryCrossProjectReferences, tryGetOptionsForReferencedProject, projectSiteProvider.GetProjectSite(), serviceProvider, projectId, projectFileName, extraProjectInfo, projectOptionsTable, useUniqueStamp)|> snd
264+
| None-> getProjectOptionsForProjectSite(enableInMemoryCrossProjectReferences, tryGetOptionsForReferencedProject, projectSiteProvider.GetProjectSite(), serviceProvider, projectId, projectFileName, extraProjectInfo, projectOptionsTable)|> snd
265265
| Some options-> options
266266
yield projectFileName,(outputPath, referencedProjectOptions)|]
267267

268-
andgetProjectOptionsForProjectSite(enableInMemoryCrossProjectReferences,tryGetOptionsForReferencedProject,projectSite,serviceProvider,projectId,fileName,extraProjectInfo,projectOptionsTable,useUniqueStamp)=
268+
andgetProjectOptionsForProjectSite(enableInMemoryCrossProjectReferences,tryGetOptionsForReferencedProject,projectSite,serviceProvider,projectId,fileName,extraProjectInfo,projectOptionsTable)=
269269
letreferencedProjectFileNames,referencedProjectOptions=
270270
if enableInMemoryCrossProjectReferencesthen
271-
referencedProjectsOf(enableInMemoryCrossProjectReferences, tryGetOptionsForReferencedProject, projectSite, serviceProvider, extraProjectInfo, projectOptionsTable, useUniqueStamp)
271+
referencedProjectsOf(enableInMemoryCrossProjectReferences, tryGetOptionsForReferencedProject, projectSite, serviceProvider, extraProjectInfo, projectOptionsTable)
272272
|> Array.unzip
273273
else[||],[||]
274274
letoption=
@@ -283,7 +283,7 @@ type internal ProjectSitesAndFiles() =
283283
UnresolvedReferences= None
284284
OriginalLoadReferences=[]
285285
ExtraProjectInfo=extraProjectInfo
286-
Stamp=if useUniqueStampthen(stamp<- stamp+1L; Some stamp)else None
286+
Stamp=(stamp<- stamp+1L; Some stamp)
287287
}
288288
match projectId, projectOptionsTablewith
289289
| Some id, Some optionsTable->
@@ -313,10 +313,10 @@ type internal ProjectSitesAndFiles() =
313313
|> Seq.toArray
314314

315315
/// Create project options for this project site.
316-
static memberGetProjectOptionsForProjectSite(enableInMemoryCrossProjectReferences,tryGetOptionsForReferencedProject,projectSite:IProjectSite,serviceProvider,projectId,filename,extraProjectInfo,projectOptionsTable,useUniqueStamp)=
316+
static memberGetProjectOptionsForProjectSite(enableInMemoryCrossProjectReferences,tryGetOptionsForReferencedProject,projectSite:IProjectSite,serviceProvider,projectId,filename,extraProjectInfo,projectOptionsTable)=
317317
match projectSitewith
318318
|:? IHaveCheckOptionsas hco-> hco.OriginalCheckOptions()
319-
|_-> getProjectOptionsForProjectSite(enableInMemoryCrossProjectReferences, tryGetOptionsForReferencedProject, projectSite, serviceProvider, projectId, filename, extraProjectInfo, projectOptionsTable, useUniqueStamp)
319+
|_-> getProjectOptionsForProjectSite(enableInMemoryCrossProjectReferences, tryGetOptionsForReferencedProject, projectSite, serviceProvider, projectId, filename, extraProjectInfo, projectOptionsTable)
320320

321321
/// Create project site for these project options
322322
static memberCreateProjectSiteForScript(filename,referencedProjectFileNames,checkOptions)=

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp