Closed lucaswerkmeister closed 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:
source/foo/bar --to target
source/foo/bar/file.ceylon
→ target/file.ceylon
source/foo/bar/baz/file.ceylon
→ target/baz/file.ceylon
source/foo/bar --and source/foo/baz --to target
source/foo/bar/file.ceylon
→ target/bar/file.ceylon
source/foo/baz/bar/file.ceylon
→ target/baz/bar/file.ceylon
source/foo/bar --to target/foo/bar
(replicate current behavior)
source/foo/bar/file.ceylon
→ target/foo/bar/file.ceylon
source/foo/bar/baz/file.ceylon
→ target/foo/bar/baz/file.ceylon
source/foo/bar --and source/foo/baz --to target/foo
(replicate current behavior)
source/foo/bar/file.ceylon
→ target/foo/bar/file.ceylon
source/foo/baz/bar/file.ceylon
→ target/foo/baz/file.ceylon
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 /tmp
– home
, tmp
relative to /
– or source
and test-source
– both relative to ./
.)
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 aceylon-sdk
folder insidesource/ceylon/test
folder. (Found while verifying that #49 was fixed.)