Multiple classes in same file?

639 views
Skip to first unread message

Jesse Eichar

unread,
Jul 26, 2011, 7:27:13 AM7/26/11
to Scala IDE User
Hi,

At one point (quite a long time ago now) the eclipse scala plugin had
a very hard time when there were multiple classes defined in the same
file. As a result my project has several files containing 3 lines. I
was wondering if this is still the case or if there are no known
problems with multiple classes in the same file?

I was thinking of maybe code completion or syntax highlighting errors.

Also is it important for the package name to match the directory
structure like in java or has that been fixed as well. I know in Idea
it was much slower if this was done.

Mirco Dotta

unread,
Jul 26, 2011, 1:29:23 PM7/26/11
to scala-i...@googlegroups.com
> Hi,

Hi Jesse,

> At one point (quite a long time ago now) the eclipse scala plugin had
> a very hard time when there were multiple classes defined in the same
> file. As a result my project has several files containing 3 lines. I
> was wondering if this is still the case or if there are no known
> problems with multiple classes in the same file?

I started using the IDE only a few months ago, but I haven't experienced this
kind of issue ever. Imagine that we also use the IDE for the editing sources
in the scala compiler (and there are several files that contain multiple class defs)
and I haven't seen this issue.

Please, give it a try and if experience a problem report it.

> Also is it important for the package name to match the directory
> structure like in java or has that been fixed as well. I know in Idea
> it was much slower if this was done.

This is still a problem in the current builder. Though, I think this will go away with
the new SBT builder (crossing my fingers here ;). Hopefully, we are not far from
having it in the nightly.

-- Mirco

Miles Sabin

unread,
Jul 27, 2011, 6:07:27 AM7/27/11
to scala-i...@googlegroups.com
On Tue, Jul 26, 2011 at 12:27 PM, Jesse Eichar
<jesse....@camptocamp.com> wrote:
> At one point (quite a long time ago now) the eclipse scala plugin had
> a very hard time when there were multiple classes defined in the same
> file.  As a result my project has several files containing 3 lines.  I
> was wondering if this is still the case or if there are no known
> problems with multiple classes in the same file?

There used to be issues when top-level type names didn't match the
containing source file name (ie. via the Java convention) which would
inevitably be the case if a source file contained more than one
top-level type definitions.

But those problem were fixed a very, very long time ago, I think
probably even before the 2.8.0.final release.

Cheers,


Miles

--
Miles Sabin
tel: +44 7813 944 528
gtalk: mi...@milessabin.com
skype: milessabin
http://www.chuusai.com/
http://twitter.com/milessabin

sentimen...@gmail.com

unread,
Jul 27, 2011, 7:38:56 AM7/27/11
to Miles Sabin, scala-i...@googlegroups.com
On Wed, 27 Jul 2011 11:07:27 +0100, Miles Sabin <mi...@milessabin.com> wrote:
> On Tue, Jul 26, 2011 at 12:27 PM, Jesse Eichar
> <jesse....@camptocamp.com> wrote:
> > At one point (quite a long time ago now) the eclipse scala plugin had
> > a very hard time when there were multiple classes defined in the same
> > file.  As a result my project has several files containing 3 lines.  I
> > was wondering if this is still the case or if there are no known
> > problems with multiple classes in the same file?
>
> There used to be issues when top-level type names didn't match the
> containing source file name (ie. via the Java convention) which would
> inevitably be the case if a source file contained more than one
> top-level type definitions.
>
> But those problem were fixed a very, very long time ago, I think
> probably even before the 2.8.0.final release.

Nope, still an issue. I was caught by it about a week ago.

Bryan Hunt

Mirco Dotta

unread,
Jul 27, 2011, 7:55:39 AM7/27/11
to scala-i...@googlegroups.com, Miles Sabin
Do you have an example for it?

If not, next time be sure to report it (there may actually be other reason of why you were
getting an error).


Cheers,
Mirco

David Bernard

unread,
Jul 27, 2011, 8:01:32 AM7/27/11
to scala-i...@googlegroups.com
> Also is it important for the package name to match the directory
> structure like in java or has that been fixed as well.  I know in Idea
> it was much slower if this was done.

This is still a problem in the current builder. Though, I think this will go away with
the new SBT builder (crossing my fingers here ;). Hopefully, we are not far from
having it in the nightly.


package name still need to match directory structure if you 
* generate -sources.jar
* want to debug and allow eclipse to find source from .class (see https://groups.google.com/group/scala-ide-user/browse_thread/thread/264af53be8eb925d)

And SBT based builder can't fix that.

/davidB

Mirco Dotta

unread,
Jul 27, 2011, 8:08:42 AM7/27/11
to scala-i...@googlegroups.com
Thanks David for correcting me, I didn't know this.

-- Mirco

Bryan Hunt

unread,
Jul 27, 2011, 9:17:04 AM7/27/11
to Mirco Dotta, scala-i...@googlegroups.com, Miles Sabin
On Wed, 27 Jul 2011 13:55:39 +0200, Mirco Dotta <mirco...@gmail.com> wrote:
> Do you have an example for it?
>
> If not, next time be sure to report it (there may actually be other reason of why you were
> getting an error).


Mirco,

I stand corrected.

Using the current version of Scala-IDE and Scala 2.9.0.1:

Package name does not need to match the filesystem path.

Class name does not need to match file name.

I've added such classes to my project and it does, indeed, compile
correctly.

Your humble servant,

Bryan Hunt

Mirco Dotta

unread,
Jul 27, 2011, 9:29:47 AM7/27/11
to sentimen...@gmail.com, scala-i...@googlegroups.com, Miles Sabin
> I stand corrected.
>
> Using the current version of Scala-IDE and Scala 2.9.0.1:
>
> Package name does not need to match the filesystem path.
>
> Class name does not need to match file name.
>
> I've added such classes to my project and it does, indeed, compile
> correctly.

Good, the IDE works and I'm learning new English idioms ;)

-- Mirco

David Bernard

unread,
Jul 27, 2011, 10:36:54 AM7/27/11
to scala-i...@googlegroups.com, Mirco Dotta, Miles Sabin
And can you debug code that come into this file ?
 (break point into caller, and second test break point into this file)

/davidB
Reply all
Reply to author
Forward
0 new messages