Skip to content

Commit

Permalink
update to new stable FCS
Browse files Browse the repository at this point in the history
  • Loading branch information
baronfel committed Feb 14, 2023
1 parent fbdf1f1 commit e556b8d
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 44 deletions.
5 changes: 1 addition & 4 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,8 @@ NUGET
FSharp.Compiler.Service (>= 41.0.1) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= net5.0))
FSharp.Core (>= 6.0.1) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= net5.0))
McMaster.NETCore.Plugins (>= 1.4) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= net5.0))
FSharp.Compiler.Service (42.7.101)
FSharp.Compiler.Service (43.7.200)
FSharp.Core (7.0)
Microsoft.Build.Framework (>= 17.4)
Microsoft.Build.Tasks.Core (>= 17.4)
Microsoft.Build.Utilities.Core (>= 17.4)
System.Buffers (>= 4.5.1)
System.Collections.Immutable (>= 6.0)
System.Memory (>= 4.5.5)
Expand Down
2 changes: 0 additions & 2 deletions src/FsAutoComplete.Core/CodeGeneration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -963,8 +963,6 @@ module CodeGenerationUtils =
)
| SynType.Array(dimension, TypeIdent typeName, _) -> Some(sprintf "%s [%s]" typeName (String(',', dimension - 1)))
| SynType.MeasurePower(TypeIdent typeName, RationalConst power, _) -> Some(sprintf "%s^%s" typeName power)
| SynType.MeasureDivide(TypeIdent numerator, TypeIdent denominator, _) ->
Some(sprintf "%s/%s" numerator denominator)
| _ -> None

let expandTypeParameters (typ: SynType) =
Expand Down
4 changes: 2 additions & 2 deletions src/FsAutoComplete.Core/InlayHints.fs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ and private defaultTraversePat visitor origPath pat =
| SynPat.LongIdent(argPats = args) ->
match args with
| SynArgPats.Pats ps -> ps |> List.tryPick (traversePat visitor path)
| SynArgPats.NamePatPairs(ps, _) ->
| SynArgPats.NamePatPairs(ps, _, _) ->
ps
|> List.map (fun (_, _, pat) -> pat)
|> List.tryPick (traversePat visitor path)
Expand Down Expand Up @@ -977,7 +977,7 @@ let provideHints (text: NamedText, parseAndCheck: ParseAndCheckResults, range: R
parseAndCheck.GetParseResults.FindParameterLocations(Position.fromZ line afterParenPosInLine)

let appliedArgRanges =
parseAndCheck.GetParseResults.GetAllArgumentsForFunctionApplicationAtPostion symbolUse.Range.Start
parseAndCheck.GetParseResults.GetAllArgumentsForFunctionApplicationAtPosition symbolUse.Range.Start

match tupledParamInfos, appliedArgRanges with
| None, None -> ()
Expand Down
8 changes: 5 additions & 3 deletions src/FsAutoComplete.Core/UnionPatternMatchCaseGenerator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ let private clauseIsCandidateForCodeGen (cursorPos: Position) (SynMatchClause(pa
// The cursor should not be in the nested patterns
Range.rangeContainsPos r cursorPos
&& List.forall (not << patIsCandidate) nestedPats
| SynPat.Tuple _ -> false
| SynPat.ListCons(lhs, rhs, r, _) -> patIsCandidate lhs || patIsCandidate rhs
| SynPat.Tuple _
| SynPat.ArrayOrList _
| SynPat.Record _
| SynPat.Null _
Expand Down Expand Up @@ -115,7 +116,7 @@ let private tryFindPatternMatchExprInParsedInput (pos: Position) (parsedInput: P
and walkSynMemberDefn (memberDefn: SynMemberDefn) =
getIfPosInRange memberDefn.Range (fun () ->
match memberDefn with
| SynMemberDefn.AbstractSlot(_synValSig, _memberFlags, _range) -> None
| SynMemberDefn.AbstractSlot(_synValSig, _memberFlags, _range, _) -> None
| SynMemberDefn.AutoProperty(synExpr = expr) -> walkExpr expr
| SynMemberDefn.Interface(members = members) -> Option.bind (List.tryPick walkSynMemberDefn) members
| SynMemberDefn.Member(binding, _range) -> walkBinding binding
Expand Down Expand Up @@ -306,6 +307,7 @@ let getWrittenCases (patMatchExpr: PatternMatchExpr) =
| SynPat.IsInst(_, _)
| SynPat.QuoteExpr(_, _)
| SynPat.DeprecatedCharRange(_, _, _)
| SynPat.ListCons _
| SynPat.FromParseError(_, _) -> false

| SynPat.Tuple(_, innerPatList, _) -> List.forall checkPattern innerPatList
Expand All @@ -330,7 +332,7 @@ let getWrittenCases (patMatchExpr: PatternMatchExpr) =
Some(func ())
else
None
| SynArgPats.NamePatPairs(namedPatList, _) ->
| SynArgPats.NamePatPairs(namedPatList, _, _) ->
let patList = namedPatList |> List.unzip3 |> (fun (_, _, pat) -> pat)

if List.forall checkPattern patList then
Expand Down
38 changes: 27 additions & 11 deletions src/FsAutoComplete.Core/UntypedAstUtils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ let rec (|Sequentials|_|) =
let (|ConstructorPats|) =
function
| SynArgPats.Pats ps -> ps
| SynArgPats.NamePatPairs(xs, _) -> xs |> List.map (fun (_, _, pat) -> pat)
| SynArgPats.NamePatPairs(pats = xs) -> xs |> List.map (fun (_, _, pat) -> pat)

/// matches if the range contains the position
let (|ContainsPos|_|) pos range =
Expand Down Expand Up @@ -112,9 +112,9 @@ let internal getRangesAtPosition input (r: Position) : Range list =
addIfInside r
walkTypar t
List.iter walkType ts
| SynTypeConstraint.WhereTyparSupportsMember(ts, sign, r) ->
| SynTypeConstraint.WhereTyparSupportsMember(t, sign, r) ->
addIfInside r
List.iter walkType ts
walkType t
walkMemberSig sign
| SynTypeConstraint.WhereSelfConstrained(t, r) ->
addIfInside r
Expand Down Expand Up @@ -164,6 +164,10 @@ let internal getRangesAtPosition input (r: Position) : Range list =
addIfInside r
walkPat lpat
walkPat rpat
| SynPat.ListCons(lpat, rpat, r, _) ->
addIfInside r
walkPat lpat
walkPat rpat

and walkTypar (SynTypar(_, _, _)) = ()

Expand All @@ -176,9 +180,17 @@ let internal getRangesAtPosition input (r: Position) : Range list =
walkExpr e

returnInfo
|> Option.iter (fun (SynBindingReturnInfo(t, r, _)) ->
|> Option.iter (fun (SynBindingReturnInfo(t, r, attrs, _)) ->
addIfInside r
walkType t)
walkType t
walkAttributes attrs)

and walkAttributes (attrs: SynAttributes) =
List.iter
(fun (attrList: SynAttributeList) ->
addIfInside attrList.Range
List.iter walkAttribute attrList.Attributes)
attrs

and walkInterfaceImpl (SynInterfaceImpl(bindings = bindings; range = r)) =
addIfInside r
Expand All @@ -191,8 +203,8 @@ let internal getRangesAtPosition input (r: Position) : Range list =
| SynType.MeasurePower(t, _, r) ->
addIfInside r
walkType t
| SynType.Fun(t1, t2, r, _)
| SynType.MeasureDivide(t1, t2, r) ->
| SynType.Fun(t1, t2, r, _) ->
// | SynType.MeasureDivide(t1, t2, r) ->
addIfInside r
walkType t1
walkType t2
Expand Down Expand Up @@ -227,6 +239,10 @@ let internal getRangesAtPosition input (r: Position) : Range list =
| SynType.SignatureParameter(usedType = t; range = r) ->
addIfInside r
walkType t
| SynType.Or(lhs, rhs, r, _) ->
addIfInside r
walkType lhs
walkType rhs

and walkClause (SynMatchClause(pat, e1, e2, r, _, _)) =
addIfInside r
Expand Down Expand Up @@ -379,9 +395,9 @@ let internal getRangesAtPosition input (r: Position) : Range list =
walkExpr body

walkExpr e2
| SynExpr.TraitCall(ts, sign, e, r) ->
| SynExpr.TraitCall(t, sign, e, r) ->
addIfInside r
List.iter walkType ts
walkType t
walkMemberSig sign
walkExpr e
| SynExpr.Const(SynConst.Measure(_, _, m), r) ->
Expand Down Expand Up @@ -483,7 +499,7 @@ let internal getRangesAtPosition input (r: Position) : Range list =
| SynMemberSig.Interface(t, r) ->
addIfInside r
walkType t
| SynMemberSig.Member(vs, _, r) ->
| SynMemberSig.Member(vs, _, r, _) ->
addIfInside r
walkValSig vs
| SynMemberSig.ValField(f, r) ->
Expand All @@ -505,7 +521,7 @@ let internal getRangesAtPosition input (r: Position) : Range list =

and walkMember =
function
| SynMemberDefn.AbstractSlot(valSig, _, r) ->
| SynMemberDefn.AbstractSlot(valSig, _, r, _) ->
addIfInside r
walkValSig valSig
| SynMemberDefn.Member(binding, r) ->
Expand Down
28 changes: 6 additions & 22 deletions src/FsAutoComplete/CodeFixes/ImplementInterface.fs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@ let private tryFindInsertionData (interfaceData: InterfaceData) (ast: ParsedInpu

match lastExistingMember with
| Some(SynBinding(
attributes = attributes; valData = SynValData(memberFlags = memberFlags); headPat = headPat; expr = expr)) ->
attributes = attributes
valData = SynValData(memberFlags = memberFlags)
headPat = headPat
expr = expr
trivia = trivia)) ->
// align with existing member
// insert after last member

Expand Down Expand Up @@ -191,27 +195,7 @@ let private tryFindInsertionData (interfaceData: InterfaceData) (ast: ParsedInpu
attributes
|> List.tryHead
|> Option.map (fun attr -> attr.Range.StartColumn)
|> Option.orElseWith (fun _ ->
// leftmost `member` or `override` (and just to be sure: `default`, `abstract` or `static`)
match memberFlags with
| Some memberFlags ->
let trivia = memberFlags.Trivia

[ trivia.StaticRange
trivia.MemberRange
trivia.OverrideRange
trivia.AbstractRange
trivia.DefaultRange ]
|> List.choose id
|> List.map (fun r -> r.StartColumn)
// List.tryMin
|> List.fold
(fun m c ->
match m with
| None -> Some c
| Some m -> min c m |> Some)
None
| None -> None)
|> Option.orElseWith (fun _ -> Some trivia.LeadingKeyword.Range.StartColumn)
|> Option.defaultValue
// fallback: start of head pat (should not happen -> always `member`)
headPat.Range.StartColumn
Expand Down

0 comments on commit e556b8d

Please sign in to comment.