formatSortedImports

Formats output imports into a string.

nothrow pure @safe
string
formatSortedImports
(,
string indent = ""
)

Examples

Test for merging redundant modules.

auto visitor = visitImports(q{
    import foo : bar;
    import foo : baz, bar;
  });
assert(sortedImports(visitor.importGroups[0]).formatSortedImports ==
       "import foo : bar, baz;");

Test for modules with attributes.

  auto visitor = visitImports(q{
      import foo : bar;
      static import foo;
      public import foo : bar;
      public import foo : baz;
      import bar;
    });
  assert(sortedImports(visitor.importGroups[0]).formatSortedImports == q{
import bar;
import foo : bar;
public import foo : bar, baz;
static import foo;
    }.strip);

Meta