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

Commitff19ad6

Browse files
TIHanbrettfo
authored andcommitted
Deleting unused code
1 parent124de5b commitff19ad6

File tree

5 files changed

+39
-88
lines changed

5 files changed

+39
-88
lines changed

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

Lines changed: 30 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ open Microsoft.VisualStudio.LanguageServices.Implementation.TaskList
2525
[<AutoOpen>]
2626
moduleprivateFSharpProjectOptionsHelpers=
2727

28-
letmapProjectToSite(workspace:VisualStudioWorkspaceImpl,project:Project,serviceProvider:System.IServiceProvider,projectOptionsTable:FSharpProjectOptionsTable option)=
28+
letmapCpsProjectToSite(workspace:VisualStudioWorkspaceImpl,project:Project,serviceProvider:System.IServiceProvider,cpsCommandLineOptions:IDictionary<ProjectId,DateTime*string[]*string[]*string[]>)=
2929
lethier= workspace.GetHierarchy(project.Id)
3030
letgetCommandLineOptionsWithProjectId(projectId)=
31-
matchprojectOptionsTablewith
32-
|Some(options)->options.GetCommandLineOptionsWithProjectId(projectId)
33-
|None->[||],[||],[||]
31+
matchcpsCommandLineOptions.TryGetValue(projectId)with
32+
|true,(_, sourcePaths, referencePaths,options)->sourcePaths, referencePaths, options
33+
|false,_->[||],[||],[||]
3434
{
3535
new IProvideProjectSitewith
3636
memberx.GetProjectSite()=
@@ -88,9 +88,12 @@ type private FSharpProjectOptionsMessage =
8888
| ClearOptionsofProjectId
8989

9090
[<Sealed>]
91-
typeprivateFSharpProjectOptionsReactor(workspace: VisualStudioWorkspaceImpl,settings: EditorOptions,optionsTable: FSharpProjectOptionsTable,serviceProvider,checkerProvider: FSharpCheckerProvider)=
91+
typeprivateFSharpProjectOptionsReactor(workspace: VisualStudioWorkspaceImpl,settings: EditorOptions,serviceProvider,checkerProvider: FSharpCheckerProvider)=
9292
letcancellationTokenSource=new CancellationTokenSource()
9393

94+
// Hack to store command line options from HandleCommandLineChanges
95+
letcpsCommandLineOptions=new ConcurrentDictionary<ProjectId, DateTime* string[]* string[]* string[]>()
96+
9497
letcache= Dictionary<ProjectId, VersionStamp* FSharpParsingOptions* FSharpProjectOptions>()
9598

9699
let rectryComputeOptions(project:Project)=
@@ -130,9 +133,11 @@ type private FSharpProjectOptionsReactor (workspace: VisualStudioWorkspaceImpl,
130133
lethier= workspace.GetHierarchy(projectId)
131134
letprojectSite=
132135
match hierwith
136+
// Legacy
133137
|(:? IProvideProjectSiteas provideSite)-> provideSite.GetProjectSite()
138+
// Cps
134139
|_->
135-
letprovideSite=mapProjectToSite(workspace, project, serviceProvider,Some(optionsTable))
140+
letprovideSite=mapCpsProjectToSite(workspace, project, serviceProvider,cpsCommandLineOptions)
136141
provideSite.GetProjectSite()
137142

138143
letprojectOptions=
@@ -192,6 +197,14 @@ type private FSharpProjectOptionsReactor (workspace: VisualStudioWorkspaceImpl,
192197
member__.ClearOptionsByProjectId(projectId)=
193198
agent.Post(FSharpProjectOptionsMessage.ClearOptions(projectId))
194199

200+
member__.SetCpsCommandLineOptions(projectId,stamp,sourcePaths,referencePaths,options)=
201+
cpsCommandLineOptions.[projectId]<-(stamp, sourcePaths, referencePaths, options)
202+
203+
member__.TryGetCachedOptionsByProjectId(projectId)=
204+
match cache.TryGetValue(projectId)with
205+
|true, result-> Some(result)
206+
|_-> None
207+
195208
interface IDisposablewith
196209
member__.Dispose()=
197210
cancellationTokenSource.Cancel()
@@ -213,19 +226,12 @@ type internal FSharpProjectOptionsManager
213226
settings: EditorOptions
214227
)=
215228

216-
// A table of information about projects, excluding single-file projects.
217-
letprojectOptionsTable= FSharpProjectOptionsTable()
218-
219-
letreactor=new FSharpProjectOptionsReactor(workspace, settings, projectOptionsTable, serviceProvider, checkerProvider)
229+
letreactor=new FSharpProjectOptionsReactor(workspace, settings, serviceProvider, checkerProvider)
220230

221231
// A table of information about single-file projects. Currently we only need the load time of each such file, plus
222232
// the original options for editing
223233
letsingleFileProjectTable= ConcurrentDictionary<ProjectId, DateTime* FSharpParsingOptions* FSharpProjectOptions>()
224234

225-
lettryGetOrCreateProjectId(projectFileName:string)=
226-
letprojectDisplayName= projectDisplayNameOf projectFileName
227-
Some(workspace.ProjectTracker.GetOrCreateProjectIdForPath(projectFileName, projectDisplayName))
228-
229235
do
230236
// We need to listen to this event for lifecycle purposes.
231237
workspace.WorkspaceChanged.Add(fun args->
@@ -234,12 +240,8 @@ type internal FSharpProjectOptionsManager
234240
|_->()
235241
)
236242

237-
/// Retrieve the projectOptionsTable
238-
member__.FSharpOptions= projectOptionsTable
239-
240243
/// Clear a project from the project table
241244
memberthis.ClearInfoForProject(projectId:ProjectId)=
242-
projectOptionsTable.ClearInfoForProject(projectId)
243245
reactor.ClearOptionsByProjectId(projectId)
244246

245247
/// Clear a project from the single file project table
@@ -262,40 +264,28 @@ type internal FSharpProjectOptionsManager
262264
// compiled and #r will refer to files on disk
263265
letreferencedProjectFileNames=[||]
264266
letsite= ProjectSitesAndFiles.CreateProjectSiteForScript(fileName, referencedProjectFileNames, options)
265-
letdeps,projectOptions= ProjectSitesAndFiles.GetProjectOptionsForProjectSite(settings.LanguageServicePerformance.EnableInMemoryCrossProjectReferences, site, serviceProvider,(tryGetOrCreateProjectId fileName), fileName, options.ExtraProjectInfo, solution,Some projectOptionsTable)
267+
letdeps,projectOptions= ProjectSitesAndFiles.GetProjectOptionsForProjectSite(settings.LanguageServicePerformance.EnableInMemoryCrossProjectReferences, site, serviceProvider,(tryGetOrCreateProjectId fileName), fileName, options.ExtraProjectInfo, solution,None)
266268
letparsingOptions,_= checkerProvider.Checker.GetParsingOptionsFromProjectOptions(projectOptions)
267269
return(deps, parsingOptions, projectOptions)
268270
else
269271
letsite= ProjectSitesAndFiles.ProjectSiteOfSingleFile(fileName)
270-
letdeps,projectOptions= ProjectSitesAndFiles.GetProjectOptionsForProjectSite(settings.LanguageServicePerformance.EnableInMemoryCrossProjectReferences, site, serviceProvider,(tryGetOrCreateProjectId fileName), fileName, extraProjectInfo, solution,Some projectOptionsTable)
272+
letdeps,projectOptions= ProjectSitesAndFiles.GetProjectOptionsForProjectSite(settings.LanguageServicePerformance.EnableInMemoryCrossProjectReferences, site, serviceProvider,(tryGetOrCreateProjectId fileName), fileName, extraProjectInfo, solution,None)
271273
letparsingOptions,_= checkerProvider.Checker.GetParsingOptionsFromProjectOptions(projectOptions)
272274
return(deps, parsingOptions, projectOptions)
273275
}
274276

275-
/// Update the info for a project in the project table
276-
memberthis.UpdateProjectInfo(tryGetOrCreateProjectId,projectId,site,userOpName,invalidateConfig,solution)=
277-
Logger.Log LogEditorFunctionId.LanguageService_UpdateProjectInfo
278-
projectOptionsTable.AddOrUpdateProject(projectId,(fun isRefresh->
279-
letextraProjectInfo= Some(box workspace)
280-
letreferencedProjects,projectOptions= ProjectSitesAndFiles.GetProjectOptionsForProjectSite(settings.LanguageServicePerformance.EnableInMemoryCrossProjectReferences, site, serviceProvider, Some(projectId), site.ProjectFileName, extraProjectInfo, solution, Some projectOptionsTable)
281-
if invalidateConfigthen checkerProvider.Checker.InvalidateConfiguration(projectOptions, startBackgroundCompileIfAlreadySeen=not isRefresh, userOpName= userOpName+".UpdateProjectInfo")
282-
letreferencedProjectIds= referencedProjects|> Array.choose tryGetOrCreateProjectId
283-
letparsingOptions,_= checkerProvider.Checker.GetParsingOptionsFromProjectOptions(projectOptions)
284-
referencedProjectIds, parsingOptions, Some site, projectOptions))
285-
286277
/// Get compilation defines relevant for syntax processing.
287278
/// Quicker then TryGetOptionsForDocumentOrProject as it doesn't need to recompute the exact project
288279
/// options for a script.
289280
memberthis.GetCompilationDefinesForEditingDocument(document:Document)=
290-
letprojectOptionsOpt= this.TryGetOptionsForProject(document.Project.Id)
291-
letparsingOptions=
292-
match projectOptionsOptwith
293-
| Some(parsingOptions,_site,_projectOptions)-> parsingOptions
281+
letparsingOptions=
282+
match reactor.TryGetCachedOptionsByProjectId(document.Project.Id)with
283+
| Some(_, parsingOptions,_)-> parsingOptions
294284
|_->{ FSharpParsingOptions.Defaultwith IsInteractive= IsScript document.Name}
295-
CompilerEnvironment.GetCompilationDefinesForEditing parsingOptions
285+
CompilerEnvironment.GetCompilationDefinesForEditing parsingOptions
296286

297-
/// Try and get the Options for aproject
298-
memberthis.TryGetOptionsForProject(projectId:ProjectId)= projectOptionsTable.TryGetOptionsForProject(projectId)
287+
memberthis.TryGetOptionsByProject(project)=
288+
reactor.TryGetOptionsByProjectAsync(project)
299289

300290
/// Get the exact options for a document or project
301291
memberthis.TryGetOptionsForDocumentOrProject(document:Document)=
@@ -340,33 +330,11 @@ type internal FSharpProjectOptionsManager
340330
return result|> Option.map(fun(parsingOptions,_,projectOptions)-> parsingOptions, projectOptions)
341331
}
342332

