diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0da80b541..2f0545f60 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -102,7 +102,7 @@ jobs: BuildNet8: ${{ matrix.build_net8 }} - name: Run and report tests - run: dotnet test -c Release -f ${{ matrix.test_tfm }} --no-restore --no-build --no-build --logger GitHubActions /p:AltCover=true /p:AltCoverAssemblyExcludeFilter="System.Reactive|FSharp.Compiler.Service|Ionide.ProjInfo|FSharp.Analyzers|Analyzer|Humanizer|FSharp.Core|FSharp.DependencyManager" -- Expecto.fail-on-focused-tests=true + run: dotnet test -c Release -f ${{ matrix.test_tfm }} --no-restore --no-build --no-build --logger GitHubActions /p:AltCover=true /p:AltCoverAssemblyExcludeFilter="System.Reactive|FSharp.Compiler.Service|Ionide.ProjInfo|FSharp.Analyzers|Analyzer|Humanizer|FSharp.Core|FSharp.DependencyManager" -- Expecto.fail-on-focused-tests=true --blame-hang --blame-hang-timeout 1m working-directory: test/FsAutoComplete.Tests.Lsp env: BuildNet7: ${{ matrix.build_net7 }} diff --git a/paket.dependencies b/paket.dependencies index 4328f2285..1f5809159 100644 --- a/paket.dependencies +++ b/paket.dependencies @@ -4,7 +4,7 @@ framework: netstandard2.0, netstandard2.1, net6.0, net7.0, net8.0 source https://api.nuget.org/v3/index.json # this is the FCS nightly feed, re-enable at your own risk! -#source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json +# source: https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json #source: ./libs storage: none strategy: min @@ -13,7 +13,7 @@ lowest_matching: true nuget BenchmarkDotNet 0.13.5 nuget Fantomas.Client >= 0.9 -nuget FSharp.Compiler.Service >= 43.7.400 +nuget FSharp.Compiler.Service >= 43.8.100 nuget Ionide.ProjInfo >= 0.62.0 nuget Ionide.ProjInfo.FCS >= 0.62.0 nuget Ionide.ProjInfo.ProjectSystem >= 0.62.0 diff --git a/paket.lock b/paket.lock index 74559f327..09f405a5c 100644 --- a/paket.lock +++ b/paket.lock @@ -59,8 +59,8 @@ NUGET FSharp.Compiler.Service (>= 41.0.1) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net5.0)) (&& (== netstandard2.1) (>= net5.0)) FSharp.Core (>= 6.0.1) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net5.0)) (&& (== netstandard2.1) (>= net5.0)) McMaster.NETCore.Plugins (>= 1.4) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net5.0)) (&& (== netstandard2.1) (>= net5.0)) - FSharp.Compiler.Service (43.7.400) - FSharp.Core (7.0.400) + FSharp.Compiler.Service (43.8.100) + FSharp.Core (8.0.100) System.Buffers (>= 4.5.1) System.Collections.Immutable (>= 7.0) System.Diagnostics.DiagnosticSource (>= 7.0.2) @@ -74,7 +74,7 @@ NUGET FSharp.Control.Reactive (5.0.5) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0)) FSharp.Core (>= 4.7.2) System.Reactive (>= 5.0 < 6.0) - FSharp.Core (7.0.400) + FSharp.Core (8.0.100) FSharp.Data.Adaptive (1.2.13) FSharp.Core (>= 4.7) System.Reflection.Emit.Lightweight (>= 4.6) diff --git a/src/FsAutoComplete.Core/AbstractClassStubGenerator.fs b/src/FsAutoComplete.Core/AbstractClassStubGenerator.fs index 8db52d20b..397636557 100644 --- a/src/FsAutoComplete.Core/AbstractClassStubGenerator.fs +++ b/src/FsAutoComplete.Core/AbstractClassStubGenerator.fs @@ -29,7 +29,8 @@ type AbstractClassData = let private (|ExplicitCtor|_|) = function - | SynMemberDefn.Member(SynBinding(valData = SynValData(Some({ MemberKind = SynMemberKind.Constructor }), _, _)), _) -> + | SynMemberDefn.Member( + memberDefn = SynBinding(valData = SynValData(memberFlags = Some({ MemberKind = SynMemberKind.Constructor })))) -> Some() | _ -> None diff --git a/src/FsAutoComplete.Core/CodeGeneration.fs b/src/FsAutoComplete.Core/CodeGeneration.fs index a66fa48fd..35ca9c10f 100644 --- a/src/FsAutoComplete.Core/CodeGeneration.fs +++ b/src/FsAutoComplete.Core/CodeGeneration.fs @@ -578,14 +578,14 @@ module CodeGenerationUtils = /// We also get the range of the leading keyword to establish indent position let (|MemberNamePlusRangeAndKeywordRange|_|) = function - | SynBinding(valData = SynValData(Some mf, _, _); headPat = LongIdentPattern(name, range); trivia = trivia) when + | SynBinding(valData = SynValData(memberFlags = Some mf); headPat = LongIdentPattern(name, range); trivia = trivia) when mf.MemberKind = SynMemberKind.PropertyGet -> if name.StartsWith("get_", StringComparison.Ordinal) then Some(name, range, trivia.LeadingKeyword.Range) else Some("get_" + name, range, trivia.LeadingKeyword.Range) - | SynBinding(valData = SynValData(Some mf, _, _); headPat = LongIdentPattern(name, range); trivia = trivia) when + | SynBinding(valData = SynValData(memberFlags = Some mf); headPat = LongIdentPattern(name, range); trivia = trivia) when mf.MemberKind = SynMemberKind.PropertySet -> if name.StartsWith("set_", StringComparison.Ordinal) then @@ -801,9 +801,11 @@ module CodeGenerationUtils = let rec (|RationalConst|) = function - | SynRationalConst.Integer i -> string i - | SynRationalConst.Rational(numerator, denominator, _) -> sprintf "(%i/%i)" numerator denominator - | SynRationalConst.Negate(RationalConst s) -> sprintf "- %s" s + | SynRationalConst.Integer(value = i) -> string i + | SynRationalConst.Rational(numerator = numerator; denominator = denominator) -> + sprintf "(%i/%i)" numerator denominator + | SynRationalConst.Negate(rationalConst = RationalConst s) -> sprintf "- %s" s + | SynRationalConst.Paren(rationalConst = inner) -> (|RationalConst|) inner let rec (|TypeIdent|_|) = function diff --git a/src/FsAutoComplete.Core/FCSPatches.fs b/src/FsAutoComplete.Core/FCSPatches.fs index 9cbe288f3..9ecaeb359 100644 --- a/src/FsAutoComplete.Core/FCSPatches.fs +++ b/src/FsAutoComplete.Core/FCSPatches.fs @@ -461,7 +461,8 @@ module SyntaxTreeOps = | SynExpr.YieldOrReturnFrom(_, e, _) | SynExpr.DoBang(e, _) | SynExpr.Fixed(e, _) - | SynExpr.Paren(e, _, _, _) -> walkExpr e + | SynExpr.Paren(e, _, _, _) + | SynExpr.DotLambda(expr = e) -> walkExpr e | SynExpr.NamedIndexedPropertySet(_, e1, e2, _) | SynExpr.DotSet(e1, _, e2, _) @@ -495,7 +496,8 @@ module SyntaxTreeOps = yield! bindings ] | SynExpr.ForEach(enumExpr = e1; bodyExpr = e2) - | SynExpr.While(whileExpr = e1; doExpr = e2) -> walkExpr e1 || walkExpr e2 + | SynExpr.While(whileExpr = e1; doExpr = e2) + | SynExpr.WhileBang(whileExpr = e1; doExpr = e2) -> walkExpr e1 || walkExpr e2 | SynExpr.For(identBody = e1; toBody = e2; doBody = e3) -> walkExpr e1 || walkExpr e2 || walkExpr e3 diff --git a/src/FsAutoComplete.Core/Lexer.fs b/src/FsAutoComplete.Core/Lexer.fs index 5f33322f3..3168352b7 100644 --- a/src/FsAutoComplete.Core/Lexer.fs +++ b/src/FsAutoComplete.Core/Lexer.fs @@ -69,7 +69,7 @@ module Lexer = | _ -> defines, langVersion) let sourceTokenizer = - FSharpSourceTokenizer(Seq.toList defines, Some "/tmp.fsx", langVersion) + FSharpSourceTokenizer(Seq.toList defines, Some "/tmp.fsx", langVersion, None) let lineTokenizer = sourceTokenizer.CreateLineTokenizer lineStr diff --git a/src/FsAutoComplete.Core/ParseAndCheckResults.fs b/src/FsAutoComplete.Core/ParseAndCheckResults.fs index 25164017b..306cf4f48 100644 --- a/src/FsAutoComplete.Core/ParseAndCheckResults.fs +++ b/src/FsAutoComplete.Core/ParseAndCheckResults.fs @@ -558,6 +558,14 @@ type ParseAndCheckResults if symbol.IsPropertyGetterMethod then Ok(typ, [], []) else + let symbol = + // Symbol is a property with both get and set. + // Take the setter symbol in this case. + if symbol.HasGetterMethod && symbol.HasSetterMethod then + symbol.SetterMethod + else + symbol + let parms = symbol.CurriedParameterGroups |> Seq.map ( @@ -664,6 +672,7 @@ type ParseAndCheckResults | CompletionItemKind.Argument -> 4 | CompletionItemKind.Other -> 5 | CompletionItemKind.Method(isExtension = true) -> 6 + | CompletionItemKind.SuggestedName -> 7 let decls = match filter with diff --git a/src/FsAutoComplete.Core/UnionPatternMatchCaseGenerator.fs b/src/FsAutoComplete.Core/UnionPatternMatchCaseGenerator.fs index 3c455d582..8dbc3963b 100644 --- a/src/FsAutoComplete.Core/UnionPatternMatchCaseGenerator.fs +++ b/src/FsAutoComplete.Core/UnionPatternMatchCaseGenerator.fs @@ -60,7 +60,6 @@ let private clauseIsCandidateForCodeGen (cursorPos: Position) (SynMatchClause(pa | SynPat.Null _ | SynPat.IsInst _ | SynPat.QuoteExpr _ - | SynPat.DeprecatedCharRange _ | SynPat.InstanceMember _ | SynPat.FromParseError _ | SynPat.As _ @@ -306,7 +305,6 @@ let getWrittenCases (patMatchExpr: PatternMatchExpr) = | SynPat.InstanceMember(_, _, _, _, _) | SynPat.IsInst(_, _) | SynPat.QuoteExpr(_, _) - | SynPat.DeprecatedCharRange(_, _, _) | SynPat.ListCons _ | SynPat.FromParseError(_, _) -> false diff --git a/src/FsAutoComplete.Core/UntypedAstUtils.fs b/src/FsAutoComplete.Core/UntypedAstUtils.fs index 440d0477e..59c5d9513 100644 --- a/src/FsAutoComplete.Core/UntypedAstUtils.fs +++ b/src/FsAutoComplete.Core/UntypedAstUtils.fs @@ -88,6 +88,7 @@ module Syntax = let rec walkImplFileInput (ParsedImplFileInput(contents = moduleOrNamespaceList)) = List.iter walkSynModuleOrNamespace moduleOrNamespaceList + () and walkSynModuleOrNamespace (SynModuleOrNamespace(decls = decls; attribs = AllAttrs attrs; range = r) as s) = walker.WalkSynModuleOrNamespace s @@ -96,9 +97,10 @@ module Syntax = and walkAttribute (attr: SynAttribute) = walkExpr attr.ArgExpr - and walkTyparDecl (SynTyparDecl(attributes = AllAttrs attrs; Item2 = typar)) = + and walkTyparDecl (SynTyparDecl(attributes = AllAttrs attrs; typar = typar; intersectionConstraints = ts)) = List.iter walkAttribute attrs walkTypar typar + List.iter walkType ts and walkTyparDecls (typars: SynTyparDecls) = typars.TyparDecls |> List.iter walkTyparDecl @@ -155,7 +157,6 @@ module Syntax = | SynPat.Record(_, r) -> () | SynPat.Null(r) -> () | SynPat.OptionalVal(_, r) -> () - | SynPat.DeprecatedCharRange(_, _, r) -> () | SynPat.InstanceMember(_, _, _, accessibility, r) -> () | SynPat.FromParseError(_, r) -> () | SynPat.As(lpat, rpat, r) -> @@ -223,6 +224,9 @@ module Syntax = walkType lhs walkType rhs | SynType.FromParseError(r) -> () + | SynType.Intersection(typar, types, _, _) -> + Option.iter walkTypar typar + List.iter walkType types and walkClause (SynMatchClause(pat, e1, e2, r, _, _) as s) = walker.WalkClause s @@ -245,20 +249,23 @@ module Syntax = walker.WalkExpr s match s with - | SynExpr.Typed(e, _, r) -> walkExpr e - | SynExpr.Paren(e, _, _, r) - | SynExpr.Quote(_, _, e, _, r) - | SynExpr.InferredUpcast(e, r) - | SynExpr.InferredDowncast(e, r) - | SynExpr.AddressOf(_, e, _, r) - | SynExpr.DoBang(e, r) - | SynExpr.YieldOrReturn(_, e, r) - | SynExpr.ArrayOrListComputed(_, e, r) - | SynExpr.ComputationExpr(_, e, r) - | SynExpr.Do(e, r) - | SynExpr.Assert(e, r) - | SynExpr.Lazy(e, r) - | SynExpr.YieldOrReturnFrom(_, e, r) -> walkExpr e + | SynExpr.Typed(expr = e) + | SynExpr.Paren(expr = e) + | SynExpr.InferredUpcast(expr = e) + | SynExpr.InferredDowncast(expr = e) + | SynExpr.AddressOf(expr = e) + | SynExpr.DoBang(expr = e) + | SynExpr.YieldOrReturn(expr = e) + | SynExpr.ArrayOrListComputed(expr = e) + | SynExpr.ComputationExpr(expr = e) + | SynExpr.Do(expr = e) + | SynExpr.Assert(expr = e) + | SynExpr.Lazy(expr = e) + | SynExpr.YieldOrReturnFrom(expr = e) + | SynExpr.DotLambda(expr = e) -> walkExpr e + | SynExpr.Quote(operator, _, quotedExpr, _, _) -> + walkExpr operator + walkExpr quotedExpr | SynExpr.SequentialOrImplicitYield(_, e1, e2, ifNotE, r) -> walkExpr e1 walkExpr e2 @@ -337,7 +344,7 @@ module Syntax = walkType t walkMemberSig sign walkExpr e - | SynExpr.Const(SynConst.Measure(_, _, m), r) -> walkMeasure m + | SynExpr.Const(SynConst.Measure(synMeasure = m), r) -> walkMeasure m | SynExpr.Const(_, r) -> () | SynExpr.AnonRecd(isStruct, copyInfo, recordFields, r, trivia) -> () | SynExpr.Sequential(seqPoint, isTrueSeq, expr1, expr2, r) -> () @@ -368,22 +375,27 @@ module Syntax = walkExpr e1 walkExpr e2 | SynExpr.Typar(t, r) -> walkTypar t + | SynExpr.WhileBang(whileExpr = whileExpr; doExpr = doExpr) -> + walkExpr whileExpr + walkExpr doExpr and walkMeasure s = walker.WalkMeasure s match s with - | SynMeasure.Product(m1, m2, r) - | SynMeasure.Divide(m1, m2, r) -> + | SynMeasure.Product(measure1 = m1; measure2 = m2) -> walkMeasure m1 walkMeasure m2 + | SynMeasure.Divide(m1, _, m2, r) -> + Option.iter walkMeasure m1 + walkMeasure m2 | SynMeasure.Named(longIdent, r) -> () | SynMeasure.Seq(ms, r) -> List.iter walkMeasure ms - | SynMeasure.Power(m, _, r) -> walkMeasure m + | SynMeasure.Power(m, _, _, r) -> walkMeasure m | SynMeasure.Var(ty, r) -> walkTypar ty | SynMeasure.Paren(m, r) -> walkMeasure m - | SynMeasure.One - | SynMeasure.Anon _ -> () + | SynMeasure.One(_) + | SynMeasure.Anon(_) -> () and walkSimplePat s = walker.WalkSimplePat s @@ -423,14 +435,7 @@ module Syntax = | SynMemberSig.ValField(f, r) -> walkField f | SynMemberSig.NestedType(SynTypeDefnSig(typeInfo = info; typeRepr = repr; members = memberSigs), r) -> - let isTypeExtensionOrAlias = - match repr with - | SynTypeDefnSigRepr.Simple(SynTypeDefnSimpleRepr.TypeAbbrev _, _) - | SynTypeDefnSigRepr.ObjectModel(SynTypeDefnKind.Abbrev, _, _) - | SynTypeDefnSigRepr.ObjectModel(SynTypeDefnKind.Augmentation _, _, _) -> true - | _ -> false - - walkComponentInfo isTypeExtensionOrAlias info + walkComponentInfo info walkTypeDefnSigRepr repr List.iter walkMemberSig memberSigs @@ -492,7 +497,6 @@ module Syntax = | SynTypeDefnSimpleRepr.Exception(_) -> () and walkComponentInfo - isTypeExtensionOrAlias (SynComponentInfo( attributes = AllAttrs attrs; typeParams = typars; constraints = constraints; longId = longIdent; range = r) as s) = @@ -520,14 +524,7 @@ module Syntax = and walkTypeDefn (SynTypeDefn(info, repr, members, implicitCtor, r, _) as s) = walker.WalkTypeDefn s - let isTypeExtensionOrAlias = - match repr with - | SynTypeDefnRepr.ObjectModel(SynTypeDefnKind.Augmentation _, _, _) - | SynTypeDefnRepr.ObjectModel(SynTypeDefnKind.Abbrev, _, _) - | SynTypeDefnRepr.Simple(SynTypeDefnSimpleRepr.TypeAbbrev _, _) -> true - | _ -> false - - walkComponentInfo isTypeExtensionOrAlias info + walkComponentInfo info walkTypeDefnRepr repr Option.iter walkMember implicitCtor List.iter walkMember members @@ -538,7 +535,7 @@ module Syntax = match decl with | SynModuleDecl.NamespaceFragment fragment -> walkSynModuleOrNamespace fragment | SynModuleDecl.NestedModule(info, _, modules, _, r, _) -> - walkComponentInfo false info + walkComponentInfo info List.iter walkSynModuleDecl modules | SynModuleDecl.Let(_, bindings, r) -> List.iter walkBinding bindings | SynModuleDecl.Expr(expr, r) -> walkExpr expr @@ -549,6 +546,7 @@ module Syntax = | SynModuleDecl.Open(longDotId, r) -> () | SynModuleDecl.HashDirective(_, r) -> () + match input with | ParsedInput.ImplFile input -> walkImplFileInput input | _ -> () @@ -627,9 +625,9 @@ module FoldingRange = | SynMeasure.Seq(range = r) | SynMeasure.Power(range = r) | SynMeasure.Var(range = r) - | SynMeasure.Paren(range = r) -> addIfInside r - | SynMeasure.One - | SynMeasure.Anon _ -> () + | SynMeasure.Paren(range = r) + | SynMeasure.One(range = r) + | SynMeasure.Anon(range = r) -> addIfInside r override _.WalkSimplePat p = addIfInside p.Range override _.WalkField(SynField(range = r)) = addIfInside r diff --git a/src/FsAutoComplete/CodeFixes/AddMissingEqualsToTypeDefinition.fs b/src/FsAutoComplete/CodeFixes/AddMissingEqualsToTypeDefinition.fs index ff7a8ec0c..9b933ccb7 100644 --- a/src/FsAutoComplete/CodeFixes/AddMissingEqualsToTypeDefinition.fs +++ b/src/FsAutoComplete/CodeFixes/AddMissingEqualsToTypeDefinition.fs @@ -11,7 +11,7 @@ let title = "Add missing '=' to type definition" /// a codefix that adds in missing '=' characters in type declarations let fix (getFileLines: GetFileLines) = - Run.ifDiagnosticByCode (Set.ofList [ "3360" ]) (fun diagnostic codeActionParams -> + Run.ifDiagnosticByCode (Set.ofList [ "10" ]) (fun diagnostic codeActionParams -> asyncResult { let fileName = codeActionParams.TextDocument.GetFilePath() |> Utils.normalizePath diff --git a/src/FsAutoComplete/CodeFixes/AdjustConstant.fs b/src/FsAutoComplete/CodeFixes/AdjustConstant.fs index a5d8edcea..dccc76640 100644 --- a/src/FsAutoComplete/CodeFixes/AdjustConstant.fs +++ b/src/FsAutoComplete/CodeFixes/AdjustConstant.fs @@ -32,8 +32,8 @@ let inline private unreachable () = invalidOp "unreachable" let private tryFindConstant ast pos = let rec findConst range constant = match constant with - | SynConst.Measure(constant, constantRange, _) when rangeContainsPos constantRange pos -> - findConst constantRange constant + | SynConst.Measure(constant = c; constantRange = constantRange) when rangeContainsPos constantRange pos -> + findConst constantRange c | _ -> (range, constant) SyntaxTraversal.Traverse( diff --git a/test/FsAutoComplete.Tests.Lsp/CodeFixTests/Tests.fs b/test/FsAutoComplete.Tests.Lsp/CodeFixTests/Tests.fs index 9e155a0c1..724a5012f 100644 --- a/test/FsAutoComplete.Tests.Lsp/CodeFixTests/Tests.fs +++ b/test/FsAutoComplete.Tests.Lsp/CodeFixTests/Tests.fs @@ -18,7 +18,7 @@ let private addMissingEqualsToTypeDefinitionTests state = """ type Person $0{ Name : string; Age : int; City : string } """ - (Diagnostics.expectCode "3360") + (Diagnostics.expectCode "10") selectCodeFix """ type Person = { Name : string; Age : int; City : string } @@ -30,7 +30,7 @@ let private addMissingEqualsToTypeDefinitionTests state = """ type Name $0Name of string """ - (Diagnostics.expectCode "3360") + (Diagnostics.expectCode "10") selectCodeFix """ type Name = Name of string diff --git a/test/FsAutoComplete.Tests.Lsp/ScriptTests.fs b/test/FsAutoComplete.Tests.Lsp/ScriptTests.fs index a01ea7c6a..5e2b40527 100644 --- a/test/FsAutoComplete.Tests.Lsp/ScriptTests.fs +++ b/test/FsAutoComplete.Tests.Lsp/ScriptTests.fs @@ -145,7 +145,7 @@ let dependencyManagerTests state = | Ok _ -> failwith "Expected to fail typechecking a script with a dependency manager that's missing" | Core.Result.Error e -> match e with - | [| { Code = Some "3216" }; _ |] -> () // this is the error code that signals a missing dependency manager, so this is a 'success' + | [| { Code = Some "998" }; _ |] -> () // this is the error code that signals a missing dependency manager, so this is a 'success' | e -> failwithf "Unexpected error during typechecking: %A" e }) ] ]