nitpretty: better length management for long method block
authorAlexandre Terrasa <alexandre@moz-code.org>
Thu, 8 Jan 2015 13:28:35 +0000 (14:28 +0100)
committerAlexandre Terrasa <alexandre@moz-code.org>
Thu, 8 Jan 2015 13:28:35 +0000 (14:28 +0100)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

src/pretty.nit
tests/sav/nitpretty_args25.res
tests/sav/nitpretty_args27.res
tests/sav/nitpretty_args9.res

index 8d7a45a..5935987 100644 (file)
@@ -834,7 +834,6 @@ redef class AMethPropdef
                #  TODO: Handle extern annotations
 
                var before = v.indent
-               var can_inline = v.can_inline(self)
                super
                if n_kwinit != null then v.visit n_kwinit
                if n_kwmeth != null then v.visit n_kwmeth
@@ -872,7 +871,7 @@ redef class AMethPropdef
                        end
                        v.consume "do"
 
-                       if can_inline then
+                       if v.can_inline(n_block) then
                                v.adds
 
                                if n_block isa ABlockExpr then
index 6638706..0b5231c 100644 (file)
@@ -67,7 +67,9 @@ class Test[E]
                end
        end
 
-       fun save_those_nodes(nodes: Collection[Object]) do for node in nodes do count(node)
+       fun save_those_nodes(nodes: Collection[Object]) do
+               for node in nodes do count(node)
+       end
 end
 
 fun foo do
index d3ee895..422cc2a 100644 (file)
@@ -25,9 +25,7 @@ class A
        fun baz is
                a
                bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
-       do
-               print "2"
-       end
+       do print "2"
 end
 
 class B
index bd21dbb..46c03e1 100644 (file)
@@ -31,7 +31,5 @@ class A
        fun foo5 do end # comment
 
        fun foo6(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
-               aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: Int) do
-               print 1
-       end
+               aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: Int) do print 1
 end # comment