343-
/// get a siteprovider
344-
memberthis.ProvideProjectSiteProvider(project:Project)= provideProjectSiteProvider(workspace, project, serviceProvider, Some projectOptionsTable)
345-
346-
/// Tell the checker to update the project info for the specified project id
347-
memberthis.UpdateProjectInfoWithProjectId(projectId:ProjectId,userOpName,invalidateConfig,solution)=
348-
lethier= workspace.GetHierarchy(projectId)
349-
match hierwith
350-
|null->()
351-
| hwhen(h.IsCapabilityMatch("CPS"))->
352-
letproject= workspace.CurrentSolution.GetProject(projectId)
353-
ifnot(isNull project)then
354-
letsiteProvider= this.ProvideProjectSiteProvider(project)
355-
letprojectSite= siteProvider.GetProjectSite()
356-
if projectSite.CompilationSourceFiles.Length<>0then
357-
this.UpdateProjectInfo(tryGetOrCreateProjectId, projectId, projectSite, userOpName, invalidateConfig, solution)
358-
|_->()
359-
360-
/// Tell the checker to update the project info for the specified project id
361-
memberthis.UpdateDocumentInfoWithProjectId(projectId:ProjectId,documentId:DocumentId,userOpName,invalidateConfig,solution)=
362-
if workspace.IsDocumentOpen(documentId)then
363-
this.UpdateProjectInfoWithProjectId(projectId, userOpName, invalidateConfig, solution)
364-
365333
[<Export>]
366334
/// This handles commandline change notifications from the Dotnet Project-system
367335
/// Prior to VS 15.7 path contained path to project file, post 15.7 contains target binpath
368336
/// binpath is more accurate because a project file can have multiple in memory projects based on configuration
369-
memberthis.HandleCommandLineChanges(path:string,sources:ImmutableArray<CommandLineSourceFile>,references:ImmutableArray<CommandLineReference>,options:ImmutableArray<string>)=
337+
member__.HandleCommandLineChanges(path:string,sources:ImmutableArray<CommandLineSourceFile>,references:ImmutableArray<CommandLineReference>,options:ImmutableArray<string>)=
370338
use _logBlock= Logger.LogBlock(LogEditorFunctionId.LanguageService_HandleCommandLineArgs)
371339

