branch: elpa/swift-mode commit 2d0194e8065548e03a753d0268dcd025388c7b51 Author: ap4y <l...@pisem.net> Commit: ap4y <l...@pisem.net>
Correct several indentation cases for class defitinion --- swift-mode.el | 6 ++- test/indentation-tests.el | 117 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+), 2 deletions(-) diff --git a/swift-mode.el b/swift-mode.el index c61ca5c..8eecbc2 100644 --- a/swift-mode.el +++ b/swift-mode.el @@ -289,7 +289,9 @@ ;; Static indentation relatively to = ((smie-rule-parent-p "=") 2) ;; Rule for the case statement. - ((smie-rule-parent-p "case") swift-indent-offset))) + ((smie-rule-parent-p "case") swift-indent-offset) + ;; Rule for the class definition. + ((smie-rule-parent-p "class") (smie-rule-parent swift-indent-offset)))) (`(:after . "{") (if (smie-rule-parent-p "switch") @@ -317,7 +319,7 @@ ;; definitions with swift-indent-offset (`(:before . ",") (if (smie-rule-parent-p "class") - swift-indent-offset)) + (smie-rule-parent swift-indent-offset))) (`(:before . "if") (if (smie-rule-prev-p "else") diff --git a/test/indentation-tests.el b/test/indentation-tests.el index 837108f..4a2ebc1 100644 --- a/test/indentation-tests.el +++ b/test/indentation-tests.el @@ -639,6 +639,66 @@ class Foo: Foo, Bar, } ") +(check-indentation indents-class-declaration/6 + " +class Foo: +|Foo, Bar, Baz { +} +" " +class Foo: + |Foo, Bar, Baz { +} +") + +(check-indentation indents-class-declaration/7 + " +class Foo: Bar<A, B, +|C> +" " +class Foo: Bar<A, B, + |C> +") + +(check-indentation indents-class-declaration/8 + " +class Foo: Bar<A, B, +|[C]> +" " +class Foo: Bar<A, B, + |[C]> +") + +(check-indentation indents-class-declaration/9 + " +class Foo<A: B<C>>: + |Bar +" " +class Foo<A: B<C>>: + |Bar +") + +(check-indentation indents-public-class-declaration/1 + " +public class Foo: Foo, Bar, +|Baz { +} +" " +public class Foo: Foo, Bar, + |Baz { +} +") + +(check-indentation indents-public-class-declaration/2 + " +public class Foo { + |foo +} +" " +public class Foo { + |foo +} +") + (check-indentation indents-func-declaration/1 " func Foo(a: String) { @@ -1037,6 +1097,63 @@ func foo() { } ") +(check-indentation block-inside-parenthesis/3 + " +\({ +|a +}) +" " +\({ + |a +}) +") + +(check-indentation indent-long-if-else-if/1 + " +if a { + a +} else if a { + a +} else if a { + |a +} else { + a +} +" " +if a { + a +} else if a { + a +} else if a { + |a +} else { + a +} +") + +(check-indentation indent-long-if-else-if/2 + " +if a { + a +} else if a { + a +} else if a { + a +|} else { + a +} +" " +if a { + a +} else if a { + a +} else if a { + a +|} else { + a +} +") + (provide 'indentation-tests) ;;; indentation-tests.el ends here