Suggestion for Better Presentation and Refactoring of .scala source files with multiple definitions.

Currently, the plugin follows the IntelliJ Java concept of displaying a Class oriented view of the project. It is common to combine multiple classes / objects into a single Scala source file. Support for this scenario is not strong, and I think is a point of confusion and frustration for some.

I would suggest:

1. Show the .scala files in the Project view.

e.g.
- com.package
    -MyFile.scala
        MyObject1
        MyClass1

Perhaps this level would remain omitted from the Packages view.

At the moment, I have to go to the Scope -> All view to see the .scala files, which is unintuitive.

2. Support the 'move' and 'copy' and 'rename' refactorings at the .scala file level as well as at the Class / Object / Trait level.

Rename: com/package/MyFile.scala -> com/package/MyFileRenamed.scala
Move / Copy: com/package/MyFile.scala -> com/newpackage/MyFile.scala (the package declaration in the file should be updated)

3. Extend the Move and Copy refactorings for Scala Class / Object / Trait to optionally specifiy the name of the target .scala source file.

This could be an existing file, or a new file. Special support could be provided to move a class in a multi-class source file to its own file, named after the class.

These refactorings should be able to work on multiple selections, for example to move some related classed and objects from MyFile.scala to MySmallerFile.scala.



To simplify all of this, a constraint could be placed that the folder structure is kept consistent with the package structure. Violations of this convention should be highlighted with an Inspection.

What other ideas do people have for supporting this?

-jason

0
4 comments

Ok, thanks for great ideas for project structure. It can be handy, may be just as project structure option (to add file level).
We'll keep it in mind.
Move refactoring will be improved soon (it's my first-order task), and this is really interesting to add file level for this.

Best regards,
Alexander Podkhalyuzin.

0
Avatar
Permanently deleted user

I submitted a patch to JIRA to handle the first part of this:

http://jetbrains.net/jira/browse/SCL-1077

Screenshot: http://jetbrains.net/jira/secure/attachment/29947/proj.png

-jason

0
Avatar
Permanently deleted user

Jason.

Actually, it's great. I looked at your patch and I'm going to integrate it to the repository. As for advanced move/copy oprion it sounds reasonable, but first what should be implemented (and what we're going to) is to move/copy classes separately from files in the case of several classes in one file.

With best regards,
Ilya

0
Avatar
Permanently deleted user

Your changes were successfully integrated. Thanks.

With best regards,
Ilya

0

Please sign in to leave a comment.