372340
letprojectId=
@@ -381,6 +349,6 @@ type internal FSharpProjectOptionsManager
381349
letsourcePaths= sources|> Seq.map(fun s-> fullPath s.Path)|> Seq.toArray
382350
letreferencePaths= references|> Seq.map(fun r-> fullPath r.Reference)|> Seq.toArray
383351

384-
projectOptionsTable.SetOptionsWithProjectId(projectId, sourcePaths, referencePaths, options.ToArray())
352+
reactor.SetCpsCommandLineOptions(projectId, DateTime.UtcNow, sourcePaths, referencePaths, options.ToArray())
385353

386354
member__.Checker= checkerProvider.Checker

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

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,15 @@ type internal LegacyProjectWorkspaceMap(workspace: VisualStudioWorkspaceImpl,
3232
letlegacyProjectLookup= ConcurrentDictionary()
3333
letsetupQueue= ConcurrentQueue()
3434

35-
lettryGetOrCreateProjectId(workspace:VisualStudioWorkspaceImpl)(projectFileName:string)=
36-
letprojectDisplayName= projectDisplayNameOf projectFileName
37-
Some(workspace.ProjectTracker.GetOrCreateProjectIdForPath(projectFileName, projectDisplayName))
38-
3935
do
4036
solution.AdviseSolutionEvents(this)|> ignore
4137

4238
/// Sync the Roslyn information for the project held in 'projectContext' to match the information given by 'site'.
4339
/// Also sync the info in ProjectInfoManager if necessary.
44-
memberthis.SyncLegacyProject(projectId:ProjectId,projectContext:IWorkspaceProjectContext,site:IProjectSite,workspace:VisualStudioWorkspaceImpl,forceUpdate,userOpName)=
40+
memberthis.SyncLegacyProject(projectId:ProjectId,projectContext:IWorkspaceProjectContext,site:IProjectSite)=
4541
letwellFormedFilePathSetIgnoreCase(paths:seq<string>)=
4642
HashSet(paths|> Seq.filter isPathWellFormed|> Seq.map(fun s->try Path.GetFullPath(s)with_-> s), StringComparer.OrdinalIgnoreCase)
4743

48-
let mutableupdated= forceUpdate
49-
5044
// Sync the source files in projectContext. Note that these source files are __not__ maintained in order in projectContext
5145
// as edits are made. It seems this is ok because the source file list is only used to drive roslyn per-file checking.
5246
letupdatedFiles= site.CompilationSourceFiles|> wellFormedFilePathSetIgnoreCase
@@ -58,12 +52,10 @@ type internal LegacyProjectWorkspaceMap(workspace: VisualStudioWorkspaceImpl,
5852
for filein updatedFilesdo
5953
ifnot(originalFiles.Contains(file))then
6054
projectContext.AddSourceFile(file)
61-
updated<-true
6255

6356
for filein originalFilesdo
6457
ifnot(updatedFiles.Contains(file))then
6558
projectContext.RemoveSourceFile(file)
66-
updated<-true
6759

6860
letupdatedRefs= site.CompilationReferences|> wellFormedFilePathSetIgnoreCase
6961
letoriginalRefs=
@@ -74,12 +66,10 @@ type internal LegacyProjectWorkspaceMap(workspace: VisualStudioWorkspaceImpl,
7466
for refin updatedRefsdo
7567
ifnot(originalRefs.Contains(ref))then
7668
projectContext.AddMetadataReference(ref, MetadataReferenceProperties.Assembly)
77-
updated<-true
7869

7970
for refin originalRefsdo
8071
ifnot(updatedRefs.Contains(ref))then
8172
projectContext.RemoveMetadataReference(ref)
82-
updated<-true
8373

8474
// Update the project options association
8575
letok,originalOptions= optionsAssociation.TryGetValue(projectContext)
@@ -99,17 +89,10 @@ type internal LegacyProjectWorkspaceMap(workspace: VisualStudioWorkspaceImpl,
9989
if okthen optionsAssociation.Remove(projectContext)|> ignore
10090
optionsAssociation.Add(projectContext, updatedOptions)
10191

102-
updated<-true
103-
104-
// update the cached options
105-
if updatedthen
106-
projectInfoManager.UpdateProjectInfo(tryGetOrCreateProjectId workspace, projectId, site, userOpName+".SyncLegacyProject", invalidateConfig=true, solution=workspace.CurrentSolution)
107-
10892
letinfo=(updatedFiles, updatedRefs)
10993
legacyProjectLookup.AddOrUpdate(projectId, info,fun _ _-> info)|> ignore
11094

111-
memberthis.SetupLegacyProjectFile(siteProvider:IProvideProjectSite,workspace:VisualStudioWorkspaceImpl,userOpName)=
112-
letuserOpName= userOpName+".SetupProjectFile"
95+
memberthis.SetupLegacyProjectFile(siteProvider:IProvideProjectSite,workspace:VisualStudioWorkspaceImpl)=
11396
let recsetup(site:IProjectSite)=
11497
letprojectGuid= Guid(site.ProjectGuid)
11598
letprojectFileName= site.ProjectFileName
@@ -138,13 +121,13 @@ type internal LegacyProjectWorkspaceMap(workspace: VisualStudioWorkspaceImpl,
138121
letrealProjectId= workspace.ProjectTracker.GetOrCreateProjectIdForPath(projectFileName, projectDisplayName)
139122

140123
// Sync IProjectSite --> projectContext, and IProjectSite --> ProjectInfoManage
141-
this.SyncLegacyProject(realProjectId, projectContext, site, workspace, forceUpdate=true, userOpName=userOpName)
124+
this.SyncLegacyProject(realProjectId, projectContext, site)
142125

143126
site.BuildErrorReporter<- Some(projectContext:?> Microsoft.VisualStudio.Shell.Interop.IVsLanguageServiceBuildErrorReporter2)
144127

145128
// TODO: consider forceUpdate = false here. forceUpdate=true may be causing repeated computation?
146129
site.AdviseProjectSiteChanges(FSharpConstants.FSharpLanguageServiceCallbackName,
147-
AdviseProjectSiteChanges(fun()-> this.SyncLegacyProject(realProjectId, projectContext, site, workspace, forceUpdate=true, userOpName="AdviseProjectSiteChanges."+userOpName)))
130+
AdviseProjectSiteChanges(fun()-> this.SyncLegacyProject(realProjectId, projectContext, site)))
148131

149132
site.AdviseProjectSiteClosed(FSharpConstants.FSharpLanguageServiceCallbackName,
150133
AdviseProjectSiteChanges(fun()->
@@ -167,7 +150,7 @@ type internal LegacyProjectWorkspaceMap(workspace: VisualStudioWorkspaceImpl,
167150
member__.OnAfterOpenProject(hier,_)=
168151
match hierwith
169152
|:? IProvideProjectSiteas siteProvider->
170-
letsetup=fun()-> this.SetupLegacyProjectFile(siteProvider, workspace,"LegacyProjectWorkspaceMap.OnAfterOpenProject")
153+
letsetup=fun()-> this.SetupLegacyProjectFile(siteProvider, workspace)
171154
let_,o= solution.GetProperty(int__VSPROPID.VSPROPID_IsSolutionOpen)
172155
if(match owith|:? boolas isOpen-> isOpen|_->false)then
173156
setup()

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ module internal SymbolHelpers =
4444
projects
4545
|> Seq.map(fun project->
4646
async{
47-
match projectInfoManager.TryGetOptionsForProject(project.Id)with
48-
| Some(_parsingOptions,_site,projectOptions)->
47+
match! projectInfoManager.TryGetOptionsByProject(project)with
48+
| Some(_parsingOptions, projectOptions)->
4949
let!projectCheckResults= checker.ParseAndCheckProject(projectOptions, userOpName= userOpName)
5050
let!uses= projectCheckResults.GetUsesOfSymbol(symbol)
5151
letdistinctUses= uses|> Array.distinctBy(fun symbolUse-> symbolUse.RangeAlternate)

‎vsintegration/src/FSharp.Editor/Navigation/NavigateToSearchService.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ type internal FSharpNavigateToSearchService
247247
interface INavigateToSearchService_RemoveInterfaceAboveAndRenameThisAfterInternalsVisibleToUsersUpdatewith
248248
member__.SearchProjectAsync(project,_priorityDocuments,searchPattern,kinds,cancellationToken):Task<ImmutableArray<INavigateToSearchResult>>=
249249
asyncMaybe{
250-
let!parsingOptions,_site,_options= projectInfoManager.TryGetOptionsForProject(project.Id)
250+
let!parsingOptions,_options= projectInfoManager.TryGetOptionsByProject(project)
251251
let!items=
252252
project.Documents
253253
|> Seq.map(fun document-> getCachedIndexedNavigableItems(document, parsingOptions, kinds))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp