From ac20c53ff22befc919d60bb055bb015fd9114f88 Mon Sep 17 00:00:00 2001 From: webwarrior Date: Wed, 31 Jan 2024 11:53:26 +0100 Subject: [PATCH] Framework,Rules: adapt code to changes in FCS Adapte code to changes in FSharp.Compiler.Service. --- .../Framework/AbstractSyntaxArray.fs | 2 +- src/FSharpLint.Core/Framework/Ast.fs | 64 ++++++++++++------- src/FSharpLint.Core/Framework/Utilities.fs | 4 +- .../Rules/Conventions/AvoidTooShortNames.fs | 6 +- .../Conventions/Binding/TupleOfWildcards.fs | 8 +-- .../FunctionReimplementationHelper.fs | 4 +- .../ReimplementsFunction.fs | 4 +- .../Conventions/Naming/EnumCasesNames.fs | 2 +- .../Conventions/Naming/GenericTypesNames.fs | 2 +- .../Rules/Conventions/Naming/MemberNames.fs | 2 +- .../Rules/Conventions/Naming/NamingHelper.fs | 13 ++-- .../Conventions/Naming/ParameterNames.fs | 2 +- .../NumberOfItems/MaxNumberOfMembers.fs | 2 +- .../Rules/Hints/HintMatcher.fs | 17 ++--- .../Rules/Typography/Indentation.fs | 2 +- .../Framework/TestAbstractSyntaxArray.fs | 2 +- 16 files changed, 73 insertions(+), 63 deletions(-) diff --git a/src/FSharpLint.Core/Framework/AbstractSyntaxArray.fs b/src/FSharpLint.Core/Framework/AbstractSyntaxArray.fs index 142b85c18..c19f2cc7e 100644 --- a/src/FSharpLint.Core/Framework/AbstractSyntaxArray.fs +++ b/src/FSharpLint.Core/Framework/AbstractSyntaxArray.fs @@ -107,7 +107,7 @@ module AbstractSyntaxArray = | Expression(_) -> SyntaxNode.Expression | Pattern(SynPat.Ands(_)) -> SyntaxNode.And | Pattern(SynPat.Or(_)) -> SyntaxNode.Or - | Pattern(Cons(_)) -> SyntaxNode.Cons + | Pattern(SynPat.ListCons(_)) -> SyntaxNode.Cons | Pattern(SynPat.Wild(_)) -> SyntaxNode.Wildcard | Pattern(SynPat.Const(constant, _)) -> constToSyntaxNode constant | Pattern(SynPat.ArrayOrList(_)) -> SyntaxNode.ArrayOrList diff --git a/src/FSharpLint.Core/Framework/Ast.fs b/src/FSharpLint.Core/Framework/Ast.fs index 74b8a1bf5..039e36c1c 100644 --- a/src/FSharpLint.Core/Framework/Ast.fs +++ b/src/FSharpLint.Core/Framework/Ast.fs @@ -108,9 +108,11 @@ module Ast = match pattern with | SynPat.LongIdent(SynLongIdent([identifier], _, _), _, _, - SynArgPats.Pats([SynPat.Tuple(_, [lhs; rhs], _)]), _, _) + SynArgPats.Pats([SynPat.Tuple(_, [lhs; rhs], _, _)]), _, _) when identifier.idText = "op_ColonColon" -> Some(lhs, rhs) + | SynPat.ListCons(lhsPat, rhsPat, _, _) -> + Some(lhsPat, rhsPat) | _ -> None /// Gets a string literal from the AST. @@ -146,13 +148,20 @@ module Ast = | SynType.App(synType, _, types, _, _, _, _) -> types |> List.revIter (Type >> add) add <| Type synType - | SynType.Tuple(_, types, _) -> - types |> List.revIter (snd >> Type >> add) + | SynType.Tuple(_, typeSegments, _) -> + typeSegments + |> List.revIter + (fun segment -> + match segment with + | SynTupleTypeSegment.Type(typ) -> typ |> Type |> add + | _ -> ()) | SynType.Fun(synType, synType1, _, _) - | SynType.StaticConstantNamed(synType, synType1, _) - | SynType.MeasureDivide(synType, synType1, _) -> + | SynType.Or(synType, synType1, _, _) + | SynType.StaticConstantNamed(synType, synType1, _) -> add <| Type synType1 add <| Type synType + | SynType.MeasurePower(synType, _, _) -> + add <| Type synType | SynType.Var(_) | SynType.Anon(_) | SynType.LongIdent(_) @@ -166,20 +175,26 @@ module Ast = typeNames |> List.revIter (snd >> Type >> add) | SynType.Paren(innerType, _) -> add <| Type innerType + | SynType.FromParseError(_) -> + () + | SynType.Intersection(_, types, _, _) -> + types |> List.revIter (Type >> add) + | SynType.SignatureParameter(_, _, _, synType, _) -> + add <| Type synType + /// Concatenates the typed-or-untyped structure of `SynSimplePats` into a `SynSimplePat list` to keep other code /// mostly unchanged. let inline extractPatterns (simplePats:SynSimplePats) = - let rec loop pat acc = + let loop pat acc = match pat with - | SynSimplePats.SimplePats(patterns, _range) -> patterns @ acc - | SynSimplePats.Typed(patterns, _type, _range) -> loop patterns acc + | SynSimplePats.SimplePats(patterns, _, _range) -> patterns @ acc loop simplePats [] let inline private memberDefinitionChildren node add = match node with | SynMemberDefn.Member(binding, _) -> add <| Binding binding - | SynMemberDefn.ImplicitCtor(_, _, patterns, _, _, _) -> + | SynMemberDefn.ImplicitCtor(_, _, patterns, _, _, _, _) -> let combinedPatterns = extractPatterns patterns combinedPatterns |> List.revIter (SimplePattern >> add) | SynMemberDefn.ImplicitInherit(synType, expression, _, _) -> @@ -195,10 +210,10 @@ module Ast = | SynMemberDefn.AbstractSlot(_) -> () | SynMemberDefn.ValField(field, _) -> add <| Field field | SynMemberDefn.NestedType(typeDefinition, _, _) -> add <| TypeDefinition typeDefinition - | SynMemberDefn.AutoProperty(_, _, _, Some(synType), _, _, _, _, _, expression, _, _, _) -> + | SynMemberDefn.AutoProperty(_, _, _, Some(synType), _, _, _, _, _, expression, _, _) -> add <| Expression expression add <| Type synType - | SynMemberDefn.AutoProperty(_, _, _, None, _, _, _, _, _, expression, _, _, _) -> + | SynMemberDefn.AutoProperty(_, _, _, None, _, _, _, _, _, expression, _, _) -> add <| Expression expression | SynMemberDefn.GetSetMember(memberDefnForGet, memberDefnForSet, _, _) -> memberDefnForGet |> Option.iter (Binding >> add) @@ -215,7 +230,7 @@ module Ast = add <| Pattern pattern1 add <| Pattern pattern | SynPat.ArrayOrList(_, patterns, _) - | SynPat.Tuple(_, patterns, _) + | SynPat.Tuple(_, patterns, _, _) | SynPat.Ands(patterns, _) -> patterns |> List.revIter (Pattern >> add) | SynPat.Attrib(pattern, _, _) | SynPat.Paren(pattern, _) -> add <| Pattern pattern @@ -225,10 +240,9 @@ module Ast = | SynPat.Wild(_) | SynPat.FromParseError(_) | SynPat.InstanceMember(_) - | SynPat.DeprecatedCharRange(_) | SynPat.Null(_) | SynPat.OptionalVal(_) -> () - | Cons(lhs, rhs) -> + | SynPat.ListCons(lhs, rhs, _, _) -> add <| Pattern rhs add <| Pattern lhs | SynPat.LongIdent(_, _, _, constructorArguments, _, _) -> @@ -277,9 +291,9 @@ module Ast = | SynExpr.ArrayOrList(_, expressions, _) -> expressions |> List.revIter (Expression >> add) | SynExpr.Record(_, Some(expr, _), _, _) -> add <| Expression expr | SynExpr.Record(_, None, _, _) -> () - | SynExpr.AnonRecd(_, Some (expr,_), _, _) -> + | SynExpr.AnonRecd(_, Some (expr,_), _, _, _) -> add <| Expression expr - | SynExpr.AnonRecd(_, None, _, _) -> () + | SynExpr.AnonRecd(_, None, _, _, _) -> () | SynExpr.ObjExpr(synType, _, _, bindings, _, _, _, _) -> bindings |> List.revIter (Binding >> add) add <| Type synType @@ -362,6 +376,13 @@ module Ast = | SynExpr.IndexRange(expr1, _, expr2, _, _, _) -> expr1 |> Option.iter (Expression >> add) expr2 |> Option.iter (Expression >> add) + | SynExpr.DotLambda(expr, _, _) -> + expr |> Expression |> add + | SynExpr.Typar(typar, _) -> + () + | SynExpr.WhileBang(_, whileExpr, doExpr, _) -> + add <| Expression whileExpr + add <| Expression doExpr let inline private typeSimpleRepresentationChildren node add = match node with @@ -376,11 +397,8 @@ module Ast = let inline private simplePatternsChildren node add = match node with - | SynSimplePats.SimplePats(simplePatterns, _) -> + | SynSimplePats.SimplePats(simplePatterns, _, _) -> simplePatterns |> List.revIter (SimplePattern >> add) - | SynSimplePats.Typed(simplePatterns, synType, _) -> - add <| Type synType - add <| SimplePatterns simplePatterns let inline private simplePatternChildren node add = match node with @@ -404,7 +422,7 @@ module Ast = match node with | SynArgPats.Pats(patterns) -> patterns |> List.revIter (Pattern >> add) - | SynArgPats.NamePatPairs(namePatterns, _) -> + | SynArgPats.NamePatPairs(namePatterns, _, _) -> namePatterns |> List.revIter (fun (_, _, pattern) -> pattern |> Pattern |> add) let inline private typeRepresentationChildren node add = @@ -443,7 +461,7 @@ module Ast = | Type(x) -> typeChildren x add | Match(x) -> matchChildren x add | MemberDefinition(x) -> memberDefinitionChildren x add - | Field(SynField(_, _, _, synType, _, _, _, _)) -> add <| Type synType + | Field(SynField(_, _, _, synType, _, _, _, _, _)) -> add <| Type synType | Pattern(x) -> patternChildren x add | ConstructorArguments(x) -> constructorArgumentsChildren x add | SimplePattern(x) -> simplePatternChildren x add @@ -462,7 +480,7 @@ module Ast = | Else(x) | Expression(x) -> expressionChildren x add - | File(ParsedInput.ImplFile(ParsedImplFileInput(_, _, _, _, _, moduleOrNamespaces, _, _))) -> + | File(ParsedInput.ImplFile(ParsedImplFileInput(_, _, _, _, _, moduleOrNamespaces, _, _, _))) -> moduleOrNamespaces |> List.revIter (ModuleOrNamespace >> add) | UnionCase(x) -> unionCaseChildren x add diff --git a/src/FSharpLint.Core/Framework/Utilities.fs b/src/FSharpLint.Core/Framework/Utilities.fs index 398f8b1df..6aae803c7 100644 --- a/src/FSharpLint.Core/Framework/Utilities.fs +++ b/src/FSharpLint.Core/Framework/Utilities.fs @@ -48,8 +48,8 @@ module ExpressionUtilities = /// Converts an operator name e.g. op_Add to the operator symbol e.g. + let identAsDecompiledOpName (ident:Ident) = - if ident.idText.StartsWith("op_") then - PrettyNaming.DecompileOpName ident.idText + if PrettyNaming.IsLogicalOpName ident.idText then + PrettyNaming.ConvertValLogicalNameToDisplayNameCore ident.idText else ident.idText let identAsCompiledOpName (identName: string) = diff --git a/src/FSharpLint.Core/Rules/Conventions/AvoidTooShortNames.fs b/src/FSharpLint.Core/Rules/Conventions/AvoidTooShortNames.fs index 6b6ef5423..70b2b87a1 100644 --- a/src/FSharpLint.Core/Rules/Conventions/AvoidTooShortNames.fs +++ b/src/FSharpLint.Core/Rules/Conventions/AvoidTooShortNames.fs @@ -40,7 +40,7 @@ let private getParameterWithBelowMinimumLength (pats: SynPat list): (Ident * str match pat with | SynPat.Typed(typedPat, _, _) -> loop (typedPat::tail) acc - | SynPat.Tuple(_, elementPats, _) -> + | SynPat.Tuple(_, elementPats, _, _) -> loop elementPats acc | _ -> loop (pat::tail) acc | SynPat.LongIdent(_, _, _, argPats, _, _)::tail -> @@ -77,12 +77,12 @@ let private getIdentifiers (args:AstNodeRuleParams) = | SynPat.Named(SynIdent(identifier, _), _, _, _) when isIdentifierTooShort identifier.idText -> (identifier, identifier.idText, None) |> Array.singleton | _ -> Array.empty - | AstNode.Field(SynField(_, _, Some identifier, _, _, _, _, _)) when isIdentifierTooShort identifier.idText -> + | AstNode.Field(SynField(_, _, Some identifier, _, _, _, _, _, _)) when isIdentifierTooShort identifier.idText -> (identifier, identifier.idText, None) |> Array.singleton | AstNode.TypeDefinition(SynTypeDefn(componentInfo, _typeDef, _, _, _, _)) -> let checkTypes types = seq { - for SynTyparDecl(_attr, SynTypar(id, _, _)) in types do + for SynTyparDecl(_attr, SynTypar(id, _, _), _, _) in types do if isIdentifierTooShort id.idText then yield (id, id.idText, None) } diff --git a/src/FSharpLint.Core/Rules/Conventions/Binding/TupleOfWildcards.fs b/src/FSharpLint.Core/Rules/Conventions/Binding/TupleOfWildcards.fs index 2fc6757b1..9dcb453df 100644 --- a/src/FSharpLint.Core/Rules/Conventions/Binding/TupleOfWildcards.fs +++ b/src/FSharpLint.Core/Rules/Conventions/Binding/TupleOfWildcards.fs @@ -19,7 +19,7 @@ let private checkTupleOfWildcards pattern identifier = constructorName + "(" + arguments + ")" match pattern with - | SynPat.Tuple(_isStruct, patterns, range) when List.length patterns > 1 && patterns |> List.forall isWildcard -> + | SynPat.Tuple(_isStruct, patterns, _commaRanges, range) when List.length patterns > 1 && patterns |> List.forall isWildcard -> let errorFormat = Resources.GetString("RulesTupleOfWildcardsError") let refactorFrom = constructorString (List.length patterns) let refactorTo = (constructorString 1) @@ -37,14 +37,14 @@ let private isTupleMemberArgs breadcrumbs tupleRange = | _ -> None match breadcrumbs with - | AstNode.Binding(MemberBindingArgs(SynPat.Tuple(_, _, range)))::AstNode.Expression(SynExpr.ObjExpr(_))::_ - | AstNode.Binding(MemberBindingArgs(SynPat.Tuple(_, _, range)))::AstNode.MemberDefinition(_)::_ -> + | AstNode.Binding(MemberBindingArgs(SynPat.Tuple(_, _, _, range)))::AstNode.Expression(SynExpr.ObjExpr(_))::_ + | AstNode.Binding(MemberBindingArgs(SynPat.Tuple(_, _, _, range)))::AstNode.MemberDefinition(_)::_ -> tupleRange = range | _ -> false let private runner (args:AstNodeRuleParams) = match args.AstNode with - | AstNode.Pattern(SynPat.LongIdent(identifier, _, _, SynArgPats.Pats([SynPat.Paren(SynPat.Tuple(_, _, range) as pattern, _)]), _, _)) -> + | AstNode.Pattern(SynPat.LongIdent(identifier, _, _, SynArgPats.Pats([SynPat.Paren(SynPat.Tuple(_, _, _, range) as pattern, _)]), _, _)) -> let breadcrumbs = args.GetParents 2 if (not << isTupleMemberArgs breadcrumbs) range then let identifier = identifier.LongIdent |> List.map (fun x -> x.idText) diff --git a/src/FSharpLint.Core/Rules/Conventions/FunctionReimplementation/FunctionReimplementationHelper.fs b/src/FSharpLint.Core/Rules/Conventions/FunctionReimplementation/FunctionReimplementationHelper.fs index 94cb0d1e8..ab67e2a47 100644 --- a/src/FSharpLint.Core/Rules/Conventions/FunctionReimplementation/FunctionReimplementationHelper.fs +++ b/src/FSharpLint.Core/Rules/Conventions/FunctionReimplementation/FunctionReimplementationHelper.fs @@ -5,7 +5,7 @@ open FSharpLint.Framework.Ast open FSharpLint.Framework.Rules let rec getLambdaParamIdent = function - | SynSimplePats.SimplePats([pattern], _) -> + | SynSimplePats.SimplePats([pattern], _, _) -> let rec getIdent = function | SynSimplePat.Id(ident, _, _, _, _, _) -> ident | SynSimplePat.Typed(simplePattern, _, _) @@ -14,8 +14,6 @@ let rec getLambdaParamIdent = function getIdent pattern |> Some | SynSimplePats.SimplePats(_) -> None - | SynSimplePats.Typed(simplePatterns, _, _) -> - getLambdaParamIdent simplePatterns let checkLambda (args:AstNodeRuleParams) checker = match args.AstNode with diff --git a/src/FSharpLint.Core/Rules/Conventions/FunctionReimplementation/ReimplementsFunction.fs b/src/FSharpLint.Core/Rules/Conventions/FunctionReimplementation/ReimplementsFunction.fs index a4faa6e22..1fb561281 100644 --- a/src/FSharpLint.Core/Rules/Conventions/FunctionReimplementation/ReimplementsFunction.fs +++ b/src/FSharpLint.Core/Rules/Conventions/FunctionReimplementation/ReimplementsFunction.fs @@ -25,8 +25,8 @@ let private validateLambdaIsNotPointless (text:string) lambda range = let identifier = identifier |> List.map (fun x -> - if PrettyNaming.IsMangledOpName x.idText then - PrettyNaming.DecompileOpName x.idText |> sprintf "( %s )" + if PrettyNaming.IsLogicalOpName x.idText then + PrettyNaming.ConvertValLogicalNameToDisplayNameCore x.idText |> sprintf "( %s )" else x.idText) |> String.concat "." diff --git a/src/FSharpLint.Core/Rules/Conventions/Naming/EnumCasesNames.fs b/src/FSharpLint.Core/Rules/Conventions/Naming/EnumCasesNames.fs index a4252b9e7..b0d5c260a 100644 --- a/src/FSharpLint.Core/Rules/Conventions/Naming/EnumCasesNames.fs +++ b/src/FSharpLint.Core/Rules/Conventions/Naming/EnumCasesNames.fs @@ -7,7 +7,7 @@ open FSharpLint.Rules.Helper.Naming let private getIdentifiers (args:AstNodeRuleParams) = match args.AstNode with - | AstNode.EnumCase(SynEnumCase(_, SynIdent(identifier, _), _, _, _, _, _)) -> + | AstNode.EnumCase(SynEnumCase(_, SynIdent(identifier, _), _, _, _, _)) -> (identifier, identifier.idText, None) |> Array.singleton | _ -> Array.empty diff --git a/src/FSharpLint.Core/Rules/Conventions/Naming/GenericTypesNames.fs b/src/FSharpLint.Core/Rules/Conventions/Naming/GenericTypesNames.fs index d67553ef3..cadbc9f5d 100644 --- a/src/FSharpLint.Core/Rules/Conventions/Naming/GenericTypesNames.fs +++ b/src/FSharpLint.Core/Rules/Conventions/Naming/GenericTypesNames.fs @@ -10,7 +10,7 @@ let private getIdentifiers (args: AstNodeRuleParams) = | AstNode.TypeDefinition(SynTypeDefn(componentInfo, _typeDef, _, _, _, _)) -> let checkTypes types = seq { - for SynTyparDecl(_attr, SynTypar(id, _, _)) in types do + for SynTyparDecl(_attr, SynTypar(id, _, _), _, _) in types do yield (id, id.idText, None) } diff --git a/src/FSharpLint.Core/Rules/Conventions/Naming/MemberNames.fs b/src/FSharpLint.Core/Rules/Conventions/Naming/MemberNames.fs index 486de1b1c..2e29ee179 100644 --- a/src/FSharpLint.Core/Rules/Conventions/Naming/MemberNames.fs +++ b/src/FSharpLint.Core/Rules/Conventions/Naming/MemberNames.fs @@ -35,7 +35,7 @@ let private getIdentifiers (args:AstNodeRuleParams) = Array.empty | AstNode.MemberDefinition(memberDef) -> match memberDef with - | SynMemberDefn.AbstractSlot(SynValSig(_, SynIdent(identifier, _), _, _, _, _, _, _, _, _, _, _), _, _) -> + | SynMemberDefn.AbstractSlot(SynValSig(_, SynIdent(identifier, _), _, _, _, _, _, _, _, _, _, _), _, _, _) -> (identifier, identifier.idText, None) |> Array.singleton | _ -> Array.empty | _ -> Array.empty diff --git a/src/FSharpLint.Core/Rules/Conventions/Naming/NamingHelper.fs b/src/FSharpLint.Core/Rules/Conventions/Naming/NamingHelper.fs index b71ce007b..b6944c385 100644 --- a/src/FSharpLint.Core/Rules/Conventions/Naming/NamingHelper.fs +++ b/src/FSharpLint.Core/Rules/Conventions/Naming/NamingHelper.fs @@ -203,7 +203,7 @@ let getAccessControlLevel (syntaxArray:AbstractSyntaxArray.Node []) i = | TypeSimpleRepresentation(SynTypeDefnSimpleRepr.Record(access, _, _)) | TypeSimpleRepresentation(SynTypeDefnSimpleRepr.Union(access, _, _)) | UnionCase(SynUnionCase(_, _, _, _, access, _, _)) - | Field(SynField(_, _, _, _, _, _, access, _)) + | Field(SynField(_, _, _, _, _, _, access, _, _)) | ComponentInfo(SynComponentInfo(_, _, _, _, _, _, access, _)) | ModuleOrNamespace (SynModuleOrNamespace.SynModuleOrNamespace(_, _, _, _, _, _, access, _, _)) | ExceptionRepresentation(SynExceptionDefnRepr.SynExceptionDefnRepr(_, _, _, _, access, _)) @@ -318,12 +318,12 @@ let rec getPatternIdents<'T> (accessibility:AccessControlLevel) (getIdents:GetId let hasNoArgs = match args with - | SynArgPats.NamePatPairs(pats, _) -> pats.IsEmpty + | SynArgPats.NamePatPairs(pats, _, _) -> pats.IsEmpty | SynArgPats.Pats(pats) -> pats.IsEmpty let argSuggestions = match args with - | SynArgPats.NamePatPairs(pats, _) -> + | SynArgPats.NamePatPairs(pats, _, _) -> pats |> List.toArray |> Array.collect (fun(_, _, synPat) -> getPatternIdents AccessControlLevel.Private getIdents false synPat) @@ -347,7 +347,7 @@ let rec getPatternIdents<'T> (accessibility:AccessControlLevel) (getIdents:GetId | SynPat.Paren(p, _) -> getPatternIdents accessibility getIdents false p | SynPat.Ands(pats, _) - | SynPat.Tuple(_, pats, _) + | SynPat.Tuple(_, pats, _, _) | SynPat.ArrayOrList(_, pats, _) -> pats |> List.toArray @@ -361,11 +361,14 @@ let rec getPatternIdents<'T> (accessibility:AccessControlLevel) (getIdents:GetId | SynPat.Const(_) | SynPat.Wild(_) | SynPat.OptionalVal(_) - | SynPat.DeprecatedCharRange(_) | SynPat.InstanceMember(_) | SynPat.FromParseError(_) -> Array.empty + | SynPat.InstanceMember(_) | SynPat.FromParseError(_) -> Array.empty | SynPat.As(lhsPat, rhsPat, _) -> Array.append (getPatternIdents accessibility getIdents false lhsPat) (getPatternIdents accessibility getIdents false rhsPat) + | SynPat.ListCons(lhsPat, rhsPat, _, _) -> + [|lhsPat; rhsPat|] + |> Array.collect (getPatternIdents accessibility getIdents false) let rec identFromSimplePat = function | SynSimplePat.Id(ident, _, _, _, _, _) -> Some ident diff --git a/src/FSharpLint.Core/Rules/Conventions/Naming/ParameterNames.fs b/src/FSharpLint.Core/Rules/Conventions/Naming/ParameterNames.fs index b5a5c6297..e2f49b2eb 100644 --- a/src/FSharpLint.Core/Rules/Conventions/Naming/ParameterNames.fs +++ b/src/FSharpLint.Core/Rules/Conventions/Naming/ParameterNames.fs @@ -29,7 +29,7 @@ let private getIdentifiers (args:AstNodeRuleParams) = match args.AstNode with | AstNode.MemberDefinition(memberDef) -> match memberDef with - | SynMemberDefn.ImplicitCtor(_, _, ctorArgs, _, _, _) -> + | SynMemberDefn.ImplicitCtor(_, _, ctorArgs, _, _, _, _) -> ctorArgs |> extractPatterns |> List.toArray diff --git a/src/FSharpLint.Core/Rules/Conventions/NumberOfItems/MaxNumberOfMembers.fs b/src/FSharpLint.Core/Rules/Conventions/NumberOfItems/MaxNumberOfMembers.fs index 4a01efa30..946a07bc2 100644 --- a/src/FSharpLint.Core/Rules/Conventions/NumberOfItems/MaxNumberOfMembers.fs +++ b/src/FSharpLint.Core/Rules/Conventions/NumberOfItems/MaxNumberOfMembers.fs @@ -15,7 +15,7 @@ let private getMembers (members:SynMemberDefn list) = let isPublicMember = function | SynMemberDefn.AbstractSlot(_) -> true | SynMemberDefn.Member(SynBinding(access, _, _, _, _, _, _, _, _, _, _, _, _), _) - | SynMemberDefn.AutoProperty(_, _, _, _, _, _, _, access, _, _, _, _, _) -> isPublic access + | SynMemberDefn.AutoProperty(_, _, _, _, _, _, _, _, access, _, _, _) -> isPublic access | _ -> false members diff --git a/src/FSharpLint.Core/Rules/Hints/HintMatcher.fs b/src/FSharpLint.Core/Rules/Hints/HintMatcher.fs index d3d3742b9..33bd59e36 100644 --- a/src/FSharpLint.Core/Rules/Hints/HintMatcher.fs +++ b/src/FSharpLint.Core/Rules/Hints/HintMatcher.fs @@ -16,11 +16,9 @@ open FSharpLint.Framework.Rules type Config = { HintTrie:MergeSyntaxTrees.Edges } -let rec private extractSimplePatterns = function - | SynSimplePats.SimplePats(simplePatterns, _) -> +let private extractSimplePatterns = function + | SynSimplePats.SimplePats(simplePatterns, _, _) -> simplePatterns - | SynSimplePats.Typed(simplePatterns, _, _) -> - extractSimplePatterns simplePatterns let rec private extractIdent = function | SynSimplePat.Id(ident, _, isCompilerGenerated, _, _, _) -> (ident, isCompilerGenerated) @@ -443,20 +441,13 @@ module private MatchPattern = and private matchTuple (pattern, hint) = match (pattern, hint) with - | SynPat.Tuple(_, patterns, _), Pattern.Tuple(hintExpressions) -> + | SynPat.Tuple(_, patterns, _, _), Pattern.Tuple(hintExpressions) -> doPatternsMatch patterns hintExpressions | _ -> false and private matchConsPattern (pattern, hint) = match (pattern, hint) with - | SynPat.LongIdent( - SynLongIdent([ident], _, _), - _, - _, - SynArgPats.Pats([SynPat.Tuple(_, [leftPattern;rightPattern], _)]), - _, - _), Pattern.Cons(left, right) - when ident.idText = "op_ColonColon" -> + | SynPat.ListCons(leftPattern, rightPattern, _, _), Pattern.Cons(left, right) -> matchHintPattern (leftPattern, left) && matchHintPattern (rightPattern, right) | _ -> false diff --git a/src/FSharpLint.Core/Rules/Typography/Indentation.fs b/src/FSharpLint.Core/Rules/Typography/Indentation.fs index b393995cb..2f5ed2ae8 100644 --- a/src/FSharpLint.Core/Rules/Typography/Indentation.fs +++ b/src/FSharpLint.Core/Rules/Typography/Indentation.fs @@ -63,7 +63,7 @@ module ContextBuilder = match node with | TypeDefinition (SynTypeDefn(_, SynTypeDefnRepr.Simple(SynTypeDefnSimpleRepr.Record(_, fields, _), _), _, _, _, _)) -> fields - |> List.map (fun (SynField (_, _, _, _, _, _, _, range)) -> range) + |> List.map (fun (SynField (_, _, _, _, _, _, _, range, _)) -> range) |> firstRangePerLine |> createAbsoluteAndOffsetOverridesBasedOnFirst | Expression (SynExpr.Tuple (_, exprs, _, _)) -> diff --git a/tests/FSharpLint.Core.Tests/Framework/TestAbstractSyntaxArray.fs b/tests/FSharpLint.Core.Tests/Framework/TestAbstractSyntaxArray.fs index dc030093c..ebedd06c9 100644 --- a/tests/FSharpLint.Core.Tests/Framework/TestAbstractSyntaxArray.fs +++ b/tests/FSharpLint.Core.Tests/Framework/TestAbstractSyntaxArray.fs @@ -26,7 +26,7 @@ type TestAst() = match ast with | ParsedInput.ImplFile(x) -> match x with - | ParsedImplFileInput(_, _, _, _, _, Module(app)::_, _, _) -> + | ParsedImplFileInput(_, _, _, _, _, Module(app)::_, _, _, _) -> app | _ -> failwith "Expected at least one module or namespace." | _ -> failwith "Expected an implementation file."