eclipse / epsilon

Epsilon is a family of Java-based scripting languages for automating common model-based software engineering tasks, such as code generation, model-to-model transformation and model validation, that work out of the box with EMF (including Xtext and Sirius), UML (including Cameo/MagicDraw), Simulink, XML and other types of models.
https://eclipse.org/epsilon
Eclipse Public License 2.0
55 stars 11 forks source link

ForTask: Return empty array if fileset has no files #17

Closed Arkaedan closed 1 year ago

Arkaedan commented 1 year ago

Fixes #16

If the fileset has no files then return an empty array.

The getFiles() method relies on the AbstractFileSet toString() method which will return an empty string if there are no included files. We need to check if there are no files, otherwise this will result in a string array with one element (empty string) even though there are no files.

kolovos commented 1 year ago

Thanks for the PR! I've had a look at the implementation of AbstractFileset.toString() and replaced return fileset.toString().split(";") with return fileset.getDirectoryScanner().getIncludedFiles() in https://github.com/eclipse/epsilon/commit/68f9570fd9a400e54ba6aa98e6fbe6392be01e40, which fixes this issue without having to join/split strings.

Arkaedan commented 1 year ago

I did originally look at doing fileset.getDirectoryScanner().getIncludedFiles() but noticed that all of the methods inside the AbstractFileset appear to call dieOnCircularReference() first and wondered if it would cause issues if we don't call that as well.

kolovos commented 1 year ago

Good point. Fixed in https://github.com/eclipse/epsilon/commit/3540ab75343f903cccca39980773b26eedde82d4.