Skip to content

Commit

Permalink
Update to Fantomas 7.0.0 (#1344)
Browse files Browse the repository at this point in the history
* - update fantomas to v7.0.0
- remove fsharp_max_dot_get_expression_width from .editorconfig as it was removed from fantomas

* format

* add entry to .git-blame-ignore-revs
  • Loading branch information
dawedawe authored Jan 17, 2025
1 parent 805e94e commit b48b166
Show file tree
Hide file tree
Showing 16 changed files with 23 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"rollForward": false
},
"fantomas": {
"version": "6.3.11",
"version": "7.0.0",
"commands": [
"fantomas"
],
Expand Down
1 change: 0 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ trim_trailing_whitespace = false
[*.{fs,fsx}]
indent_size = 2
fsharp_max_array_or_list_width=80
fsharp_max_dot_get_expression_width=80
fsharp_max_function_binding_width=80
fsharp_max_value_binding_width=80

Expand Down
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Fantomas v7.0.0
e0ab543f5e6c52bcdacd818a3899bfe7d35d2364
# Fantomas v5.0.0-alpha-005
ca9fa561df53e90f6509e95681f8e4fd3ab385c4
3 changes: 1 addition & 2 deletions src/FsAutoComplete.Core/Commands.fs
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,7 @@ module Commands =
| Some(recordEpr, (Some recordDefinition), insertionPos) ->
if shouldGenerateRecordStub recordEpr recordDefinition then
let result =
(formatRecord insertionPos "$1" recordDefinition recordEpr.FieldExprList)
.TrimStart(' ')
(formatRecord insertionPos "$1" recordDefinition recordEpr.FieldExprList).TrimStart(' ')

return CoreResponse.Res(result, insertionPos.InsertionPos)
else
Expand Down
8 changes: 2 additions & 6 deletions src/FsAutoComplete.Core/CompilerServiceInterface.fs
Original file line number Diff line number Diff line change
Expand Up @@ -500,9 +500,7 @@ type FSharpCompilerServiceChecker(hasAnalyzers, typecheckCacheSize, parallelRefe

if shouldCache then
let ops =
MemoryCacheEntryOptions()
.SetSize(1)
.SetSlidingExpiration(TimeSpan.FromMinutes(5.))
MemoryCacheEntryOptions().SetSize(1).SetSlidingExpiration(TimeSpan.FromMinutes(5.))

return lastCheckResults.Set(filePath, r, ops)
else
Expand Down Expand Up @@ -553,9 +551,7 @@ type FSharpCompilerServiceChecker(hasAnalyzers, typecheckCacheSize, parallelRefe

if shouldCache then
let ops =
MemoryCacheEntryOptions()
.SetSize(1)
.SetSlidingExpiration(TimeSpan.FromMinutes(5.))
MemoryCacheEntryOptions().SetSize(1).SetSlidingExpiration(TimeSpan.FromMinutes(5.))

return lastCheckResults.Set(filePath, r, ops)
else
Expand Down
3 changes: 1 addition & 2 deletions src/FsAutoComplete.Core/FCSPatches.fs
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,7 @@ module ReflectionDelegates =
let method = instanceType.GetMethod(getterName, BindingFlagsToSeeAll)

let getFunc =
typedefof<Func<_, _, _>>
.MakeGenericType(instanceType, arg1, typeof<'returnType>)
typedefof<Func<_, _, _>>.MakeGenericType(instanceType, arg1, typeof<'returnType>)

let delegate2 = method.CreateDelegate(getFunc)
// TODO: Emit IL for performance
Expand Down
12 changes: 6 additions & 6 deletions src/FsAutoComplete.Core/FsprojEdit.fs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module FsProjEditor =

let moveFileUp (fsprojPath: string) (file: string) =
let xDoc = System.Xml.XmlDocument()
xDoc.PreserveWhitespace <- true // to keep custom formatting if present
xDoc.PreserveWhitespace <- true // to keep custom formatting if present
xDoc.Load fsprojPath
let xpath = sprintf "//Compile[@Include='%s']/.." file
let itemGroup = xDoc.SelectSingleNode(xpath)
Expand All @@ -65,7 +65,7 @@ module FsProjEditor =

let moveFileDown (fsprojPath: string) (file: string) =
let xDoc = System.Xml.XmlDocument()
xDoc.PreserveWhitespace <- true // to keep custom formatting if present
xDoc.PreserveWhitespace <- true // to keep custom formatting if present
xDoc.Load fsprojPath
let xpath = sprintf "//Compile[@Include='%s']/.." file
let itemGroup = xDoc.SelectSingleNode(xpath)
Expand Down Expand Up @@ -98,7 +98,7 @@ module FsProjEditor =

let addFileBelow (fsprojPath: string) (belowFile: string) (newFileName: string) =
let xDoc = System.Xml.XmlDocument()
xDoc.PreserveWhitespace <- true // to keep custom formatting if present
xDoc.PreserveWhitespace <- true // to keep custom formatting if present
xDoc.Load fsprojPath

if fileAlreadyIncludedViaCompileTag xDoc newFileName then
Expand All @@ -115,7 +115,7 @@ module FsProjEditor =

let renameFile (fsprojPath: string) (oldFileName: string) (newFileName: string) =
let xDoc = System.Xml.XmlDocument()
xDoc.PreserveWhitespace <- true // to keep custom formatting if present
xDoc.PreserveWhitespace <- true // to keep custom formatting if present
xDoc.Load fsprojPath
let xpath = sprintf "//Compile[@Include='%s']" oldFileName
let node = xDoc.SelectSingleNode(xpath)
Expand All @@ -124,7 +124,7 @@ module FsProjEditor =

let addFile (fsprojPath: string) (newFileName: string) =
let xDoc = System.Xml.XmlDocument()
xDoc.PreserveWhitespace <- true // to keep custom formatting if present
xDoc.PreserveWhitespace <- true // to keep custom formatting if present
xDoc.Load fsprojPath

if fileAlreadyIncludedViaCompileTag xDoc newFileName then
Expand Down Expand Up @@ -161,7 +161,7 @@ module FsProjEditor =

let removeFile (fsprojPath: string) (fileToRemove: string) =
let xDoc = System.Xml.XmlDocument()
xDoc.PreserveWhitespace <- true // to keep custom formatting if present
xDoc.PreserveWhitespace <- true // to keep custom formatting if present
xDoc.Load fsprojPath
let sanitizedFileToRemove = fileToRemove.Replace("\\", "/")

Expand Down
5 changes: 1 addition & 4 deletions src/FsAutoComplete.Core/Sourcelink.fs
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,7 @@ let private tryGetUrlWithExactMatch
(urlPattern: string<Url>)
(document: Document)
=
if
(UMX.untag pathPattern)
.Equals(UMX.untag document.Name, System.StringComparison.Ordinal)
then
if (UMX.untag pathPattern).Equals(UMX.untag document.Name, System.StringComparison.Ordinal) then
Some(urlPattern, normalizeRepoPath (UMX.cast<SourcelinkPattern, RepoPathSegment> pathPattern), document)
else
None
Expand Down
7 changes: 1 addition & 6 deletions src/FsAutoComplete.Core/TipFormatter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -683,12 +683,7 @@ module private Format =
/// For example, this allows to print '>' in the tooltip instead of '&gt;'
/// </summary>
let private unescapeSpecialCharacters (text: string) =
text
.Replace("&lt;", "<")
.Replace("&gt;", ">")
.Replace("&quot;", "\"")
.Replace("&apos;", "'")
.Replace("&amp;", "&")
text.Replace("&lt;", "<").Replace("&gt;", ">").Replace("&quot;", "\"").Replace("&apos;", "'").Replace("&amp;", "&")

let applyAll (text: string) =
text
Expand Down
3 changes: 1 addition & 2 deletions src/FsAutoComplete.Core/Utils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -727,8 +727,7 @@ module Version =

let private informationalVersion () =
let assemblies =
typeof<VersionInfo>.Assembly
.GetCustomAttributes(typeof<AssemblyInformationalVersionAttribute>, true)
typeof<VersionInfo>.Assembly.GetCustomAttributes(typeof<AssemblyInformationalVersionAttribute>, true)

match assemblies with
| [| x |] ->
Expand Down
8 changes: 2 additions & 6 deletions src/FsAutoComplete.Logging/FsLibLog.fs
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,7 @@ module Providers =
Expression.Call(instanceCast, isEnabledMethodInfo, levelCast)

let isEnabled =
Expression
.Lambda<Func<obj, obj, bool>>(isEnabledMethodCall, instanceParam, levelParam)
.Compile()
Expression.Lambda<Func<obj, obj, bool>>(isEnabledMethodCall, instanceParam, levelParam).Compile()

let writeMethodInfo =
loggerType.GetMethod("Write", [| logEventLevelType; typedefof<string>; typedefof<obj[]> |])
Expand Down Expand Up @@ -800,9 +798,7 @@ module Providers =
let beginScopeMethodCall =
Expression.Call(instanceCast, beginScopeMethodInfo, stateParam)

Expression
.Lambda<Func<ILogger, obj, IDisposable>>(beginScopeMethodCall, instanceParam, stateParam)
.Compile()
Expression.Lambda<Func<ILogger, obj, IDisposable>>(beginScopeMethodCall, instanceParam, stateParam).Compile()
|> FuncConvert.FromFunc

{ Write = write
Expand Down
4 changes: 1 addition & 3 deletions src/FsAutoComplete.Logging/FsOpenTelemetry.fs
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,7 @@ type ActivityExtensions =

[<Extension>]
static member inline SetStatusErrorSafe(span: Activity, description: string) =
span
.SetTagSafe("otel.status_code", "ERROR")
.SetTagSafe("otel.status_description", description)
span.SetTagSafe("otel.status_code", "ERROR").SetTagSafe("otel.status_description", description)

[<Extension>]
static member inline SetSourceCodeFilePath(span: Activity, value: string) =
Expand Down
3 changes: 1 addition & 2 deletions src/FsAutoComplete/LspHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@ module Conversions =
let getLine (lines: string[]) (pos: LspPosition) = lines.[int pos.Line]

let getText (lines: string[]) (r: LspRange) =
lines.[int r.Start.Line]
.Substring(int r.Start.Character, int (r.End.Character - r.Start.Character))
lines.[int r.Start.Line].Substring(int r.Start.Character, int (r.End.Character - r.Start.Character))

[<AutoOpen>]
module internal GlyphConversions =
Expand Down
7 changes: 1 addition & 6 deletions src/FsAutoComplete/LspServers/AdaptiveFSharpLspServer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,7 @@ type AdaptiveFSharpLspServer
)
|> Option.defaultValue (async { return () })
| (Some { Title = "Install globally" }) ->
let! result =
Cli
.Wrap("dotnet")
.WithArguments("tool install -g fantomas")
.ExecuteBufferedAsync()
.Task
let! result = Cli.Wrap("dotnet").WithArguments("tool install -g fantomas").ExecuteBufferedAsync().Task

if result.ExitCode = 0 then
fantomasLogger.info (Log.setMessage "fantomas was installed globally")
Expand Down
4 changes: 1 addition & 3 deletions src/FsAutoComplete/LspServers/Common.fs
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,7 @@ module ObservableExtensions =

/// Fires an event only after the specified interval has passed in which no other pending event has fired. Buffers all events leading up to that emit.
member x.BufferedDebounce(ts: TimeSpan) =
x
.Publish(fun shared -> shared.Window(shared.Throttle(ts)))
.SelectMany(fun l -> l.ToList())
x.Publish(fun shared -> shared.Window(shared.Throttle(ts))).SelectMany(fun l -> l.ToList())

module Helpers =
let notImplemented<'t> = async.Return LspResult.notImplemented<'t>
Expand Down
4 changes: 1 addition & 3 deletions src/FsAutoComplete/Parser.fs
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,7 @@ module Parser =
let version = FsAutoComplete.Utils.Version.info().Version

let resourceBuilder =
ResourceBuilder
.CreateDefault()
.AddService(serviceName = serviceName, serviceVersion = version)
ResourceBuilder.CreateDefault().AddService(serviceName = serviceName, serviceVersion = version)


meterProvider <-
Expand Down

0 comments on commit b48b166

Please sign in to comment.