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

Commit4156112

Browse files
authored
Merge pull requestdotnet#5886 from Microsoft/merges/dev16.0-preview1-to-dev16.0
Merge dev16.0-preview1 to dev16.0
2 parents8f68b85 +729adcb commit4156112

File tree

11 files changed

+341
-174
lines changed

11 files changed

+341
-174
lines changed

‎vsintegration/src/FSharp.Editor/Diagnostics/UnusedDeclarationsAnalyzer.fs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ type internal UnusedDeclarationsAnalyzer() =
106106

107107
do Trace.TraceInformation("{0:n3} (start) UnusedDeclarationsAnalyzer", DateTime.Now.TimeOfDay.TotalSeconds)
108108
do! Async.Sleep DefaultTuning.UnusedDeclarationsAnalyzerInitialDelay|> liftAsync// be less intrusive, give other work priority most of the time
109-
match getProjectInfoManager(document).TryGetOptionsForEditingDocumentOrProject(document)with
110-
|Some(_parsingOptions, projectOptions)->
109+
match! getProjectInfoManager(document).TryGetOptionsForEditingDocumentOrProject(document)with
110+
|(_parsingOptions, projectOptions)->
111111
let!sourceText= document.GetTextAsync()
112112
letchecker= getChecker document
113113
let!_,_,checkResults= checker.ParseAndCheckDocument(document, projectOptions, sourceText= sourceText, userOpName= userOpName)
@@ -117,7 +117,6 @@ type internal UnusedDeclarationsAnalyzer() =
117117
unusedRanges
118118
|> Seq.map(fun m-> Diagnostic.Create(Descriptor, RoslynHelpers.RangeToLocation(m, sourceText, document.FilePath)))
119119
|> Seq.toImmutableArray
120-
| None->return ImmutableArray.Empty
121120
}
122121
|> Async.map(Option.defaultValue ImmutableArray.Empty)
123122
|> RoslynHelpers.StartAsyncAsTask cancellationToken

‎vsintegration/src/FSharp.Editor/Formatting/EditorFormattingService.fs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ type internal FSharpEditorFormattingService
151151
let!sourceText= document.GetTextAsync(cancellationToken)|> Async.AwaitTask
152152
let!options= document.GetOptionsAsync(cancellationToken)|> Async.AwaitTask
153153
letindentStyle= options.GetOption(FormattingOptions.SmartIndent, FSharpConstants.FSharpLanguageName)
154-
letprojectOptionsOpt= projectInfoManager.TryGetOptionsForEditingDocumentOrProject document
154+
let!projectOptionsOpt= projectInfoManager.TryGetOptionsForEditingDocumentOrProject document
155155
let!textChange= FSharpEditorFormattingService.GetFormattingChanges(document.Id, sourceText, document.FilePath, checkerProvider.Checker, indentStyle, projectOptionsOpt, position)
156156
return textChange|> Option.toList|> toIList
157157
}
@@ -162,7 +162,7 @@ type internal FSharpEditorFormattingService
162162
let!options= document.GetOptionsAsync(cancellationToken)|> Async.AwaitTask
163163
lettabSize= options.GetOption<int>(FormattingOptions.TabSize, FSharpConstants.FSharpLanguageName)
164164

165-
match projectInfoManager.TryGetOptionsForEditingDocumentOrProject documentwith
165+
match! projectInfoManager.TryGetOptionsForEditingDocumentOrProject documentwith
166166
| Some(parsingOptions,_)->
167167
let!textChanges= FSharpEditorFormattingService.GetPasteChanges(document.Id, sourceText, document.FilePath, settings.Formatting, tabSize, parsingOptions, currentClipboard, span)
168168
return textChanges|> Option.defaultValue Seq.empty|> toIList

