The purpose of this proposal is to replace the existing "New XXX" wizards with a new wizard, which on the one side is simplified to the concept of creating new files and on the other side gives the complexity of changing a file to the editor, which can do this much better.
There is a lot of information in the current wizards, most of it is only rarely used. Furthermore there a lot of bugs which make some features of the wizards unusable. Because there are a lot of features hidden under the surface of the wizard it is difficult to get all of them right.
Therefore I propose a new wizard which is simplified in so far that it can only create a new file, without any
additional modifications. It should be possible to place a file at an arbitrary location inside of a project. This include source folders, normal folders and packages. The only support the wizard should give while doing this is code completion of an existing path and a warning/error when a given file already exists or when its name is invalid. This would require only one text field where one can insert all the necessary information. Example:
In the above string
is the name of the project,
the name of the source folder,
the package name and
the name of the file. In order to simplify the creation of such a part the IDE should auto insert the project, source folder and filename ending. A special text field that allows to mark some parts to be read-only could further simplify the process of creating a file name. Especially the project and the filename ending are very unlikely to be edited and therefore don't need to be editable. Further, the package can be auto inserted as well when one right clicks a given package or opens the wizard with a key combination, while a editor is selected, which represents a file in a given package.
The advantage of such a "New File" wizard would be that the location of a file is the only thing one needs to care about, the disadvantage is that a newly created file is completely empty.
This brings another point of this proposal to the top: Creating a file out of a template. Once a filename is selected one can concentrate on the content of a file. A selection box that shows all possible templates is needed for this part. The selection box should contain templates for creating new classes, objects, package objects, traits, apps (objects that extend the trait App) and so on. A template feature is already available but not used by the current wizard. At the moment it has its own templates which are impossible to change.
The advantage of the template based content creation is that it is easy and extensible. One can easily add a new template to the IDE and get it as option in the wizard dialog. The disadvantage is that options to specify superclasses or class modifiers can only included when the template includes them.
Several more advantages of this proposal would be:
- The filename extension can be changed. No one prevents the wizard from creating a new Java file, internally it only needs to select different validators to check the correctness of the Java file.
- A code preview that shows the content of the generated file can be shown. With a real editor in the background (which is somehow cached to make it fast) could show full semantic highlighting.
- New templates can be added by extensions to the Scala IDE, not only by users while editing the preferences.
Image version that shows how it could look:
The first disadvantage is handled by the second part of the proposal, the second disadvantage is not addressed and can not without adding more features to the wizard. Even though, I think that all additional features are unnecessary. The task of a wizard is to provide a way to create files - it is the part of the editor to change them. This should be addressed more intensively in future. If one wants to add a modifier to a class it is the task of the editor to make this as easy as possible. It can provide code completions, quick fixes and so on - the editor has enough features to do support users in this regard.
Adding more features to the wizard makes them more difficult to maintain, with only less benefits. Normally, in the current wizard, one uses the mouse to select its features - this takes so much time that it is probably more efficient to create a new file with less content and add additional content with the help of the full feature set of the editor.