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

Commit0e2da7d

Browse files
remove Async.AwaitTask boilerplate
1 parent17f85d2 commit0e2da7d

File tree

21 files changed

+61
-59
lines changed

21 files changed

+61
-59
lines changed

‎vsintegration/src/FSharp.Editor/Classification/ColorizationService.fs‎

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,17 @@ namespace Microsoft.VisualStudio.FSharp.Editor
44

55
openSystem
66
openSystem.Composition
7-
openSystem.Collections.Concurrent
87
openSystem.Collections.Generic
9-
openSystem.Linq
108
openSystem.Threading
11-
openSystem.Threading.Tasks
129
openSystem.Runtime.CompilerServices
1310

1411
openMicrosoft.CodeAnalysis
1512
openMicrosoft.CodeAnalysis.Classification
1613
openMicrosoft.CodeAnalysis.Editor
17-
openMicrosoft.CodeAnalysis.Editor.Implementation.Classification
18-
openMicrosoft.CodeAnalysis.Editor.Implementation.BlockCommentEditing
19-
openMicrosoft.CodeAnalysis.Editor.Shared.Utilities
2014
openMicrosoft.CodeAnalysis.Host.Mef
2115
openMicrosoft.CodeAnalysis.Text
2216

2317
openMicrosoft.VisualStudio.FSharp.LanguageService
24-
openMicrosoft.VisualStudio.Text
25-
openMicrosoft.VisualStudio.Text.Tagging
26-
openMicrosoft.VisualStudio.Text.Operations
27-
openMicrosoft.VisualStudio.Utilities
2818

2919
openMicrosoft.FSharp.Compiler.SourceCodeServices
3020

@@ -42,16 +32,16 @@ type internal FSharpColorizationService
4232
memberthis.AddSyntacticClassificationsAsync(document:Document,textSpan:TextSpan,result:List<ClassifiedSpan>,cancellationToken:CancellationToken)=
4333
async{
4434
letdefines= projectInfoManager.GetCompilationDefinesForEditingDocument(document)
45-
let!sourceText= document.GetTextAsync(cancellationToken)|> Async.AwaitTask
35+
let!sourceText= document.GetTextAsync(cancellationToken)
4636
result.AddRange(CommonHelpers.getColorizationData(document.Id, sourceText, textSpan, Some(document.FilePath), defines, cancellationToken))
4737
}|> CommonRoslynHelpers.StartAsyncUnitAsTask cancellationToken
4838

4939
memberthis.AddSemanticClassificationsAsync(document:Document,textSpan:TextSpan,result:List<ClassifiedSpan>,cancellationToken:CancellationToken)=
5040
async{
5141
match projectInfoManager.TryGetOptionsForEditingDocumentOrProject(document)with
5242
| Some options->
53-
let!sourceText= document.GetTextAsync(cancellationToken)|> Async.AwaitTask
54-
let!textVersion= document.GetTextVersionAsync(cancellationToken)|> Async.AwaitTask
43+
let!sourceText= document.GetTextAsync(cancellationToken)
44+
let!textVersion= document.GetTextVersionAsync(cancellationToken)
5545
let!_parseResults,checkResultsAnswer= checkerProvider.Checker.ParseAndCheckFileInProject(document.FilePath, textVersion.GetHashCode(), sourceText.ToString(), options)
5646

5747
letextraColorizationData=

‎vsintegration/src/FSharp.Editor/CodeFix/AddNewKeywordToDisposableConstructorInvocation.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type internal FSharpAddNewKeywordCodeFixProvider() =
2525
title,
2626
(fun(cancellationToken: CancellationToken)->
2727
async{
28-
let!sourceText= context.Document.GetTextAsync()|> Async.AwaitTask
28+
let!sourceText= context.Document.GetTextAsync()
2929
return context.Document.WithText(sourceText.WithChanges(TextChange(TextSpan(context.Span.Start,0),"new")))
3030
}|> CommonRoslynHelpers.StartAsyncAsTask(cancellationToken)),
3131
title),(context.Diagnostics|> Seq.filter(fun x-> this.FixableDiagnosticIds.Contains x.Id)).ToImmutableArray())

‎vsintegration/src/FSharp.Editor/CodeFix/AddOpenCodeFixProvider.fs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ type internal FSharpAddOpenCodeFixProvider
118118
fixUnderscoresInMenuText fullName,
119119
fun(cancellationToken: CancellationToken)->
120120
async{
121-
let!sourceText= context.Document.GetTextAsync()|> Async.AwaitTask
121+
let!sourceText= context.Document.GetTextAsync()
122122
return context.Document.WithText(sourceText.Replace(context.Span, qualifier))
123123
}|> CommonRoslynHelpers.StartAsyncAsTask(cancellationToken))
124124