‎vsintegration/src/FSharp.Editor/Formatting/IndentationService.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ type internal FSharpIndentationService
100100
let!options= document.GetOptionsAsync(cancellationToken)|> Async.AwaitTask
101101
lettabSize= options.GetOption<int>(FormattingOptions.TabSize, FSharpConstants.FSharpLanguageName)
102102
letindentStyle= options.GetOption(FormattingOptions.SmartIndent, FSharpConstants.FSharpLanguageName)
103-
letprojectOptionsOpt= projectInfoManager.TryGetOptionsForEditingDocumentOrProject document
103+
let!projectOptionsOpt= projectInfoManager.TryGetOptionsForEditingDocumentOrProject document
104104
letindent= FSharpIndentationService.GetDesiredIndentation(document.Id, sourceText, document.FilePath, lineNumber, tabSize, indentStyle, projectOptionsOpt)
105105
return
106106
match indentwith

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

Lines changed: 242 additions & 60 deletions
Large diffs are not rendered by default.

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ type internal FSharpLanguageService(package : FSharpPackage, solution: IVsSoluti
206206
letprojectDisplayName= projectDisplayNameOf projectFileName
207207
Some(workspace.ProjectTracker.GetOrCreateProjectIdForPath(projectFileName, projectDisplayName))
208208

209-
letmutablelegacyProjectWorkspaceMap= Unchecked.defaultof<LegacyProjectWorkspaceMap>
209+
let_legacyProjectWorkspaceMap=new LegacyProjectWorkspaceMap(solution, projectInfoManager, package.ComponentModel.GetService<IWorkspaceProjectContextFactory>())
210210

211211
overridethis.Initialize()=
212212
base.Initialize()
@@ -216,9 +216,6 @@ type internal FSharpLanguageService(package : FSharpPackage, solution: IVsSoluti
216216

217217
this.Workspace.DocumentClosed.Add<|fun args-> tryRemoveSingleFileProject args.Document.Project.Id
218218

219-
legacyProjectWorkspaceMap<- LegacyProjectWorkspaceMap(this.Workspace, solution, projectInfoManager, package.ComponentModel.GetService<IWorkspaceProjectContextFactory>(), this.SystemServiceProvider)
220-
legacyProjectWorkspaceMap.Initialize()
221-
222219
lettheme= package.ComponentModel.DefaultExportProvider.GetExport<ISetThemeColors>().Value
223220
theme.SetColors()
224221

@@ -240,7 +237,7 @@ type internal FSharpLanguageService(package : FSharpPackage, solution: IVsSoluti
240237

241238
singleFileProjects.[projectId]<- projectContext
242239

243-
let_referencedProjectFileNames,parsingOptions,projectOptions= projectInfoManager.ComputeSingleFileOptions(tryGetOrCreateProjectId workspace, fileName, loadTime, fileContents)|> Async.RunSynchronously
240+
let_referencedProjectFileNames,parsingOptions,projectOptions= projectInfoManager.ComputeSingleFileOptions(tryGetOrCreateProjectId workspace, fileName, loadTime, fileContents, workspace.CurrentSolution)|> Async.RunSynchronously
244241
projectInfoManager.AddOrUpdateSingleFileProject(projectId,(loadTime, parsingOptions, projectOptions))
245242

246243
overridethis.ContentTypeName= FSharpConstants.FSharpContentTypeName

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

Lines changed: 67 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,28 @@ open Microsoft.VisualStudio.LanguageServices.ProjectSystem
2020
openMicrosoft.VisualStudio.Shell.Interop
2121

2222
[<Sealed>]
23-
typeinternalLegacyProjectWorkspaceMap(workspace: VisualStudioWorkspaceImpl,
24-
solution: IVsSolution,
23+
typeinternalLegacyProjectWorkspaceMap(solution: IVsSolution,
2524
projectInfoManager: FSharpProjectOptionsManager,
26-
projectContextFactory: IWorkspaceProjectContextFactory,
27-
serviceProvider: IServiceProvider)as this=
25+
projectContextFactory: IWorkspaceProjectContextFactory)as this=
2826

2927
letinvalidPathChars= set(Path.GetInvalidPathChars())
3028
letoptionsAssociation= ConditionalWeakTable<IWorkspaceProjectContext, string[]>()
3129
letisPathWellFormed(path:string)=not(String.IsNullOrWhiteSpace path)&& path|> Seq.forall(fun c->not(Set.contains c invalidPathChars))
3230

31+
letlegacyProjectIdLookup= ConcurrentDictionary()
3332
letlegacyProjectLookup= ConcurrentDictionary()
33+
letsetupQueue= ConcurrentQueue()
3434

35-
lettryGetOrCreateProjectId(workspace:VisualStudioWorkspaceImpl)(projectFileName:string)=
36-
letprojectDisplayName= projectDisplayNameOf projectFileName
37-
Some(workspace.ProjectTracker.GetOrCreateProjectIdForPath(projectFileName, projectDisplayName))
38-
39-
memberthis.Initialize()=
35+
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(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-
letmutableupdated= forceUpdate
44+
letprojectId= projectContext.Id
4945

5046
// Sync the source files in projectContext. Note that these source files are __not__ maintained in order in projectContext
5147
// as edits are made. It seems this is ok because the source file list is only used to drive roslyn per-file checking.
@@ -58,12 +54,10 @@ type internal LegacyProjectWorkspaceMap(workspace: VisualStudioWorkspaceImpl,
5854
for filein updatedFilesdo
5955
ifnot(originalFiles.Contains(file))then
6056
projectContext.AddSourceFile(file)
61-
updated<-true
6257

6358
for filein originalFilesdo
6459
ifnot(updatedFiles.Contains(file))then
6560
projectContext.RemoveSourceFile(file)
66-
updated<-true
6761

6862
letupdatedRefs= site.CompilationReferences|> wellFormedFilePathSetIgnoreCase
6963
letoriginalRefs=
@@ -74,12 +68,10 @@ type internal LegacyProjectWorkspaceMap(workspace: VisualStudioWorkspaceImpl,
7468
for refin updatedRefsdo
7569
ifnot(originalRefs.Contains(ref))then
7670
projectContext.AddMetadataReference(ref, MetadataReferenceProperties.Assembly)
77-
updated<-true
7871

7972
for refin originalRefsdo
8073
ifnot(updatedRefs.Contains(ref))then
8174
projectContext.RemoveMetadataReference(ref)
82-
updated<-true
8375

8476
// Update the project options association
8577
letok,originalOptions= optionsAssociation.TryGetValue(projectContext)
@@ -99,94 +91,93 @@ type internal LegacyProjectWorkspaceMap(workspace: VisualStudioWorkspaceImpl,
9991
if okthen optionsAssociation.Remove(projectContext)|> ignore
10092
optionsAssociation.Add(projectContext, updatedOptions)
10193

102-
updated<-true
103-
104-
// update the cached options
105-
if updatedthen
106-
projectInfoManager.UpdateProjectInfo(tryGetOrCreateProjectId workspace, projectId, site, userOpName+".SyncLegacyProject", invalidateConfig=true)
94+
projectContext.BinOutputPath<- Option.toObj site.CompilationBinOutputPath
10795

10896
letinfo=(updatedFiles, updatedRefs)
10997
legacyProjectLookup.AddOrUpdate(projectId, info,fun _ _-> info)|> ignore
11098

111-
memberthis.SetupLegacyProjectFile(siteProvider:IProvideProjectSite,workspace:VisualStudioWorkspaceImpl,userOpName)=
112-
letuserOpName= userOpName+".SetupProjectFile"
113-
let recsetup(site:IProjectSite)=
99+
memberthis.SetupLegacyProjectFile(siteProvider:IProvideProjectSite)=
100+
let recsetup(site:IProjectSite)=
114101
letprojectGuid= Guid(site.ProjectGuid)
115102
letprojectFileName= site.ProjectFileName
116103
letprojectDisplayName= projectDisplayNameOf projectFileName
117104

118-
// This projectId is not guaranteed to be the same ProjectId that will actually be created once we call CreateProjectContext
119-
// in Roslyn versions once https://github.com/dotnet/roslyn/pull/26931 is merged. Roslyn will still guarantee that once
120-
// there is a project in the workspace with the same path, it'll return the ID of that. So this is sufficient to use
121-
// in that case as long as we only use it to call GetProject.
122-
letfakeProjectId= workspace.ProjectTracker.GetOrCreateProjectIdForPath(projectFileName, projectDisplayName)
123-
124-
if isNull(workspace.ProjectTracker.GetProject fakeProjectId)then
125-
lethierarchy=
126-
site.ProjectProvider
127-
|> Option.map(fun p-> p:?> IVsHierarchy)
128-
|> Option.toObj
129-
130-
// Roslyn is expecting site to be an IVsHierarchy.
131-
// It just so happens that the object that implements IProvideProjectSite is also
132-
// an IVsHierarchy. This assertion is to ensure that the assumption holds true.
133-
Debug.Assert(not(isNull hierarchy),"About to CreateProjectContext with a non-hierarchy site")
134-
135-
letprojectContext=
136-
projectContextFactory.CreateProjectContext(
137-
FSharpConstants.FSharpLanguageName,
138-
projectDisplayName,
139-
projectFileName,
140-
projectGuid,
141-
hierarchy,
142-
Option.toObj site.CompilationBinOutputPath)
143-
144-
// The real project ID that was actually added. See comments for fakeProjectId why this one is actually good.
145-
letrealProjectId= workspace.ProjectTracker.GetOrCreateProjectIdForPath(projectFileName, projectDisplayName)
146-
147-
// Sync IProjectSite --> projectContext, and IProjectSite --> ProjectInfoManage
148-
this.SyncLegacyProject(realProjectId, projectContext, site, workspace, forceUpdate=true, userOpName=userOpName)
149-
150-
site.BuildErrorReporter<- Some(projectContext:?> Microsoft.VisualStudio.Shell.Interop.IVsLanguageServiceBuildErrorReporter2)
151-
152-
// TODO: consider forceUpdate = false here. forceUpdate=true may be causing repeated computation?
153-
site.AdviseProjectSiteChanges(FSharpConstants.FSharpLanguageServiceCallbackName,
154-
AdviseProjectSiteChanges(fun()-> this.SyncLegacyProject(realProjectId, projectContext, site, workspace, forceUpdate=true, userOpName="AdviseProjectSiteChanges."+userOpName)))
155-
156-
site.AdviseProjectSiteClosed(FSharpConstants.FSharpLanguageServiceCallbackName,
157-
AdviseProjectSiteChanges(fun()->
158-
projectInfoManager.ClearInfoForProject(realProjectId)
159-
optionsAssociation.Remove(projectContext)|> ignore
160-
projectContext.Dispose()))
161-
162-
for referencedSitein ProjectSitesAndFiles.GetReferencedProjectSites(Some realProjectId, site, serviceProvider, Some(workspace:>obj), Some projectInfoManager.FSharpOptions)do
163-
setup referencedSite
105+
lethierarchy=
106+
site.ProjectProvider
107+
|> Option.map(fun p-> p:?> IVsHierarchy)
108+
|> Option.toObj
109+
110+
// Roslyn is expecting site to be an IVsHierarchy.
111+
// It just so happens that the object that implements IProvideProjectSite is also
112+
// an IVsHierarchy. This assertion is to ensure that the assumption holds true.
113+
Debug.Assert(not(isNull hierarchy),"About to CreateProjectContext with a non-hierarchy site")
114+
115+
letprojectContext=
116+
projectContextFactory.CreateProjectContext(
117+
FSharpConstants.FSharpLanguageName,
118+
projectDisplayName,
119+
projectFileName,
120+
projectGuid,
121+
hierarchy,
122+
Option.toObj site.CompilationBinOutputPath)
123+
124+
legacyProjectIdLookup.[projectGuid]<- projectContext.Id
125+
126+
// Sync IProjectSite --> projectContext, and IProjectSite --> ProjectInfoManage
127+
this.SyncLegacyProject(projectContext, site)
128+
129+
site.BuildErrorReporter<- Some(projectContext:?> Microsoft.VisualStudio.Shell.Interop.IVsLanguageServiceBuildErrorReporter2)
130+
131+
// TODO: consider forceUpdate = false here. forceUpdate=true may be causing repeated computation?
132+
site.AdviseProjectSiteChanges(FSharpConstants.FSharpLanguageServiceCallbackName,
133+
AdviseProjectSiteChanges(fun()-> this.SyncLegacyProject(projectContext, site)))
134+
135+
site.AdviseProjectSiteClosed(FSharpConstants.FSharpLanguageServiceCallbackName,
136+
AdviseProjectSiteChanges(fun()->
137+
projectInfoManager.ClearInfoForProject(projectContext.Id)
138+
optionsAssociation.Remove(projectContext)|> ignore
139+
projectContext.Dispose()))
164140

165141
setup(siteProvider.GetProjectSite())
166142

167143
interface IVsSolutionEventswith
168144

169-
member__.OnAfterCloseSolution(_)= VSConstants.S_OK
145+
member__.OnAfterCloseSolution(_)=
146+
// Clear
147+
let mutablesetup= Unchecked.defaultof<_>
148+
while setupQueue.TryDequeue(&setup)do()
149+
VSConstants.S_OK
170150

171151
member__.OnAfterLoadProject(_,_)= VSConstants.S_OK
172152

173153
member__.OnAfterOpenProject(hier,_)=
174154
match hierwith
175155
|:? IProvideProjectSiteas siteProvider->
176-
this.SetupLegacyProjectFile(siteProvider, workspace,"LegacyProjectWorkspaceMap.Initialize")
156+
letsetup=fun()-> this.SetupLegacyProjectFile(siteProvider)
157+
let_,o= solution.GetProperty(int__VSPROPID.VSPROPID_IsSolutionOpen)
158+
if(match owith|:? boolas isOpen-> isOpen|_->false)then
159+
setup()
160+
else
161+
setupQueue.Enqueue(setup)
177162
|_->()
178163
VSConstants.S_OK
179164

180-
member__.OnAfterOpenSolution(_,_)= VSConstants.S_OK
165+
member__.OnAfterOpenSolution(_,_)=
166+
let mutablesetup= Unchecked.defaultof<_>
167+
while setupQueue.TryDequeue(&setup)do
168+
setup()
169+
VSConstants.S_OK
181170

182171
member__.OnBeforeCloseProject(hier,_)=
183172
match hierwith
184173
|:? IProvideProjectSiteas siteProvider->
185174
letsite= siteProvider.GetProjectSite()
186-
letprojectFileName= site.ProjectFileName
187-
letprojectDisplayName= projectDisplayNameOf projectFileName
188-
letprojectId= workspace.ProjectTracker.GetOrCreateProjectIdForPath(projectFileName, projectDisplayName)
189-
legacyProjectLookup.TryRemove(projectId)|> ignore
175+
letprojectGuid= Guid(site.ProjectGuid)
176+
match legacyProjectIdLookup.TryGetValue(projectGuid)with
177+
|true, projectId->
178+
legacyProjectIdLookup.TryRemove(projectGuid)|> ignore
179+
legacyProjectLookup.TryRemove(projectId)|> ignore
180+
|_->()
190181
|_->()
191182
VSConstants.S_OK
192183

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp