Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
fsharp
提交
db6ce1b7
F
fsharp
项目概览
dotNET Platform
/
fsharp
12 个月 前同步成功
通知
0
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
fsharp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
db6ce1b7
编写于
4月 06, 2022
作者:
K
kerams
提交者:
GitHub
4月 06, 2022
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implement triple quoted interpolation code fix (#12945)
上级
08992b32
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
133 addition
and
1 deletion
+133
-1
src/fsharp/service/FSharpParseFileResults.fs
src/fsharp/service/FSharpParseFileResults.fs
+8
-0
src/fsharp/service/FSharpParseFileResults.fsi
src/fsharp/service/FSharpParseFileResults.fsi
+3
-0
tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected
...s/FSharp.CompilerService.SurfaceArea.netstandard.expected
+1
-0
vsintegration/src/FSharp.Editor/CodeFix/UseTripleQuotedInterpolation.fs
...src/FSharp.Editor/CodeFix/UseTripleQuotedInterpolation.fs
+51
-0
vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj
vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj
+1
-0
vsintegration/src/FSharp.Editor/FSharp.Editor.resx
vsintegration/src/FSharp.Editor/FSharp.Editor.resx
+4
-1
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.cs.xlf
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.cs.xlf
+5
-0
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.de.xlf
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.de.xlf
+5
-0
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.es.xlf
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.es.xlf
+5
-0
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.fr.xlf
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.fr.xlf
+5
-0
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.it.xlf
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.it.xlf
+5
-0
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ja.xlf
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ja.xlf
+5
-0
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ko.xlf
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ko.xlf
+5
-0
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pl.xlf
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pl.xlf
+5
-0
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pt-BR.xlf
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pt-BR.xlf
+5
-0
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ru.xlf
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ru.xlf
+5
-0
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.tr.xlf
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.tr.xlf
+5
-0
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hans.xlf
...tegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hans.xlf
+5
-0
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hant.xlf
...tegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hant.xlf
+5
-0
未找到文件。
src/fsharp/service/FSharpParseFileResults.fs
浏览文件 @
db6ce1b7
...
...
@@ -306,6 +306,14 @@ type FSharpParseFileResults(diagnostics: FSharpDiagnostic[], input: ParsedInput,
Some
(
app
.
Range
,
lambdaArgs
.
Range
,
lambdaBody
.
Range
)
|
_
->
defaultTraverse
binding
})
member
_.
TryRangeOfStringInterpolationContainingPos
pos
=
SyntaxTraversal
.
Traverse
(
pos
,
input
,
{
new
SyntaxVisitorBase
<_>()
with
member
_.
VisitExpr
(_,
_,
defaultTraverse
,
expr
)
=
match
expr
with
|
SynExpr
.
InterpolatedString
(
range
=
range
)
when
rangeContainsPos
range
pos
->
Some
range
|
_
->
defaultTraverse
expr
})
member
_.
TryRangeOfExprInYieldOrReturn
pos
=
SyntaxTraversal
.
Traverse
(
pos
,
input
,
{
new
SyntaxVisitorBase
<_>()
with
member
_.
VisitExpr
(_
path
,
_,
defaultTraverse
,
expr
)
=
...
...
src/fsharp/service/FSharpParseFileResults.fsi
浏览文件 @
db6ce1b7
...
...
@@ -20,6 +20,9 @@ type public FSharpParseFileResults =
/// Attempts to find the range of an attempted lambda expression or pattern, the argument range, and the expr range when writing a C#-style "lambda" (which is actually an operator application)
member
TryRangeOfParenEnclosingOpEqualsGreaterUsage
:
opGreaterEqualPos
:
pos
->
(
range
*
range
*
range
)
option
/// Attempts to find the range of the string interpolation that contains a given position.
member
TryRangeOfStringInterpolationContainingPos
:
pos
:
pos
->
range
option
/// Attempts to find the range of an expression `expr` contained in a `yield expr` or `return expr` expression (and bang-variants).
member
TryRangeOfExprInYieldOrReturn
:
pos
:
pos
->
range
option
...
...
tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected
浏览文件 @
db6ce1b7
...
...
@@ -2069,6 +2069,7 @@ FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Microsoft.FSharp.Core.FShar
FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] TryRangeOfNameOfNearestOuterBindingContainingPos(FSharp.Compiler.Text.Position)
FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] TryRangeOfRecordExpressionContainingPos(FSharp.Compiler.Text.Position)
FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] TryRangeOfRefCellDereferenceContainingPos(FSharp.Compiler.Text.Position)
FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] TryRangeOfStringInterpolationContainingPos(FSharp.Compiler.Text.Position)
FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] ValidateBreakpointLocation(FSharp.Compiler.Text.Position)
FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range]] GetAllArgumentsForFunctionApplicationAtPostion(FSharp.Compiler.Text.Position)
FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`2[FSharp.Compiler.Syntax.Ident,System.Int32]] TryIdentOfPipelineContainingPosAndNumArgsApplied(FSharp.Compiler.Text.Position)
...
...
vsintegration/src/FSharp.Editor/CodeFix/UseTripleQuotedInterpolation.fs
0 → 100644
浏览文件 @
db6ce1b7
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
namespace
Microsoft
.
VisualStudio
.
FSharp
.
Editor
open
System
.
Composition
open
Microsoft
.
CodeAnalysis
.
Text
open
Microsoft
.
CodeAnalysis
.
CodeFixes
[<
ExportCodeFixProvider
(
FSharpConstants
.
FSharpLanguageName
,
Name
=
"UseTripleQuotedInterpolation"
);
Shared
>]
type
internal
FSharpUseTripleQuotedInterpolationCodeFixProvider
[<
ImportingConstructor
>]
(
)
=
inherit
CodeFixProvider
()
let
fixableDiagnosticIds
=
[
"FS3373"
]
override
_.
FixableDiagnosticIds
=
Seq
.
toImmutableArray
fixableDiagnosticIds
override
_.
RegisterCodeFixesAsync
context
=
asyncMaybe
{
let
!
parseResults
=
context
.
Document
.
GetFSharpParseResultsAsync
(
nameof
(
FSharpUseTripleQuotedInterpolationCodeFixProvider
))
|>
liftAsync
let
!
sourceText
=
context
.
Document
.
GetTextAsync
(
context
.
CancellationToken
)
let
errorRange
=
RoslynHelpers
.
TextSpanToFSharpRange
(
context
.
Document
.
FilePath
,
context
.
Span
,
sourceText
)
let
!
interpolationRange
=
parseResults
.
TryRangeOfStringInterpolationContainingPos
errorRange
.
Start
let
!
interpolationSpan
=
RoslynHelpers
.
TryFSharpRangeToTextSpan
(
sourceText
,
interpolationRange
)
let
replacement
=
let
interpolation
=
sourceText
.
GetSubText
(
interpolationSpan
).
ToString
()
TextChange
(
interpolationSpan
,
"$
\"\"
"
+
interpolation
.[
1
..
]
+
"
\"\"
"
)
let
diagnostics
=
context
.
Diagnostics
|>
Seq
.
filter
(
fun
x
->
fixableDiagnosticIds
|>
List
.
contains
x
.
Id
)
|>
Seq
.
toImmutableArray
let
title
=
SR
.
UseTripleQuotedInterpolation
()
let
codeFix
=
CodeFixHelpers
.
createTextChangeCodeFix
(
title
,
context
,
(
fun
()
->
asyncMaybe
.
Return
[|
replacement
|]))
context
.
RegisterCodeFix
(
codeFix
,
diagnostics
)
}
|>
Async
.
Ignore
|>
RoslynHelpers
.
StartAsyncUnitAsTask
(
context
.
CancellationToken
)
vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj
浏览文件 @
db6ce1b7
...
...
@@ -121,6 +121,7 @@
<Compile
Include=
"CodeFix\MissingReferenceCodeFixProvider.fs"
/>
<Compile
Include=
"CodeFix\FixIndexerAccess.fs"
/>
<Compile
Include=
"CodeFix\RenameParamToMatchSignature.fs"
/>
<Compile
Include=
"CodeFix\UseTripleQuotedInterpolation.fs"
/>
<Compile
Include=
"Build\SetGlobalPropertiesForSdkProjects.fs"
/>
<Compile
Include=
"AutomaticCompletion\BraceCompletionSessionProvider.fsi"
/>
<Compile
Include=
"AutomaticCompletion\BraceCompletionSessionProvider.fs"
/>
...
...
vsintegration/src/FSharp.Editor/FSharp.Editor.resx
浏览文件 @
db6ce1b7
...
...
@@ -288,4 +288,7 @@
<data
name=
"UseNameof"
xml:space=
"preserve"
>
<value>
Use 'nameof'
</value>
</data>
</root>
<data
name=
"UseTripleQuotedInterpolation"
xml:space=
"preserve"
>
<value>
Use triple quoted string interpolation.
</value>
</data>
</root>
\ No newline at end of file
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.cs.xlf
浏览文件 @
db6ce1b7
...
...
@@ -262,6 +262,11 @@
<target
state=
"translated"
>
Použít nameof
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"UseTripleQuotedInterpolation"
>
<source>
Use triple quoted string interpolation.
</source>
<target
state=
"new"
>
Use triple quoted string interpolation.
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"UseUpcastKeyword"
>
<source>
Use 'upcast'
</source>
<target
state=
"translated"
>
Použijte upcast
</target>
...
...
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.de.xlf
浏览文件 @
db6ce1b7
...
...
@@ -262,6 +262,11 @@
<target
state=
"translated"
>
"nameof" verwenden
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"UseTripleQuotedInterpolation"
>
<source>
Use triple quoted string interpolation.
</source>
<target
state=
"new"
>
Use triple quoted string interpolation.
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"UseUpcastKeyword"
>
<source>
Use 'upcast'
</source>
<target
state=
"translated"
>
"upcast" verwenden
</target>
...
...
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.es.xlf
浏览文件 @
db6ce1b7
...
...
@@ -262,6 +262,11 @@
<target
state=
"translated"
>
Usar 'nameof'
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"UseTripleQuotedInterpolation"
>
<source>
Use triple quoted string interpolation.
</source>
<target
state=
"new"
>
Use triple quoted string interpolation.
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"UseUpcastKeyword"
>
<source>
Use 'upcast'
</source>
<target
state=
"translated"
>
Usar "upcast"
</target>
...
...
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.fr.xlf
浏览文件 @
db6ce1b7
...
...
@@ -262,6 +262,11 @@
<target
state=
"translated"
>
Utiliser « nameof »
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"UseTripleQuotedInterpolation"
>
<source>
Use triple quoted string interpolation.
</source>
<target
state=
"new"
>
Use triple quoted string interpolation.
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"UseUpcastKeyword"
>
<source>
Use 'upcast'
</source>
<target
state=
"translated"
>
Utiliser 'upcast'
</target>
...
...
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.it.xlf
浏览文件 @
db6ce1b7
...
...
@@ -262,6 +262,11 @@
<target
state=
"translated"
>
Usa 'nameof'
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"UseTripleQuotedInterpolation"
>
<source>
Use triple quoted string interpolation.
</source>
<target
state=
"new"
>
Use triple quoted string interpolation.
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"UseUpcastKeyword"
>
<source>
Use 'upcast'
</source>
<target
state=
"translated"
>
Usare 'upcast'
</target>
...
...
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ja.xlf
浏览文件 @
db6ce1b7
...
...
@@ -262,6 +262,11 @@
<target
state=
"translated"
>
'nameof' を使用する
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"UseTripleQuotedInterpolation"
>
<source>
Use triple quoted string interpolation.
</source>
<target
state=
"new"
>
Use triple quoted string interpolation.
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"UseUpcastKeyword"
>
<source>
Use 'upcast'
</source>
<target
state=
"translated"
>
'upcast' を使用する
</target>
...
...
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ko.xlf
浏览文件 @
db6ce1b7
...
...
@@ -262,6 +262,11 @@
<target
state=
"translated"
>
'nameof' 사용
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"UseTripleQuotedInterpolation"
>
<source>
Use triple quoted string interpolation.
</source>
<target
state=
"new"
>
Use triple quoted string interpolation.
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"UseUpcastKeyword"
>
<source>
Use 'upcast'
</source>
<target
state=
"translated"
>
'upcast' 사용
</target>
...
...
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pl.xlf
浏览文件 @
db6ce1b7
...
...
@@ -262,6 +262,11 @@
<target
state=
"translated"
>
Użyj wyrażenia "nameof"
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"UseTripleQuotedInterpolation"
>
<source>
Use triple quoted string interpolation.
</source>
<target
state=
"new"
>
Use triple quoted string interpolation.
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"UseUpcastKeyword"
>
<source>
Use 'upcast'
</source>
<target
state=
"translated"
>
Użyj operatora „upcast”
</target>
...
...
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pt-BR.xlf
浏览文件 @
db6ce1b7
...
...
@@ -262,6 +262,11 @@
<target
state=
"translated"
>
Usar 'nameof'
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"UseTripleQuotedInterpolation"
>
<source>
Use triple quoted string interpolation.
</source>
<target
state=
"new"
>
Use triple quoted string interpolation.
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"UseUpcastKeyword"
>
<source>
Use 'upcast'
</source>
<target
state=
"translated"
>
Usar 'upcast'
</target>
...
...
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ru.xlf
浏览文件 @
db6ce1b7
...
...
@@ -262,6 +262,11 @@
<target
state=
"translated"
>
Использовать "nameof"
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"UseTripleQuotedInterpolation"
>
<source>
Use triple quoted string interpolation.
</source>
<target
state=
"new"
>
Use triple quoted string interpolation.
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"UseUpcastKeyword"
>
<source>
Use 'upcast'
</source>
<target
state=
"translated"
>
Используйте "upcast"
</target>
...
...
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.tr.xlf
浏览文件 @
db6ce1b7
...
...
@@ -262,6 +262,11 @@
<target
state=
"translated"
>
“Nameof” kullanın
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"UseTripleQuotedInterpolation"
>
<source>
Use triple quoted string interpolation.
</source>
<target
state=
"new"
>
Use triple quoted string interpolation.
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"UseUpcastKeyword"
>
<source>
Use 'upcast'
</source>
<target
state=
"translated"
>
'upcast' kullan
</target>
...
...
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hans.xlf
浏览文件 @
db6ce1b7
...
...
@@ -262,6 +262,11 @@
<target
state=
"translated"
>
使用 "nameof"
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"UseTripleQuotedInterpolation"
>
<source>
Use triple quoted string interpolation.
</source>
<target
state=
"new"
>
Use triple quoted string interpolation.
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"UseUpcastKeyword"
>
<source>
Use 'upcast'
</source>
<target
state=
"translated"
>
使用“向上转换”
</target>
...
...
vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hant.xlf
浏览文件 @
db6ce1b7
...
...
@@ -262,6 +262,11 @@
<target
state=
"translated"
>
使用 'nameof'
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"UseTripleQuotedInterpolation"
>
<source>
Use triple quoted string interpolation.
</source>
<target
state=
"new"
>
Use triple quoted string interpolation.
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"UseUpcastKeyword"
>
<source>
Use 'upcast'
</source>
<target
state=
"translated"
>
使用「向上轉型」
</target>
...
...
麦壳饼
@mysticboy
mentioned in commit
c408e9ce
·
5月 11, 2022
mentioned in commit
c408e9ce
mentioned in commit c408e9ce3b562c99d1781a99b0b7938cae9bc38a
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录