eclipse-archived / ceylon.formatter

A formatter for the Ceylon programming language, written in Ceylon.
Apache License 2.0
14 stars 11 forks source link

multiPart/folders are moved around strangely #50

Closed lucaswerkmeister closed 10 years ago

lucaswerkmeister commented 10 years ago

I don’t have the time to write a better bug report right now (gotta head off), but ceylon run ceylon.formatter ../ceylon-sdk/source/ceylon/test put a ceylon-sdk folder inside source/ceylon/test folder. (Found while verifying that #49 was fixed.)

lucaswerkmeister commented 10 years ago

From run.ceylon, this is the current intended behavior:

if (sources.size == 1) {
    // source/foo/bar → target/foo/bar
    ...
} else {
    // source1/foo/bar → target/source1/foo/bar, source2/baz → target/source2/baz
    ...
}

I’m beginning to think that this might not be ideal. Instead, how about this:

The folder structure of the sources will be copied from the point where they diverge. This means that for a single source, no parent directories will be copied, giving the user maximum flexibility of where they want the files to be (the formatter will create missing directories in the target path, so you can replicate the old behavior by writing the parent directories “by hand”). For multiple sources, no more directory structure will be created as necessary – again, if you need it all, you can still specify it “by hand” in the target tree.

Examples:

lucaswerkmeister commented 10 years ago

This proposal can actually solve #48 as well, with the rule that all sources must have the same root – either the implicit ./ (all paths relative), or an explicit / (all paths absolute, Unix-like), or an explicit drive letter C:, D:, etc. (all paths absolute, Windows – note: the drive letter must be the same!). If all source paths have the same root, we can determine the point where they diverge, and their paths relative to this point are relative paths that we can append to the target path (which can be absolute or relative, don’t care). (This even works with “immediate divergence“ like /home and /tmphome, tmp relative to / – or source and test-source – both relative to ./.)