Skip to content

Commit

Permalink
Merge pull request ionide#1180 from fsharp/nightly
Browse files Browse the repository at this point in the history
Merge nightly into main for the release!
  • Loading branch information
baronfel authored Nov 16, 2023
2 parents ee65267 + 9cf7b31 commit a3f4ed3
Show file tree
Hide file tree
Showing 14 changed files with 76 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
4 changes: 2 additions & 2 deletions paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion src/FsAutoComplete.Core/AbstractClassStubGenerator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 7 additions & 5 deletions src/FsAutoComplete.Core/CodeGeneration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions src/FsAutoComplete.Core/FCSPatches.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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, _)
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/FsAutoComplete.Core/Lexer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions src/FsAutoComplete.Core/ParseAndCheckResults.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions src/FsAutoComplete.Core/UnionPatternMatchCaseGenerator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _
Expand Down Expand Up @@ -306,7 +305,6 @@ let getWrittenCases (patMatchExpr: PatternMatchExpr) =
| SynPat.InstanceMember(_, _, _, _, _)
| SynPat.IsInst(_, _)
| SynPat.QuoteExpr(_, _)
| SynPat.DeprecatedCharRange(_, _, _)
| SynPat.ListCons _
| SynPat.FromParseError(_, _) -> false

Expand Down
84 changes: 41 additions & 43 deletions src/FsAutoComplete.Core/UntypedAstUtils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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) ->
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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) -> ()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
=
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -549,6 +546,7 @@ module Syntax =
| SynModuleDecl.Open(longDotId, r) -> ()
| SynModuleDecl.HashDirective(_, r) -> ()


match input with
| ParsedInput.ImplFile input -> walkImplFileInput input
| _ -> ()
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/FsAutoComplete/CodeFixes/AdjustConstant.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions test/FsAutoComplete.Tests.Lsp/CodeFixTests/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/FsAutoComplete.Tests.Lsp/ScriptTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}) ] ]

Expand Down

0 comments on commit a3f4ed3

Please sign in to comment.