File tree Expand file tree Collapse file tree 1 file changed +10
-10
lines changed
src/FSharpLint.Core/Rules/Conventions/Naming Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change 11module FSharpLint.Rules.Helper.Naming
22
33open System
4- open System.Text
54open FSharp.Compiler .Syntax
65open FSharp.Compiler .Text
76open FSharpLint.Framework
@@ -54,16 +53,17 @@ module QuickFixes =
5453 Some { FromText = ident.idText; FromRange = ident.idRange; ToText = camelCaseIdent })
5554
5655 let splitByCaseChange ( name : string ) : seq < string > =
57- let builder = System.Text.StringBuilder()
56+ let partitionPoints =
57+ seq {
58+ yield 0
59+ for ( index, ( current, next)) in name |> Seq.pairwise |> Seq.indexed do
60+ if ( Char.IsUpper next || not ( Char.IsLetter next)) && not ( Char.IsUpper current) then
61+ yield index + 1
62+ yield name.Length
63+ }
5864 seq {
59- let isUppercase = Char.IsUpper name.[ 0 ]
60- for char in name do
61- if isUppercase <> Char.IsUpper char then
62- yield builder.ToString()
63- builder.Clear() |> ignore< StringBuilder>
64- builder.Append char |> ignore< StringBuilder>
65- if builder.Length > 0 then
66- yield builder.ToString()
65+ for ( start, finish) in Seq.pairwise partitionPoints do
66+ yield name.Substring( start, finish - start)
6767 }
6868
6969 let private convertAllToCase ( caseMapping : string -> string ) ( underscoresConfig : Option < NamingUnderscores >) ( ident : Ident ) =
You can’t perform that action at this time.
0 commit comments