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

Commit4abb633

Browse files
vasily-kirichenkoKevinRansom
authored andcommitted
InlineRenameService adds/removes double backtickes automatically (dotnet#2236)
1 parentf0e945c commit4abb633

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

‎src/fsharp/lexhelp.fs‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -342,12 +342,16 @@ module Keywords =
342342
|_->
343343
IdentifierToken args lexbuf s
344344

345+
let inlineprivateDoesIdentifierNeedQuotation(s:string):bool=
346+
not(String.forall IsIdentifierPartCharacter s)// if it has funky chars
347+
|| s.Length>0&&(not(IsIdentifierFirstCharacter s.[0]))// or if it starts with a non-(letter-or-underscore)
348+
|| keywordTable.ContainsKey s// or if it's a language keyword like "type"
349+
345350
/// A utility to help determine if an identifier needs to be quoted
346351
letQuoteIdentifierIfNeeded(s:string):string=
347-
ifnot(String.forall IsIdentifierPartCharacter s)// if it has funky chars
348-
|| s.Length>0&&(not(IsIdentifierFirstCharacter s.[0]))// or if it starts with a non-(letter-or-underscore)
349-
|| keywordTable.ContainsKey s// or if it's a language keyword like "type"
350-
then"``"+s+"``"// then it needs to be ``quoted``
351-
else s
352-
352+
if DoesIdentifierNeedQuotation sthen"``"+ s+"``"else s
353353

354+
/// Quote identifier with double backticks if needed, remove unnecessary double backticks quotation.
355+
letNormalizeIdentifierBackticks(s:string):string=
356+
lets=if s.StartsWith"``"&& s.EndsWith"``"then s.[2..s.Length-3]else s
357+
QuoteIdentifierIfNeeded s

‎src/fsharp/lexhelp.fsi‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,6 @@ module Keywords =
6767
valKeywordOrIdentifierToken:lexargs->UnicodeLexing.Lexbuf->string->Parser.token
6868
valIdentifierToken:lexargs->UnicodeLexing.Lexbuf->string->Parser.token
6969
valQuoteIdentifierIfNeeded:string->string
70+
valNormalizeIdentifierBackticks:string->string
7071
valkeywordNames:string list
7172
valkeywordTypes:Set<string>

‎vsintegration/src/FSharp.Editor/InlineRename/InlineRenameService.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ type internal InlineRenameInfo
105105
member__.DisplayName= symbolUse.Symbol.DisplayName
106106
member__.FullDisplayName=try symbolUse.Symbol.FullNamewith_-> symbolUse.Symbol.DisplayName
107107
member__.Glyph= Glyph.MethodPublic
108-
member__.GetFinalSymbolName replacementText= replacementText
108+
member__.GetFinalSymbolName replacementText=Lexhelp.Keywords.NormalizeIdentifierBackticksreplacementText
109109

110110
member__.GetReferenceEditSpan(location,cancellationToken)=
111111
lettext= getDocumentText location.Document cancellationToken

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp