diff --git a/ReSharper.FSharp/src/FSharp.Common/src/Util/FSharpGlobalUtil.fs b/ReSharper.FSharp/src/FSharp.Common/src/Util/FSharpGlobalUtil.fs index af2f947656..e22ea02a64 100644 --- a/ReSharper.FSharp/src/FSharp.Common/src/Util/FSharpGlobalUtil.fs +++ b/ReSharper.FSharp/src/FSharp.Common/src/Util/FSharpGlobalUtil.fs @@ -19,7 +19,7 @@ module FSharpGlobalUtil = let someUnit = Some () - let (|IsNonNull|_|) value = + let (|NotNull|_|) value = if isNotNull value then Some value else None diff --git a/ReSharper.FSharp/src/FSharp.Psi.Features/src/RearrangeCode/RearrangeCode.fs b/ReSharper.FSharp/src/FSharp.Psi.Features/src/RearrangeCode/RearrangeCode.fs index b041432066..4e44f1532b 100644 --- a/ReSharper.FSharp/src/FSharp.Psi.Features/src/RearrangeCode/RearrangeCode.fs +++ b/ReSharper.FSharp/src/FSharp.Psi.Features/src/RearrangeCode/RearrangeCode.fs @@ -1,5 +1,6 @@ module JetBrains.ReSharper.Plugins.FSharp.Psi.Features.RearrangeCode.RearrangeCode +open System open JetBrains.Diagnostics open JetBrains.ReSharper.Feature.Services.RearrangeCode open JetBrains.ReSharper.Plugins.FSharp.Psi @@ -7,40 +8,34 @@ open JetBrains.ReSharper.Plugins.FSharp.Psi.Impl.Tree open JetBrains.ReSharper.Plugins.FSharp.Psi.Parsing open JetBrains.ReSharper.Plugins.FSharp.Psi.Tree open JetBrains.ReSharper.Psi.ExtensionsAPI.Tree +open JetBrains.ReSharper.Psi.Tree +open JetBrains.ReSharper.Psi.Util open JetBrains.ReSharper.Resources.Shell -// todo: move xmldoc +type FSharpRearrangeableSimpleSwap<'TNode, 'TParent when + 'TNode: not struct and 'TNode :> ITreeNode and + 'TParent: not struct and 'TParent :> ITreeNode>(title, direction, parentFunc, + childrenFunc: 'TParent -> TreeNodeEnumerable<'TNode>) = + inherit RearrangeableSimpleSwap<'TNode>.SimpleSwapType<'TParent>(title, direction, Func<_,_>(parentFunc), + Func<_,_>(childrenFunc >> Seq.cast)) -type RearrangeableCaseFieldDeclaration(field: ICaseFieldDeclaration) = - inherit RearrangeableElementSwap(field, "case field declaration", Direction.LeftRight) - - override this.GetSiblings() = - UnionCaseFieldDeclarationListNavigator.GetByField(field).NotNull().Fields :> _ [] type RearrangeableCaseFieldDeclarationProvider() = - inherit RearrangeableSingleElementBase.TypeBase() - - override this.CreateElement(field: ICaseFieldDeclaration): IRearrangeable = - RearrangeableCaseFieldDeclaration(field) :> _ + inherit FSharpRearrangeableSimpleSwap( + "case field declaration", Direction.LeftRight, UnionCaseFieldDeclarationListNavigator.GetByField, + fun l -> l.FieldsEnumerable) -type RearrangeableRecordFieldDeclaration(field: IRecordFieldDeclaration) = - inherit RearrangeableElementSwap(field, "record field declaration", Direction.All) - - override this.GetSiblings() = - RecordFieldDeclarationListNavigator.GetByFieldDeclaration(field).NotNull().FieldDeclarations :> _ - [] type RearrangeableRecordFieldDeclarationProvider() = - inherit RearrangeableSingleElementBase.TypeBase() - - override this.CreateElement(field: IRecordFieldDeclaration): IRearrangeable = - RearrangeableRecordFieldDeclaration(field) :> _ + inherit FSharpRearrangeableSimpleSwap( + "record field declaration", Direction.All, RecordFieldDeclarationListNavigator.GetByFieldDeclaration, + fun l -> l.FieldDeclarationsEnumerable) -type RearrangeableEnumCaseLikeDeclaration(caseDeclaration: IEnumCaseLikeDeclaration) = - inherit RearrangeableElementSwap(caseDeclaration, "enum case like declaration", Direction.All) +type RearrangeableEnumCaseLikeDeclaration(decl: IEnumCaseLikeDeclaration) = + inherit RearrangeableElementSwap(decl, "enum case like declaration", Direction.All) let addBarIfNeeded (caseDeclaration: IEnumCaseLikeDeclaration) = if isNull caseDeclaration.Bar && isNotNull caseDeclaration.FirstChild then @@ -51,14 +46,14 @@ type RearrangeableEnumCaseLikeDeclaration(caseDeclaration: IEnumCaseLikeDeclarat ] |> ignore override this.GetSiblings() = - match caseDeclaration with + match decl with | :? IUnionCaseDeclaration as caseDeclaration -> UnionRepresentationNavigator.GetByUnionCase(caseDeclaration).NotNull().UnionCases |> Seq.cast | :? IEnumCaseDeclaration as caseDeclaration -> EnumRepresentationNavigator.GetByEnumCase(caseDeclaration).NotNull().EnumCases |> Seq.cast - | _ -> failwithf $"Unexpected declaration: {caseDeclaration}" + | _ -> failwithf $"Unexpected declaration: {decl}" override this.Swap(child, target) = addBarIfNeeded child @@ -72,3 +67,98 @@ type RearrangeableEnumCaseLikeDeclarationProvider() = override this.CreateElement(caseDeclaration: IEnumCaseLikeDeclaration): IRearrangeable = RearrangeableEnumCaseLikeDeclaration(caseDeclaration) :> _ + + +type RearrangeableMatchClause(matchClause: IMatchClause, matchExpr: IMatchLikeExpr) = + inherit RearrangeableElementSwap(matchClause, "match clause", Direction.All) + + let isLastClause (clause: IMatchClause) = + clause == matchExpr.Clauses.Last() + + let missingIndent (clause: IMatchClause) = + let expr = clause.Expression + isNotNull expr && clause.Indent = expr.Indent + + let addIndent (clause: IMatchClause) = + if not (isLastClause clause) then () else + + let expr = clause.Expression + if isNull expr || expr.Indent <> clause.Indent then () else + + if expr.IsSingleLine then + let oldRange = TreeRange(clause.RArrow.NextSibling, expr.PrevSibling) + ModificationUtil.ReplaceChildRange(oldRange, TreeRange(Whitespace())) |> ignore + else + if clause.RArrow.StartLine.Plus1() < expr.StartLine then + let lineEnding = expr.GetLineEnding() + let oldRange = TreeRange(clause.RArrow.NextSibling, expr.PrevSibling) + ModificationUtil.DeleteChildRange(oldRange) + ModificationUtil.AddChildAfter(clause.RArrow, Whitespace(clause.Indent)) |> ignore + ModificationUtil.AddChildAfter(clause.RArrow, NewLine(lineEnding)) |> ignore + + let indentSize = expr.GetIndentSize() + shiftWithWhitespaceBefore indentSize expr + + let removeIndent (clause: IMatchClause) (expr: IFSharpExpression) = + let clauseIndent = clause.Indent + let indentDiff = expr.Indent - clauseIndent + + shiftWithWhitespaceBefore -indentDiff expr + + let arrow = clause.RArrow + let arrowStartLine = arrow.StartLine + let exprStartLine = expr.StartLine + + if arrowStartLine.Plus1() >= exprStartLine then + let lineEnding = expr.GetLineEnding() + addNodesAfter arrow [ + NewLine(lineEnding) + if arrowStartLine = exprStartLine then + NewLine(lineEnding) + Whitespace(clauseIndent) + ] |> ignore + + override this.Swap(child, target) = + addIndent child + addIndent target + + base.Swap(child, target) + + override this.GetSiblings() = + matchExpr.Clauses :> _ + + override this.MoveUnderPsiTransaction(direction) = + use writeLockCookie = WriteLockCookie.Create(matchClause.IsPhysical()) + + // todo: comments + + match isLastClause matchClause, matchClause.Expression, missingIndent matchClause, direction with + | true, NotNull expr, _, Direction.Down -> + removeIndent matchClause expr + expr :> _ + + | true, NotNull expr, true, Direction.Up -> + addIndent matchClause + expr :> _ + + | _ -> base.MoveUnderPsiTransaction(direction) + + override this.CanMove(direction) = + base.CanMove(direction) || + + match isLastClause matchClause, matchClause.Expression, missingIndent matchClause, direction with + | true, NotNull expr, _, Direction.Down -> + let arrow = matchClause.RArrow + isNotNull arrow && arrow.StartLine.Plus1() >= expr.StartLine + | true, NotNull _, true, Direction.Up -> true + | _ -> false + +[] +type RearrangeableMatchClauseProvider() = + inherit RearrangeableSingleElementBase.TypeBase() + + override this.CreateElement(clause: IMatchClause): IRearrangeable = + let matchExpr = MatchExprNavigator.GetByClause(clause) + if isNull matchExpr then null else + + RearrangeableMatchClause(clause, matchExpr) :> _ diff --git a/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 01.fs b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 01.fs new file mode 100644 index 0000000000..af2a17c01a --- /dev/null +++ b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 01.fs @@ -0,0 +1,6 @@ +// ${DIRECTION:Down} + +do + match () with + | a -> () + | b -> (){caret} diff --git a/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 01.fs.gold b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 01.fs.gold new file mode 100644 index 0000000000..d449a313d5 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 01.fs.gold @@ -0,0 +1,8 @@ +// ${DIRECTION:Down} + +do + match () with + | a -> () + | b -> + + () diff --git a/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 02 - Multiline.fs b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 02 - Multiline.fs new file mode 100644 index 0000000000..7681000d9f --- /dev/null +++ b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 02 - Multiline.fs @@ -0,0 +1,7 @@ +// ${DIRECTION:Down} + +do + match () with + | a -> () + | b -> [1 + 2]{caret} diff --git a/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 02 - Multiline.fs.gold b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 02 - Multiline.fs.gold new file mode 100644 index 0000000000..bc0e6cae74 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 02 - Multiline.fs.gold @@ -0,0 +1,9 @@ +// ${DIRECTION:Down} + +do + match () with + | a -> () + | b -> + + [1 + 2] diff --git a/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 03 - Lambda body.fs b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 03 - Lambda body.fs new file mode 100644 index 0000000000..de84df8fe1 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 03 - Lambda body.fs @@ -0,0 +1,7 @@ +// ${DIRECTION:Down} + +do + match () with + | a -> () + | b -> fun _ -> + (){caret} diff --git a/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 04 - Add empty line.fs b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 04 - Add empty line.fs new file mode 100644 index 0000000000..2869c314da --- /dev/null +++ b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 04 - Add empty line.fs @@ -0,0 +1,7 @@ +// ${DIRECTION:Down} + +do + match () with + | a -> () + | b -> + (){caret} diff --git a/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 04 - Add empty line.fs.gold b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 04 - Add empty line.fs.gold new file mode 100644 index 0000000000..d449a313d5 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 04 - Add empty line.fs.gold @@ -0,0 +1,8 @@ +// ${DIRECTION:Down} + +do + match () with + | a -> () + | b -> + + () diff --git a/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 05 - Not applicable.fs b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 05 - Not applicable.fs new file mode 100644 index 0000000000..4f8cc0b144 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 05 - Not applicable.fs @@ -0,0 +1,8 @@ +// ${DIRECTION:Down} + +do + match () with + | a -> () + | b -> + + (){caret} diff --git a/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 05 - Not applicable.fs.gold b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 05 - Not applicable.fs.gold new file mode 100644 index 0000000000..a28b5e3dfc --- /dev/null +++ b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 05 - Not applicable.fs.gold @@ -0,0 +1,8 @@ +// ${DIRECTION:Down} + +do + match () with + | a -> () + | b -> + + () diff --git a/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 06 - App.fs b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 06 - App.fs new file mode 100644 index 0000000000..77fb4ed393 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 06 - App.fs @@ -0,0 +1,7 @@ +// ${DIRECTION:Down} + +do + match () with + | a -> () + | b -> ignore + (){caret} diff --git a/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 06 - App.fs.gold b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 06 - App.fs.gold new file mode 100644 index 0000000000..09a625e0c9 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 06 - App.fs.gold @@ -0,0 +1,9 @@ +// ${DIRECTION:Down} + +do + match () with + | a -> () + | b -> + + ignore + () diff --git a/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 07 - New line.fs b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 07 - New line.fs new file mode 100644 index 0000000000..6c43d07bcc --- /dev/null +++ b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 07 - New line.fs @@ -0,0 +1,7 @@ +// ${DIRECTION:Down} + +do + match () with + | a -> () + | b -> + (){caret} diff --git a/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 07 - New line.fs.gold b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 07 - New line.fs.gold new file mode 100644 index 0000000000..d449a313d5 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 07 - New line.fs.gold @@ -0,0 +1,8 @@ +// ${DIRECTION:Down} + +do + match () with + | a -> () + | b -> + + () diff --git a/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 08 - Operator deindent.fs b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 08 - Operator deindent.fs new file mode 100644 index 0000000000..589f62a1d9 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 08 - Operator deindent.fs @@ -0,0 +1,7 @@ +// ${DIRECTION:Down} + +do + match () with + | a -> () + | b -> 1{caret} + + 1 diff --git a/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 08 - Operator deindent.fs.gold b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 08 - Operator deindent.fs.gold new file mode 100644 index 0000000000..a9480f9fa9 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 08 - Operator deindent.fs.gold @@ -0,0 +1,9 @@ +// ${DIRECTION:Down} + +do + match () with + | a -> () + | b -> + + 1 + + 1 diff --git a/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 09 - Operator deindent.fs b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 09 - Operator deindent.fs new file mode 100644 index 0000000000..c4ad6d85d2 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 09 - Operator deindent.fs @@ -0,0 +1,6 @@ +// ${DIRECTION:Down} + +match () with +| a -> () +| b -> 1{caret} + + 1 diff --git a/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 09 - Operator deindent.fs.gold b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 09 - Operator deindent.fs.gold new file mode 100644 index 0000000000..44687078f3 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Down 09 - Operator deindent.fs.gold @@ -0,0 +1,8 @@ +// ${DIRECTION:Down} + +match () with +| a -> () +| b -> + +1 ++ 1 diff --git a/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Up 01 - Single line.fs b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Up 01 - Single line.fs new file mode 100644 index 0000000000..22886c9ab0 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Up 01 - Single line.fs @@ -0,0 +1,8 @@ +// ${DIRECTION:Up} + +do + match () with + | a -> () + | b -> + + (){caret} diff --git a/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Up 01 - Single line.fs.gold b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Up 01 - Single line.fs.gold new file mode 100644 index 0000000000..7cda221753 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Up 01 - Single line.fs.gold @@ -0,0 +1,6 @@ +// ${DIRECTION:Up} + +do + match () with + | a -> () + | b -> () diff --git a/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Up 02.fs b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Up 02.fs new file mode 100644 index 0000000000..068e2abf75 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Up 02.fs @@ -0,0 +1,5 @@ +// ${DIRECTION:Up} + +match () with +| a -> () +| b -> (){caret} diff --git a/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Up 02.fs.gold b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Up 02.fs.gold new file mode 100644 index 0000000000..597b531eb5 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Up 02.fs.gold @@ -0,0 +1,5 @@ +// ${DIRECTION:Up} + +match () with +| b -> () +| a -> () diff --git a/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Up 03 - Multiline.fs b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Up 03 - Multiline.fs new file mode 100644 index 0000000000..38c1214a8f --- /dev/null +++ b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Up 03 - Multiline.fs @@ -0,0 +1,9 @@ +// ${DIRECTION:Up} + +do + match () with + | a -> () + | b -> + + [1 + 2]{caret} diff --git a/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Up 03 - Multiline.fs.gold b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Up 03 - Multiline.fs.gold new file mode 100644 index 0000000000..74d3e3f255 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Up 03 - Multiline.fs.gold @@ -0,0 +1,8 @@ +// ${DIRECTION:Up} + +do + match () with + | a -> () + | b -> + [1 + 2] diff --git a/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Up 05 - App.fs b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Up 05 - App.fs new file mode 100644 index 0000000000..2bf23fe1c0 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Up 05 - App.fs @@ -0,0 +1,9 @@ +// ${DIRECTION:Up} + +do + match () with + | a -> () + | b -> + + ignore + (){caret} diff --git a/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Up 05 - App.fs.gold b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Up 05 - App.fs.gold new file mode 100644 index 0000000000..a4f4049e3b --- /dev/null +++ b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Last - Up 05 - App.fs.gold @@ -0,0 +1,8 @@ +// ${DIRECTION:Up} + +do + match () with + | a -> () + | b -> + ignore + () diff --git a/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Match - Fix indent 01.fs b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Match - Fix indent 01.fs new file mode 100644 index 0000000000..e0912eb433 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Match - Fix indent 01.fs @@ -0,0 +1,7 @@ +// ${DIRECTION:Down} + +match () with +| a{caret} -> () +| b -> + +() diff --git a/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Match - Fix indent 01.fs.gold b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Match - Fix indent 01.fs.gold new file mode 100644 index 0000000000..1f48dfe36c --- /dev/null +++ b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Match - Fix indent 01.fs.gold @@ -0,0 +1,5 @@ +// ${DIRECTION:Down} + +match () with +| b -> () +| a -> () diff --git a/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Match - Fix indent 02 - Multiline.fs b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Match - Fix indent 02 - Multiline.fs new file mode 100644 index 0000000000..2284a0b0fa --- /dev/null +++ b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Match - Fix indent 02 - Multiline.fs @@ -0,0 +1,8 @@ +// ${DIRECTION:Down} + +match () with +| a{caret} -> () +| b -> + +() +() diff --git a/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Match - Fix indent 02 - Multiline.fs.gold b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Match - Fix indent 02 - Multiline.fs.gold new file mode 100644 index 0000000000..f9976f8e9e --- /dev/null +++ b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Match - Fix indent 02 - Multiline.fs.gold @@ -0,0 +1,7 @@ +// ${DIRECTION:Down} + +match () with +| b -> + () + () +| a -> () diff --git a/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Match 01.fs b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Match 01.fs new file mode 100644 index 0000000000..068e2abf75 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Match 01.fs @@ -0,0 +1,5 @@ +// ${DIRECTION:Up} + +match () with +| a -> () +| b -> (){caret} diff --git a/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Match 01.fs.gold b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Match 01.fs.gold new file mode 100644 index 0000000000..597b531eb5 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/rearrangeCode/Match clause - Match 01.fs.gold @@ -0,0 +1,5 @@ +// ${DIRECTION:Up} + +match () with +| b -> () +| a -> () diff --git a/ReSharper.FSharp/test/src/FSharp.Tests/RearrangeCodeTest.fs b/ReSharper.FSharp/test/src/FSharp.Tests/RearrangeCodeTest.fs index f47b7c35f5..ec84c67f39 100644 --- a/ReSharper.FSharp/test/src/FSharp.Tests/RearrangeCodeTest.fs +++ b/ReSharper.FSharp/test/src/FSharp.Tests/RearrangeCodeTest.fs @@ -36,6 +36,24 @@ type RearrangeCodeTest() = [] member x.``Field - Union case - Separate line 01``() = x.DoNamedTest() [] member x.``Field - Union case - Separate line 02``() = x.DoNamedTest() + [] member x.``Match clause - Last - Down 01``() = x.DoNamedTest() + [] member x.``Match clause - Last - Down 02 - Multiline``() = x.DoNamedTest() + [] member x.``Match clause - Last - Down 03 - Lambda body``() = x.DoNamedTest() + [] member x.``Match clause - Last - Down 04 - Add empty line``() = x.DoNamedTest() + [] member x.``Match clause - Last - Down 05 - Not applicable``() = x.DoNamedTest() + [] member x.``Match clause - Last - Down 06 - App``() = x.DoNamedTest() + [] member x.``Match clause - Last - Down 07 - New line``() = x.DoNamedTest() + [] member x.``Match clause - Last - Down 08 - Operator deindent``() = x.DoNamedTest() + [] member x.``Match clause - Last - Down 09 - Operator deindent``() = x.DoNamedTest() + [] member x.``Match clause - Last - Up 01 - Single line``() = x.DoNamedTest() + [] member x.``Match clause - Last - Up 02``() = x.DoNamedTest() + [] member x.``Match clause - Last - Up 03 - Multiline``() = x.DoNamedTest() + [] member x.``Match clause - Last - Up 04 - Lambda body``() = x.DoNamedTest() + [] member x.``Match clause - Last - Up 05 - App``() = x.DoNamedTest() + [] member x.``Match clause - Match 01``() = x.DoNamedTest() + [] member x.``Match clause - Match - Fix indent 01``() = x.DoNamedTest() + [] member x.``Match clause - Match - Fix indent 02 - Multiline``() = x.DoNamedTest() + [] member x.``Union case - No bar 01``() = x.DoNamedTest() [] member x.``Union case - No bar 02 - Single line``() = x.DoNamedTest() [] member x.``Union case - No bar 03 - Wrong indent``() = x.DoNamedTest()