@@ -129,7 +129,7 @@ type internal FSharpAddOpenCodeFixProvider
129129
fixUnderscoresInMenuText displayText,
130130
(fun(cancellationToken: CancellationToken)->
131131
async{
132-
let!sourceText= context.Document.GetTextAsync()|> Async.AwaitTask
132+
let!sourceText= context.Document.GetTextAsync()
133133
return context.Document.WithText(InsertContext.insertOpenDeclaration sourceText ctx ns)
134134
}|> CommonRoslynHelpers.StartAsyncAsTask(cancellationToken)),
135135
displayText)
@@ -171,8 +171,8 @@ type internal FSharpAddOpenCodeFixProvider
171171
async{
172172
match projectInfoManager.TryGetOptionsForEditingDocumentOrProject context.Documentwith
173173
| Some options->
174-
let!sourceText= context.Document.GetTextAsync(context.CancellationToken)|> Async.AwaitTask
175-
let!textVersion= context.Document.GetTextVersionAsync(context.CancellationToken)|> Async.AwaitTask
174+
let!sourceText= context.Document.GetTextAsync(context.CancellationToken)
175+
let!textVersion= context.Document.GetTextVersionAsync(context.CancellationToken)
176176
let!parseResults,checkFileAnswer= checker.ParseAndCheckFileInProject(context.Document.FilePath, textVersion.GetHashCode(), sourceText.ToString(), options)
177177
match parseResults.ParseTree, checkFileAnswerwith
178178
| None,_

‎vsintegration/src/FSharp.Editor/CodeFix/PrefixUnusedValueWithUnderscore.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type internal FSharpPrefixUnusedValueWithUnderscoreCodeFixProvider() =
2222
title,
2323
(fun(cancellationToken: CancellationToken)->
2424
async{
25-
let!sourceText= context.Document.GetTextAsync()|> Async.AwaitTask
25+
let!sourceText= context.Document.GetTextAsync()
2626
return context.Document.WithText(sourceText.WithChanges(textChange))
2727
}|> CommonRoslynHelpers.StartAsyncAsTask(cancellationToken)),
2828
title)

‎vsintegration/src/FSharp.Editor/Commands/HelpContextService.fs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ type internal FSharpHelpContextService
108108
async{
109109
match projectInfoManager.TryGetOptionsForEditingDocumentOrProject(document)with
110110
| Some options->
111-
let!sourceText= document.GetTextAsync(cancellationToken)|> Async.AwaitTask
112-
let!textVersion= document.GetTextVersionAsync(cancellationToken)|> Async.AwaitTask
111+
let!sourceText= document.GetTextAsync(cancellationToken)
112+
let!textVersion= document.GetTextVersionAsync(cancellationToken)
113113
letdefines= projectInfoManager.GetCompilationDefinesForEditingDocument(document)
114114
lettextLine= sourceText.Lines.GetLineFromPosition(textSpan.Start)
115115
lettokens= CommonHelpers.getColorizationData(document.Id, sourceText, textLine.Span, Some document.Name, defines, cancellationToken)

‎vsintegration/src/FSharp.Editor/Common/CommonHelpers.fs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,3 +521,12 @@ module internal Extensions =
521521
let!result= input
522522
return f result
523523
}
524+
525+
typeAsyncBuilderwith
526+
member__.Bind(computation:System.Threading.Tasks.Task<'a>,binder:'a->Async<'b>):Async<'b>=
527+
async{
528+
let!a= Async.AwaitTask computation
529+
return! binder a
530+
}
531+
532+
member__.ReturnFrom(computation:System.Threading.Tasks.Task<'a>):Async<'a>= Async.AwaitTask computation

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ type internal ProjectInfoManager
146146
letloadTime,_= singleFileProjectTable.[projectId]
147147
letfileName= document.FilePath
148148
let!cancellationToken= Async.CancellationToken
149-
let!sourceText= document.GetTextAsync(cancellationToken)|> Async.AwaitTask
149+
let!sourceText= document.GetTextAsync(cancellationToken)
150150
let!options= this.ComputeSingleFileOptions(fileName, loadTime, sourceText.ToString(), document.Project.Solution.Workspace)
151151
singleFileProjectTable.[projectId]<-(loadTime, options)
152152
return Some options

‎vsintegration/src/FSharp.Editor/Completion/CompletionProvider.fs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ type internal FSharpCompletionProvider
130130
async{
131131
match projectInfoManager.TryGetOptionsForEditingDocumentOrProject(context.Document)with
132132
| Some options->
133-
let!sourceText= context.Document.GetTextAsync(context.CancellationToken)|> Async.AwaitTask
134-
let!textVersion= context.Document.GetTextVersionAsync(context.CancellationToken)|> Async.AwaitTask
133+
let!sourceText= context.Document.GetTextAsync(context.CancellationToken)
134+
let!textVersion= context.Document.GetTextVersionAsync(context.CancellationToken)
135135
let!results= FSharpCompletionProvider.ProvideCompletionsAsyncAux(checkerProvider.Checker, sourceText, context.Position, options, context.Document.FilePath, textVersion.GetHashCode())
136136
context.AddItems(results)
137137
| None->()

‎vsintegration/src/FSharp.Editor/Completion/SignatureHelp.fs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ type internal FSharpSignatureHelpProvider
246246
try
247247
match projectInfoManager.TryGetOptionsForEditingDocumentOrProject(document)with
248248
| Some options->
249-
let!sourceText= document.GetTextAsync(cancellationToken)|> Async.AwaitTask
250-
let!textVersion= document.GetTextVersionAsync(cancellationToken)|> Async.AwaitTask
249+
let!sourceText= document.GetTextAsync(cancellationToken)
250+
let!textVersion= document.GetTextVersionAsync(cancellationToken)
251251

252252
lettriggerTypedChar=
253253
if triggerInfo.TriggerCharacter.HasValue&& triggerInfo.TriggerReason= SignatureHelpTriggerReason.TypeCharCommandthen

‎vsintegration/src/FSharp.Editor/Debugging/BreakpointResolutionService.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ type internal FSharpBreakpointResolutionService
5555
async{
5656
match projectInfoManager.TryGetOptionsForEditingDocumentOrProject(document)with
5757
| Some options->
58-
let!sourceText= document.GetTextAsync(cancellationToken)|> Async.AwaitTask
58+
let!sourceText= document.GetTextAsync(cancellationToken)
5959
let!location= FSharpBreakpointResolutionService.GetBreakpointLocation(checkerProvider.Checker, sourceText, document.Name, textSpan, options)
6060
returnmatch locationwith
6161
| None->null

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp